Imagine an arithmetic test where you wanted student to avoid taking

advantage of Webwork's flexibility in allowing operations like

1.2*6.73/0.2 as the answer.

cs

This forum has a limit to the number of forum postings you can make in a given time period - this is currently set at 10 posting(s) in 1 day

In reply to Christian Seberino
### Re: How force answer to be ONLY a decimal in PGML? or ONLY a fraction? (No operations allowed.)

by Davide Cervone -

These features are controlled by the Context that you have selected. The answers in PGML use the currently active context, so if you set the context to the Fraction context, for example, then the answer will only be able to be fractions. E.g.,

loadMacros("contextFraction.pl"); Context("Fraction-NoDecimals"); BEGIN_PGML .5 = [_______]{"1/2"} END_PGMLwould force the student to enter a value that produces .5 without using decimal numbers (but perhaps one of the strict fraction contexts would be better, here, see the documentation for details).

Similarly, you could use the limited numeric context to force decimal representation:

Context("LimitedNUmeric"); BEGIN_PGML [:1/2:] = [_______]{.5} END_PGMLwould not accept 1/2.

You can do both in the same problem by doing:

loadMacros("contextFraction.pl"); Context("Fraction-NoDecimals"); $ans1 = Compute("1/2"); Context("LimitedNumeric"); $ans2 = Compute(".5"); BEGIN_PGML [`.5`] = [_______]{$ans1} [:1/2:] = [_______]{$ans2} END_PGMLHope that helps.

Davide

In reply to Davide Cervone
### Re: How force answer to be ONLY a decimal in PGML? or ONLY a fraction? (No operations allowed.)

by Christian Seberino -

Great! Thanks. Very thorough answer.

cs