Copied from https://webwork.maa.org/moodle/mod/forum/discuss.php?d=6553
When using the cmp method for a Matrix MathObject, if a student enters a list that is not a matrix, then they get an error like the following:
Error messages
'require' trapped by operation mask at /usr/lib64/perl5/vendor_perl/Encode.pm line 5. Compilation failed in require at /usr/lib64/perl5/vendor_perl/Encode/Alias.pm line 22.
Call stack
The following information can help locate the source of the problem.
in WeBWorK::PG::Local::new called at line 51 of /opt/webwork/webwork2/lib/WeBWorK/PG.pm
in WeBWorK::PG::new called at line 738 of /opt/webwork/webwork2/lib/WeBWorK/ContentGenerator/Problem.pm
in WeBWorK::ContentGenerator::Problem::pre_header_initialize called at line 213 of /opt/webwork/webwork2/lib/WeBWorK/ContentGenerator.pm
in WeBWorK::ContentGenerator::go called at line 386 of /opt/webwork/webwork2/lib/WeBWorK.pm
The one exception is if they enter the correct answer without the outer brackets.
A MWE is quoted at the end of this message. For that MWE, if a student enters a valid matrix, it is graded properly. If they enter a matrix with a syntax error, they get an appropriate message. If they enter a list that is not a matrix (e.g. "1,2", or "[1,2],[3,5]"), they get the error quoted above. The one exception is if they enter "[1,2],[3,4]", which is marked correct (and shouldn't be IMO, since that is a list of 1x2 matrices, and not a 2x2 matrix).
DOCUMENT(); # This should be the first executable line in the problem.
loadMacros(
"PG.pl",
"PGbasicmacros.pl",
"MathObjects.pl",
);
TEXT(&beginproblem);
$showPartialCorrectAnswers = 1;
Context("Matrix");
$B = Matrix([[1,2],[3,4]]);
BEGIN_TEXT
Enter \(\{$B->TeX\}\)$PAR
\{ans_rule(50)\}
END_TEXT
ANS($B->cmp());
ENDDOCUMENT();
Copied from https://webwork.maa.org/moodle/mod/forum/discuss.php?d=6553
When using the cmp method for a Matrix MathObject, if a student enters a list that is not a matrix, then they get an error like the following:
The one exception is if they enter the correct answer without the outer brackets.
A MWE is quoted at the end of this message. For that MWE, if a student enters a valid matrix, it is graded properly. If they enter a matrix with a syntax error, they get an appropriate message. If they enter a list that is not a matrix (e.g. "1,2", or "[1,2],[3,5]"), they get the error quoted above. The one exception is if they enter "[1,2],[3,4]", which is marked correct (and shouldn't be IMO, since that is a list of 1x2 matrices, and not a 2x2 matrix).