From: dpvc v. a. <we...@ma...> - 2005-12-31 15:01:22
|
Log Message: ----------- Added a new flag that controls how a list with a single entry that is a list is handled. In the past, the student could not specify such an item, but now the default is to form a list with a single entry that is a list, provided the student has used parens explicitly around his list. So "1,2" will be a list with two items and "(1,2)" will be a list with one item (a list). This improves the ability to use the list checker for lists of arbitrary pairs (like "(1,max)") especially when you want to check for lists of these (e.g., "(1,max),(2,min)"), since otherwise a single pair "(1,max)" entered by the student would become the list "1,max" rather than the list containing the single pair. If you really want "(1,max)" to become the list "1,max", use List("1,max")->cmp(implicitList=>0); to prevent single lists from forming a list of a single item. Modified Files: -------------- pg/lib/Value: AnswerChecker.pm Revision Data ------------- Index: AnswerChecker.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Value/AnswerChecker.pm,v retrieving revision 1.74 retrieving revision 1.75 diff -Llib/Value/AnswerChecker.pm -Llib/Value/AnswerChecker.pm -u -r1.74 -r1.75 --- lib/Value/AnswerChecker.pm +++ lib/Value/AnswerChecker.pm @@ -1012,6 +1012,7 @@ extra => undef, requireParenMatch => 1, removeParens => 1, + implicitList => 1, ); } @@ -1047,6 +1048,7 @@ my $showParenHints = getOption($ans,'showParenHints'); my $partialCredit = getOption($ans,'partialCredit'); my $requireParenMatch = $ans->{requireParenMatch}; + my $implicitList = $ans->{implicitList}; my $typeMatch = $ans->{typeMatch}; my $value = $ans->{entry_type}; my $ltype = $ans->{list_type} || lc($self->type); @@ -1074,11 +1076,19 @@ my $student = $ans->{student_value}; my @student = ($student); my ($sOpen,$sClose) = ('',''); if (Value::isFormula($student) && $student->type eq $self->type) { - @student = Value::List->splitFormula($student,$ans); - $sOpen = $student->{tree}{open}; $sClose = $student->{tree}{close}; + if ($implicitList && $student->{tree}{open} ne '') { + @student = ($student); + } else { + @student = Value::List->splitFormula($student,$ans); + $sOpen = $student->{tree}{open}; $sClose = $student->{tree}{close}; + } } elsif ($student->class ne 'Formula' && $student->class eq $self->type) { - @student = @{$student->{data}}; - $sOpen = $student->{open}; $sClose = $student->{close}; + if ($implicitList && $student->{open} ne '') { + @student = ($student); + } else { + @student = @{$student->{data}}; + $sOpen = $student->{open}; $sClose = $student->{close}; + } } return if $ans->{split_error}; # |