PREP 2015 Question Authoring - Archived

Problems executing unorderedAnswer macro

Problems executing unorderedAnswer macro

by tim Payer -
Number of replies: 2
Hello,

I can't seem to make the unorderedAnswer macro work for me. Can you see my glitch here?

Thanks, Tim

# DESCRIPTION  problem1
# Algebra_Review
# WeBWorK problem written by TimPayer <tsp1@humboldt.edu>
# ENDDESCRIPTION

## DBsubject(Algebra)
## DBchapter(Factoring)
## DBsection(Factoring Difference of Squares)
## Institution(Humboldt State University)
## Author(Tim Payer)
## KEYWORDS(reduce, difference of squares)

DOCUMENT();
loadMacros(
"PGstandard.pl",
"MathObjects.pl",
"PGML.pl",
"unorderedAnswer.pl",
"PGcourse.pl"
#"parserMultiAnswer.pl"
#"parserFormulaUpToConstant.pl"
);

Context("Numeric");
$a = Real(random(2,13,1));
do {$b =(random(2,13,1));} until (gcd($b,$a)==1);
$c = Real(random(2,10,2));
$d = Real(random(2,10,1));
$ans1 =Formula("$a*x+$b");
$ans2 =Formula("$a*x-$b");

BEGIN_PGML
>> Factor the expression of [``[$a**2] x^2 -[$b**2]``] completely.<<  
>> Given that the factored form can be expressed as<<  
>> (Ax + B)(Ax - B), <<  
>>Find the given factors: <<  

>> (Ax + B) = [__________]{"($a* x +$b)"} <<  
>> (Ax - B) = [__________]{"($a* x- $b)"} <<  
END_PGML

#Answers

$showPartialCorrectAnswers = 0;
install_problem_grader(~~&std_problem_grader);


UNORDERED_ANS( 
$ans1->cmp(), 
$ans2->cmp(), 
);

BEGIN_PGML_SOLUTION

*SOLUTION*

A preliminary check for all factoring problems is to be sure that all common factors have been pulled. Here there are no common factors to pull. Next, given the difference of two terms, [``[$a**2] x^2 -[$b**2]``], consider whether the two terms are a difference of squares  in the form of [`A^2-B^2`] ? If so this can be reduced using the conjugate pairs of the square roots of each term. Specifically [`A^2-B^2 = (A + B)(A - B)`]  
Then we should "see" that [``[$a**2] x^2 = \left([$a] x\right)^2``], then [`[$a] x = A`].  
Additionally we can see that [``[$b**2] = \left([$b] x\right)^2``], then [`[$b] = B`].  
It follows that since [`A^2-B^2 = (A + B)(A - B)`], then so will:
[``[$a**2] x^2 -[$b**2]=([$a] x + [$b])([$a] x - [$b])``].


END_PGML_SOLUTION

ENDDOCUMENT();

In reply to tim Payer

Re: Problems executing unorderedAnswer macro

by Paul Pearson -
Hi Tim,

You're giving the answers twice.  Try replacing [___]{"answer string"} with [____] and leaving UNORDERED_ANS(...) as it is.

On formatting: people are trained to read text that is left justified, so I would suggest you remove almost all centering.

On the forum: you should start posting your questions to the main problem authoring forum, which reaches a wider audience.

Best regards,

Paul Pearson