-
-
Notifications
You must be signed in to change notification settings - Fork 76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inconsistent/incomplete behaviour for radio button custom answer checkers #942
Comments
For your item 1, For your item 2, the shuffled answers are in $label = $RB->{labels}[(grep { $RB->{order}[$_] == $i } 0 .. $RB->{n} - 1)[0]]; If you want the label for the answer string $label = $RB->{labels}[(grep { $RB->{orderedChoices}[$_] eq $s } 0 .. $RB->{n} - 1)[0]]; should do the trick. If you need to look up the labels of a lot of answers, then you might want to make the reverse mapping from my @reverse;
map {$reverse[$RB->{order}[$_]] = $_] 0 .. $RB->{n} - 1; so that $label = $RB->{labels}[$reverse[$i]]; will be the label for the choice at position |
One thing that you can do is use the new DOCUMENT();
loadMacros('PGstandard.pl', 'PGML.pl', 'parserRadioButtons.pl', 'PGcourse.pl');
$checker = sub {
my ($correct, $student) = @_;
return $correct == $student || $student eq 'second correct';
};
$RB = RadioButtons(
[ [ 'First correct', 'Second correct', 'First incorrect' ] ], 0,
labels => 'ABC',
values => ['first correct', 'second correct', 'first incorrect']
);
BEGIN_PGML
[_]{$RB->cmp(checker=>$checker)}
END_PGML
ENDDOCUMENT(); This will work with PG 2.18, but not before of course. |
Another thing you could do that I believe would work prior to PG 2.18 is DOCUMENT();
loadMacros('PGstandard.pl', 'PGML.pl', 'parserRadioButtons.pl', 'PGcourse.pl');
$checker = sub {
my ($correct, $student) = @_;
return $correct == $student || $RB->answerChoice($student) eq 'Second correct';
};
$RB = RadioButtons([ [ 'First correct', 'Second correct', 'First incorrect' ] ], 0, labels => 'ABC');
BEGIN_PGML
[_]{$RB->cmp(checker=>$checker)}
END_PGML
ENDDOCUMENT(); Of course these suggestions don't address your concern about |
This was motivated by https://webwork.maa.org/moodle/mod/forum/discuss.php?d=8369 which asks about custom answer checkers for multiple choice problems.
Consider the following MWE:
There are a couple of concerns:
warn
statements produce inconsistent output. For the student answer what is displayed is the underlying MathObject value (i.e.B0
,B1
, orB2
), whereas for the correct answer the label is displayed by default (i.e.A
,B
orC
in this example). The underlying checking compares the MathObject values, so$correct==$student
returns the proper value, but the values that are displayed in the warn statement are confusing.$correct->Value
returns the proper choice after randomization, but'B1'
will refer to answer B in the scrambled choices, which doesn't consistently correspond to any specific answer. I don't see a way to get the index of "Second correct" after the entries have been scrambled.I don't know that there is going to be an easy way to fix the second issue. I wonder if it's possible to make the labels of the scrambled answers available to the problem author. This could also be useful in solutions. For example for a "which of the following statements is true" type question, the solution could discuss why each incorrect option is false, and refer to them by their labels.
The text was updated successfully, but these errors were encountered: