I'm having difficulty setting the correct answers in the parserMultiAnswer.pl macro when the input is determined on the fly. While the grading of these sort of problems is fine, it would be nice to have the correct answers displayed for students after the due date (for example).
This issue can be shown using the linked code as an example, which I've also listed below. The attached screenshot reveals that the "correct" answers are the dummy zero values which were given when MultiAnswer function is initialized.
DOCUMENT();
loadMacros('PGstandard.pl', 'PGML.pl', 'parserMultiAnswer.pl', 'PGcourse.pl');
$ma = MultiAnswer(0, 0, 0, 0, 0)->with(
checker => sub {
my ($correct, $student, $self, $ansHash) = @_;
my $mass = $student->[0];
my $h2o_cyl = $student->[1];
my $h2o_bar_cyl = $student->[2];
my $vol = $student->[3];
my $den = $mass / $vol;
my $bar_vol = $h2o_bar_cyl - $h2o_cyl;
return (
1, 1, 1,
$bar_vol == $vol ? 1 : 0,
$den == $student->[4] ? 1 : 0
);
}
);
BEGIN_PGML
*_Determining the Density of a Solid Metal Bar_*
A. Mass of your metal bar: [_]{$ma}{10} g.
B. Initial volume of water in the graduated cylinder: [_]{$ma}{10} mL.
C. Volume of water and metal bar in the graduated cylinder: [_]{$ma}{10} mL.
D. Calculate the volume of your metal bar: [_]{$ma}{10} mL.
E. Calculate the density of your metal bar: [_]{$ma}{10} g/mL.
END_PGML
ENDDOCUMENT();