WeBWorK Problems

Using Context(Fraction-NoDecimal) on FormulaUpToConstant

Re: Using Context(Fraction-NoDecimal) on FormulaUpToConstant

by Davide Cervone -
Number of replies: 0
I thought that with Context("Fraction"), there was no actual difference with the Formula math object, compared to Context("Numeric"). But you are saying there is?

Yes, there is a difference. When Context("Fraction") is in effect, fractions are retained as fractions and will display as fractions, even when reduceConstants is false (unless the fractions are combined with other constants). It's not much of a difference, but it one.

On the other hand, unreduced fractions do **not** produce warnings in formulas. The reason is that the warnings are produced by an answer checker post-filter that is applied to the Fraction object class. So it doesn't run for Formula objects (and would be hard to make work in that setting).

In order to make unreduced fractions report warnings in formulas, the warning message would need to be generated the the fraction is created (as part of the larger formula) rather than in a post-filter.

In some ways, this was a bad design decision, and one that affects several other objects as well (e.g., the check for parallel vectors is in a post-filter). I thought the post-filters would be a good way to do this, but it turns out it would be better to have those checks made in the objects themselves, so that equality checks in custom answer checkers, for example, could take advantage of them.

Unfortunately, at this time, there is no mechanism for forcing reduced fractions in formulas.