[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 3515 Revision 3516
197# 197#
198sub cmp_class { 198sub cmp_class {
199 my $self = shift; my $ans = shift; 199 my $self = shift; my $ans = shift;
200 my $class = $self->showClass; $class =~ s/Real //; 200 my $class = $self->showClass; $class =~ s/Real //;
201 return $class if $class =~ m/Formula/; 201 return $class if $class =~ m/Formula/;
202 return "an Interval, Set or Union" if $class =~ m/Interval|Set|Union/i; 202 return "an Interval, Set or Union" if $self->isSetOfReals;
203 return $class; 203 return $class;
204} 204}
205 205
206# 206#
207# Student answer evaluation failed. 207# Student answer evaluation failed.
258 foreach my $i (0..$#R) { 258 foreach my $i (0..$#R) {
259 return "Your$nth union can be written in a simpler form" 259 return "Your$nth union can be written in a simpler form"
260 unless $R[$i] == $S[$i] && $R[$i]->length == $S[$i]->length; 260 unless $R[$i] == $S[$i] && $R[$i]->length == $S[$i]->length;
261 } 261 }
262 } elsif ($student->type eq 'Set' && $student->length >= 2) { 262 } elsif ($student->type eq 'Set' && $student->length >= 2) {
263 return "Your$nth set should have no redundant elements" 263 return "Your$nth set should have no repeated elements"
264 unless $student->reduce->length == $student->length; 264 unless $student->reduce->length == $student->length;
265 } 265 }
266 return; 266 return;
267} 267}
268 268
801 requireParenMatch => 1, 801 requireParenMatch => 1,
802)} 802)}
803 803
804sub typeMatch { 804sub typeMatch {
805 my $self = shift; my $other = shift; 805 my $self = shift; my $other = shift;
806 return 0 unless ref($other) && $other->class ne 'Formula'; 806 return 0 if !Value::isValue($other) || $other->isFormula;
807 return $other->length == 2 && 807 return $other->canBeInUnion;
808 ($other->{open} eq '(' || $other->{open} eq '[') &&
809 ($other->{close} eq ')' || $other->{close} eq ']')
810 if $other->type =~ m/^(Point|List)$/;
811 $other->type =~ m/^(Interval|Union|Set)$/;
812} 808}
813
814 809
815# 810#
816# Check for unreduced sets and unions 811# Check for unreduced sets and unions
817# 812#
818sub cmp_compare { 813sub cmp_compare {
849 844
850package Value::Set; 845package Value::Set;
851 846
852sub typeMatch { 847sub typeMatch {
853 my $self = shift; my $other = shift; 848 my $self = shift; my $other = shift;
854 return 0 unless ref($other) && $other->class ne 'Formula'; 849 return 0 if !Value::isValue($other) || $other->isFormula;
855 return $other->length == 2 && 850 return $other->canBeInUnion;
856 ($other->{open} eq '(' || $other->{open} eq '[') &&
857 ($other->{close} eq ')' || $other->{close} eq ']')
858 if $other->type =~ m/^(Point|List)$/;
859 $other->type =~ m/^(Interval|Union|Set)/;
860} 851}
861 852
862# 853#
863# Use the List checker for sets, in order to get 854# Use the List checker for sets, in order to get
864# partial credit. Set the various types for error 855# partial credit. Set the various types for error
903 return 0 unless ref($other) && $other->class ne 'Formula'; 894 return 0 unless ref($other) && $other->class ne 'Formula';
904 return $other->length == 2 && 895 return $other->length == 2 &&
905 ($other->{open} eq '(' || $other->{open} eq '[') && 896 ($other->{open} eq '(' || $other->{open} eq '[') &&
906 ($other->{close} eq ')' || $other->{close} eq ']') 897 ($other->{close} eq ')' || $other->{close} eq ']')
907 if $other->type =~ m/^(Point|List)$/; 898 if $other->type =~ m/^(Point|List)$/;
908 $other->type =~ m/^(Interval|Union|Set)/; 899 $other->isSetOfReals;
909} 900}
910 901
911# 902#
912# Use the List checker for unions, in order to get 903# Use the List checker for unions, in order to get
913# partial credit. Set the various types for error 904# partial credit. Set the various types for error

Legend:
Removed from v.3515  
changed lines
  Added in v.3516

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9