We are using a custom answer checker that incorporates answer hints for round off error at some given margin of error. These respective answers are also weighted.
An example of the custom answer checker is shown below.
Our new problem is that when we try to use the custom answer check with NumberWithUnits the message of "Your numeric answer needs units" overrides any chance of checking for round off error.
Does anyone have any suggestions of how to incorporate NumberWithUnits with a custom answer checker?
Please help if you have any insight....
Thanks, Tim
######## Weighted Answer Hints with Round off error messages
######## that do not work. The suspected reason why is that these
######## answers use units...Then a question for the Forum?
WEIGHTED_ANS($ans2->cmp(
checker => sub {
my ($c, $s, $ans) = @_;
$diff = abs($ans2 -$s); ## establishing the error
if(($diff <= $err1) && ($diff >= 0.051))
{
$score = 0; ## has round-off error
$ans->{ans_message} = "Your answer is close. You likely have round-off error. Try using exact values in your calculation." ;
} elsif($s == $ans2) {
$score = 1; ## a correct calculation within 0.05
$ans->{ans_message} = "Yes!" ;
} else {
$ans->{ans_message} = "Nope! But, Keep Trying!";
$score= 0; ### All other scenarios
}
return $score;
}
),30); ## 30pts is the weighted value of this problem.