WeBWorK Main Forum

Setting the answer as one of a few answers

Setting the answer as one of a few answers

by Utku Demir -
Number of replies: 1
Hi all,

I am setting the variables for the answer in the beginning of a problem. Is there a way to assign a few values so that when the student enters only one of the answers the question will count this as a correct answer? Here's an examples in case my problem sounds vague:
Please enter an even integer in [0,8]: I want only one answer, so if the student enters only, for example, 2 the answer will be accepted.
In reply to Utku Demir

Re: Setting the answer as one of a few answers

by Alex Jordan -
Hi Utku,

If there are only a few options, one approach is to load parserOneOf.pl. Then you can define the answer to be OneOf(0,2,4,6,8);


You can write a custom answer checker that literally checks if the submitted answer is even, greater than or equal to 0, and less than or equal to 8:


With that approach, you have to declare one number to be "the correct answer" as far as what gets displayed to a student as the correct answer after the answer date.