## WeBWorK Main Forum

### How make Webwork give partial credit for "almost right" answers e.g. wrong units or off by just a minus sign?

by Christian Seberino -
Number of replies: 7
Every student since the beginning of tests wants to get partial credit if their answers are ever "almost right".

Is there any way to make Webwork give partial credit, like a 0.5, if
only the units are wrong or if the answer is off by a minus sign?

(There may even be more types of "almost right" answers. I'm sure other
teachers have the same issues with their students. Maybe someone has
to partial credit?!?)

cs

### Re: How make Webwork give partial credit for "almost right" answers e.g. wrong units or off by just a minus sign?

by Lars Jensen -
Hi Christian,

How about giving them a couple of extra tries to let them go for full credit?

Lars.

### Re: How make Webwork give partial credit for "almost right" answers e.g. wrong units or off by just a minus sign?

by Christian Seberino -
Sorry I should have mentioned I was referring to timed exams.

Yes I already give unlimited tries for homeworks and that has worked out
great.

I'm not sure how multiple tries would work for exams or if that is advisable.
Do people really have exams that allow multiple tries?

### Re: How make Webwork give partial credit for "almost right" answers e.g. wrong units or off by just a minus sign?

by Michael Gage -
I've allowed two tries on GatewayQuiz mode quizzes -- the concept being that they can fix typos but don't get to flail wildly.

You can design the question to give partial credit for certain answers by customizing  the answer_evaluators (answer_checkers).

gives an example of customizing the error message/hint depending on the answer.
ANS($ans1->cmp->withPostFilter(sub { my$ans = shift;
$ans->{ans_message} = "Enter '-1' instead of '-'" if$ans->{ans_message} eq "Missing operand after '-'";
return $ans; }));  You want to do something similar but need to adjust the grade. To adjust the grade or "score" for the question set the score field in the answer_hash $ans->{score} to what ever value between 0 and 1 you wish. (or outside 0 and 1 if you want to get creative. :-) ).  In the example above the variable $ans is a reference to the answer_hash. The student's answer is in$ans->{student_ans}.

See below for some more hints about using info contained in the answer hash
and play with short fragments of the code in PGlabs to see all of the information contained in the answer hash.

### Re: How make Webwork give partial credit for "almost right" answers e.g. wrong units or off by just a minus sign?

by Christian Seberino -
Wow that is awesome. I never thought to allow 2 tries. That would allow students to fix issues with units and other minor issues.

Some students of course will still whine that they were "almost correct" if they just missed units or a minus sign....even with 2 chances. By allowing them 2 tries, at least we can make the case we bent as much as we could to be as nice as possible.

cs

### Re: How make Webwork give partial credit for "almost right" answers e.g. wrong units or off by just a minus sign?

by Alex Jordan -
I recommend allowing unlimited tries for all problems.
• If the purpose of homework is formative, then why not? Exams are the time to get something right with limited attempts.
• Capping attempts encourages students to give up and just move on.
• Some students are of a mind not to ask for help until they have it wrong say 20 times - it's their way of showing respect by "not bothering" you.
• Even for multiple choice and matching questions, I frequently have students who get the problem wrong, then correct it via elimination, and then come to me saying, "I know I only got this right by elimination; please help me understand this better."
• The subpopulation that occasionally somehow takes unwarranted advantage of unlimited attempts is very small. And assuming that you weigh homework low for grades, abuse like that will not have a measurable effect on final grades.
• As a bonus, you have fewer complaints from students of this nature.
I'd also add my opinion on "almost right". If a student comes to me with such a claim, I point out that they are not (yet) the expert on what constitutes "almost right". It's not too hard to show that the visual similarity of two numbers could be irrelevant in an application problem. sin(3.14) is over twice as large as sin(3.141). Such differences can make a bridge collapse.

### Re: How make Webwork give partial credit for "almost right" answers e.g. wrong units or off by just a minus sign?

by Christian Seberino -
I agree regarding unlimited tries for homeworks and have been doing that for a long time.

cs

### Re: How make Webwork give partial credit for "almost right" answers e.g. wrong units or off by just a minus sign?

by Davide Cervone -
The answerHints.pl macro file can be used to do this. See the documentation for answerHints for some details. There are also examples in the wiki.

The basic idea is that you provide answers for which you want to give some helpful message or partial credit, and supply the message or credit that you want to give for that. So

    loadMacros("answerHints.pl");

$n = Compute("sqrt(2)"); BEGIN_TEXT$n = \{ans_rule(10)\}
END_TEXT

ANS($n->cmp->withPostFilter(AnswerHints( -$n => ["Check the sign of your answer",score=>.25]
)));

would give 25% credit for the negative of the correct answer, and provide a message to check the sign. If you don't want the message, you can make it blank, i.e., "".

You can provide a list of such hints, and you can even provide a subroutine that determines when the hint is to be applied (rather than a fixed value), so

    loadMacros("answerHints.pl");

$n = Compute("sqrt(2)"); BEGIN_TEXT$n = \{ans_rule(10)\}
END_TEXT

ANS($n->cmp->withPostFilter(AnswerHints( sub { my ($correct,$student,$ans) = @_;