## WeBWorK Problems

### A weighty problem ?! ### A weighty problem ?!

by Zak Zarychta -
Number of replies: 2
Is it possible when weighting a problem to negatively weight a wrong answer?

Zak In reply to Zak Zarychta

### Re: A weighty problem ?!

by Arnold Pizer -
Hi,

I'm going to give a pretty vague answer to this.

First of all I am not certain if your are talking about the grade for a whole problem which is controlled by a problem grader or for an answer for a part (maybe the only part) of a problem which is controlled by an answer evaluator. You can have custom problem graders and custom answer evaluators. The default problem graders are in .../webwork/pg/macros/PGanswermacros.pl

Normally an answer evaluator returns a number in [0,1] (usually 0 or 1) for each part of the problem. Then the problem grader takes this information, the current "correctness" of the problem (usually a number in [0,1]), and other info (reduced scoring, number of attempts, etc) and produces and records a new "correctness" number. This gets multiplied by the problem weight (usually 1, but could be any positive integer) to calculate the score.

You have total control over the problem grader and answer evaluators. However, it may be true in the system code for WeBWorK 2 that results from answer evaluators and/or problem graders are truncated to the range [0,1]. I just don't remember and would have to look at the code.

You can look through the code or try a few experiments and see.

Arnie In reply to Zak Zarychta

### Re: A weighty problem ?!

by Davide Cervone -
I sort of remember that a negative score for a problmem has special meaning somehow, but I can't seem to find it in the code anywhere, so I may be misremembering it.

You would probably need to write your own grader for this, as the standard ones only set the problem's score if the score on the current attempt is greater than the recorded score, which I think defaults to 0. That means that although an attempt might yield a negative score, it would never be saved. The grader is the place where this is done, and you could return a negative score there if you wanted, but you would need to be careful about the logic; in particular, how to treat scores of zero (like when no answers have been given, or no previous answers have been recorded) so that the student can't prevent the negative score by simply submitting all blank answers (getting a score of 0).

Davide