Log Message:
-----------
Interval (and Union) checker now accepts requireParenMatch flag for
deciding whether the interval type must match. Setting
requireParenMatch to 0 will let (1,2) match (1,2] or [1,2], etc.
Modified Files:
--------------
pg/lib/Value:
AnswerChecker.pm
Interval.pm
Revision Data
-------------
Index: AnswerChecker.pm
===================================================================
RCS file: /webwork/cvs/system/pg/lib/Value/AnswerChecker.pm,v
retrieving revision 1.49
retrieving revision 1.50
diff -Llib/Value/AnswerChecker.pm -Llib/Value/AnswerChecker.pm -u -r1.49 -r1.50
--- lib/Value/AnswerChecker.pm
+++ lib/Value/AnswerChecker.pm
@@ -760,6 +760,7 @@
shift->SUPER::cmp_defaults(@_),
showEndpointHints => 1,
showEndTypeHints => 1,
+ requireParenMatch => 1,
)}
sub typeMatch {
@@ -772,6 +773,15 @@
$other->type =~ m/^(Interval|Union)$/;
}
+sub cmp_compare {
+ my $self = shift; my $other = shift; my $ans = shift;
+ my $oldignore = $self->{requireParenMatch};
+ $self->{ignoreEndpointTypes} = !$ans->{requireParenMatch};
+ my $equal = $self->SUPER::cmp_compare($other,$ans);
+ $self->{ignoreEndpointTypes} = $oldignore;
+ return $equal;
+}
+
#
# Check for wrong enpoints and wrong type of endpoints
#
@@ -788,7 +798,7 @@
push(@errors,"Your right endpoint is incorrect")
if ($self->{data}[1] != $other->{data}[1]);
}
- if (scalar(@errors) == 0 && $ans->{showEndTypeHints}) {
+ if (scalar(@errors) == 0 && $ans->{showEndTypeHints} && $ans->{requireParenMatch}) {
push(@errors,"The type of interval is incorrect")
if ($self->{open}.$self->{close} ne $other->{open}.$other->{close});
}
Index: Interval.pm
===================================================================
RCS file: /webwork/cvs/system/pg/lib/Value/Interval.pm,v
retrieving revision 1.19
retrieving revision 1.20
diff -Llib/Value/Interval.pm -Llib/Value/Interval.pm -u -r1.19 -r1.20
--- lib/Value/Interval.pm
+++ lib/Value/Interval.pm
@@ -174,8 +174,8 @@
if ($flag) {my $tmp = $l; $l = $r; $r = $tmp};
my ($la,$lb) = @{$l->data}; my ($ra,$rb) = @{$r->data};
my $cmp = $la <=> $ra; return $cmp if $cmp;
+ $cmp = $lb <=> $rb; return $cmp if $cmp || $l->{ignoreEndpointTypes};
$cmp = $l->{open} cmp $r->{open}; return $cmp if $cmp;
- $cmp = $lb <=> $rb; return $cmp if $cmp;
return $l->{close} cmp $r->{close};
}
|