[system] / trunk / pg / lib / Value / AnswerChecker.pm Repository:
ViewVC logotype

Diff of /trunk/pg/lib/Value/AnswerChecker.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 2595 Revision 2596
77# 77#
78# Check if the parsed student answer equals the professor's answer 78# Check if the parsed student answer equals the professor's answer
79# 79#
80sub cmp_equal { 80sub cmp_equal {
81 my $self = shift; my $ans = shift; 81 my $self = shift; my $ans = shift;
82 my $v = $ans->{correct_value}; 82 if ($ans->{correct_value}->typeMatch($ans->{student_value},$ans)) {
83 my $V = $ans->{student_value}; 83 my $equal = eval {$ans->{correct_value} == $ans->{student_value}};
84 if ($v->typeMatch($V,$ans)) {
85 my $equal = eval {$v == $V}; # let the overloaded == do the check
86 if (defined($equal) || !$ans->{showEqualErrors}) {$ans->score(1) if $equal; return} 84 if (defined($equal) || !$ans->{showEqualErrors}) {$ans->score(1) if $equal; return}
87 my $cmp_error = $ans->{cmp_error} || 'cmp_error'; 85 my $cmp_error = $ans->{cmp_error} || 'cmp_error';
88 $self->$cmp_error($ans); 86 $self->$cmp_error($ans);
89 } else { 87 } else {
90 $ans->{ans_message} = $ans->{error_message} = 88 $ans->{ans_message} = $ans->{error_message} =
91 "Your answer isn't ".$v->showClass." (it looks like ".$V->showClass.")" 89 "Your answer isn't ".$ans->{correct_value}->showClass.
90 " (it looks like ".$ans->{student_value}->showClass.")"
92 if !$ans->{isPreview} && $ans->{showTypeWarnings} && !$ans->{error_message}; 91 if !$ans->{isPreview} && $ans->{showTypeWarnings} && !$ans->{error_message};
93 } 92 }
94} 93}
95 94
96# 95#
134 $string =~ s/>/\>/g; 133 $string =~ s/>/\>/g;
135 $string; 134 $string;
136} 135}
137 136
138############################################################# 137#############################################################
138#############################################################
139
140package Value::Real;
141
142sub typeMatch {
143 my $self = shift; my $other = shift; my $ans = shift;
144 if ($other->type eq 'String') {
145 $ans->{showEqualErrors} = 0;
146 return 1;
147 }
148 $self->type eq $other->type;
149}
150
139############################################################# 151#############################################################
140 152
141package Value::List; 153package Value::List;
142 154
143# 155#

Legend:
Removed from v.2595  
changed lines
  Added in v.2596

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9