This article has been retained as a historical document. It is not up-to-date and the formatting may be lacking. Use the information herein with caution.

This problem has been replaced with a newer version of this problem

## Answer is a Fraction - Try the problem in WeBWorK

Click to enlarge

This PG code shows how to write a question in which the answer must be a fraction (rational number).

PG problem file Explanation

Problem tagging:

DOCUMENT();

'PGML.pl','PGcourse.pl');

TEXT(beginproblem());


Initialization:

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 contextFraction.pl BEGIN_PGML Simplify [ \displaystyle \frac{6}{4} ]. Answer = [_______________]{$answer->cmp(
studentsMustReduceFractions=>1,
reduceFractions=>1,
allowMixedNumbers=>0,
)}


BEGIN_PGML_SOLUTION