[LON-CAPA-cvs] cvs: loncom /homework grades.pm
foxr
lon-capa-cvs-allow@mail.lon-capa.org
Tue, 06 Nov 2007 11:21:30 -0000
foxr Tue Nov 6 06:21:30 2007 EDT
Modified files:
/loncom/homework grades.pm
Log:
BZ4074 - Correct handling of doubble bubble detection and bubble
corrections for the case where the bubble sheets use positional notation
Index: loncom/homework/grades.pm
diff -u loncom/homework/grades.pm:1.481 loncom/homework/grades.pm:1.482
--- loncom/homework/grades.pm:1.481 Tue Nov 6 05:12:27 2007
+++ loncom/homework/grades.pm Tue Nov 6 06:21:21 2007
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# The LON-CAPA Grading handler
#
-# $Id: grades.pm,v 1.481 2007/11/06 10:12:27 foxr Exp $
+# $Id: grades.pm,v 1.482 2007/11/06 11:21:21 foxr Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -5149,14 +5149,14 @@
}
} elsif ($field eq 'answer') {
&scantron_get_maxbubble(); # Need the bubble counter info.
- my $length=$scantron_config->{'Qlength'};
+ my $length =$scantron_config->{'Qlength'};
my $off=$scantron_config->{'Qoff'};
my $on=$scantron_config->{'Qon'};
- my $answer=${off}x$length;
my $question_number = $args->{'question'} -1;
my $first_position = $first_bubble_line{$question_number};
my $bubble_count = $bubble_lines_per_response{$question_number};
my $bubbles_per_line= $$scantron_config{'Qlength'};
+ my $answer=${off}x($bubbles_per_line*$bubble_count);
my $final_answer;
if ($$scantron_config{'Qon'} eq 'letter' ||
$$scantron_config{'Qon'} eq 'number') {
@@ -5173,18 +5173,24 @@
my @alphabet=('A'..'Z');
$answer=$alphabet[$bubble_number];
} elsif ($on eq 'number') {
- $answer=$args->{$bubble_number+1};
+ $answer= $bubble_number+1;
if ($answer == 10) { $answer = '0'; }
} else {
- substr($answer,$args->{'response'},1)=$on;
+ substr($answer,$bubble_number+$bubble_line*$bubbles_per_line,1)=$on;
+ $final_answer = $answer;
}
&scan_data($scan_data,
"$whichline.no_bubble.".$args->{'question'},undef,'1');
- for (my $l = 0; $l < $bubble_count; $l++) {
- if ($l eq $bubble_line) {
- $final_answer .= $answer;
- } else {
- $final_answer .= ' ';
+
+ # Positional notation already has the right final answer length..
+
+ if (($on eq 'letter') || ($on eq 'number')) {
+ for (my $l = 0; $l < $bubble_count; $l++) {
+ if ($l eq $bubble_line) {
+ $final_answer .= $answer;
+ } else {
+ $final_answer .= ' ';
+ }
}
}
}
@@ -5192,7 +5198,7 @@
#substr($line,$where-1,$length)=$answer;
substr($line,
$scantron_config->{'Qstart'}+$first_position-1,
- $bubbles_per_line) = $final_answer;
+ $bubbles_per_line*$length) = $final_answer;
}
}
return $line;
@@ -5440,7 +5446,11 @@
if (!&scan_data($scan_data,"$whichline.no_bubble.$questnum")) {
push(@{$record{"scantron.missingerror"}},$questnum);
}
- } elsif (scalar(@array) lt 2) {
+
+ # If the bubble is not the last position, there will be
+ # 2 elements. If it is the last position, there will be 1 element.
+
+ } elsif (scalar(@array) le 2) {
my $location = length($array[0]);
my $line_num = $location / $$scantron_config{'Qlength'};