## WeBWorK Problems

by Steven Fiedler -
Number of replies: 2
I'm attempting to create a set of a small number of multiple choice questions, which are graded as a whole. In this manner, I'm hoping to deter students using a simple brute force approach to solve such questions with a limited number of options.

I was able to accomplish this using a combination of radio buttons and a multiAnswer problem.  However, the "Entered" and "Answer Preview" values contain a superfluous suffix (; _) when only one of the multiple choice problems is previewed or checked by the student.  This issue is not present when zero or all questions are answered.  The issue is also not present when the multiple choice questions are moved out of the MultiAnswer() function.

I would appreciate any thought about cleaning this up.  Code for a MWE is given below and attached is a screenshot with red arrows indicated the text in question.

Thank you,

Steven

DOCUMENT();

$radio1 = RadioButtons([ 1, 2, 3], 1, );$radio2 = RadioButtons( [ 4, 5, 6],  0, );

$multians = MultiAnswer($radio1, $radio2)->with( singleResult => 1, checker => sub { my ($correct, $student,$self) = @_;
my ($f1stu,$f2stu) = @{$student}; my ($f1,    $f2) = @{$correct};
if (($f1 ==$f1stu && $f2 ==$f2stu)
|| ($f1 ==$f2stu && $f2 ==$f1stu))
{
return [ 1, 1 ];
} else {
if ($f1 ==$f1stu || $f2 ==$f1stu) {
return [ 1, 0 ];
} elsif ($f1 ==$f2stu || $f2 ==$f2stu) {
return [ 0, 1 ];
} else {
return [ 0, 0 ];
} } });

BEGIN_PGML
1+1 =
[___]{$multians} 2+2 = [___]{$multians}
END_PGML

ENDDOCUMENT();

by Danny Glin -
The behaviour is consistent with what I would expect. Since you have singleResult => 1 it is treating the two answer blanks as one answer, so it is displaying the two student answers separated by a semicolon. Since the student did not choose an option for the second part it indicates this with the underscores.

There are different approaches available depending on what exactly your goal is. One feature of your example is that if a student doesn't answer all of the parts of the MultiAnswer then it is automatically marked wrong. For example, if the student answers the first part correctly but leaves the second part blank then they receive a grade of 0. This may be what you want in order to prevent students from guessing just the first part until they get it right, then moving on to the second part. You can change this behaviour by setting allowBlankAnswers => 1 in the MultiAnswer object.

Some alternatives:
If you want to prevent students from seeing which answers are correct, but still give them credit for each correct answer, you can set $showPartialCorrectAnswers = 0; in the problem. This should be functionally equivalent to your example. DOCUMENT(); loadMacros('PGstandard.pl', 'PGML.pl','parserRadioButtons.pl','PGcourse.pl');$showPartialCorrectAnswers = 0;

$radio1 = RadioButtons([ 1, 2, 3], 1, );$radio2 = RadioButtons( [ 4, 5, 6],  0, );

BEGIN_PGML
1+1 =
[___]{$radio1} 2+2 = [___]{$radio2}
END_PGML

ENDDOCUMENT();

Note that this only affects the "Submit Answers" button, and not the "Check Answers" button, so if you are testing this in the problem editor you will be shown which answers are correct, but when the problem is used in an assignment where the student can still receive credit they will only get a grade, and no feedback on the individual answers, as shown in the attached image.

If you want true all-or-nothing behaviour (no feedback on which answers are correct, and a grade of 0 unless they get all answers correct), then you can use the std_problem_grader:

DOCUMENT();

$showPartialCorrectAnswers = 0; install_problem_grader(~~&std_problem_grader);$radio1 = RadioButtons([ 1, 2, 3],  1, );
$radio2 = RadioButtons( [ 4, 5, 6], 0, ); BEGIN_PGML 1+1 = [___]{$radio1}