WeBWorK Problems

manipulating webwork answers

manipulating webwork answers

by Helena Verrill -
Number of replies: 1
Is it possible to manipulate answers students given to webwork problems?
From the examples I am looking at in the library, I can't see how to do this.

It would be very convenient, if instead of just being able to compare the students answer with a given answer, I apply some function to the answer they enter first. 
E.g., I am trying to write a problem where the student should enter the gcd of two numbers a,b, and also u,v such that au + bv = gcd(a,b).
Since u,v are not uniquely determined, it would be much nicer if I could just
take the values u,v which the student enters, and compute au + bv, and compare this with the value of the gcd.  That way, I don't need to bother telling the student to put u in the range 0 to b, and also it ought to be easier to do this test than to get the webwork to actually calculate some values for u, v.
I can imagine plenty of other cases where it would be nice to manipulate answers, so help on how to do this would be great.
In reply to Helena Verrill

Re: manipulating webwork answers

by Davide Cervone -
If you use the new MathObjects (formerly called Parser objects), you can easily include custom answer checkers that could do more sophisticated checking of answers. You should look at the MultiPart object (in pg/macros/parserMultiPart.pl), and the custom answer checkers (in pg/macros/answerCustom.pl). There are some comments at the beginning of these files that should help. Also there are some examples in the past discussions. Try

http://65.206.22.46/moodle/mod/forum/discuss.php?d=1199

http://65.206.22.46/moodle/mod/forum/discuss.php?d=1180

http://65.206.22.46/moodle/mod/forum/discuss.php?d=1102

http://65.206.22.46/moodle/mod/forum/discuss.php?d=1089

http://65.206.22.46/moodle/mod/forum/discuss.php?d=1077

for starters.

Davide