You can also manually set the correct answer latex string for a MathObject. For example:
$ans->{correct_ans_latex_string} = "2\sqrt{2}";
This will override what appears in the "Correct Answers" column of the results table, but there are a couple of things to watch out for:
- Variables will be interpolated (so you could do $ans->{correct_ans_latex_string} = "2\sqrt{$a}";), but no further processing will be done on the string.
- Since you are overriding the display it is possible to have the correct answer that is displayed to students differ from the actual correct answer (for example due to a typo, or modifying $ans after setting correct_ans_latex_string).