--- loncom/homework/grades.pm 2004/04/20 06:11:49 1.186 +++ loncom/homework/grades.pm 2004/04/29 04:47:47 1.191 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # The LON-CAPA Grading handler # -# $Id: grades.pm,v 1.186 2004/04/20 06:11:49 albertel Exp $ +# $Id: grades.pm,v 1.191 2004/04/29 04:47:47 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -3422,6 +3422,7 @@ sub scantron_uploads { my $cname=$ENV{'course.'.$ENV{'request.course.id'}.'.num'}; my @files=&Apache::lonnet::dirlist('userfiles',$cdom,$cname, &Apache::loncommon::propath($cdom,$cname)); + $result.=""; foreach my $filename (@files) { ($filename)=split(/&/,$filename); if ($filename!~/^scantron_orig_/) { next ; } @@ -3435,6 +3436,7 @@ sub scantron_uploads { sub scantron_scantab { my $fh=Apache::File->new($Apache::lonnet::perlvar{'lonTabDir'}.'/scantronformat.tab'); my $result=''.$namechoice.''; @@ -3487,7 +3490,7 @@ sub scantron_selectphase {
-
+ $default_form_data @@ -3512,10 +3515,10 @@ sub scantron_selectphase { + @@ -3579,6 +3582,40 @@ UPLOAD SCANTRONFORM } + $r->print(< + + +SCANTRONFORM $r->print(< @@ -3648,17 +3685,20 @@ sub scantron_fixup_scanline { $args->{'username'}.':'.$args->{'domain'}); } } elsif ($field eq 'CODE') { - if (length($args->{'CODE'}) > $$scantron_config{'CODElength'}) { - return ($line,1,'New CODE value too large'); - } - if (length($args->{'CODE'}) < $$scantron_config{'CODElength'}) { - $args->{'CODE'}=sprintf('%-'.$$scantron_config{'CODElength'}.'s', - $args->{'CODE'}); - } - substr($line,$$scantron_config{'CODEstart'}-1, - $$scantron_config{'CODElength'})=$args->{'CODE'}; - if ($args->{'CODE'}=~/^\s*$/) { - &scan_data($scan_data,"$whichline.CODE",$args->{'CODE'}); + if ($args->{'CODE'} eq 'use_unfound') { + &scan_data($scan_data,"$whichline.useCODE",'1'); + } else { + if (length($args->{'CODE'}) > $$scantron_config{'CODElength'}) { + return ($line,1,'New CODE value too large'); + } + if (length($args->{'CODE'}) < $$scantron_config{'CODElength'}) { + $args->{'CODE'}=sprintf('%-'.$$scantron_config{'CODElength'}.'s',$args->{'CODE'}); + } + substr($line,$$scantron_config{'CODEstart'}-1, + $$scantron_config{'CODElength'})=$args->{'CODE'}; +# if ($args->{'CODE'}=~/^\s*$/) { +# &scan_data($scan_data,"$whichline.CODE",$args->{'CODE'}); +# } } } elsif ($field eq 'answer') { my $length=$scantron_config->{'Qlength'}; @@ -3690,18 +3730,23 @@ sub scan_data { } sub scantron_parse_scanline { - my ($line,$whichline,$scantron_config,$scan_data)=@_; + my ($line,$whichline,$scantron_config,$scan_data,$justCODE)=@_; my %record; my $questions=substr($line,$$scantron_config{'Qstart'}-1); my $data=substr($line,0,$$scantron_config{'Qstart'}-1); if ($$scantron_config{'CODElocation'} ne 0) { if ($$scantron_config{'CODElocation'} < 0) { - $record{'scantron.CODE'}=substr($data,$$scantron_config{'CODEstart'}-1, + $record{'scantron.CODE'}=substr($data, + $$scantron_config{'CODEstart'}-1, $$scantron_config{'CODElength'}); + if (&scan_data($scan_data,"$whichline.useCODE")) { + $record{'scantron.useCODE'}=1; + } } else { #FIXME interpret first N questions } } + if ($justCODE) { return \%record; } $record{'scantron.ID'}=substr($data,$$scantron_config{'IDstart'}-1, $$scantron_config{'IDlength'}); $record{'scantron.PaperID'}= @@ -3794,7 +3839,15 @@ sub scantron_process_corrections { 'username'=>$ENV{'form.scantron_username'}, 'domain'=>$ENV{'form.scantron_domain'}}); } elsif ($ENV{'form.scantron_corrections'} =~ /^(duplicate|incorrect)CODE$/) { - my $newCODE=$ENV{'form.scantron_CODE'}; + my $resolution=$ENV{'form.scantron_CODE_resolution'}; + my $newCODE; + if ($resolution eq 'use_unfound') { + $newCODE='use_unfound'; + } elsif ($resolution eq 'use_found') { + $newCODE=$ENV{'form.scantron_CODE_selectedvalue'}; + } elsif ($resolution eq 'use_typed') { + $newCODE=$ENV{'form.scantron_CODE_newvalue'}; + } ($line,$err,$errmsg)= &scantron_fixup_scanline(\%scantron_config,$scan_data,$line,$which, 'CODE',{'CODE'=>$newCODE}); @@ -3826,6 +3879,8 @@ sub scantron_validate_file { if ($ENV{'form.scantron_corrections'}) { &scantron_process_corrections($r); } + $r->print("

Gathering neccessary info.

");$r->rflush(); + my $max_bubble=&scantron_get_maxbubble($r); #get the student pick code ready $r->print(&Apache::loncommon::studentbrowser_javascript()); my $result= < - + + + + + $default_form_data SCANTRONFORM $r->print($result); @@ -4061,18 +4120,42 @@ sub scantron_get_correction { $r->print(''); } elsif ($error =~ /CODE$/) { if ($error eq 'incorrectCODE') { - $r->print("The encoded CODE is not in the list of possible CODEs

\n"); + $r->print("

The encoded CODE is not in the list of possible CODEs

\n"); } elsif ($error eq 'duplicateCODE') { - $r->print("The encoded CODE has also been used by a previous paper $arg, and CODEs were supposed to be unique

\n"); + $r->print("

The encoded CODE has also been used by a previous paper $arg, and CODEs were supposed to be unique

\n"); } + $r->print("

The CODE on the form is ". + $$scan_record{'scantron.CODE'}."
\n"); $r->print("

The ID on the form is ". $$scan_record{'scantron.ID'}."
\n"); $r->print("The name on the paper is ". $$scan_record{'scantron.LastName'}.",". $$scan_record{'scantron.FirstName'}."

"); $r->print("

How should I handle this?
\n"); - $r->print("\n

  • "); - $r->print('
  • '); + $r->print("\n
    "); + $r->print(" Use the CODE ".$$scan_record{'scantron.CODE'}." that is was on the paper, ignoring the error."); + $r->print("\n
    "); + $r->print(< +function change_radio(field) { + var slct=document.scantronupload.scantron_CODE_resolution; + var i; + for (i=0;i +ENDSCRIPT + my $href="/adm/pickcode?". + "form=".&Apache::lonnet::escape("scantronupload"). + "&scantron_format=".&Apache::lonnet::escape($ENV{'form.scantron_format'}). + "&scantron_CODElist=".&Apache::lonnet::escape($ENV{'form.scantron_CODElist'}). + "&curCODE=".&Apache::lonnet::escape($$scan_record{'scantron.CODE'}). + "&scantron_selectfile=".&Apache::lonnet::escape($ENV{'form.scantron_selectfile'}); + $r->print(" Select a CODE from the list of all CODEs and use it. Selected CODE is "); + $r->print("\n
    "); + $r->print(" Use as the CODE."); + $r->print("\n

    "); } elsif ($error eq 'doublebubble') { #FIXME Need to print out who this is along with the paper info $r->print("

    There have been multiple bubbles scanned for a some question(s)

    \n"); @@ -4128,11 +4211,10 @@ sub scantron_validate_CODE { if ($scantron_config{'CODElocation'} && $scantron_config{'CODEstart'} && $scantron_config{'CODElength'}) { - if (!$ENV{'form.scantron_CODElist'}) { + if (!defined($ENV{'form.scantron_CODElist'})) { &FIXME_blow_up() } } else { - &Apache::lonnet::logthis(" CODE stuf $scantron_config{'CODElocation'}:$scantron_config{'CODEstart'}:$scantron_config{'CODElength'}"); return (0,$currentphase+1); } @@ -4142,7 +4224,7 @@ sub scantron_validate_CODE { my $cdom =$ENV{'course.'.$ENV{'request.course.id'}.'.domain'}; my $cnum =$ENV{'course.'.$ENV{'request.course.id'}.'.num'}; my %result=&Apache::lonnet::get('CODEs',[$old_name],$cdom,$cnum); - my %allcodes=map {($_,1)} split(',',$result{$old_name}); + my %allcodes=map {(&Apache::lonprintout::num_to_letters($_),1)} split(',',$result{$old_name}); my ($scanlines,$scan_data)=&scantron_getfile(); for (my $i=0;$i<=$scanlines->{'count'};$i++) { @@ -4152,7 +4234,7 @@ sub scantron_validate_CODE { $scan_data); my $CODE=$$scan_record{'scantron.CODE'}; my $error=0; - if (!exists($allcodes{$CODE})) { + if (!exists($allcodes{$CODE}) && !$$scan_record{'scantron.useCODE'}) { &scantron_get_correction($r,$i,$scan_record, \%scantron_config, $line,'incorrectCODE',$CODE); @@ -4192,6 +4274,31 @@ sub scantron_validate_doublebubble { return (0,$currentphase+1); } +sub scantron_get_maxbubble { + my ($r)=@_; + if (defined($ENV{'form.scantron_maxbubble'}) && + $ENV{'form.scantron_maxbubble'}) { + return $ENV{'form.scantron_maxbubble'}; + } + my $navmap=Apache::lonnavmaps::navmap->new(); + my (undef,undef,$sequence)= + &Apache::lonnet::decode_symb($ENV{'form.selectpage'}); + my $map=$navmap->getResourceByUrl($sequence); + my @resources=$navmap->retrieveResources($map,\&scantron_filter,1,0); + &Apache::lonnet::delenv('form.counter'); + foreach my $resource (@resources) { + my $result=&Apache::lonnet::ssi($resource->src()); + } + &Apache::lonnet::delenv('scantron\.'); + my $envfile=$ENV{'user.environment'}; + $envfile=~/\/([^\/]+)\.id$/; + $envfile=$1; + &Apache::lonnet::transfer_profile_to_env($r->dir_config('lonIDsDir'), + $envfile); + $ENV{'form.scantron_maxbubble'}=$ENV{'form.counter'}-1; + return $ENV{'form.scantron_maxbubble'}; +} + sub scantron_validate_missingbubbles { my ($r,$currentphase) = @_; #get student info @@ -4201,7 +4308,7 @@ sub scantron_validate_missingbubbles { #get scantron line setup my %scantron_config=&get_scantron_config($ENV{'form.scantron_format'}); my ($scanlines,$scan_data)=&scantron_getfile(); - my $max_bubble=$ENV{'form.scantron_maxbubble'}; + my $max_bubble=&scantron_get_maxbubble(); if (!$max_bubble) { $max_bubble=2**31; } for (my $i=0;$i<=$scanlines->{'count'};$i++) { my $line=&scantron_get_line($scanlines,$i);
Each CODE is only to be used once: $CODE_unique
Options: - - Last line to expect an answer on: - + Redo skipped records
+ Ignore Original Corrections
+ + + + + + + + + + + + + + + + +
+  Download a scoring office file +
Filename of scoring office file: $file_selector
+ Records to download + + Skipped Records
+ Corrected Records
+ Original Records +
+ +
+ +