## WeBWorK Main Forum

### timing for take-home test

by Joel Trussell -
Number of replies: 6
Is it possible to give a student a time-limit on a take home test? In other words start the clock when the student signs on to a problem set and have to due time a couple of hour later.
This would be more convenient than setting a specific time interval for the entire class.
I don't see a way to do this but there might be a way. I know I can read some parameters like the student name. I don't know about the due time.

### Re: timing for take-home test

by Danny Glin -
Do you mean that the instructor wants to give one student a time limit while the rest don't have one?

The ability to give a time limit to the whole class from when they first access the assignment is a standard feature of the gateway quiz mode. If you change the assignment type to gateway/quiz, then one of the options is "Test Time Limit", which applies from when they start. More information about gateway quiz settings can be found at http://webwork.maa.org/wiki/Gateway_Tests_and_Quizzes.

If you are looking to give a time limit to only some students, then that might be more complicated, since I don't think you can set the type to "homework" for some students and "gateway quiz" for others.

### Re: timing for take-home test

by Joel Trussell -
Thanks - I have heard the term Gateway Quiz, but never used it. This looks like it will do the trick.

### Re: timing for take-home test

by Joel Trussell -
I tried the Gateway quiz with a short quiz I had used to test timing for students in class of 45 - to see if that many students wold slow the Webwork server. I had included an interactive graphics problem, (move vectors to the correct location on a graph).
The graphics part was coded using Geogebra. The problem was that the answers to the graphics part were not recorded. The answers to the submit a number and use the drop-down menu for multiple choice worked OK. But the answer was recorded as if the graphics were totally wrong. The problem worked well when given in a short timed test as a homework type. But the same problem as a Gateway quiz didn't record the graphics answers - it drew the graph and allowed movement of the vectors OK, but when the student submitted no record of the graphic input.

The code is below

## DESCRIPTION
# Problem for 'NCSU ECE451 Lu'.
# WeBWorK problem written by H. J. Trussell, <hjt@ncsu.edu>
# ENDDESCRIPTION

## DBsubject(Electrical Engineering)
## DBchapter(CHAPTER 3 The Synchronous Machine)
## DBsection(NA)
## Institution(North Carolina State University)
## Autho(H. J. Trussell)
## TitleText1('Fundamentals of Applied Electromagnetics')
## AuthorText1('John Grainger, Jr.', 'William Stevenson ')
## EditionText1('1')
## Problem1('3.3')
## Keywords('three-phase synchronous generator')
## Resources()

DOCUMENT();

"PGstandard.pl", # Standard macros for PG language
"MathObjects.pl",
"PGinfo.pl",
"AppletObjects.pl",
"PGcourse.pl", # Customization file for the course
"parserPopUp.pl",
);

TEXT(beginproblem());

Context("Complex");
Context()->flags->set(
tolerance => 0.01,
tolType => "absolute",
);

Context()->variables->are(t=>'Real');
Context()->{format}{number} = "%.4f#";

#Initialize values, to be changed for each question
$Xd = Real(random(1,1.5,0.1)); # pu #$Va_Mag = Real(random(1,2,0.2)); # V
$Va_Mag = Real(1.0); # V$Va_Ang = 0;
$Ia1_Mag = Real(random(1,2,0.2)); # A$Ia1_Ang = Real(random(20,40,5)); # degrees
$Ia2_Mag = Real(random(1,2,0.2)); # A$Ia2_Ang = 0; # degrees
$Ia3_Mag = Real(random(1,2,0.2)); # A$Ia3_Ang = -$Ia1_Ang; # degrees # default values for checking #$Xd = Real(1.65); $Va_Mag = Real(1);$Ia1_Mag = Real(1); $Ia1_Ang = Real(30); #$Ia2_Mag = Real(1); $Ia3_Mag = Real(1); # Answer calculation$Ia1_Ang_rad = Compute($Ia1_Ang*pi/180);$Ei1 = Compute($Va_Mag*exp(j*$Va_Ang) + $Ia1_Mag*$Xd*exp(j* ($Ia1_Ang_rad + pi/2)));$I_Xd_prod = Compute($Ia1_Mag*$Xd);
$I_Xd_Ang = Compute($Ia1_Ang + 90);
$Ei1_Mag = Compute(abs($Ei1));
$Ei1_Ang = Compute(arg($Ei1));
$Ei1_Ang_deg = Compute($Ei1_Ang*180/pi);

