WeBWorK Problems

Conditional Hints for Numbers with Units not Triggering

Conditional Hints for Numbers with Units not Triggering

by Todd Ruskell -
Number of replies: 0

I've been playing with conditional hints for numerical answers with units, and they're not behaving as I'd expect.  

If the correct answer is "1 m", then the answer checker will also correctly accept equivalent answers with different units.  In this case, for example, "100 cm" or "39.37 in" are also considered correct.  

But if I code a conditional hint that should be triggered for an incorrect answer of, say, "0.1 m", then equivalently wrong answers of "10 cm" or "3.937 in" do not trigger the hint.    Shouldn't the student answer be compared to the conditional hint answer in the same way the student answer is compared to the correct answer?  

Here's a simple bit of code that demonstrates this.  The incorrect answer of "0.1 m" triggers the hint.  But the equivalent incorrect answer of "10 cm" does not.

Any ideas?
----------------------------------

DOCUMENT();
loadMacros(
"PGstandard.pl",
"PGML.pl",
"MathObjects.pl",
"answerHints.pl",
"parserNumberWithUnits.pl",
);
Context("Numeric");
Context()->texStrings();
$DistanceUnit = NumberWithUnits(1.00, "m");
$ans = $DistanceUnit->cmp()->withPostFilter(AnswerHints(
NumberWithUnits(0.1, "m")=> "You need a distance 10 times larger"));

BEGIN_PGML
Enter a number equal to 1.00 m.
Distance = [_]{$ans}{10}
END_PGML
ENDDOCUMENT();