-
-
Notifications
You must be signed in to change notification settings - Fork 80
Description
If a NumberWithUnits is a part answer for a MultiAnswer or RadioMultiAnswer that has allowBlankAnswers => 1, then the correct answer for that part is not accepted as correct with the recent changes to NumberWithUnits.pm. I believe the problem is that with the recent changes, the NumberWithUnits uses a pre filter. However, when the allowBlankAnswer => 1 option is used, then all pre filters are removed including the new units pre filter.
The following MWE demonstrates the issue. Of course it doesn't make sense to use a MultiAnswer for a single answer like this, but this is a MWE and the actual problems where this is now an issue have other parts.
DOCUMENT();
loadMacros(
'PGstandard.pl', 'PGML.pl',
'parserNumberWithUnits.pl', 'parserMultiAnswer.pl'
);
$x = random(10, 100);
$ansUnit = NumberWithUnits(90, "~~x{00B0}");
$multians = MultiAnswer($ansUnit)->with(
allowBlankAnswers => 1,
checker => sub {
my ($correct, $student, $ma, $ans) = @_;
return $correct->[0] == $student->[0];
}
);
BEGIN_PGML
[`[$ansUnit] = `] [_]{$multians}{10}
END_PGML
ENDDOCUMENT();With that problem if you enter 90° (use MathQuill and type deg which is changed to the degree symbol) the checker is not called, and instead the message Unexpected character '°' is shown. With this same problem and WeBWorK/PG 2.19 the answer is accepted as correct.
Also, if you remove the allowBlankAnswers => 0 option and enter 90 without the degree unit, then you get the warning
Evaluation error in new process: Answer AnSwEr0001:
UNITS_NONE
::
Your answer doesn't look like a number with units
Note that if you add the checkTypes => 0 option , then you don't even get the message Your answer doesn't look like a number with units at all. Although the warning message is not shown.
Also the checker is called for the answer without the degree unit (a warn statement in the checker reveals this). It was not called in this case for 2.19.