-
-
Notifications
You must be signed in to change notification settings - Fork 77
Closed
Description
The uniq
function in PGbasicmacros.pl returns an array of unique items from the input array, but it doesn't maintain a consistent order of the items in the returned array.
Consider the following MWE
DOCUMENT();
loadMacros("PGstandard.pl",
"parserRadioButtons.pl",
"PGML.pl");
## Do NOT show partial correct answers
$showPartialCorrectAnswers = 0;
@answers = ('a','b','c','b','a');
@options = uniq(@answers);
$mc = RadioButtons([@options],'b');
BEGIN_PGML
[_]{$mc}
END_PGML
ENDDOCUMENT();
Each time you load the problem the options can be presented in a different order, which means that even if you select the correct answer it may be marked incorrect since the array could be reordered on submit.
All of the examples that I found in the OPL (Contrib actually) take this into account and sort the resulting array, so it may be that this behaviour is understood, but there is a comment in the code that says "sort is causing trouble with Safe.??", which makes me think that the intention was to have the function sort the array.
Metadata
Metadata
Assignees
Labels
No labels