WeBWorK Main Forum

How to let PGML accept multiple alternative string answers for a single question

Re: How to let PGML accept multiple alternative string answers for a single question

by Davide Cervone -
Number of replies: 0
You can use the OneOf MathObject available from the parserOneOf.pl file (see its documentation for details). For example:
    loadMacros(
      "PGML.pl",
      "parerOneOf.pl",
    );
    
    BEGIN_PGML
    Your answer is: [__________]{OneOf("x+1","x-1")}
    END_PGML
would allow the student to answer either x+1 or x-1 (or 1+x, or -(1-x), or anything equivalent to one of those).

On the other hand, I've just posted an answer to another question that includes a context for permutations, in in that context, both of your answers would be marked correct automatically. So you might be better off using that context directly.

In your can, you might also need to accept "(312)", "(231)", "(312)(4)", "(231)(4)", "(4)(123)", etc., unless you are forcing the students to enter the permutation in a canonical form. The context that I created allows you some control over whether the student must use disjoint cycles, or use the canonical form.