I am using a problem developed by authors at PCC to have students enter the solution set, {4}, along with their solved solution to equations, in the form, "x = 4".
Somehow it works without errors when the correct answer is entered in my second answer blank (asking for the solution set), but if the incorrect fraction is entered in the solution set answer blank, the following warning is displayed. Interestingly, if the student enters an integer in braces, this error is not shown.
WeBWorK Warnings
WeBWorK has encountered warnings while processing your request. If this occured when viewing a problem, it was likely caused by an error or ambiguity in that problem. Otherwise, it may indicate a problem with the WeBWorK system itself. If you are a student, report these warnings to your professor to have them corrected. If you are a professor, please consult the warning output below for more information.
Warning messages
Use of uninitialized value $a in division (/) at line 680 of [PG]/macros/contextFraction.pl
Request information
Time | Thu Sep 11 12:28:30 2014 |
Method | POST |
URI | /webwork2/MTH_104_Intermediate_Algebra/HW4-SolvingLinearEquations/3/ |
Here is the code for the problem, but note that it is using a macro from PCC (found in the OPL macro folder under PCC) named SolveLinearEquationPCC.pl.
# WeBWorK problem written by Carl Yao
# Portland Community College
#
# Solve equations like ax + b= cx + d; the solution is a fraction.
#
# Last updated: Kling 7/21/13; Jordan 7/20/13; Hughes 7/2/13 Yao, 6/27/13
# ENDDESCRIPTION
## DBsubject('Algebra')
## DBchapter('Basic Algebra')
## DBsection('Algebraic Expressions')
## KEYWORDS('solve','linear','equation','fraction','multiply','add','subtract')
## DBCCSS('6.EE.7','7.EE.4','8.EE.7')
## TitleText1('')
## EditionText1('')
## AuthorText1('')
## Section1('')
## Problem1('')
## Author('Alex Jordan, Carl Yao, Chris Hughes')
## Institution('PCC')
##############################################
DOCUMENT();
loadMacros(
"PGstandard.pl",
"MathObjects.pl",
"PGML.pl",
"parserAssignment.pl",
"PCCmacros.pl",
"answerHints.pl",
"contextFraction.pl",
"SolveLinearEquationPCC.pl",
"PGcourse.pl",
);
##############################################
Context("Fraction");
$var = RandomVariableName();
Context()->variables->are($var => 'Real');
Context()->noreduce('(-x)-y','(-x)+y');
do {
$a = random(2,10,1);
$b = random(2,10,1);
$c = random(2,10,1);
$d = random(2,10,1);
} until (abs($c-$a)>1 and $b != $d and ($d-$b)/($c-$a) != int(($d-$b)/($c-$a)) );
$ans = Fraction($d-$b,$a-$c);
$left = Formula("$a $var + $b");
$right = Formula("$c $var + $d");
@vArray = ($var);
@aArray = ($ans);
($ansEqRef, $eqTypesRef) = contextSetup(~~@vArray, ~~@aArray);
##############################################
TEXT(beginproblem());
BEGIN_PGML
[@instructions(~~@vArray)@]**
[`` [$left]=[$right] ``]
[_______________________________]
Note that you should enter your answers using reduced fraction form, where needed.
END_PGML
##############################################
answerCheck($ansEqRef, $eqTypesRef);
##############################################
BEGIN_TEXT
$PAR
Enter the $BBOLD solution set$EBOLD: \{ans_rule(10)\}
END_TEXT
$ss = Set("{$ans}");
ANS($ss->cmp());
BEGIN_PGML_SOLUTION
To solve this equation, use addition and subtraction to move variable terms to one side and constant terms to the other. Then divide.
[``
\begin{aligned}
[$left] &= [$right]\\
[$left] \mathbf{{}-[$b]}&= [$right]\mathbf{{}-[$b]}\\
[$a][$var] &= [$c][$var]+[$d-$b]\\
[$a][$var] \mathbf{{}-[$c][$var]}&= [$c][$var]+[$d-$b]\mathbf{{}-[$c][$var]}\\
[$a-$c][$var] &= [$d-$b]\\
\frac{[$a-$c][$var]}{[$a-$c]} &= \frac{[$d-$b]}{[$a-$c]}\\
[$var] &= [$ans]
\end{aligned}
``]
[@summary($ansEqRef->[0],$left,$right);@]**
END_PGML_SOLUTION
ENDDOCUMENT();