Rather than using checker
, you should use list_checker
so that you replace the complete list checker rather than the individual entry checker. In that case, $correct
and $student
are array references rather than MathObjects, and they point to arrays containing the elements of the lists (in this case, the elements in the set). So you do have to put them back into sets.
Here is an example:
ANS($ans->cmp( list_checker=>sub{ my ($correct, $student, $ansHash ) = @_; $correct = Set(@{$correct}); $student = Set(@{$student}); return ($correct->isSubsetOf($student) && $student->isSubsetOf($together) ? $student->length : 0); }Note that the list_checker returns the number of correct entries in the student answer, so that is why we use
$student->length
as the return value when the answer is correct.
I know it is too late for your question, but I hope this helps someone in the future.
Davide