The "old" answer checker had an option to specify the units for an answer:
&ANS(num_cmp($ans1,reltol=>1,format=>'%0.4g',units=>'ohm') );
Is there a way to do this in PGML? The old answer checker was really good about "knowing" how to convert units (24 cm = 240 mm = .24 m). Will PGML use this same option?
You can use any answer checkering in PGML that you could in traditional problems. For example, you could use
$cmp = num_cmp($ans1,reltol=>1,format=>'%0.4g',units=>'ohm') ; BEGIN_PGML The answer is [_________________]{$cmp}; END_PGMLBut you could also use the MathObject version of that by loading
parserNumberWithUnits.pl
and then creating a MathObject with NUmberWithUnits()
. E.g.,
loadMacros("parserNumberWithUnits.pl"); $ans = NumberWithUnits($ans1,'ohm'); BEGIN_PGML The answer is [_________________]{$ans}; END_PGMLThis uses the same library as the traditional
num_cmp
to do the units checking, so it should provide the same functionality as the traditional approach.