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 contextFraction.pl macro provides four contexts:
Context('Fraction');
Context('Fraction-NoDecimals');
Context('LimitedFraction');
Context('LimitedProperFraction');See contextFraction.pl for the differences between these contexts.
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 documentation for the contextFraction.pl macro for more details.
BEGIN_PGML_SOLUTION Factor and cancel to obtain [`\displaystyle [$answer]`]. END_PGML_SOLUTION ENDDOCUMENT();
Solution
A solution should be provided here.