--- loncom/homework/grades.pm 2003/09/29 21:31:30 1.130.2.1.2.6 +++ loncom/homework/grades.pm 2003/09/30 06:35:20 1.130.2.1.2.7 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # The LON-CAPA Grading handler # -# $Id: grades.pm,v 1.130.2.1.2.6 2003/09/29 21:31:30 albertel Exp $ +# $Id: grades.pm,v 1.130.2.1.2.7 2003/09/30 06:35:20 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -3276,33 +3276,36 @@ sub username_to_idmap { } sub scantron_fixup_scanline { - my ($scantron_config,$scan_data,$line,$whichline,$field,$newvalue,$arg)=@_; + my ($scantron_config,$scan_data,$line,$whichline,$field,$args)=@_; if ($field eq 'ID') { - if ($newvalue > $$scantron_config{'IDlength'}) { + if (length($args->{'newid'}) > $$scantron_config{'IDlength'}) { return ($line,1,'New value to large'); } - if ($newvalue < $$scantron_config{'IDlength'}) { - $newvalue=sprintf('%-'.$$scantron_config{'IDlength'}.'s', - $newvalue); + if (length($args->{'newid'}) < $$scantron_config{'IDlength'}) { + $args->{'newid'}=sprintf('%-'.$$scantron_config{'IDlength'}.'s', + $args->{'newid'}); } substr($line,$$scantron_config{'IDstart'}-1, - $$scantron_config{'IDlength'})=$newvalue; + $$scantron_config{'IDlength'})=$args->{'newid'}; + if ($args->{'newid'}=~/^\s*$/) { + &scan_data($scan_data,"$whichline.user", + $args->{'username'}.':'.$args->{'domain'}); + } } elsif ($field eq 'answer') { my $length=$scantron_config->{'Qlength'}; my $off=$scantron_config->{'Qoff'}; my $on=$scantron_config->{'Qon'}; my $answer=${off}x$length; - if ($arg eq 'none') { - &scan_data($scan_data,"$whichline.no_bubble.$newvalue",'1'); + if ($args->{'response'} eq 'none') { + &scan_data($scan_data, + "$whichline.no_bubble.".$args->{'question'},'1'); } else { - substr($answer,$arg,1)=$on; - &scan_data($scan_data,"$whichline.no_bubble.$newvalue",undef,'1'); + substr($answer,$args->{'response'},1)=$on; + &scan_data($scan_data, + "$whichline.no_bubble.".$args->{'question'},undef,'1'); } - my $where=$length*($newvalue-1)+$scantron_config->{'Qstart'}; - Apache->request->print("where $where arg $arg "); - Apache->request->print('b:
'.$line.''); + my $where=$length*($args->{'question'}-1)+$scantron_config->{'Qstart'}; substr($line,$where-1,$length)=$answer; - Apache->request->print('a:
'.$line.''); } return $line; } @@ -3358,10 +3361,11 @@ sub scantron_parse_scanline { $record{"scantron.$questnum.answer"}=$alphabet[length($array[0])]; } if (scalar(@array) gt 2) { + Apache->request->print("snippet is
$currentquest"); push(@{$record{'scantron.doubleerror'}},$questnum); my @ans=@array; my $i=length($ans[0]);shift(@ans); - while (@ans) { + while ($#ans) { $i+=length($ans[0])+1; $record{"scantron.$questnum.answer"}.=$alphabet[$i]; shift(@ans); @@ -3382,8 +3386,11 @@ sub scantron_add_delay { } sub scantron_find_student { - my ($scantron_record,$idmap)=@_; + my ($scantron_record,$scan_data,$idmap,$line)=@_; my $scanID=$$scantron_record{'scantron.ID'}; + if ($scanID =~ /^\s*$/) { + return &scan_data($scan_data,"$line.user"); + } foreach my $id (keys(%$idmap)) { #Apache->request->print('
checking studnet -'.$id.'- againt -'.$scanID.'-'); if (lc($id) eq lc($scanID)) { @@ -3402,14 +3409,6 @@ sub scantron_filter { return 0; } -#FIXME I think I am doing this in the wrong order, I think it would be -#better to make a several passes analyzing all of the lines in the -#file for common errors wrong/invalid PID/username duplicated -#PID/username, missing bubbles, double bubbles, missing/invalid CODE -#and then get the instructor to fix all of these errors, then grade -#the corrected one, I'll still need to catch error conditions, but -#maybe most will taken care even before we start - sub scantron_process_corrections { my ($r) = @_; my %scantron_config=&get_scantron_config($ENV{'form.scantron_format'}); @@ -3426,13 +3425,16 @@ sub scantron_process_corrections { my $newid=$classlist->{$newstudent}->[&Apache::loncoursedata::CL_ID]; ($line,$err,$errmsg)= &scantron_fixup_scanline(\%scantron_config,$scan_data,$line,$which, - 'ID',$newid); + 'ID',{'newid'=>$newid, + 'username'=>$ENV{'form.scantron_username'}, + 'domain'=>$ENV{'form.scantron_domain'}}); } 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, - $which,'answer',$question, - $ENV{"form.scantron_correct_Q_$question"}); + $which,'answer', + { 'question'=>$question, + 'response'=>$ENV{"form.scantron_correct_Q_$question"}}); if ($err) { last; } } } @@ -3458,7 +3460,6 @@ sub scantron_validate_file { $r->print(&Apache::loncommon::studentbrowser_javascript()); my $result= <
Validating ".$validate_phases[$currentphase]."
"); + $r->rflush(); my $which="scantron_validate_".$validate_phases[$currentphase]; { no strict 'refs'; ($stop,$currentphase)=&$which($r,$currentphase); } } - $r->print(""); + if (!$stop) { + $r->print("Validation process complete, click 'Submit' to start proccssing"); + $r->print(''); + } else { + $r->print(''); + $r->print(""); + } + $r->print('