https://webwork.maa.org/mediawiki_new/index.php?title=External_Answer_Checkers_-_PGML&feed=atom&action=historyExternal Answer Checkers - PGML - Revision history2024-03-29T00:26:37ZRevision history for this page on the wikiMediaWiki 1.34.0https://webwork.maa.org/mediawiki_new/index.php?title=External_Answer_Checkers_-_PGML&diff=16466&oldid=prevDpvc: Initial version2015-05-13T12:09:02Z<p>Initial version</p>
<p><b>New page</b></p><div>== Using ANS() with PGML ==<br />
<br />
Although it is customary to provide the correct answer right for an answer blank after the blank in the PGML code, it is also possible to provide the answer later using the <code>ANS()</code> macro, as is done with <code>BEGIN_TEXT/END_TEXT</code> blocks. To do this, simply don't put any braces after the answer blank.<br />
<br />
loadMacros("contextLimitedNumeric.pl");<br />
Context("LimitedNumeric");<br />
$a = 3; $b = 5;<br />
$answer = Real($a+$b);<br />
<br />
BEGIN_PGML<br />
The value of [: [$a] + [$b] :] is [_______]<br />
END_PGML<br />
<br />
ANS($answer->cmp);<br />
<br />
You can use all the traditional or MathObject based answer checkers this way.<br />
<br />
If there is more than one answer blank, then the answer checkers are paired with them by order, as usual.<br />
<br />
Context("Numeric");<br />
Context()->functions->disable("sqrt");<br />
Context()->operators->remove("^","**");<br />
$a = 16; $b = 9;<br />
$ra = Real(sqrt($a)); $rb = Real(sqrt($b));<br />
<br />
BEGIN_PGML<br />
The value of [: sqrt([$a]) :] is [___________] <br />
The value of [: sqrt([$b]) :] is [___________]<br />
END_PGML<br />
<br />
ANS(<br />
$ra->cmp,<br />
$rb->cmp<br />
);<br />
<br />
[[Category:PGML]]<br />
[[Category:PGML Syntax]]<br />
[[Category:PGML Answers]]</div>Dpvc