[system] / trunk / pg / macros / contextFraction.pl Repository: Repository Listing bbplugincoursesdistsnplrochestersystemwww

# Diff of /trunk/pg/macros/contextFraction.pl

Revision 5975 Revision 5976
19 19
20and then select the appropriate context -- one of the following three: 20and then select the appropriate context -- one of the following three:
21 21
22 Context("Fraction"); 22 Context("Fraction");
23 Context("Fraction-NoDecimal"); 23 Context("Fraction-NoDecimals");
24 Context("LimitedFraction"); 24 Context("LimitedFraction");
25 25
26The first is the most general, and allows fractions to be intermixed 26The first is the most general, and allows fractions to be intermixed
27with real numbers, so 1/2 + .5 would be allowed. Also, 1/2.5 is 27with real numbers, so 1/2 + .5 would be allowed. Also, 1/2.5 is
28allowed, though it produces a real number, not a fraction, since this 28allowed, though it produces a real number, not a fraction, since this
86 ANS(\$b->cmp); 86 ANS(\$b->cmp);
87 87
88There are several options to the cmp() method that control how the 88There are several options to the cmp() method that control how the
89answer checker will work. The first is controls whether unreduced 89answer checker will work. The first is controls whether unreduced
90fractions are accepted as correct. Unreduced fractions are allowed in 90fractions are accepted as correct. Unreduced fractions are allowed in
91the Fraction and Fraction->NoDecimals contexts, but not in the 91the Fraction and Fraction-NoDecimals contexts, but not in the
92LimitedFraction context. You can control this using the 92LimitedFraction context. You can control this using the
93studentsMustReduceFractions option: 93studentsMustReduceFractions option:
94 94
95 Context("Fraction"); 95 Context("Fraction");
96 ANS(Compute("1/2")->cmp(studentsMustReduceFractions=>1)); 96 ANS(Compute("1/2")->cmp(studentsMustReduceFractions=>1));
137 137
138This determines whether division is allowed only between integers or 138This determines whether division is allowed only between integers or
139not. If you want to prevent division from accepting non-integers, 139not. If you want to prevent division from accepting non-integers,
140then set strictFractions=>1 (and also strictMinus=>1 and 140then set strictFractions=>1 (and also strictMinus=>1 and
141strictMultiplication=>1). These are all three 0 by default in the 141strictMultiplication=>1). These are all three 0 by default in the
142Fraction and Fraction->NoDecimals contexts, but 1 in LimitedFraction. 142Fraction and Fraction-NoDecimals contexts, but 1 in LimitedFraction.
143 143
144=item S<C<< allowProperFractions >>> 144=item S<C<< allowProperFractions >>>
145 145
146This determines whether a space between a whole number and a fraction 146This determines whether a space between a whole number and a fraction
147is interpretted as implicit multiplication (as it usually would be in 147is interpretted as implicit multiplication (as it usually would be in
148WeBWorK), or as addition, allowing "4 1/2" to mean "4 and 1/2". By 148WeBWorK), or as addition, allowing "4 1/2" to mean "4 and 1/2". By
149default, it acts as multiplication in the Fraction and 149default, it acts as multiplication in the Fraction and
150Fraction->NoDecimals contexts, and as addition in LimitedFraction. If 150Fraction-NoDecimals contexts, and as addition in LimitedFraction. If
151you set allowProperFractions=>1 you should also set reduceConstants=>0. 151you set allowProperFractions=>1 you should also set reduceConstants=>0.
152 152
153=item S<C<< requireProperFractions >>> 153=item S<C<< requireProperFractions >>>
154 154
155This determines whether fractions MUST be entered as proper fractions. 155This determines whether fractions MUST be entered as proper fractions.

Legend:
 Removed from v.5975 changed lines Added in v.5976