## WeBWorK Problems

### Re: Showing correct answers as expressions in PG

by Davide Cervone -
Number of replies: 0
As Alex points out, the value of $b is a Real, and when $b is inserted into a string (like the text of the hint), it's value is inserted. The original string is saved to be used as the correct answer string, but that is the only place the original string is used.

Alex suggests setting reduceConstants=>0 and using Formula rather than Compute to get the effect you want. That is a good suggestion provided you are not using $b as an answer that the student must enter. If you make $b a formula, then ANS($b->cmp) will make an answer checker that expects the student to enter a formula (not a number) and will produce error messages to that effect, which could be misleading. There are two solutions to this. Either use ANS($b->eval->cmp) if you use $b as an answer, or use $b=Compute("1+\$a") and $$b->{original_formula}$$ instead (along with the reduceConstants=>0 flag).

Hope that helps.

Davide