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_PGML
But 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_PGML
This 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.