WeBWorK Problems

Checking against multiple correct answers

Checking against multiple correct answers

by Danny Glin -
Number of replies: 1
I was wondering if there was an easy way to specify a short list of different correct answers for a single answer blank. The problem is as follows:
Students are asked to calculate the characteristic polynomial of a 3x3 matrix. Depending on how they are taught, some will answer det(A-xI) and some will answer det(xI-A), which differ by a factor of -1. I would like the system to accept either of these two answers, but nothing else.
Any suggestions?
In reply to Danny Glin

Re: Checking against multiple correct answers

by Davide Cervone -
Well, if you are using MathObjects, then providing a custom answer checker might be the way to go. Something like
    $p = Formula("your formula here");
    ...
    ANS($p->cmp(checker => sub {
      my ($correct,$student) = @_;
      return $correct == $student || $correct == -$student;
    });
should do the trick.

Davide