#FYI
#hp
DOCUMENT();
loadMacros(
"PGstandard.pl",
"MathObjects.pl",
"PGML.pl",
"parserImplicitPlane.pl",
"PCCmacros.pl",
"contextTypeset.pl",
"PGcourse.pl",
"parserMultiAnswer.pl",
);
TEXT(beginproblem());
##############################################
Context("ImplicitPlane");
Context()->flags->set(showExtraParens=>0);
Context()->variables->are(n=>'Real',d=>'Real', q=>'Real', x=>'Real',y=>'Real');
Context()->flags->set(reduceConstants=>0);
@ratio_text = ("twice", "three times", "four times");
@ratio_values = (2,3,4);
$r = list_random(0,1,2);
$r_text = $ratio_text[$r];
$r_value = $ratio_values[$r];
$difference = random(4,10);
$n_nickels = random($difference, 2*$difference);
$n_dimes = $r_value *$n_nickels;
$n_quarters = $n_dimes - $difference;
$Value = 5*$n_nickels+10*$n_dimes+25*$n_quarters ;
$ans1 = Compute("q = d-$difference");
$ans2 = Compute("3n=d");
$ans3 = Compute("5n + 10 d + 25 q = $Value");
$n_nickels = Compute($n_nickels);
$n_dimes = Compute ($n_dimes);
$n_quarters = Compute ($n_quarters);
$multians = MultiAnswer($ans1, $ans2, $ans3)->with(
singleResult => 0,
allowBlankAnswers=>1,
checker => sub {
my ( $correct, $student, $self ) = @_;
my @s = @{$student};
my @c = @{$correct};
@ret = ();
foreach (0..$#c){@ret = (@ret,0)}
foreach $i (0..$#c){
foreach $j (0..$#c){
if ( ref($c[$j]) eq ref($s[$i]) && $s[$i]==$c[$j]){$ret[$i]=1}
else {@c_next = (@c_next, $c[$j]);}
}
@c = @c_next;
@c_next = ();
}
return [@ret];
}
);
BEGIN_PGML
A collection of coins made up of nickels, dimes and quarters is worth $ [@ sprintf("%.2f",$Value/100) @]. There are [$r_text] as many dimes as nickels and [$difference] less quarters than dimes. We need to find how many of each coin there is.
Using n for nickels, d for dimes and q for the number of quarters, write three equations that you would use to solve this situation.
[@$multians->ans_rule(20)@]*
[@$multians->ans_rule(20)@]*
[@$multians->ans_rule(20)@]*
There were [___________] nickels
There were [___________] dimes
There were [___________] quarters
END_PGML
ANS( $multians->cmp() );
ANS( $n_nickels->cmp() );
ANS( $n_dimes->cmp() );
ANS( $n_quarters->cmp() );
ENDDOCUMENT();
Hi Hedley,
What is the code you shared with us? Why did you share it? Do you have a question? Please clarify and please refrain from posts without explanations in the future.
Thanks!
Paul
"Multianswer for unordered List of answers" that is the code.
FYI - For Your Information - means no question; is the forum only for questions?
I thought I had an idea to share; if it is a bad idea here is the transparency.
Sorry I offended.
Hedley Pinsent
FYI - For Your Information - means no question; is the forum only for questions?
I thought I had an idea to share; if it is a bad idea here is the transparency.
Sorry I offended.
Hedley Pinsent
Hi Hedley,
I was confused, not offended. Also, I should have said that my remarks were meant to promote good list etiquette.
A more complete explanation of what you posted would have been appreciated. If you had started your original post with some context, then the post would have made more sense. For instance, you could have said, "For a while, I was unable to figure out how to use a MultiAnswer object in PGML. Here is some PGML code I wrote that allows me to use a MultiAnswer object."
If your original post had been more clear, my reply would have been that there are other ways to implement MultiAnswer objects in PGML, and they are documented on the Subject Area Templates
http://webwork.maa.org/wiki/Category:Subject_Area_Templates
which have links to wiki documentation such as
http://webwork.maa.org/wiki/Spacecurve1
that have links under the heading "PGML location in OPL" to working PGML code such as
https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/Parametric/Spacecurve1_PGML.pg
This last link shows another, perhaps easier, way to use MultiAnswer objects with PGML. In particular, for a MultiAnswer object named $multians you can use
Answer 1 = [____]{$multians}
Answer 2 = [____]{$multians}
in PGML.
Best regards,
Paul Pearson
Thank you.
Hedley
Hedley