$Ia2_Ang_rad = Compute($Ia2_Ang*pi/180);
$Ei2 = Compute($Va_Mag*exp(j*$Va_Ang) +$Ia2_Mag*$Xd*exp(j* ($Ia2_Ang_rad + pi/2)));
$I_Xd_prod2 = Compute($Ia2_Mag*$Xd);$I_Xd_Ang2 = Compute($Ia2_Ang + 90);$Ei2_Mag = Compute(abs($Ei2));$Ei2_Ang = Compute(arg($Ei2));$Ei2_Ang_deg = Compute($Ei2_Ang*180/pi);$Ia3_Ang_rad = Compute($Ia3_Ang*pi/180);$Ei3 = Compute($Va_Mag*exp(j*$Va_Ang) + $Ia3_Mag*$Xd*exp(j* ($Ia3_Ang_rad + pi/2)));$I_Xd_prod3 = Compute($Ia3_Mag*$Xd);
$I_Xd_Ang3 = Compute($Ia3_Ang + 90);
$Ei3_Mag = Compute(abs($Ei3));
$Ei3_Ang = Compute(arg($Ei3));
$Ei3_Ang_deg = Compute($Ei3_Ang*180/pi);

$Xd_Ang_rad_1 = Compute($Ia1_Ang_rad + pi/2);
$answer1 = Real(60*60/(4/2));$popupA = PopUp(["?", "increase", "decrease","remain the same"], "decrease");

$popupB = PopUp(["?", "increase", "decrease","remain the same"], "increase");$answer = Compute("($Ia1_Mag,$Ia1_Ang_rad,$Ei1_Mag,$Ei1_Ang)");
@tol=(0.5,pi/60); # Magnitude Tolerance 0.1, Angular Tolerance 3 degrees
@type=(0,1,0,1,0,1); #0 for magnitude value, 1 for angular value in degrees

######################################
###################################
# You can name your applet (anything reasonable :-) )
# Adjust the height and width as desired
# Paste the geogebra parameters in at the bottom of the page just above the
# command end command
# so that they don't get in the way
###################################

$appletName = "ggbfoo";$applet = GeogebraWebApplet(
code => "geogebra.GeoGebraApplet",
archive => "geogebra.jar",
codebase => findAppletCodebase("geogebra.jar"),
appletName => $appletName, appletId =>$appletName,
submitActionAlias => 'getAppletValues', # default actionAlias
initializeActionAlias => '', # default actionAlias
setStateAlias => 'setXML',
getStateAlias => 'getXML',
setConfigAlias => '',
getConfigAlias => '',
returnFieldName => '',
width => 700, # may want to modify width
height => 700, # may want to modify height
# mayscript => "true",
debugMode => 0, # set debugMode to 0 for no debug
# to 1 to make xml representation visible
# through the applet
onInit => 'ggbOnInit',
type => 'geogebraweb',
submitActionScript => qq{ getQE('answerBox').value = getAppletValues() },
params => GEOGEBRA_PARAMS(),# paste parameters in
);

##################################
# Setup GeogebraWebApplet --
###################################
###############################################
#
# For persistence of GeoGebra applet state
# when answers are submitted or page is refreshed.
# Uses JavaScript interface to GeoGebra.

qq!
<script language="javascript">
function ggbOnInit(param) {
if (param == "$appletName") { applet_loaded(param,1); // report that applet is ready. ww_applet_list[param].safe_applet_initialize(2); } } </script> <noscript>For this question to work properly, you must enable JavaScript, or use another browser (or computer) on which JavaScript works.</noscript> !); ####################################################### # # For setting initial values in GeoGebra from WeBWorK # Uses JavaScript interface to GeoGebra. TEXT( MODES(TeX=>'', HTML=><<END_SCRIPT ) ); <script language="javascript"> function setAppletCoefficients() { var applet=getApplet("$appletName"); // alert("Updating coefficients");
if (typeof(applet)!="undefined") {
if (typeof(applet.setValue)!="undefined") {
////////////////////////////////////////////////////////////////
// List the values of the parameters to be set in the applet here

} else {
setTimeout("setAppletCoefficients()", 1000);
}
} else {
setTimeout("setAppletCoefficients()",1000);
}
}
ww_applet_list["$appletName"].setConfig = function() {setAppletCoefficients()}; </script> END_SCRIPT HEADER_TEXT( MODES(TeX=>'', HTML=><<END_SCRIPT ) ); <script language="javascript"> function getAppletValues() { console.log("getAppletValues() entered"); // get a handle for the applet object var applet =$appletName;
var Iam = applet.getValue("Iam");
var Iaang= applet.getValue("Iaang");
var Eim = applet.getValue("Eim");
var Eiang= applet.getValue("Eiang");
return(Iam + ',' +Iaang +','+Eim + ',' +Eiang);
}
</script>
END_SCRIPT

BEGIN_TEXT
Find the rotor speed of a 4-pole generator to generate 60Hz 3-phase power: $BR a) Speed is \{ans_rule(10)\} $$RPM$$ \{AnswerFormatHelp("numbers") \}$BR
b) A generator is supplying a 100 MW load. If we increase the load to 105MW, the system frequency (i.e., the rotor speed) will \{$popupA->menu()\}$BR
c)A generator is supplying a 100MW load with a power factor at 1.0. If the power factor drops to 0.9 lagging (power is still 100 MW), the excitation current ($$I_f$$) will \{$popupB->menu()\}$PAR
In the graph below, move point C ($$E_i$$) to (0.44,1.20). Move the red vector ($$Ia$$) to (1.09,0.51). You can move each phasor by clicking on its arrow head and dragging it around. The vector values indicated beside the vectors are represented in polar coordinates, as are the answers in the answer-checker. $BR END_TEXT Context()->normalStrings; ################################### #insert applet into body -- this does not need to be changed # except to adjust the insertion of the reinitialize_button or # a hidden AnswerBox ################################### TEXT($PAR, MODES(TeX=>'geogebraweb code',
HTML=>$applet->insertAll( debug =>0, reinitialize_button => 1, includeAnswerBox=>1, ))); TEXT( "run SetConfig", q!<script language="javascript">setConfig()</script> !) if$inputs_ref->{ "${appletName}_state"} =~ "restart_applet"; ##############################$showPartialCorrectAnswers = 1;
#ANS($Ei1->cmp()); #ANS($Ei2->cmp());
#ANS($Ei3->cmp()); ANS($answer1->cmp());
ANS($popupA->cmp()); ANS($popupB->cmp());

