| … | |
… | |
| 876 | if ( $units_match ) { |
876 | if ( $units_match ) { |
| 877 | # units are ok. Evaluate the numerical part of the answer |
877 | # units are ok. Evaluate the numerical part of the answer |
| 878 | $rh_ans->{'tolerance'} = $rh_ans->{'tolerance'}* $correct_units{'factor'}/$units{'factor'} if |
878 | $rh_ans->{'tolerance'} = $rh_ans->{'tolerance'}* $correct_units{'factor'}/$units{'factor'} if |
| 879 | $rh_ans->{'tolType'} eq 'absolute'; # the tolerance is in the units specified by the instructor. |
879 | $rh_ans->{'tolType'} eq 'absolute'; # the tolerance is in the units specified by the instructor. |
| 880 | $rh_ans->{correct_ans} = prfmt($rh_ans->{correct_ans}*$correct_units{'factor'}/$units{'factor'}); |
880 | $rh_ans->{correct_ans} = prfmt($rh_ans->{correct_ans}*$correct_units{'factor'}/$units{'factor'}); |
|
|
881 | $rh_ans->{student_units} = $units; |
| 881 | $rh_ans->{student_ans} = $num_answer; |
882 | $rh_ans->{student_ans} = $num_answer; |
| 882 | |
883 | |
| 883 | } else { |
884 | } else { |
| 884 | $rh_ans -> setKeys( ans_message => 'There is an error in the units for this answer.' ); |
885 | $rh_ans -> setKeys( ans_message => 'There is an error in the units for this answer.' ); |
| 885 | $rh_ans -> throw_error ( 'UNITS', 'There is an error in the units for this answer.' ); |
886 | $rh_ans -> throw_error ( 'UNITS', 'There is an error in the units for this answer.' ); |
| … | |
… | |
| 1468 | # We'll leave these next lines out for now, so that the evaluated versions of the student's and professor's |
1469 | # We'll leave these next lines out for now, so that the evaluated versions of the student's and professor's |
| 1469 | # can be displayed in the answer message. This may still cause a few anomolies when strings are used |
1470 | # can be displayed in the answer message. This may still cause a few anomolies when strings are used |
| 1470 | # |
1471 | # |
| 1471 | ############################################################################### |
1472 | ############################################################################### |
| 1472 | |
1473 | |
| 1473 | # $answer_evaluator->install_post_filter(sub {my $rh_ans = shift; |
1474 | $answer_evaluator->install_post_filter(\&fix_answers_for_display); |
| 1474 | # |
|
|
| 1475 | # $rh_ans->{student_ans} = $rh_ans->{original_student_ans}; |
|
|
| 1476 | # $rh_ans->{correct_ans} = $rh_ans->{original_correct_ans}; |
|
|
| 1477 | # $rh_ans;} |
|
|
| 1478 | # ); |
|
|
| 1479 | |
1475 | |
| 1480 | $answer_evaluator->install_post_filter(sub {my $rh_ans = shift; |
1476 | $answer_evaluator->install_post_filter(sub {my $rh_ans = shift; |
| 1481 | return $rh_ans unless $rh_ans->catch_error('EVAL'); |
1477 | return $rh_ans unless $rh_ans->catch_error('EVAL'); |
| 1482 | $rh_ans->{student_ans} = $rh_ans->{original_student_ans}. ' '. $rh_ans->{error_message}; |
1478 | $rh_ans->{student_ans} = $rh_ans->{original_student_ans}. ' '. $rh_ans->{error_message}; |
| 1483 | $rh_ans->clear_error('EVAL'); } ); |
1479 | $rh_ans->clear_error('EVAL'); } ); |
| … | |
… | |
| 1488 | |
1484 | |
| 1489 | |
1485 | |
| 1490 | $answer_evaluator; |
1486 | $answer_evaluator; |
| 1491 | } |
1487 | } |
| 1492 | |
1488 | |
| 1493 | |
1489 | sub fix_answers_for_display { |
|
|
1490 | my ($rh_ans, %options) = @_; |
|
|
1491 | if (defined ($rh_ans->{student_units})) { |
|
|
1492 | $rh_ans->{student_ans} = $rh_ans->{student_ans}. ' '. $rh_ans->{student_units}; |
|
|
1493 | } |
|
|
1494 | $rh_ans->{correct_ans} = $rh_ans->{original_correct_ans}; |
|
|
1495 | $rh_ans; |
|
|
1496 | } |
| 1494 | |
1497 | |
| 1495 | |
1498 | |
| 1496 | |
1499 | |
| 1497 | ########################################################################## |
1500 | ########################################################################## |
| 1498 | ########################################################################## |
1501 | ########################################################################## |