Traditional Answer Checkers - PGML

From WeBWorK_wiki
Jump to navigation Jump to search

Using Traditional Answer Checkers

The answer blanks in PGML usually use Category:MathObjects to provide the answer checkers for them, but you can also use the traditional answer checkers, like num_cmp() and str_cmp() in PGML. To do so, simply include the traditional-answer-checker function-call in the braces following the answer blank.

 $a = 3; $b = 5;
 BEGIN_PGML
 The value of [: [$a] + [$b] :] is [________]{strict_num_cmp($a+$b)}
 END_PGML

The traditional string answer checkers amy be useful to use, since they provide some options not available in MathObjects, and don't require setting up the context to include the desired strings.

You can also store an answer checker in a variable and pass that to PGML:

 $a = 3; $b = 5;
 $cmp = strict_num_cmp($a+$b);
 BEGIN_PGML
 The value of [: [$a] + [$b] :] is [________]{$cmp}
 END_PGML

This can make the text of your PGML block problem easier to read.