openwebwork/pg — pull request #24 by dpvc (2013-06-15 15:20:38+00:00)
Title: Fix correct_ans for Compute() when the result is a constant

Fix `correct_ans` generated by `Compute()` when the computed value is a constant (the correct_ans was incorrectly being set to the constant, not the original string that generated it, so `Compute("sqrt(2)")` would show `1.4142...` rather than `sqrt(2)` as the correct answer.

Also, moved creation of `correct_ans_latex_string` to `Compute()` so it properly corresponds to the correct answer string, and is available immediately. For answers not created through `Compute()`, move creation of `correct_ans_latex` string to `cmp()` rather than `cmp_parse()`, since the latter may not be called (e.g., withblank answers), leaving no latex string. That means that the correct answer will be displayed as un-formatted text for blank answers, but typeset math when an answer is entered. Moving the creation of `corrections_latex_string` to `cmp()` resolved that problem.