WeBWorK Main Forum

Giving bonus credit

Giving bonus credit

by Darwyn Cook -
Number of replies: 1
I have written a problem for calculus III which has some historical significance (the volume of the double square umbrella) . I would like to write a multi-part problem that explores Archimedes (and Hui's) derivation of this volume, but I would like the historical part of the problem to be done for extra-credit. Is there a way to have Webwork score part of a problem as extra credit?

P.S. I think it needs to be done as a multi-part problem since once you give the solid a name Google gives the answer away. sad
In reply to Darwyn Cook

Re: Giving bonus credit

by Davide Cervone -
This can be done using the compoundProblem.pl library (available from the Union problem library), though you need to change one setting in order to make the last part an extra credit one.

Here's an example of a problem that gives 10% extra credit for the second part, which is hidden until the first part is shown.

DOCUMENT();

loadMacros(
  "PGstandard.pl",
  "compoundProblem.pl",
);

TEXT(beginproblem);

$isProfessor = ($studentLogin eq 'dpvc');  # your userID here

#
#  Start a compound problem.  See the compoundProblem.pl
#  file for more details about the parameters you
#  can supply.
#
$cp = new compoundProblem(
  parts => 2,                  # the total number of parts in this problem
  weights => [1,.1],           # 10% extra credit for second part
  allowReset => $isProfessor,  # professors get Reset button for testing
);
$cp->{totalWeight} = 1;        # make part 2 extra credit

$part = $cp->part;             # look up the current part


if ($part == 1) {

#
#  Use a named answer rule here so we can include
#  the value the student typed in the second half.
#

BEGIN_TEXT
Main Answer: \{NAMED_ANS_RULE("a",25)\}
END_TEXT

NAMED_ANS(a => num_cmp(5));

}

if ($part == 2) {

BEGIN_TEXT
Main Answer: $a
$PAR

Extra Credit: \{ans_rule(25)\}
END_TEXT

ANS(num_cmp(10));

}

ENDDOCUMENT();
See if that does what you want. The going on to the next part is awkward because the grader will not have been run yet when the text of the problem is being generated, and so you don't know whether the student's answer is right at the time the problem is being displayed. You don't know that until the NEXT time through, and so you need to have the extra "go on to the next part" step. I haven't found a way around that.

The key step for making the second part extra credit rather than part of the full credit is the line

    $cp->{totalWeight} = 1;
which resets it from being 1.1 to being just 1, so when the student gets the second part, the total will be 110% rather than 100%.

It would be possible to adjust the messages at the bottom somewhat, but you really don't have enough control over those to make it perfect.

Davide