Fraction answer
Download file: FractionAnswer.pg
DOCUMENT(); loadMacros('PGstandard.pl', 'PGML.pl', 'contextFraction.pl', 'PGcourse.pl');
Preamble
The macro contextFraction.pl
must be loaded.
Context('Fraction-NoDecimals'); $answer = Compute('3/2');
Setup
The macro contextFraction.pl
provides four contexts:
'Fraction');
Context('Fraction-NoDecimals');
Context('LimitedFraction');
Context('LimitedProperFraction'); Context(
For the differences among these, see the POD documentation for contextFraction.pl.
BEGIN_PGML Simplify [``\frac{6}{4}``]. Answer = [_]{$answer->cmp( studentsMustReduceFractions => 1, reduceFractions => 1, allowMixedNumbers => 0 )}{15} END_PGML
Statement
There are many context flags that control how fraction answers are checked. See the POD documentation for contextFraction.pl.
BEGIN_PGML_SOLUTION Factor and cancel to obtain [`\displaystyle [$answer]`]. END_PGML_SOLUTION ENDDOCUMENT();
Solution
A solution should be provided here.