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();

loadMacros(
"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[0] = 1;
$power[1] = 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[0] = random(1,4,1);
$divisor[0] = 1;
$divisor[1] = $divisor[0];
while ($divisor[1] == $divisor[0]) {
$divisor[1] = random(1,4,1);
}

$constant[0] = non_zero_random(-8,8,2);
$constant[1] = non_zero_random(-7,7,2);


$function[0] = Formula("(x^$power[0])/$divisor[0] + $constant[0]")->reduce;
$function[1] = Formula("(x^$power[1])/$divisor[1] + $constant[1]")->reduce;


$at[0] = random(3,10,1);
$at[1] = $at[0];
while ($at[1] == $at[0]) {
$at[1] = random(3,10,1);
};
$at[1] = -$at[1];

Context("Fraction");

#The error message that eventually occurs points to these lines
$evaluated[0] = Compute($function[0]->substitute(x=>Formula("$at[0]")));
$evaluated[1] = Compute($function[1]->substitute(x=>Formula("$at[1]")));

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

Context()->texStrings;

BEGIN_TEXT

Evaluate the function \(f\) for \(x=$at[0]\), where \(f\) is given by \(f(x)=$function[0]\). $BR
$SPACE $SPACE $SPACE \{ans_rule(15)\}$PAR

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

END_TEXT

Context()->normalStrings;

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

$showPartialCorrectAnswers=1;

ANS( $evaluated[0] -> cmp() );
ANS( $evaluated[1] -> 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