Using Context(“Fraction”) and only the associated context default values, I have found that responses that use decimal approximations in response to an answer blank that is assigned a Fraction object for comparison are unable to achieve a valid result whenever the decimal form is non-terminating (regardless of how many significant figures are provided, and despite the default tolerance).
In such a case, no error is provided by default - but using the AnswerHashInfo option, an error appears in the student_formula portion of the answer hash as follows:
Unable to determine stringify for this item Can’t locate object method “string” via package “context::Fraction::Real” at /opt/WeBWorK/pg/lib/Parser/Number.pm line 66
I have attempted to add a variety of string methods to the context::Fraction::Real segment of contextFraction.pl to no avail. There’s still something I’m not grasping about perl inheritance, perhaps...
@dpvc any ideas?
Context(“Fraction”);
$ans = Fraction(1,3);
BEGIN_PGML
Try a decimal approximation of [`\frac{1}{3}`]: [_______]{$ans}
END_PGML
Using Context(“Fraction”) and only the associated context default values, I have found that responses that use decimal approximations in response to an answer blank that is assigned a Fraction object for comparison are unable to achieve a valid result whenever the decimal form is non-terminating (regardless of how many significant figures are provided, and despite the default tolerance).
In such a case, no error is provided by default - but using the AnswerHashInfo option, an error appears in the
student_formulaportion of the answer hash as follows:Unable to determine stringify for this item Can’t locate object method “string” via package “context::Fraction::Real” at /opt/WeBWorK/pg/lib/Parser/Number.pm line 66I have attempted to add a variety of string methods to the context::Fraction::Real segment of contextFraction.pl to no avail. There’s still something I’m not grasping about perl inheritance, perhaps...
@dpvc any ideas?