We've
been discovering a few numerical bugs with the code we've written for a
problem using the Parser. If you enter seed 1234 and enter the point
(10.6, 2.9), then Webwork marks the answer as partially incorrect. If
you enter points with integer coefficients such as (2,5) or (10,3),
the answer is marked as correct. Some decimal answers do work, but many
don't. I don't see any problem with the code (which is attached below).
By the way, the problem below is a simplification that still shows the
error.
Thanks in advance for your suggestions,
Tom
## DESCRIPTION
## KEYWORDS('vectors', 'independent', 'dependent', 'relation')
##
## ENDDESCRIPTION
DOCUMENT(); # This should be the first executable line in the problem.
loadMacros(
PG.pl,
PGbasicmacros.pl,
PGchoicemacros.pl,
PGanswermacros.pl,
PGgraphmacros.pl,
PGmatrixmacros.pl,
PGnumericalmacros.pl,
PGauxiliaryFunctions.pl,
PGmorematrixmacros.pl,
PGdiffeqmacros.pl,
"Parser.pl",
"Generic.pl"
);
TEXT(beginproblem());
$showPartialCorrectAnswers = 1;
$p1 = non_zero_random(6,6,1);
$p2 = random(5,5,2);
$q1 = non_zero_random(6,6,1);
$q2 = random(6,6,2);
$ans1 = $q1$p1;
$ans2 = $q2$p2;
$vecp = Matrix>new_column_matrix([$p1, $p2]);
$slope = Matrix>new_column_matrix([$ans1, $ans2]);
$v1 = new Matrix(2,1);
$v1>assign(1,1, $ans1);
$v1>assign(2,1, $ans2);
BEGIN_TEXT
Enter a point on the line
{ mbox( '( v = )', display_matrix($vecp), '( + t) ', display_matrix($slope), '.' ) }
$BR
{ mbox( '(x=)', answer_matrix(2,1,5) ) }
END_TEXT
$spot=0;
ANS(generic_cmp("1", type => 'Number', length=>1, checker=> ~~&check));
ANS(generic_cmp("1", type => 'Number', length=>1, checker=> ~~&check));
sub check{
my $stu=shift();
$w[$spot]=$stu>extract(1);
if($spot<1){
$spot=$spot+1; 1;
}else{
$ww[0]=$w[0]$p1;
$ww[1]=$w[1]$p2;
$avec1=$v1>element(1,1);
$avec2=$v1>element(2,1);
if($avec1 * $ww[1] == $ww[0] * $avec2){
1;
}else{
0;
}
}
}
ENDDOCUMENT() ;
< Post or View Comments >
