## WeBWorK Problems

### Negative mixed numbers are not handled correctly

Number of replies: 1
The following code should require that the student enter "-1 7/10", but this generates an error message "You can only use '-' with (non-negative) numbers"

Any thoughts?

----

DOCUMENT();

"PGstandard.pl", # Standard macros for PG language
"MathObjects.pl",
"contextFraction.pl",
);

$a1 = -17;$a2 = 10;

Context("LimitedFraction");
$ansa = Compute("$a1/$a2"); Context()->texStrings; BEGIN_TEXT $$\frac{a1}{a2}=$$ \{ans_rule(35) \}$BR$BR END_TEXT Context()->normalStrings; ANS(Compute($ansa)->cmp);

ENDDOCUMENT();
Incidentally, there are two improvements I'd recommend for your code snippet above. First, you don't need the Compute() in the ANS call, as $ansa is already a MathObject, so computing it again is a waste of time. Second, you can use$ansa to generate the fraction in the text of the problem rather than having to write the LaTeX yourself, but you have to force it to use showMixedNumbers=>0 to get it to show as a pure fraction:
$$\{ansa->with(showProperFractions=>0)\} =$$ \{ans_rule(35)\}