With the first problem, the error message "Try again" is correctly displayed if you submit an answer of 0.
With the second problem, the error message is not displayed if you submit the zero matrix as an answer.
Can anyone tell me what is missing from the second problem to get this to work? I'm using ww_version 2.9, pg_version 2.9.
Thanks!
#########################
## Problem 1
DOCUMENT();
loadMacros(
"PGstandard.pl",
"MathObjects.pl",
);
TEXT(beginproblem());
Context("Numeric");
$ans = Compute("1");
Context()->texStrings;
BEGIN_TEXT
Enter the identity in \(\mathbb{R}^\times\):
\(e = \) \{ $ans->ans_rule \}
END_TEXT
Context()->normalStrings;
$showPartialCorrectAnswers = 1;
sub mycheck {</font></div><div><font face="courier new, courier, monospace" size="2"><span class="Apple-tab-span" style="white-space:pre;"> </span>my ($correct, $student, $ansHash) = @_;</font></div><div><font face="courier new, courier, monospace" size="2"><span class="Apple-tab-span" style="white-space:pre;"> </span>Value->Error("Try again") if $student->isZero;</font></div><div><font face="courier new, courier, monospace" size="2"><span class="Apple-tab-span" style="white-space:pre;"> </span>return $student->isOne;</font></div><div><font face="courier new, courier, monospace" size="2">}
ANS( $ans->cmp( checker=>~~&mycheck ) );
ENDDOCUMENT();
###################################################
#########################
## Problem 2
DOCUMENT();
loadMacros(
"PGstandard.pl",
"MathObjects.pl",
);
TEXT(beginproblem());
Context("Matrix");
@A = ([1,0],[0,1]);
$ans = Matrix(@A);
Context()->texStrings;
BEGIN_TEXT
Enter the identity in \(\operatorname{GL}_2(\mathbb{R})\):
\(e = \) \{ $ans->ans_array \}
END_TEXT
Context()->normalStrings;
$showPartialCorrectAnswers = 1;
sub mycheck {</div><div><span class="Apple-tab-span" style="white-space:pre;"> </span>my ($correct, $student, $ansHash) = @_;</div><div><span class="Apple-tab-span" style="white-space:pre;"> </span>Value->Error("Try again") if $student->isZero;</div><div><span class="Apple-tab-span" style="white-space:pre;"> </span>return $student->isOne;</div><div>}
ANS( $ans->cmp( checker=>~~&mycheck ) );
ENDDOCUMENT();