WeBWorK Main Forum

Checkboxes with partial marks

Checkboxes with partial marks

by Sergio Chaves -
Number of replies: 5

Hello

I am trying to create a problem that uses checkboxes, but I am not able to set it up in such a way that students get partial marks for the correct selected answers. It is only marked correct if and only if all correct answers are selected (and full marks are awarded).

I have tried to use

install_problem_grader(~~&avg_problem_grader);
as it works for other problems. However, it is not working with checkboxes. See below a problem that I am creating if that helps. Thanks in advance

###########################
#  Initialization

DOCUMENT();  

loadMacros(
"PGstandard.pl",
"PGchoicemacros.pl",
"PGunion.pl",
"choiceUtils.pl",
"PGcourse.pl",
"PGML.pl",
);

TEXT(beginproblem());

###########################
#  Setup

$mc = new_checkbox_multiple_choice();

$mc -> qa (
"Select all expressions that are equivalent to  
\( (x+y)^2  \).  There may be more than
one correct answer. $BR", 
"\( x^2 + 2xy + y^2 \) $BR $BR",
"\( (x+y)(x+y) \) $BR $BR",                
);

$mc -> extra(
"\( x^2 + y^2 \) $BR $BR",
);

$mc -> makeLast("None of the above");

###########################
#  Main text

BEGIN_PGML
[@ $mc -> print_q() @]*
[@ $mc -> print_a() @]*
END_PGML

install_problem_grader(~~&avg_problem_grader);

ANS( checkbox_cmp( $mc->correct_ans() ) );

BEGIN_PGML_SOLUTION
The correct answer is [@ $mc->correct_ans() @]*.
END_PGML_SOLUTION

ENDDOCUMENT();



In reply to Sergio Chaves

Re: Checkboxes with partial marks

by Danny Glin -
What you are trying to do isn't going to be easy using checkboxes.  The way checkboxes are coded WeBWorK submits a string of which answers the students selected (e.g. ABD), which is compared against the correct answer string, so either it matches and the student gets full credit or it doesn't and they get no credit.  Short of making major changes to the answer checker you're stuck with this.

When I want to do what you're asking I create a separate PopUp (i.e. drop-down menu) question for each option.  Then the default answer grader assigns the same value to each part, and students receive partial credit.

In your case for each expression there would be a drop down menu where the options are something like "is equivalent" and "is not equivalent".  If you need help creating the PopUp menus beyond the linked help please ask.
In reply to Sergio Chaves

Re: Checkboxes with partial marks

by Nathan Wallach -

I had a need to do something like this in the past, and just modified the hacked up AnswerHints.pl approach I used to make a generic sample. It requires some tweaks whenever it is used, and I was not able to get it to give partial credit when no boxes were marked (apparently the empty string does not get into the AnswerHints handling.)

Attached is a sample file, which I am putting in the public domain - use and modify at will.

If it seems good enough for others to use, we can add a comment about this to https://webwork.maa.org/wiki/MultipleSelectProblems in the future.

In reply to Nathan Wallach

Re: Checkboxes with partial marks

by Nathan Wallach -

Attached is an improved version with improved debug messages.

  • Change the setting of $debugOn to enable it during problem testing.
  • Make sure it is off in production use.)

K. Andrew Parker suggested including the "total % possible" in the debug report, and provided a patch which was slightly modified.

Additional data on how the grade was computed was added, and a minor bug in the debug output was fixed.

In reply to Nathan Wallach

Re: Checkboxes with partial marks

by Sergio Chaves -
Thank you Nathan, this has been very helpful and I was able to successfully create the problem that I wanted. Just out of curiosity, this does not work when no checkboxes are selected because of how the checkbox object has been coded in the "PGchoicemacros.pl", macro, right?
In reply to Sergio Chaves

Re: Checkboxes with partial marks

by Nathan Wallach -
Basically yes. I think that when nothing is marked - the answer gets handled by a "pre filter" in such a manner that AnswerHints does not receive it for processing. I did not look into it deeply enough to be certain.