WeBWorK Main Forum

Answer checker question

Re: Answer checker question

by Danny Glin -
Number of replies: 0
Here's what I was able to determine:
The Compute function parses the string you pass it and tries to determine what type of object it is. Because you are in the Numeric context it is expecting numbers (and the strings you have added), so it is interpreting (a,b) as a list of strings/numbers. Thus it accepts either a,b or b,a (without parentheses) as a correct answers. If a student includes parentheses in their submitted answer, it assumes that they intended to enter a point, so it complains about the wrong type of input. It's worth noting that (as far as I can tell) the entry_type flag doesn't change the behaviour of the answer checker. It simply changes the feedback messages to students.

The Point context is probably closer to what you want, but there are at least two problems: 1. The Point context doesn't support strings, and 2. The error messages will talk about points and not pairs. The following code at least appears to grade things properly (marking correct answers correct and incorrect answers wrong), but the error messages when a student enters something in the wrong format are not what you want.


foreach my $i(a..w) {



$a1 = Compute("(a,b)");

$a2 = Compute("(a,b), (c,d)");


Enter [`(a, b)`] [____________]

Enter [`(a, b), (c, d)`] [____________]


# Answer evaluation

$showPartialCorrectAnswers = 1;