## WeBWorK Problems

### Re: Answer preview format string for MathObjects.

by Davide Cervone -
Number of replies: 0

No, there are no options to control this directly, but you can use a post-filter for the answer checker to adjust the values that are displayed.

For example:

$a = Compute(12.34)->with( correct_ans_latex_string => "\text{The number } 12.34", # The "Correct Answer" column correct_ans => "The number 12.34", # The "Correct Answer" popup ); TEXT($a->ans_rule(5));

ANS($a->cmp->withPostFilter(sub { my$ans = shift;
if (!$ans->{error_message} &&$ans->{preview_text_string}) {
$ans->{student_ans} = "The number$ans->{student_ans}";                           # The "Entered" colomn
$ans->{preview_latex_string} = "\text{The number }$ans->{preview_latex_string}";  # The "Answer Preview" column
$ans->{preview_text_string} = "The number$ans->{preview_text_string}";           # "Answer Preview" Popup
}
return \$ans;
}));

You can, of course, adjust the values to be whatever you want. The test for existence of error_message is so that if there is a syntax error, for example, you won't overwrite the syntax highlighting.