WeBWorK Problems

Post-Filter answer hints to flag round-off error entries?

Re: Post-Filter answer hints to flag round-off error entries?

by tim Payer -
Number of replies: 0
With some help from co-worker, Tim Lauck, we were able to arrive at a custom answer checker for weighted answers involving round-off error.

For any who might want to use something similar here is the code block:

########################
#### Custom Weighted Answer Checker for Round-off error:
########################
## The correct value: $c
## The student's entry: $s
## The returned score: $ans
## Note: Be sure that the tolerance in the settings (0.0001)
## do not restrict the custom answer checker.

WEIGHTED_ANS($mean->cmp(
checker => sub {
my ($c, $s, $ans) = @_;
$diff = abs($mean -$s); ## establishing the error
if(($diff <= 0.01) && ($diff >= 0.0002))
{
$score = 0; ## has round-off error
$ans->{ans_message} = "You have round-off error. Try using exact values (think: Fractions) in your calculation." ;
} elsif($s == $wm) {
$score = 0; ## Using a geometric mean in error.
$ans->{ans_message} = "No, Your mean calculation did not account for differing likelihoods." ;
} elsif($s == $mean) {
$score = 1; ## a correct calculation within 0.0001
$ans->{ans_message} = "Yes!" ;
} else {
$ans->{ans_message} = "Nope! But, Keep Trying!";
$score= 0; ### All other scenarios
}
return $score;
}
),10); ## 10pts is the weighted value of this problem.

Tim