--- loncom/homework/grades.pm 2007/10/15 09:47:47 1.459 +++ loncom/homework/grades.pm 2007/10/17 10:48:20 1.461 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # The LON-CAPA Grading handler # -# $Id: grades.pm,v 1.459 2007/10/15 09:47:47 foxr Exp $ +# $Id: grades.pm,v 1.461 2007/10/17 10:48:20 foxr Exp $ # # Copyright Michigan State University Board of Trustees # @@ -57,9 +57,7 @@ my %first_bubble_line = (); # First bubb sub save_bubble_lines { - &Apache::lonnet::logthis("Saving bubble_lines..."); foreach my $line (keys(%bubble_lines_per_response)) { - &Apache::lonnet::logthis("Saving form.scantron.bubblelines.$line value: $bubble_lines_per_response{$line}"); $env{"form.scantron.bubblelines.$line"} = $bubble_lines_per_response{$line}; $env{"form.scantron.first_bubble_line.$line"} = $first_bubble_line{$line}; @@ -72,7 +70,6 @@ sub restore_bubble_lines { %bubble_lines_per_response = (); while ($env{"form.scantron.bubblelines.$line"}) { my $value = $env{"form.scantron.bubblelines.$line"}; - &Apache::lonnet::logthis("Restoring form.scantron.bubblelines.$line value: $value"); $bubble_lines_per_response{$line} = $value; $first_bubble_line{$line} = $env{"form.scantron.first_bubble_line.$line"}; @@ -87,12 +84,14 @@ sub restore_bubble_lines { sub get_response_bubbles { my ($parsed_line, $response) = @_; - my $bubble_line = $first_bubble_line{$response}; - my $bubble_lines= $bubble_lines_per_response{$response}; + + my $bubble_line = $first_bubble_line{$response-1} +1; + my $bubble_lines= $bubble_lines_per_response{$response-1}; + my $selected = ""; for (my $bline = 0; $bline < $bubble_lines; $bline++) { - $selected .= $$parsed_line{"scantron.$bubble_line.answer"}; + $selected .= $$parsed_line{"scantron.$bubble_line.answer"}.":"; $bubble_line++; } return $selected; @@ -5269,7 +5268,12 @@ sub scantron_parse_scanline { || (&occurence_count($currentquest, "[A-Z]") > 1)) { push(@{$record{'scantron.doubleerror'}},$questnum); for (my $ans = 0; $ans < $answers_needed; $ans++) { - $record{"scantron.$ansnum.answer"}=''; + my $bubble = substr($currentquest, $ans, 1); + if ($bubble =~ /[A-Z]/ ) { + $record{"scantron.$ansnum.answer"} = $bubble; + } else { + $record{"scantron.$ansnum.answer"}=''; + } $ansnum++; } @@ -5304,7 +5308,12 @@ sub scantron_parse_scanline { || (&occurence_count($currentquest, '\d') > 1)) { push(@{$record{'scantron.doubleerror'}},$questnum); for (my $ans = 0; $ans < $answers_needed; $ans++) { - $record{"scantron.$ansnum.answer"}=''; + my $bubble = substr($currentquest, $ans, 1); + if ($bubble =~ /\d/) { + $record{"scantron.$ansnum.answer"} = $alphabet[$bubble]; + } else { + $record{"scantron.$ansnum.answer"}=' '; + } $ansnum++; } @@ -5747,7 +5756,6 @@ SCANTRONFORM my $line = 0; while (defined($env{"form.scantron.bubblelines.$line"})) { - &Apache::lonnet::logthis("Saving chunk for $line"); my $chunk = ''."\n"; $chunk .= @@ -5813,7 +5821,6 @@ sub scantron_validate_file { } my $currentphase=$env{'form.validatepass'}; - &Apache::lonnet::logthis("Phase: $currentphase"); my $stop=0; while (!$stop && $currentphase < scalar(@validate_phases)) { @@ -6424,10 +6431,10 @@ ENDSCRIPT $r->print($message); $r->print("
Please indicate which bubble should be used for grading
"); foreach my $question (@{$arg}) { - my $selected = &get_response_bubbles($scan_record, $question); + my @select_array = split(/:/,$selected); &scantron_bubble_selector($r,$scan_config,$question, - split('',$selected)); + @select_array); } } elsif ($error eq 'missingbubble') { $r->print("There have been no bubbles scanned for some question(s)
\n"); @@ -6458,22 +6465,24 @@ ENDSCRIPT $r - Apache request object $scan_config - hash from &get_scantron_config() $quest - number of the bubble line to make a corrector for - $selected - array of letters of previously selected bubbles + $lines - array of answer lines. =cut sub scantron_bubble_selector { - my ($r,$scan_config,$quest,@selected)=@_; + my ($r,$scan_config,$quest,@lines)=@_; my $max=$$scan_config{'Qlength'}; + my $scmode=$$scan_config{'Qon'}; + my $bubble_length = scalar(@lines); + if ($scmode eq 'number' || $scmode eq 'letter') { $max=10; } my $response = $quest-1; my $lines = $bubble_lines_per_response{$response}; - &Apache::lonnet::logthis("Question $quest, lines: $lines"); my $total_lines = $lines*2; my @alphabet=('A'..'Z'); @@ -6483,12 +6492,8 @@ sub scantron_bubble_selector { if ($l != 0) { $r->print('