There is a flag, showEqualErrors
that controls whether the MathObject answer checker reports errors that occur during the equality comparison (which is when the checker
is called). For most object types, this is set to 1, but for the Matrix class, it is 0 by default. I no longer remember why that was set to 0, but it has been that way for the past 14 years. So Value->Error()
inside a Matrix checker
routine will stop the answer checker from running, but will not report the error in the answer table. Again, I don't remember why that was done, but it has been the case for quite some time.
There are several possible solutions.
Set
showEqualErrors=>1
in thecmp()
call for the answers that could have error message.Use something like
ANS($answer->cmp(checker => sub { my ($correct, $student,$ans) = @_; $correct->cmp_Error($ans,'testing'); }));
for the error messages rather than
Value->Error();
.Modify
pg/lib/Value/AnswerChecker.pm
to change the setting forshowEqualErrors
to 1 in theValue::Matrix
package.Use
parserCustomization.pl
to do something like$context{Matrix} = Context("Matrix"); Context->{cmpDefaults}{Matrix}{showEqualErrors} = 1; Context("Numeric");
(The middle line could also be used in a .pg file to set this for all Matrix answers)
Note that, other than 2 above, these may cause other unwanted error messages to show up. I think the reason they were turned off is that if the student enters a Matrix of the wrong size, the message will be "Can't compare matrices of different dimensions" or something like that, rather than the better "Matrix dimension is not correct", but I suppose you could use the Context()->{msg}
remapping mechanism to fix that as well. There might be other situations that I'm not able to think of at this point.
In any case, I don't see how the problem would have been working in the past without having done one of these things, since the code that controls it has been there for more than a decade.