WeBWorK Problems

error with LimitedPolynomial?

error with LimitedPolynomial?

by Richard Lynch -
Number of replies: 1
Hi Everyone. When we updated our system to the  new version of Webwork, a bunch of problems using the limited polynomial context started to produce errors. In particular, it gave the error "Can't locate object method 'weaken' via package 'LimitedPolynomial::UOP::minus'..." The code that uses the context is below. It is giving an error at the line in which Formula is called. Again, these all worked fine before, and the code doesn't appear to be incorrect, which is why I think it may be an issue with the context itself. Any ideas? Thank you!

###########################################################################
# setup contexts and variables 
###########################################################################
Context("LimitedPolynomial-Strict");
$var = list_random('x','y','z','t','p','q','u','v');
Context()->variables->are(lc($var)=>"Real", uc($var)=>"Real");

do {($a2,$a1,$a0) = (non_zero_random(-7,7), non_zero_random(-7,7), non_zero_random(-7,7))} until (abs($a1) != abs($a2));
do {($b2,$b1,$b0) = (non_zero_random(-7,7), non_zero_random(-7,7), non_zero_random(-7,7))} until (abs($b2) != abs($a2) || abs($b1) != abs($a1));

$poly1 = nicestring([$a2,$a1,$a0], ["$var^2","$var",""]);
$poly2 = nicestring([$b2,$b1,$b0], ["$var^2","$var",""]);
$expn = "($poly1) + ($poly2)";

$poly = nicestring([$a2+$b2,$a1+$b1,$a0+$b0], ["$var^2","$var",""]);
$answer = Formula($poly)->reduce;


###########################################################################
# state the problem 
###########################################################################
Context()->texStrings;
BEGIN_TEXT
Perform the operation
$PAR\[ $expn \] $PAR
and combine line terms. Simplify your answer as much as possible.
$PAR
Answer: \{ans_rule(30)\}
END_TEXT
Context()->normalStrings;


###########################################################################
# check the answer  
###########################################################################
ANS($answer->cmp());



Attachment Capture2.PNG
In reply to Richard Lynch

Re: error with LimitedPolynomial?

by Davide Cervone -
The code sample you provide works for me on the development version of WeBWorK, and with WW 2.5.

What version of WeBWorK and PG are you using? There were some changes to both WW and PG to address some issues with how packages are handled, and it changed how the LimitedPolynomial context is split up. Originally, the macro file was all in one piece, but changes to Perl caused it to be broken into two (a .pl file in pg/macros and a .pm file in pg/lib) in order to avoid some error messages in the log file. Recently, we were able to recombine the two again. So if you updated PG without updating WW, that might be the source of your problem. Alternatively, if you updated both but had overridden ${pg}{modules} in your site configuration file, that might be the problem, as that list no longer needs to include the .pm file.

Davide