--- loncom/homework/grades.pm 2003/09/29 20:58:50 1.130.2.1.2.5 +++ loncom/homework/grades.pm 2003/09/29 21:31:30 1.130.2.1.2.6 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # The LON-CAPA Grading handler # -# $Id: grades.pm,v 1.130.2.1.2.5 2003/09/29 20:58:50 albertel Exp $ +# $Id: grades.pm,v 1.130.2.1.2.6 2003/09/29 21:31:30 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -3276,7 +3276,7 @@ sub username_to_idmap { } sub scantron_fixup_scanline { - my ($scantron_config,$scan_data,$line,$field,$newvalue,$arg) = @_; + my ($scantron_config,$scan_data,$line,$whichline,$field,$newvalue,$arg)=@_; if ($field eq 'ID') { if ($newvalue > $$scantron_config{'IDlength'}) { return ($line,1,'New value to large'); @@ -3292,11 +3292,11 @@ sub scantron_fixup_scanline { my $off=$scantron_config->{'Qoff'}; my $on=$scantron_config->{'Qon'}; my $answer=${off}x$length; - if ($arg ne 'none') { - substr($answer,$arg,1)=$on; - &scan_data($scan_data,"no_bubble.$newvalue",undef,'1'); + if ($arg eq 'none') { + &scan_data($scan_data,"$whichline.no_bubble.$newvalue",'1'); } else { - &scan_data($scan_data,"no_bubble.$newvalue",'1'); + substr($answer,$arg,1)=$on; + &scan_data($scan_data,"$whichline.no_bubble.$newvalue",undef,'1'); } my $where=$length*($newvalue-1)+$scantron_config->{'Qstart'}; Apache->request->print("where $where arg $arg "); @@ -3308,7 +3308,7 @@ sub scantron_fixup_scanline { } sub scan_data { - my ($scan_data,$key,$value,$delete); + my ($scan_data,$key,$value,$delete)=@_; my $filename=$ENV{'form.scantron_selectfile'}; if (defined($value)) { $scan_data->{$filename.'_'.$key} = $value; @@ -3318,7 +3318,7 @@ sub scan_data { } sub scantron_parse_scanline { - my ($line,$scantron_config,$scan_data)=@_; + my ($line,$whichline,$scantron_config,$scan_data)=@_; my %record; my $questions=substr($line,$$scantron_config{'Qstart'}-1); my $data=substr($line,0,$$scantron_config{'Qstart'}-1); @@ -3351,7 +3351,7 @@ sub scantron_parse_scanline { my @array=split($$scantron_config{'Qon'},$currentquest,-1); if (length($array[0]) eq $$scantron_config{'Qlength'}) { $record{"scantron.$questnum.answer"}=''; - if (!&scan_data($scan_data,"no_bubble.$questnum")) { + if (!&scan_data($scan_data,"$whichline.no_bubble.$questnum")) { push(@{$record{"scantron.missingerror"}},$questnum); } } else { @@ -3425,13 +3425,13 @@ sub scantron_process_corrections { $ENV{'form.scantron_domain'}; my $newid=$classlist->{$newstudent}->[&Apache::loncoursedata::CL_ID]; ($line,$err,$errmsg)= - &scantron_fixup_scanline(\%scantron_config,$scan_data,$line,'ID', - $newid); + &scantron_fixup_scanline(\%scantron_config,$scan_data,$line,$which, + 'ID',$newid); } elsif ($ENV{'form.scantron_corrections'} =~ /^(missing|double)bubble$/) { foreach my $question (split(',',$ENV{'form.scantron_questions'})) { ($line,$err,$errmsg)= &scantron_fixup_scanline(\%scantron_config,$scan_data,$line, - 'answer',$question, + $which,'answer',$question, $ENV{"form.scantron_correct_Q_$question"}); if ($err) { last; } } @@ -3586,7 +3586,8 @@ sub scantron_validate_ID { for (my $i=0;$i<=$scanlines->{'count'};$i++) { my $line=&scantron_get_line($scanlines,$i); if (!$line) { next; } - my $scan_record=&scantron_parse_scanline($line,\%scantron_config,$scan_data); + my $scan_record=&scantron_parse_scanline($line,$i,\%scantron_config, + $scan_data); my $id=$$scan_record{'scantron.ID'}; $r->print("

Checking ID ".$$scan_record{'scantron.ID'}. " on paper ID ".$$scan_record{'scantron.PaperID'}."

\n"); @@ -3713,7 +3714,8 @@ sub scantron_validate_doublebubble { for (my $i=0;$i<=$scanlines->{'count'};$i++) { my $line=&scantron_get_line($scanlines,$i); if (!$line) { next; } - my $scan_record=&scantron_parse_scanline($line,\%scantron_config,$scan_data); + my $scan_record=&scantron_parse_scanline($line,$i,\%scantron_config, + $scan_data); if (!defined($$scan_record{'scantron.doubleerror'})) { next; } &scantron_get_correction($r,$i,$scan_record,\%scantron_config,$line, 'doublebubble', @@ -3737,7 +3739,8 @@ sub scantron_validate_missingbubbles { for (my $i=0;$i<=$scanlines->{'count'};$i++) { my $line=&scantron_get_line($scanlines,$i); if (!$line) { next; } - my $scan_record=&scantron_parse_scanline($line,\%scantron_config,$scan_data); + my $scan_record=&scantron_parse_scanline($line,$i,\%scantron_config, + $scan_data); if (!defined($$scan_record{'scantron.missingerror'})) { next; } my @to_correct; foreach my $missing (@{$$scan_record{'scantron.missingerror'}}) { @@ -3795,7 +3798,8 @@ SCANTRONFORM my $line=&scantron_get_line($scanlines,$i); if (!$line) { next; } $r->print('
line is'.$line.'
'); - my $scan_record=&scantron_parse_scanline($line,\%scantron_config,$scan_data); + my $scan_record=&scantron_parse_scanline($line,$i,\%scantron_config, + $scan_data); my ($uname,$udom); unless ($uname=&scantron_find_student($scan_record,\%idmap)) { &scantron_add_delay(\@delayqueue,$line, @@ -4165,6 +4169,7 @@ sub send_header { #remotewindow.close(); #"); $request->print(&Apache::loncommon::bodytag('Grading')); + $request->rflush(); } sub send_footer {