Basically, the problem accesses a macro to give students information about a particular element (atomic number, symbol, etc). They are then to answer some simple information about the element. What is happening now is that if a student answers incorrectly they get a new element and not the one thsy answered. If they simply refresh the page without any answer entry, they also get a new element.
Previously the student's numbers would persist as they do in most problems. I am wondering if the issue is with list_random or something else. Using ww and pg 2.12 on ubuntu 16.04.
Any help would be appreciated.
Here is the code I am referencing:
DOCUMENT(); # This should be the first executable line in the problem.
loadMacros(
"PG.pl",
"PGbasicmacros.pl",
"PGchoicemacros.pl",
"PGanswermacros.pl",
"PGauxiliaryFunctions.pl",
"isotopes.pl"
);
TEXT(&beginproblem);
$showPartialCorrectAnswers = 1;
@atomic_numbers = keys %isotopes;
$Z = list_random(@atomic_numbers);
$name = $isotopes{$Z}{name};
$symbol = $isotopes{$Z}{symbol};
for $who ( @{ $isotopes{$Z}{atomic_mass} } ) {
@atomic_mass = $who->{at_mass};
}
$A = list_random(@atomic_mass);
BEGIN_TEXT
How many protons are in a neutral atom of $name?
$BR
Number of protons = \{ans_rule(15)\} $BR
END_TEXT
$protons = $Z;
&ANS(num_cmp($protons,reltol=>1,format=>'%0.4g') );
ENDDOCUMENT();
The macro file has the basic structure:
%isotopes=( 1=>{name=>Hydrogen, symbol=>H, atomic_mass=> [{at_mass=>1}, {at_mass=>2}, ],}, 2=>{name=>Helium, symbol=>He, atomic_mass=> [{at_mass=>4}, {at_mass=>3}, ],}, 3=>{name=>Lithium, symbol=>Li, atomic_mass=> [{at_mass=>6}, {at_mass=>7}, ],}, 5=>{name=>Boron, symbol=>B, atomic_mass=> [{at_mass=>11}, {at_mass=>10}, ],},