# NAMED_ANS( 'answerBox' => $answer->cmp(ordered=>1) ); NAMED_ANS( 'answerBox' =>$answer->
cmp(list_checker => sub {
my ($correct,$student,$ansHash,$value) = @_;
my $n = scalar(@$student); # number of student answers
my $score = 0; # number of correct student answers my @errors = (); # stores error messages my$i; # loop counters
#
# Loop though the student answers
##
for ($i = 0;$i < $n;$i++) {
my $err,$errt;
my $ith = Value::List->NameForNumber($i+1);
my $p =$student->[$i]; # i-th student answer my$a = $p->value; my$q = $correct->[$i]; # i-th student answer
my $b =$q->value;
if ($type[$i]==0){
$err=abs($a-$b) } if ($type[$i]==1){$errt=abs($a-$b);
$err=min($errt,360-$errt); } if ($err<$tol[$type[$i]] ) {$score++} else {
push(@errors,"Your $ith point is not correct") unless$ansHash->{isPreview}
}
}
return ($score,@errors); })); ############################## # Solution Context()->texStrings; BEGIN_SOLUTION;$PAR
$BBOLD SOLUTION$EBOLD
$PAR $$E_i \angle 0^{ \circ } = V_a \angle 0^{ \circ } + I_a \angle \theta \times X_d \angle 90^{ \circ }$$$BR
$$= Va_Mag \angle 0^{ \circ } + Ia1_Mag \angle \theta \times Xd \angle 90^{ \circ }$$ $BR $$= Va_Mag \angle 0^{ \circ } + I_Xd_prod \angle (90^{ \circ } + \theta)$$$PAR

a) $$\theta = Ia1_Ang^{ \circ }$$ $BR $$E_i = Va_Mag \angle 0^{ \circ } + I_Xd_prod \angle I_Xd_Ang ^{ \circ }$$$BR
$$E_i = Ei1 = Ei1_Mag \angle Ei1_Ang_deg^{ \circ }$$ per unit $PAR b) $$\theta = Ia2_Ang^{ \circ }$$$BR
$$E_i = Va_Mag \angle 0^{ \circ } + I_Xd_prod2 \angle I_Xd_Ang2 ^{ \circ }$$ $BR $$E_i = Ei2 = Ei2_Mag \angle Ei2_Ang_deg^{ \circ }$$ per unit$PAR

c) $$\theta = Ia3_Ang^{ \circ }$$ $BR $$E_i = Va_Mag \angle 0^{ \circ } + I_Xd_prod3 \angle I_Xd_Ang3 ^{ \circ }$$$BR
$$E_i = Ei3 = Ei3_Mag \angle Ei3_Ang_deg^{ \circ }$$ per unit $PAR END_SOLUTION Context()->normalStrings; sub GEOGEBRA_PARAMS { my$result = {
showResetIcon=>"false" ,
enableRightClick=>"false" ,
enableLabelDrags=>"false",
showToolBar=>"false",
showAlgebraInput=>"false",
useBrowserForJS=>"true",
allowRescaling=>"false",
enableShiftDragZoom=>"false",
};

\$result;
}
ENDDOCUMENT();

### Re: timing for take-home test

by Glenn Rice -
The problem seems to be that HEADER_TEXT does not work for gateway quizzes. This causes problems at two levels for your problem. First, you call HEADER_TEXT directly, and then the AppletObjects.pl calls HEADER_TEXT.

You can work around your calls to HEADER_TEXT by just calling TEXT, but I am not sure how to work around the calls in the macro.

### Re: timing for take-home test

by Glenn Rice -
It seems that even if the HEADER_TEXT method is fixed for gateway quizzes this problem will still not work. There also seems to be an issue with the fact that applets used named answers that do not have the quiz prefix.

In short applet problems are a long way from being functional in gateway quizzes at this point.