Traditional Answer Checkers - PGML

From WeBWorK_wiki
Revision as of 06:54, 13 May 2015 by Dpvc (talk | contribs) (Add example of using a variable)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Using Traditional Answer Checkers[edit]

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.