--- loncom/homework/grades.pm 2004/03/31 05:23:59 1.185
+++ loncom/homework/grades.pm 2004/04/20 06:11:49 1.186
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# The LON-CAPA Grading handler
#
-# $Id: grades.pm,v 1.185 2004/03/31 05:23:59 albertel Exp $
+# $Id: grades.pm,v 1.186 2004/04/20 06:11:49 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -3445,6 +3445,30 @@ sub scantron_scantab {
return $result;
}
+sub scantron_CODElist {
+ my $cdom = $ENV{'course.'.$ENV{'request.course.id'}.'.domain'};
+ my $cnum = $ENV{'course.'.$ENV{'request.course.id'}.'.num'};
+ my @names=&Apache::lonnet::getkeys('CODEs',$cdom,$cnum);
+ my $namechoice='';
+ foreach my $name (@names) {
+ $namechoice.='';
+ }
+ $namechoice='';
+ return $namechoice;
+}
+
+sub scantron_CODEunique {
+ my $result='
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'}."
How should I handle this?
\n");
+ $r->print("\n
There have been multiple bubbles scanned for a some question(s)
\n"); @@ -4060,6 +4124,48 @@ sub scantron_bubble_selector { sub scantron_validate_CODE { my ($r,$currentphase) = @_; #FIXME doesn't do anything yet + my %scantron_config=&get_scantron_config($ENV{'form.scantron_format'}); + if ($scantron_config{'CODElocation'} && + $scantron_config{'CODEstart'} && + $scantron_config{'CODElength'}) { + if (!$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); + } + + my %usedCODEs; + + my $old_name=$ENV{'form.scantron_CODElist'}; + 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 ($scanlines,$scan_data)=&scantron_getfile(); + for (my $i=0;$i<=$scanlines->{'count'};$i++) { + my $line=&scantron_get_line($scanlines,$i); + if ($line=~/^[\s\cz]*$/) { next; } + my $scan_record=&scantron_parse_scanline($line,$i,\%scantron_config, + $scan_data); + my $CODE=$$scan_record{'scantron.CODE'}; + my $error=0; + if (!exists($allcodes{$CODE})) { + &scantron_get_correction($r,$i,$scan_record, + \%scantron_config, + $line,'incorrectCODE',$CODE); + return(1); + } + if (exists($usedCODEs{$CODE}) && $ENV{'form.scantron_CODEunique'}) { + &scantron_get_correction($r,$i,$scan_record, + \%scantron_config, + $line,'duplicateCODE',$CODE); + return(1); + } + $usedCODEs{$CODE}++; + } return (0,$currentphase+1); }