WeBWorK Problems

using contexts for grade school answers

Re: using contexts for grade school answers

by Davide Cervone -
Number of replies: 0
Looks to me like the error is the line
   #my $F = Parser::Formula($ans->{correct_ans})->{tree};
where you have commented out the command, so $F never gets defined, and then in the next line $F->{lop} is also undefined, and so $F->{lop}->eval is trying to call eval on an undefined value. That is what the error message suggests, and certainly having this command commented out is a copying error.

You say that the entered and preview answer disagree, but they look like they agree to me. The usual result of a numeric answer checker is to make the "entered" field be the result of formula the student answered, and the "preview" field be the typeset version of the parsed answer. That is what is happening here.

You can control how the student answer is shown using the formatStudentAnswer context flag. Since you are switching contexts so much, it might be easier to use it on the MathObject itself:

    $ans3 = Compute("$a3/$b3")->with(formatStudentAnswer=>"parsed");
and the same for $ans4. That will cause the "entered" field to show the full equation rather than the result of the equation. That is probably what you are after.

Davide