WeBWorK Problems

Basic PGML question about answer order

Basic PGML question about answer order

by Peter Garfield -
Number of replies: 4
I'm trying to write a basic question, with multiple parts, the middle of which is a pop-up question. Here's what I've tried:

DOCUMENT();

loadMacros(
"PGstandard.pl",
"MathObjects.pl",
"PGML.pl",
"PGcourse.pl",
"PG.pl",
"PGbasicmacros.pl",
"PGchoicemacros.pl",
"PGanswermacros.pl",
"parserPopUp.pl",
"PGauxiliaryFunctions.pl"
);

TEXT(beginproblem());
$showPartialCorrectAnswers = 1;

$a=random(8,18,1);
$b=random(5,20,5);
$c=random(2000,3000,1000);
$d=random(500,700,100);

$TFPartB = PopUp(
["?","True","False"],
"True",
);

BEGIN_PGML

Testing Problem.

a) What is [`[$a]+[$b]`]?

[`[$a]+[$b]=`] [____]{"$a+$b"}{20}

a) *True* or *False*: This statement is True

Answer: [@ $TFPartB->menu() @]*

a) What is [`[$c]+[$d]`]?

[`[$c]+[$d]=`] [____]{"$c+$d"}{20}
END_PGML

ANS( $TFPartB->cmp() );

ENDDOCUMENT();

The problem is that the answers are graded in order (a), (c), (b), so the answer to the third part is "True", not $c+$d. Is there a simple fix? Thank you!
In reply to Peter Garfield

Re: Basic PGML question about answer order

by Glenn Rice -
Try the following:

DOCUMENT();

loadMacros(
"PGstandard.pl",
"MathObjects.pl",
"PGML.pl",
"PGcourse.pl",
"PG.pl",
"PGbasicmacros.pl",
"PGchoicemacros.pl",
"PGanswermacros.pl",
"parserPopUp.pl",
"PGauxiliaryFunctions.pl"
);

TEXT(beginproblem());
$showPartialCorrectAnswers = 1;

$a=random(8,18,1);
$b=random(5,20,5);
$c=random(2000,3000,1000);
$d=random(500,700,100);

Context()->strings->add(True => {}, False => {}, "?" => {});

$TFPartB = PopUp(
["?","True","False"],
1,
);

BEGIN_PGML

Testing Problem.

a) What is [`[$a]+[$b]`]?

[`[$a]+[$b]=`] [____]{$a+$b}{20}

a) *True* or *False*: This statement is True

Answer: [_]{$TFPartB}

a) What is [`[$c]+[$d]`]?

[`[$c]+[$d]=`] [____]{$c+$d}{20}
END_PGML

ENDDOCUMENT();

In reply to Peter Garfield

Re: Basic PGML question about answer order

by Alex Jordan -
This does not answer your actual question, but you can use PGML with PopUps:

[__]{$TFPartB}

will keep it all inside PGML. (Assuming the version of PG is recent enough.)