You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I ran across an issue where lib/WeBWorK/PG/Translator.pm (line 1514) in avg_problem_grader is warning that Error in grading this problem the total 1 is larger than 1, which should only trigger if $total > $count which appear to both be 1 when using a single MultiAnswer grader.
Here is my test problem:
DOCUMENT();
loadMacros(
'PGstandard.pl',
'PGML.pl',
'parserMultiAnswer.pl',
);
$showPartialCorrectAnswers = 1;
$ans1 = Compute("pi");
$ans2 = Compute("x^2");
$ans3 = Compute("3");
$ans4 = Compute("4");
$ans5 = Compute("5");
$ans6 = Compute("6");
$ma = MultiAnswer($ans1, $ans2, $ans3, $ans4, $ans5, $ans6)->with(
singleResult => 1,
allowBlankAnswer => 1,
checkTypes => 1,
format => '%s; %s; %s; %s; %s; %s',
tex_format => '%s; %s; %s; %s; %s; %s',
checker => sub {
my ($correct, $student, $self, $ansHash) = @_;
my @c = @{$correct};
my @s = @{$student};
my $score = 0;
$score += 0.3 if ($c[0] == $s[0]);
$score += 0.5 if ($c[1] == $s[1]);
foreach (2..5) {
$score += 0.05 if ($c[$_] == $s[$_]);
}
#Value->Error($score);
return $score;
}
);
BEGIN_PGML
+ Enter [`\pi`]: [_]{$ma}
+ Enter [`x^2`]: [_]{$ma}
+ Enter [`3`]: [_]{$ma}
+ Enter [`4`]: [_]{$ma}
+ Enter [`5`]: [_]{$ma}
+ Enter [`6`]: [_]{$ma}
END_PGML
ENDDOCUMENT();
The warning only happens if the problem has all answers parts correct. I have tried this with both 2 and 4 answer boxes and the warning doesn't occur, so it is something subtle in the grader I wrote, but can't track it down.
The text was updated successfully, but these errors were encountered:
Trying to debug this, it seems that this is floating point rounding issue. But when the number is actually printed as a string, the floating point error is lost. I was able to fix the issue in this problem by just using return round(100*$score)/100; which seemed to get rid of any hidden floating point issues this particular sum of values created. (Note if I used 0.3 + 0.3 + 0.1 + 0.1 + 0.1 + 0.1, the warning would vanish, the problem would say partial credit was 100% correct, but the WeBWorK AttemptsTable.pm would say the problem was incorrect, so rounding issue was on the other side).
I think the issue is PG should round the score value earlier in the logic chain to remove any possible floating point errors before it attempts any logical checks on the score (such as to see if the score is larger than 1, which is done in both PG and WeBWorK).
somiaj
changed the title
PG warns that 1 is larger than 1 with MultiAnswer
Round PG score eariler in logic chain to avoid floating point errors.
Oct 13, 2022
I ran across an issue where
lib/WeBWorK/PG/Translator.pm
(line 1514) inavg_problem_grader
is warning thatError in grading this problem the total 1 is larger than 1
, which should only trigger if$total > $count
which appear to both be1
when using a single MultiAnswer grader.Here is my test problem:
The warning only happens if the problem has all answers parts correct. I have tried this with both 2 and 4 answer boxes and the warning doesn't occur, so it is something subtle in the grader I wrote, but can't track it down.
The text was updated successfully, but these errors were encountered: