I am using WeBWorK version 2.5 on Ubuntu 10.04.3. I have a problem that asks students to find the derivative of a straight line from a graph with units, the code is below. I used this problem last semester without issue.
The problem has two answer blanks, both of which use the same answer.
A student complained to me that his first answer was being marked incorrect. I looked at his problem and WeBWorK is reporting the correct answer to the first question as -1/30 ft/min, and to the second answer as -4 ft/min (which is correct). Since both blanks use the same answer, something is amiss.
I tried giving him a new seed, but we get the same problem, just different numbers. I looked at many of the other students in the class, and he is the only one with this problem that I can find.
CODE:
loadMacros(
"PGstandard.pl",
"PGunion.pl",
"Parser.pl",
"PGcourse.pl",
"PGgraphmacros.pl",
"parserNumberWithUnits.pl",
);
TEXT(beginproblem());
BEGIN_PROBLEM();
##############################################
# Setup
$refreshCachedImages=1;
Context("Numeric");
Context()->variables->add(t=>'Real');
#
# The function to plot
#
$m = Compute(non_zero_random(-4,4));
$b = Compute(non_zero_random(-4,4));
$munits = NumberWithUnits("$m","ft/min");
$s = Formula("$m*t+$b")->reduce;
$sgraph = Formula("$m*x+$b");
#
# Graph size
#
($tm,$tM) = (-2,2);
$extreme1 = abs($s->eval(t=>"$tm"));
$extreme2 = abs($s->eval(t=>"$tM"));
if($extreme1 > $extreme2){$sM = $extreme1;}
else {$sM = $extreme2;};
$sm=-$sM;
$size = [450,450];
##############################################
#
# The plot defaults
#
@Goptions = (
$tm,$sm,$tM,$sM, # dimensions of graph
axes => [0,0], grid => [$tM-$tm,$sM-$sm], # number of grid lines
size => $size # pixel dimension
);
$plotdomain = "x in <$tm,$tM>";
$plotoptions = "using color:red and weight=2";
$graph = init_graph(@Goptions);
plot_functions($graph,"$sgraph for $plotdomain $plotoptions");
##############################################
# Main text
Context()->texStrings;
BEGIN_TEXT
$BBOLD Note: $EBOLD Your answers must include \{ helpLink('units') \}.
$BR
$BR
The position \(x\) of a car at time t is graphed below.
$BCENTER
\{ image( insertGraph($graph),width=>450, height=>450 ) \}
$ECENTER
If the position of the car is given in feet and time is measured in minutes then
\(x^\prime (t) = \) \{ans_rule\}
$BR
The velocity of the car is \{ans_rule\}
$BR
END_TEXT
Context()->normalStrings;
##################################################
# Answers
##################################################
ANS($munits->cmp() );
ANS($munits->cmp() );
END_PROBLEM();
ENDDOCUMENT(); # This should be the last executable line in the problem.
I have a speculative answer, which is not entirely consistent with the information that you gave me, but which does possibly come into play.
My hypothesis is that the student actually used different units in his/her answer. There appears to be a bug in the way that answers with units are handled if they are used more than once in an answer checker.
For example, I tried your code on PGlabs and entered the answer in a number of different units. The correct answer for my problem happened to be 3 ft/min. If I entered 3 ft/min in both answers, I got both problems correct. So here are some interesting side effects:
3/60 ft/sec and 3/60 ft/sec will only mark the first correct
3/60 ft/sec and 3/60 ft/min will mark both correct.
3/60 ft/sec and 3 ft/min will only mark the first correct
4/60 ft/sec and 3 ft/min will mark both incorrect
4/60 ft/sec and 3/60 ft/min will mark the second answer correct (even though it is incorrect)
It appears that the answer checker actually does some internal manipulation of the answer object and that units are only considered the first time the answer object is used. The numerical part is updated to match the units the student enters, but it does not remember the new units for the next time it is used.
This may not be a complete answer, but it certainly has a high likelihood of impacting the student's issue. If this is the issue, then you should get around it by creating a second object for the second answer.
However, the answers that you provided don't seem entirely compatible with my hypothesis since 1/30 would be the answer in ft/sec for 2 ft/min and not 4 ft/min. Perhaps something was not quite copied correctly? Or there is yet another issue I have not identified.
- Brian
D. Brian Walton
James Madison University
My hypothesis is that the student actually used different units in his/her answer. There appears to be a bug in the way that answers with units are handled if they are used more than once in an answer checker.
For example, I tried your code on PGlabs and entered the answer in a number of different units. The correct answer for my problem happened to be 3 ft/min. If I entered 3 ft/min in both answers, I got both problems correct. So here are some interesting side effects:
3/60 ft/sec and 3/60 ft/sec will only mark the first correct
3/60 ft/sec and 3/60 ft/min will mark both correct.
3/60 ft/sec and 3 ft/min will only mark the first correct
4/60 ft/sec and 3 ft/min will mark both incorrect
4/60 ft/sec and 3/60 ft/min will mark the second answer correct (even though it is incorrect)
It appears that the answer checker actually does some internal manipulation of the answer object and that units are only considered the first time the answer object is used. The numerical part is updated to match the units the student enters, but it does not remember the new units for the next time it is used.
This may not be a complete answer, but it certainly has a high likelihood of impacting the student's issue. If this is the issue, then you should get around it by creating a second object for the second answer.
However, the answers that you provided don't seem entirely compatible with my hypothesis since 1/30 would be the answer in ft/sec for 2 ft/min and not 4 ft/min. Perhaps something was not quite copied correctly? Or there is yet another issue I have not identified.
- Brian
D. Brian Walton
James Madison University