| … | |
… | |
| 3619 | my $sensibleAnswer = 0; |
3619 | my $sensibleAnswer = 0; |
| 3620 | $ans = str_filters( $ans, 'compress_whitespace' ); # remove trailing, leading, and double spaces. |
3620 | $ans = str_filters( $ans, 'compress_whitespace' ); # remove trailing, leading, and double spaces. |
| 3621 | my ($ans_eval) = str_cmp($rh_ans->{correct_ans}); |
3621 | my ($ans_eval) = str_cmp($rh_ans->{correct_ans}); |
| 3622 | my $temp_ans_hash = &$ans_eval($ans); |
3622 | my $temp_ans_hash = &$ans_eval($ans); |
| 3623 | $rh_ans->{test} = $temp_ans_hash; |
3623 | $rh_ans->{test} = $temp_ans_hash; |
|
|
3624 | |
| 3624 | if ($temp_ans_hash->{score} ==1 ) { # students answer matches the correct answer. |
3625 | if ($temp_ans_hash->{score} ==1 ) { # students answer matches the correct answer. |
| 3625 | $rh_ans->{score} = 1; |
3626 | $rh_ans->{score} = 1; |
| 3626 | $sensibleAnswer = 1; |
3627 | $sensibleAnswer = 1; |
| 3627 | } else { # students answer does not match the correct answer. |
3628 | } else { # students answer does not match the correct answer. |
| 3628 | my $legalString = ''; # find out if string makes sense |
3629 | my $legalString = ''; # find out if string makes sense |
| … | |
… | |
| 3636 | $sensibleAnswer = 1 unless $ans =~ /\S/; ## empty answers are sensible |
3637 | $sensibleAnswer = 1 unless $ans =~ /\S/; ## empty answers are sensible |
| 3637 | $rh_ans->throw_error('EVAL', "Your answer is not a recognized answer") unless ($sensibleAnswer); |
3638 | $rh_ans->throw_error('EVAL', "Your answer is not a recognized answer") unless ($sensibleAnswer); |
| 3638 | # $temp_ans_hash -> setKeys( 'ans_message' => 'Your answer is not a recognized answer' ) unless ($sensibleAnswer); |
3639 | # $temp_ans_hash -> setKeys( 'ans_message' => 'Your answer is not a recognized answer' ) unless ($sensibleAnswer); |
| 3639 | # $temp_ans_hash -> setKeys( 'student_ans' => uc($ans) ); |
3640 | # $temp_ans_hash -> setKeys( 'student_ans' => uc($ans) ); |
| 3640 | } |
3641 | } |
|
|
3642 | |
| 3641 | $rh_ans->{student_ans} = $ans; |
3643 | $rh_ans->{student_ans} = $ans; |
|
|
3644 | |
| 3642 | if ($sensibleAnswer) { |
3645 | if ($sensibleAnswer) { |
| 3643 | $rh_ans->throw_error('STRING', "The student's answer $rh_ans->{student_ans} is interpreted as a string."); |
3646 | $rh_ans->throw_error('STRING', "The student's answer $rh_ans->{student_ans} is interpreted as a string."); |
| 3644 | } |
3647 | } |
|
|
3648 | |
|
|
3649 | $rh_ans->{'preview_text_string'} = $ans, |
|
|
3650 | $rh_ans->{'preview_latex_string'} = $ans, |
|
|
3651 | |
| 3645 | # warn ("\$rh_ans->{answerIsString} = $rh_ans->{answerIsString}"); |
3652 | # warn ("\$rh_ans->{answerIsString} = $rh_ans->{answerIsString}"); |
| 3646 | $rh_ans; |
3653 | $rh_ans; |
| 3647 | } |
3654 | } |
| 3648 | |
3655 | |
| 3649 | =head4 check_units |
3656 | =head4 check_units |