I am using a set of algebra problems based on some from Portland Community College that I have not used since WeBWorK version 2.9 or so, and now I am getting errors.
The first error I am getting is:
------
---- PGML (eval 1336) 1489 ------
==================
Errors parsing PGML:
Error evaluating command: No such package 'Value::Fraction'
==================
__________________________
---- PGML (eval 1336) 1489 ------
==================
Errors parsing PGML:
Error evaluating command: No such package 'Value::Fraction'
==================
__________________________
when I enter my first answer.
Then when I enter the correct answer I get the following error:
Warning messages
Processing of this PG problem was not completed. Probably because of a syntax error. The translator died prematurely and no PG warning messages were transmitted. at /opt/webwork/webwork2/lib/WeBWorK/ContentGenerator/Problem.pm line 762. Odd number of elements in anonymous hash at /opt/webwork/webwork2/lib/WeBWorK/Utils/AttemptsTable.pm line 180. Use of uninitialized value in anonymous hash ({}) at /opt/webwork/webwork2/lib/WeBWorK/Utils/AttemptsTable.pm line 180.
Error messages
Can't use string ("answersSubmitted") as an ARRAY ref while "strict refs" in use at /opt/webwork/webwork2/lib/WeBWorK/Utils/AttemptsTable.pm line 202.
Call stack
The information below can help locate the source of the problem.
in WeBWorK::Utils::AttemptsTable::_init called at line 190 of /opt/webwork/webwork2/lib/WeBWorK/Utils/AttemptsTable.pm
in WeBWorK::Utils::AttemptsTable::new called at line 322 of /opt/webwork/webwork2/lib/WeBWorK/ContentGenerator/Problem.pm
in WeBWorK::ContentGenerator::Problem::attemptResults called at line 1868 of /opt/webwork/webwork2/lib/WeBWorK/ContentGenerator/Problem.pm
in WeBWorK::ContentGenerator::Problem::output_summary called at line 155 of /opt/webwork/webwork2/lib/WeBWorK/Template.pm
in WeBWorK::Template::template called at line 562 of /opt/webwork/webwork2/lib/WeBWorK/ContentGenerator.pm
in WeBWorK::ContentGenerator::content called at line 363 of /opt/webwork/webwork2/lib/WeBWorK/ContentGenerator/Problem.pm
in WeBWorK::ContentGenerator::Problem::content called at line 232 of /opt/webwork/webwork2/lib/WeBWorK/ContentGenerator.pm
in WeBWorK::ContentGenerator::go called at line 384 of /opt/webwork/webwork2/lib/WeBWorK.pm
The code for the problem is:
# WeBWorK problem written by Carl Yao
# Portland Community College
#
# Solve equations like 5x/4-6x=3/8; answer is a fraction or integer.
#
# Paul Seeburger modified this problem to allow students to enter work
# in a step-by-step manner.
#
# Last edited: Seeburger, 9/9/2014; Kling, 7/18/13; Jordan, 7/10/13; Hughes 7/1/13, Wherry, 6/28/13
# ENDDESCRIPTION
## DBsubject('Algebra')
## DBchapter('Basic Algebra')
## DBsection('Algebraic Expressions')
## KEYWORDS('solve','linear','equation','fraction')
## DBCCSS('6.EE.7','7.EE.4','8.EE.7')
## TitleText1('')
## EditionText1('')
## AuthorText1('')
## Section1('')
## Problem1('')
## Author('Alex Jordan, Carl Yao, Chris Hughes, Paul Seeburger')
## Institution('PCC, Monroe Community College')
##############################################
DOCUMENT();
loadMacros(
"PGstandard.pl",
"MathObjects.pl",
"PGML.pl",
"parserAssignment.pl",
"PCCmacros.pl",
"answerHints.pl",
"contextFraction.pl",
"SolveLinearEquationPCC.pl",
"PGcourse.pl",
);
##############################################
Context("Numeric");
$var = RandomVariableName();
Context()->variables->are($var => 'Real');
Context()->noreduce('(-x)-y','(-x)+y');
$den1 = random(2,10,2);
$num1 = random(3,9,2);
while (gcd($den1,$num1)!=1) {$num1=random(3,9,2);}
$den2 = 2*$den1;
$num2 = random(3,9,2);
while (gcd($den2,$num2)!=1) {$num2=random(3,9,2);}
#adjust $a's value to make the solution negative
$a=random(5,10,1);
$cf1 = 2*$num1;
$cf2 = $den2*$a;
$leftL = Formula("$cf1*$var - $cf2*$var");
Context()->operators->undefine("/","/ "," /");
Context()->{error}{msg}{"Can't use '/' in this context"} =
"There should no longer be a fraction on this side of the equation.";
$ans_eval1 = Compute($den2)->cmp();
$ans_eval2 = $leftL->cmp();
$ans_eval3 = Compute($num2)->cmp();
Context("Fraction");
Context()->variables->are($var => 'Real');
Context()->noreduce('(-x)-y','(-x)+y');
$ans = Fraction($num2*$den1,$num1*$den2-$a*$den1*$den2)->reduce;
@answ = $ans->value;
$ansNum = -$answ[0];
$ansDen = $answ[1];
$frac2 = Fraction($num2,$den2);
$left = Formula("$num1*$var/$den1-$a*$var");
$rightF = Formula("$frac2");
$right = "\frac{$num2}{$den2}";
$rightP = "\frac{[$num2]}{[$den2]}";
@vArray = ($var);
@aArray = ($ans);
($ansEqRef, $eqTypesRef) = contextSetup(~~@vArray, ~~@aArray);
##############################################
TEXT(beginproblem());
$tab = $SPACE.$SPACE.$SPACE;
Context()->texStrings;
BEGIN_TEXT
Solve the following equation, showing each required step.
$PAR
$tab $tab \( \displaystyle $left = $right \)
$PAR
State the LCD for the fractions in this equation: \{ans_rule \}
END_TEXT
Context()->normalStrings;
ANS($ans_eval1);
$ans_hash1 = $ans_eval1->evaluate($inputs_ref->{ANS_NUM_TO_NAME(1)});
if (1 == $ans_hash1->{score}) {
Context()->texStrings;
BEGIN_TEXT
$PAR
Now multiply the LCD into each term on both sides of the equation.
$PAR
\( \quad \quad \displaystyle {$den2($left) = $den2 \cdot $right} \)
$PAR
\{ans_rule(20)\} \( = \) \{ans_rule(20)\}
END_TEXT
Context()->normalStrings;
ANS($ans_eval2 );
$ans_hash2 = $ans_eval2->evaluate($inputs_ref->{ANS_NUM_TO_NAME(2)});
ANS($ans_eval3 );
$ans_hash3 = $ans_eval3->evaluate($inputs_ref->{ANS_NUM_TO_NAME(3)});
if (1 == $ans_hash2->{score} && 1 == $ans_hash3->{score}) {
$ans_eval4 = $ansEqRef->[0]->cmp();
# [@instructions(~~@vArray)@]**
# [`` [$left]=$right ``]
BEGIN_PGML
Do the last step(s) and enter the solution of this equation. The answer could be in the form [`` [$var] = ``] ___ , *no solution*, or *all real numbers*.
[_______________________________]
END_PGML
##############################################
answerCheck($ansEqRef, $eqTypesRef);
$ans_hash4 = $ans_eval4->evaluate($inputs_ref->{ANS_NUM_TO_NAME(4)});
if (1 == $ans_hash4->{score}) {
BEGIN_TEXT
$PAR
Finally enter the $BBOLD solution set$EBOLD : \{ans_rule(10)\}
END_TEXT
$ss = Set("{$ans}");
ANS($ss->cmp());
}
}
}
##############################################
$step1 = $den2*$num1/$den1;
$step2 = $a*$den2;
$step3 = $step1-$step2;
if ($ansDen!=1) {$ansOutput="-\frac{$ansNum}{$ansDen}";}
else {$ansOutput="-$ansNum";}
BEGIN_PGML_SOLUTION
To clear fractions from an equation, multiply each side of the equation by a common denominator. For this problem, a common denominator is [`[$den2]`].
[``
\begin{aligned}
\frac{[$num1][$var]}{[$den1]} - [$a][$var] &= \frac{[$num2]}{[$den2]} \\
[$den2] \cdot \left(\frac{[$num1][$var]}{[$den1]} - [$a][$var]\right) &= [$den2] \cdot \frac{[$num2]}{[$den2]} \\
[$den2] \cdot \frac{[$num1][$var]}{[$den1]} - [$den2] \cdot [$a][$var] &= [$den2] \cdot \frac{[$num2]}{[$den2]} \\
[$step1][$var] - [$step2][$var] &= [$num2] \\
[$step3][$var] &= [$num2] \\
\frac{[$step3][$var]}{[$step3]} &= \frac{[$num2]}{[$step3]} \\
[$var] &= [$ansOutput]
\end{aligned}
``]
[@summary($ansEqRef->[0],$left,$rightF);@]**
END_PGML_SOLUTION
ENDDOCUMENT();
Does anyone have an idea of what may have changed or what I can adjust to make it work now?
Thanks!
Paul