WeBWorK Problems

Bug with NumberWithUnits + AnswerHints

Bug with NumberWithUnits + AnswerHints

by Alex Jordan -
Number of replies: 0

The following MWE illustrates a bug. If you enter the correct answer, it is not accepted and there is a perl warning "The evaluated answer is not an answer hash : ||."

This came to my attention from an instructor who previously used certain problems in 2.16, and they worked. But now they do not work on 2.17. And this MWE does not work on 2.18. So it is possibly a bug introduced between 2.16 and 2.17.

Note that if you change $ans to a Real, there is no issue. I also tried making $ans an Interval and there was no issue. It seems to have to do with $ans being a NumberWithUnits. Also there is no issue if I remove the withPostFilter or pass an empty hash to AnswerHints. So it also seems to have to do with AnswerHints.


DOCUMENT();
loadMacros(qw(PGstandard.pl PGML.pl parserNumberWithUnits.pl answerHints.pl));
$ans = NumberWithUnits("1 m");
#$ans = Real("1");   # This works.
$cmp = $ans->cmp()->withPostFilter(AnswerHints(2 => "no"));

BEGIN_PGML
Enter [`[$ans]`].

[_]{$cmp}
END_PGML
ENDDOCUMENT();