Fraction Answer

Fraction answer

Complete Code

Download file: FractionAnswer.pg

POD for Macro Files

PG problem file

Explanation

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:

 Context('Fraction');
 Context('Fraction-NoDecimals');
 Context('LimitedFraction');
 Context('LimitedProperFraction');

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.