## DESCRIPTION ## Precalculus: answers up to multiplication ## ENDDESCRIPTION ## KEYWORDS('precalculus', 'answer up to multiplication') ## DBsubject('WeBWorK') ## DBchapter('WeBWorK Tutorial') ## DBsection('Fort Lewis Tutorial 2011') ## Date('01/30/2011') ## Author('Paul Pearson') ## Institution('Fort Lewis College') ## TitleText1('') ## EditionText1('') ## AuthorText1('') ## Section1('') ## Problem1('') ########################### # Initialization DOCUMENT(); loadMacros( "PGstandard.pl", "MathObjects.pl", "AnswerFormatHelp.pl", ); TEXT(beginproblem()); ########################### # Setup Context("Numeric"); \$aSolution = Compute("(x-2)(x+1)"); ########################### # Main text Context()->texStrings; BEGIN_TEXT Find a quadratic equation in terms of the variable \( x \) with roots \( -1 \) and \( 2 \). \$BR \$BR \( y = \) \{ ans_rule(20) \} \{ AnswerFormatHelp("formulas") \} END_TEXT Context()->normalStrings; ############################ # Answer evaluation \$showPartialCorrectAnswers = 1; ANS( \$aSolution->cmp(checker => sub { my ( \$correct, \$student, \$self ) = @_; my \$context = Context()->copy; return 0 if \$student == 0; \$context->flags->set(no_parameters=>0); \$context->variables->add('C0'=>'Parameter'); my \$c0 = Formula(\$context,'C0'); \$student = Formula(\$context,\$student); \$correct = Formula(\$context,"\$c0 * \$aSolution"); return \$correct == \$student; } ) ); ############################ # Solution Context()->texStrings; BEGIN_SOLUTION \${PAR}SOLUTION:\${PAR} Solution explanation goes here. END_SOLUTION Context()->normalStrings; COMMENT('MathObject version.'); ENDDOCUMENT();