## WeBWorK Problems

### Error with Fraction context ### Error with Fraction context

by Alex Jordan -
Number of replies: 0
I'm getting an error using Fraction context that I can't understand. Can anyone figure this out? I kind of suspect it is a bug in contextFraction.pl, because I can change the context to Numeric, and the compilation works fine (but I get decimals instead of nice fractions for reported answers).

Please note, either way I compile this, it compiles fine to *display the problem*. But I get an error message when I check "Show correct answers" and then click "Check answers".

The problem is for college algebra. It's supposed to give two functions and then ask for them to be evaluated at x-values. Here is the code, with comments where I have pinpointed the issue as best I can:

##############################################

DOCUMENT();

"PGstandard.pl",
"MathObjects.pl",
"contextFraction.pl",

);

TEXT(beginproblem());

##############################################
Context("Fraction"); #Change this to Numeric, and there are no compilation problems. But I want the answers that are displayed after the answer date to be nice fractions, and changing to Numeric undoes that.

$power = 1;$power = 2;

#The bug only happens when one of these divisors works out to be 1. So I've forced the first divisor to be 1 for debugging.

#$divisor = random(1,4,1);$divisor = 1;
$divisor =$divisor;
while ($divisor ==$divisor) {
$divisor = random(1,4,1); }$constant = non_zero_random(-8,8,2);
$constant = non_zero_random(-7,7,2);$function = Formula("(x^$power)/$divisor + $constant")->reduce;$function = Formula("(x^$power)/$divisor + $constant")->reduce;$at = random(3,10,1);
$at =$at;
while ($at ==$at) {
$at = random(3,10,1); };$at = -$at; Context("Fraction"); #The error message that eventually occurs points to these lines$evaluated = Compute($function->substitute(x=>Formula("$at")));
$evaluated = Compute($function->substitute(x=>Formula("$at"))); ############################################## Context()->texStrings; BEGIN_TEXT Evaluate the function $$f$$ for $$x=at$$, where $$f$$ is given by $$f(x)=function$$.$BR
$SPACE$SPACE $SPACE \{ans_rule(15)\}$PAR

Evaluate the function $$g$$ for $$x=at$$, where $$g$$ is given by $$g(x)=function$$. $BR$SPACE $SPACE$SPACE \{ans_rule(15)\}

END_TEXT

Context()->normalStrings;

##############################################

$showPartialCorrectAnswers=1; ANS($evaluated -> cmp() );
ANS( \$evaluated -> cmp() );

ENDDOCUMENT();

Again, for me this always compiles fine, until I ask for to "Show correct answers". The error message I get is:

Can't locate object method "make" via package "context::Fraction::Real" (perhaps you forgot to load "context::Fraction::Real"?) at /opt/webwork/pg/lib/Parser/Number.pm line 66.

Can anyone shed light on this?

Alex