2 questions about custom grader below please...
1. It gives 75% partial credit when I enter the wrong units...e.g. try entering "2 m".
However, if I add this question to an EXAM then it doesn't work. What
is different about exam mode that makes it not give partial credit for
wrong units anymore?
2. How make it give 75% partial credit
if units are *missing*? Right now it gives no credit in that case.
DOCUMENT();
loadMacros(
"MathObjects.pl",
"PGstandard.pl",
"PGML.pl",
"PGcourse.pl",
"parserNumberWithUnits.pl",
"contextArbitraryString.pl",
"parserPopUp.pl",
);
TEXT(beginproblem());
$showPartialCorrectAnswers = 1;
######################################################################
Context("Numeric") ; Context()->flags->set(tolerance => 0.01);
$A = NumberWithUnits("2 ft"); $A->{value} = $A->value;
$cmp = $A->cmp->withPostFilter(sub {
my $ans = shift;
return $ans if $ans->{ans_message};
my $correct = $ans->{correct_value};
my $student = $ans->{student_value};
return $ans unless defined($correct) && defined($student);
if ($student->{units} ne $correct->{units}) {
if ($correct->{value} == $student->value) {
$ans->{score} = .75;
$ans->{ans_message} = "Has the correct number but incorrect units.";
} else {
$ans->{score} = 0;
}
}
return $ans;
});
BEGIN_PGML
How many feet are equal to 24 inches?
[___________]{$cmp}
END_PGML
######################################################################
ENDDOCUMENT();