--- loncom/homework/grades.pm 2004/04/29 04:47:47 1.191 +++ loncom/homework/grades.pm 2004/05/07 17:40:51 1.198 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # The LON-CAPA Grading handler # -# $Id: grades.pm,v 1.191 2004/04/29 04:47:47 albertel Exp $ +# $Id: grades.pm,v 1.198 2004/05/07 17:40:51 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -2049,11 +2049,11 @@ sub saveHandGrade { } } elsif ($dropMenu eq 'reset status' && exists($record{'resource.'.$_.'.solved'})) { #don't bother if no old records -> no attempts - $newrecord{'resource.'.$_.'.tries'} = 0; - $newrecord{'resource.'.$_.'.solved'} = ''; - $newrecord{'resource.'.$_.'.award'} = ''; - $newrecord{'resource.'.$_.'.awarded'} = 0; - $newrecord{'resource.'.$_.'.regrader'}="$ENV{'user.name'}:$ENV{'user.domain'}"; + foreach my $key (keys (%record)) { + if ($key=~/^resource\.\Q$_\E\./) { $newrecord{$key} = ''; } + } + $newrecord{'resource.'.$_.'.regrader'}= + "$ENV{'user.name'}:$ENV{'user.domain'}"; } elsif ($dropMenu eq '') { $pts = ($ENV{'form.GD_BOX'.$newflg.'_'.$_} ne '' ? $ENV{'form.GD_BOX'.$newflg.'_'.$_} : @@ -3108,7 +3108,7 @@ sub displayPage { '
Validating ".$validate_phases[$currentphase]."
"); @@ -3939,6 +3954,32 @@ SCANTRONFORM return ''; } +sub scantron_remove { + my ($which)=@_; + my $cname=$ENV{'course.'.$ENV{'request.course.id'}.'.num'}; + my $cdom=$ENV{'course.'.$ENV{'request.course.id'}.'.domain'}; + my $file='scantron_'; + if ($which eq 'corrected') { + $file.='corrected_'; + } else { + return 'refused'; + } + $file.=$ENV{'form.scantron_selectfile'}; + my $result=&Apache::lonnet::removeuserfile($cname,$cdom,$file); + my @keys=&Apache::lonnet::getkeys('nohist_scantrondata',$cdom,$cname); + my @todelete; + my $filename=$ENV{'form.scantron_selectfile'}; + foreach my $key (@keys) { + if ($key=~/^\Q$filename\E_/) { + push(@todelete,$key); + } + } + if (@todelete) { + &Apache::lonnet::del('nohist_scantrondata',\@todelete,$cdom,$cname); + } + return $result; +} + sub scantron_getfile { #FIXME really would prefer a scantron directory but tokenwrapper # doesn't allow access to subdirs of userfiles @@ -4044,11 +4085,11 @@ sub scantron_validate_ID { if ($found{'ids'}{$found}) { &scantron_get_correction($r,$i,$scan_record,\%scantron_config, $line,'duplicateID',$found); - return(1); + return(1,$currentphase); } elsif ($found{'usernames'}{$username}) { &scantron_get_correction($r,$i,$scan_record,\%scantron_config, $line,'duplicateID',$username); - return(1); + return(1,$currentphase); } #FIXME store away line we previously saw the ID on to use above $found{'ids'}{$found}++; @@ -4060,18 +4101,18 @@ sub scantron_validate_ID { &scantron_get_correction($r,$i,$scan_record, \%scantron_config, $line,'duplicateID',$username); - return(1); + return(1,$currentphase); } elsif (!defined($username)) { &scantron_get_correction($r,$i,$scan_record, \%scantron_config, $line,'incorrectID'); - return(1); + return(1,$currentphase); } $found{'usernames'}{$username}++; } else { &scantron_get_correction($r,$i,$scan_record,\%scantron_config, $line,'incorrectID'); - return(1); + return(1,$currentphase); } } } @@ -4122,7 +4163,7 @@ sub scantron_get_correction { if ($error eq 'incorrectCODE') { $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 ".join(', ',@{$arg}).", and CODEs are supposed to be unique
\n"); } $r->print("The CODE on the form is ".
$$scan_record{'scantron.CODE'}."
\n");
@@ -4133,8 +4174,21 @@ sub scantron_get_correction {
$$scan_record{'scantron.FirstName'}."
How should I handle this? There have been multiple bubbles scanned for a some question(s)
\n");
$r->print("\n
");
- $r->print(" Use the CODE ".$$scan_record{'scantron.CODE'}." that is was on the paper, ignoring the error.");
+ my $i=0;
+ if ($error eq 'incorrectCODE') {
+ my ($max,$closest)=&scantron_get_closely_matching_CODEs($arg,$$scan_record{'scantron.CODE'});
+ foreach my $testcode (@{$closest}) {
+ my $checked='';
+ if (!$i) { $checked=' checked="on" '; }
+ $r->print(" Use the similar CODE ".$testcode." instead.");
+ $r->print("\n
");
+ $i++;
+ }
+ }
+ my $checked; if (!$i) { $checked=' checked="on" '; }
+ $r->print(" Use the CODE ".$$scan_record{'scantron.CODE'}." that is was on the paper, ignoring the error.");
$r->print("\n
");
+
$r->print(<
");
} elsif ($error eq 'doublebubble') {
-#FIXME Need to print out who this is along with the paper info
$r->print("