-
-
Notifications
You must be signed in to change notification settings - Fork 166
Description
There is an error in the AttemptsTable in 2.18 that causes a perl warning when entering in a non-empty set as an answer for an empty set. Consider the following example problem.
DOCUMENT();
loadMacros('PGstandard.pl', 'PGML.pl', 'PGcourse.pl');
Context('Interval');
$empty = Set("{}");
BEGIN_PGML
Enter the emptyset: [_]{$empty}
END_PGML
ENDDOCUMENT();
Enter in any non-empty set as an answer, like {1}. AttemptsTable.pm gives the following warning if viewing the problem in Problem.pm after it has been assigned to a set (this warning does not appear in the PGProblemEditor).
Argument "" isn't numeric in numeric ge (>=) at /opt/webwork/webwork2-develop/lib/WeBWorK/HTML/AttemptsTable.pm line 230.
The error is due to the previous line:
my $answerScore = $rh_answer->{score} // 0;So for some reason in this case with a non-empty set entered in as an answer for an emptyset, somewhere in pg/webwork, the answer hash $rh_answer->{score} gets set to the empty string, "", and not zero.
A quick fix for this issue was to also default $answerScore to zero if this is the empty string with:
my $answerScore = $rh_answer->{score} || 0;Though I think the issue is something else before this point setting $rh_answer->{score} to the empty string and not zero, since this warning doesn't seem to appear in other problems.
Since the AnswerTable.pm is not being used anymore, this is no longer an issue in develop, only 2.18 (though maybe a hotfix might be useful), but I think there might be a deeper issue that should be addressed instead (unsure if there might be other places that would fail of the score in this case was the empty string instead of 0 or undefined).