WeBWorK Problems

parserFunction in answers

Re: parserFunction in answers

by Davide Cervone -
Number of replies: 0
The student_value property is the wrong one to change. This is (and should always be) the MathObject that was obtained from parsing the student's answer. It is a mistake to replace this by a string, as other parts of WW may look at this value and expect to have a MathObject (e.g., AnswerHints, or other post-filters).


The field that ends up in the "Entered" column is student_ans (corresponding to corrections, just as student_value corresponds to correct_value). You certainly can set that during a custom answer checker.


But there is an easier way. The formatStudentAnswer flag in the Context controls how the entered field will be displayed. If you want it to be "f(2)" rather than "8", set it to parsed or reduced, as I did in my example above. The difference between the two is that reduced will reduce constant expressions, and so will make "f(2+3)" into "f(5)", while parsed will show the original without any modifications (so would show "f(2+3)").