--- loncom/homework/grades.pm	2004/05/14 19:15:49	1.200
+++ loncom/homework/grades.pm	2004/08/06 22:06:14	1.207
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # The LON-CAPA Grading handler
 #
-# $Id: grades.pm,v 1.200 2004/05/14 19:15:49 albertel Exp $
+# $Id: grades.pm,v 1.207 2004/08/06 22:06:14 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -167,6 +167,21 @@ sub response_type {
     return \@partlist,\%handgrade,\%responseType;
 }
 
+sub get_display_part {
+    my ($partID,$url,$symb)=@_;
+    if (!defined($symb) || $symb eq '') {
+	$symb=$ENV{'form.symb'};
+	if ($symb eq '') { $symb=&Apache::lonnet::symbread($url) }
+    }
+    my $display=&Apache::lonnet::EXT('resource.'.$partID.'.display',$symb);
+    &Apache::lonnet::logthis("\nsymb $symb\n url  $url\npartID $partID\ndisplay $display \n");
+    if (defined($display) and $display ne '') {
+	$display.= " (<font color=\"#999900\">id $partID</font>)";
+    } else {
+	$display=$partID;
+    }
+    return $display;
+}
 #--- Show resource title
 #--- and parts and response type
 sub showResourceInfo {
@@ -194,7 +209,8 @@ sub showResourceInfo {
 	    }
 	    $partsseen{$partID}=1;
 	}
-	$result.='<td><b>Part </b>'.$partID.' <font color="#999999">'.
+	my $display_part=&get_display_part($partID,$url);
+	$result.='<td><b>Part: </b>'.$display_part.' <font color="#999999">'.
 	    $resID.'</font></td>'.
 	    '<td><b>Type: </b>'.$responsetype.'</td></tr>';
 #	    '<td><b>Handgrade: </b>'.$handgrade.'</td></tr>';
@@ -349,27 +365,36 @@ sub getclasslist {
     #
     my %sections;
     my %fullnames;
-    foreach (keys(%$classlist)) {
-        # the following undefs are for 'domain', and 'username' respectively.
-	my (undef,undef,$end,$start,$id,$section,$fullname,$status)=
-            @{$classlist->{$_}};
+    foreach my $student (keys(%$classlist)) {
+        my $end      = 
+            $classlist->{$student}->[&Apache::loncoursedata::CL_END()];
+        my $start    = 
+            $classlist->{$student}->[&Apache::loncoursedata::CL_START()];
+        my $id       = 
+            $classlist->{$student}->[&Apache::loncoursedata::CL_ID()];
+        my $section  = 
+            $classlist->{$student}->[&Apache::loncoursedata::CL_SECTION()];
+        my $fullname = 
+            $classlist->{$student}->[&Apache::loncoursedata::CL_FULLNAME()];
+        my $status   = 
+            $classlist->{$student}->[&Apache::loncoursedata::CL_STATUS()];
 	# filter students according to status selected
 	if ($filterlist && $ENV{'form.Status'} ne 'Any') {
 	    if ($ENV{'form.Status'} ne $status) {
-		delete ($classlist->{$_});
+		delete ($classlist->{$student});
 		next;
 	    }
 	}
-	$section = ($section ne '' ? $section : 'no');
+	$section = ($section ne '' ? $section : 'none');
 	if (&canview($section)) {
 	    if ($getsec eq 'all' || $getsec eq $section) {
 		$sections{$section}++;
-		$fullnames{$_}=$fullname;
+		$fullnames{$student}=$fullname;
 	    } else {
-		delete($classlist->{$_});
+		delete($classlist->{$student});
 	    }
 	} else {
-	    delete($classlist->{$_});
+	    delete($classlist->{$student});
 	}
     }
     my %seen = ();
@@ -682,7 +707,9 @@ LISTJAVASCRIPT
 	    '<td>'.&nameUserString('header').'</td>';
 	if ($ENV{'form.showgrading'} eq 'yes' && $submitonly ne 'all') {
 	    foreach (sort(@$partlist)) {
-		$gradeTable.='<td><b>&nbsp;Part '.(split(/_/))[0].' Status&nbsp;</b></td>';
+		my $display_part=&get_display_part((split(/_/))[0],$url,$symb);
+		$gradeTable.='<td><b>&nbsp;Part: '.$display_part.
+		    ' Status&nbsp;</b></td>';
 	    }
 	}
 	$loop++;
@@ -1084,7 +1111,7 @@ sub sub_page_kw_js {
     var ypos = (screen.height-height)/2-30;
     ypos = (ypos < 0) ? '0' : ypos;
 
-    pWin = window.open('', 'MessageCenter', 'toolbar=no,location=no,scrollbars='+scrollbar+',screenx='+xpos+',screeny='+ypos+',width=600,height='+height);
+    pWin = window.open('', 'MessageCenter', 'resizable=yes,toolbar=no,location=no,scrollbars='+scrollbar+',screenx='+xpos+',screeny='+ypos+',width=600,height='+height);
     pWin.focus();
     pDoc = pWin.document;
     pDoc.open('text/html','replace');
@@ -1215,7 +1242,7 @@ sub sub_page_kw_js {
     var ypos = (screen.height-330)/2-30;
     ypos = (ypos < 0) ? '0' : ypos;
 
-    hwdWin = window.open('', 'KeywordHighlightCentral', 'toolbar=no,location=no,scrollbars=no,width=400,height=300,screenx='+xpos+',screeny='+ypos);
+    hwdWin = window.open('', 'KeywordHighlightCentral', 'resizeable=yes,toolbar=no,location=no,scrollbars=no,width=400,height=300,screenx='+xpos+',screeny='+ypos);
     hwdWin.focus();
     var hDoc = hwdWin.document;
     hDoc.open('text/html','replace');
@@ -1289,8 +1316,9 @@ sub gradeBox {
 		  '' : $$record{'resource.'.$partid.'.awarded'}*$wgt);
     my $result='<input type="hidden" name="WGT'.$counter.'_'.$partid.'" value="'.$wgt.'" />'."\n";
 
+    my $display_part=&get_display_part($partid,undef,$symb);
     $result.='<table border="0"><tr><td>'.
-	'<b>Part </b>'.$partid.' <b>Points: </b></td><td>'."\n";
+	'<b>Part: </b>'.$display_part.' <b>Points: </b></td><td>'."\n";
 
     my $ctr = 0;
     $result.='<table border="0"><tr>'."\n";  # display radio buttons in a nice table 10 across
@@ -1622,11 +1650,12 @@ KEYWORDS
 	    my %seenparts;
 	    for my $part (sort keys(%$handgrade)) {
 		my ($partid,$respid) = split(/_/,$part);
+		my $display_part=&get_display_part($partid,$url,$symb);
 		if ($ENV{"form.$uname:$udom:$partid:submitted_by"}) {
 		    if (exists($seenparts{$partid})) { next; }
 		    $seenparts{$partid}=1;
-		    my $submitby='<b>Part '.$partid.
-			' Collaborative submission by: </b>'.
+		    my $submitby='<b>Part:</b> '.$display_part.
+			' <b>Collaborative submission by:</b> '.
 			'<a href="javascript:viewSubmitter(\''.
 			$ENV{"form.$uname:$udom:$partid:submitted_by"}.
 			'\')"; TARGET=_self>'.
@@ -1636,8 +1665,8 @@ KEYWORDS
 		}
 		my $responsetype = $responseType->{$partid}->{$respid};
 		if (!exists($record{"resource.$partid.$respid.submission"})) {
-		    $lastsubonly.='<tr><td bgcolor="#ffffe6"><b>Part '.
-			$partid.'</b> <font color="#999999">( ID '.$respid.
+		    $lastsubonly.='<tr><td bgcolor="#ffffe6"><b>Part:</b> '.
+			$display_part.' <font color="#999999">( ID '.$respid.
 			' )</font>&nbsp; &nbsp;'.
 			'<font color="red">Nothing submitted - no attempts</font><br /><br />';
 		    next;
@@ -1665,8 +1694,9 @@ KEYWORDS
 		    if ($ENV{'form.lastSub'} eq 'lastonly' || 
 			($ENV{'form.lastSub'} eq 'hdgrade' && 
 			 $$handgrade{$part} eq 'yes')) {
-			$lastsubonly.='<tr><td bgcolor="#ffffe6"><b>Part '.
-			    $partid.'</b> <font color="#999999">( ID '.$respid.
+			my $display_part=&get_display_part($partid,$url,$symb);
+			$lastsubonly.='<tr><td bgcolor="#ffffe6"><b>Part:</b> '.
+			    $display_part.' <font color="#999999">( ID '.$respid.
 			    ' )</font>&nbsp; &nbsp;';
 			if ($record{"resource.$partid.$respid.uploadedurl"}) {
 			    &Apache::lonnet::allowuploaded('/adm/grades',
@@ -2299,7 +2329,7 @@ sub viewgrades {
     my $sectionClass;
     if ($ENV{'form.section'} eq 'all') {
 	$sectionClass='Class </h3>';
-    } elsif ($ENV{'form.section'} eq 'no') {
+    } elsif ($ENV{'form.section'} eq 'none') {
 	$sectionClass='Students in no Section </h3>';
     } else {
 	$sectionClass='Students in Section '.$ENV{'form.section'}.'</h3>';
@@ -2326,7 +2356,8 @@ sub viewgrades {
 	    $ctsparts.'" value="'.$partid.'" />'."\n";
 	$result.='<input type="hidden" name="weight_'.
 	    $partid.'" value="'.$weight{$partid}.'" />'."\n";
-	$result.='<tr><td><b>Part  '.$partid.'&nbsp; &nbsp;Point:</b> </td><td>';
+	my $display_part=&get_display_part($partid,$url,$symb);
+	$result.='<tr><td><b>Part:</b> '.$display_part.'&nbsp; &nbsp;<b>Point:</b> </td><td>';
 	$result.='<table border="0"><tr>';  
 	my $ctr = 0;
 	while ($ctr<=$weight{$partid}) { # display radio buttons in a nice table 10 across
@@ -2365,14 +2396,17 @@ sub viewgrades {
 	my $display=&Apache::lonnet::metadata($url,$part.'.display');
 	$display =~ s|^Number of Attempts|Tries<br />|; # makes the column narrower
 	if  (!$display) { $display = &Apache::lonnet::metadata($url,$part.'.name'); }
+	my ($partid) = &split_part_type($part);
+	my $display_part=&get_display_part($partid,$url,$symb);
 	if ($display =~ /^Partial Credit Factor/) {
-	    my ($partid) = &split_part_type($part);
-	    $result.='<td><b>Score Part '.$partid.'<br />(weight = '.
-		$weight{$partid}.')</b></td>'."\n";
+	    $result.='<td><b>Score Part:</b> '.$display_part.
+		' <br /><b>(weight = '.$weight{$partid}.')</b></td>'."\n";
 	    next;
+	} else {
+	    $display =~s/\[Part: \Q$partid\E\]/Part:<\/b> $display_part/;
 	}
 	$display =~ s|Problem Status|Grade Status<br />|;
-	$result.='<td><b>'.$display.'</b></td>'."\n";
+	$result.='<td><b>'.$display.'</td>'."\n";
     }
     $result.='</tr>';
 
@@ -2502,9 +2536,10 @@ sub editgrades {
 	}
     }
     foreach my $partid (@partid) {
+	my $display_part=&get_display_part($partid,$url,$symb);
 	$result .= '<td colspan="'.$columns{$partid}.
-	    '" align="center"><b>Part '.$partid.
-	    '</b> (Weight = '.$weight{$partid}.')</td>';
+	    '" align="center"><b>Part:</b> '.$display_part.
+	    ' (Weight = '.$weight{$partid}.')</td>';
 
     }
     $result .= '</tr><tr bgcolor="#deffff">';
@@ -2598,7 +2633,7 @@ sub editgrades {
     if ($noupdate) {
 #	my $numcols=(scalar(@partid)*(scalar(@parts)-1)*2)+3;
 	my $numcols=scalar(@partid)*4+2;
-	$result .= '<tr bgcolor="#ffffff"><td align="center" colspan="'.$numcols.'">No Changes Occurred For the Students Below</td></tr>'.$noupdate;
+	$result .= '<tr bgcolor="#ffffff"><td align="center" colspan="'.$numcols.'">No Changes Occurred For the Students Below</td></tr><tr bgcolor="#ffffde">'.$noupdate;
     }
     $result .= '</table></td></tr></table>'."\n".
 	&show_grading_menu_form ($symb,$url);
@@ -3213,13 +3248,14 @@ sub displaySubByDates {
 	foreach my $partid (@{$parts}) {
 	    my @matchKey = sort(grep /^resource\.\Q$partid\E\..*?\.submission$/,@versionKeys);
 #	    next if ($$record{"$version:resource.$partid.solved"} eq '');
+	    my $display_part=&get_display_part($partid,undef,$symb);
 	    foreach my $matchKey (@matchKey) {
 		if (exists($$record{$version.':'.$matchKey}) &&
 		    $$record{$version.':'.$matchKey} ne '') {
 		    my ($responseId)=($matchKey=~ /^resource\.\Q$partid\E\.(.*?)\.submission$/);
-		    $displaySub[0].='<b>Part&nbsp;'.$partid.'&nbsp;';
+		    $displaySub[0].='<b>Part:</b>&nbsp;'.$display_part.'&nbsp;';
 		    $displaySub[0].='<font color="#999999">(ID&nbsp;'.
-			$responseId.')</font>&nbsp;';
+			$responseId.')</font>&nbsp;<b>';
 		    if ($$record{"$version:resource.$partid.tries"} eq '') {
 			$displaySub[0].='Trial&nbsp;not&nbsp;counted';
 		    } else {
@@ -3237,14 +3273,14 @@ sub displaySubByDates {
 		}
 	    }
 	    if (exists $$record{"$version:resource.$partid.award"}) {
-		$displaySub[1].='<b>Part&nbsp;'.$partid.'</b> &nbsp;'.
+		$displaySub[1].='<b>Part:</b>&nbsp;'.$display_part.' &nbsp;'.
 		    lc($$record{"$version:resource.$partid.award"}).' '.
 		    $mark{$$record{"$version:resource.$partid.solved"}}.
 		    '<br />';
 	    }
 	    if (exists $$record{"$version:resource.$partid.regrader"}) {
 		$displaySub[2].=$$record{"$version:resource.$partid.regrader"}.
-		    ' (<b>'.&mt('Part').':</b> '.$partid.')';
+		    ' (<b>'.&mt('Part').':</b> '.$display_part.')';
 	    }
 	}
 	# needed because old essay regrader has not parts info
@@ -3341,12 +3377,13 @@ sub updateGradeByPage {
 		    $changeflag++;
 		    $newpts = '';
 		}
-
+		my $display_part=&get_display_part($partid,undef,
+						   $curRes->symb());
 		my $oldstatus = $ENV{'form.solved'.$question.'_'.$partid};
-		$displayPts[0].='&nbsp;<b>Part</b> '.$partid.' = '.
+		$displayPts[0].='&nbsp;<b>Part:</b> '.$display_part.' = '.
 		    (($oldstatus eq 'excused') ? 'excused' : $oldpts).
 		    '&nbsp;<br>';
-		$displayPts[1].='&nbsp;<b>Part</b> '.$partid.' = '.
+		$displayPts[1].='&nbsp;<b>Part:</b> '.$display_part.' = '.
 		     (($score eq 'excused') ? 'excused' : $newpts).
 		    '&nbsp;<br>';
 
@@ -3420,18 +3457,25 @@ sub getSequenceDropDown {
     return $result;
 }
 
-sub scantron_uploads {
-    if (!-e $Apache::lonnet::perlvar{'lonScansDir'}) { return ''};
-    my $result=	'<select name="scantron_selectfile">';
+sub scantron_filenames {
     my $cdom=$ENV{'course.'.$ENV{'request.course.id'}.'.domain'};
     my $cname=$ENV{'course.'.$ENV{'request.course.id'}.'.num'};
     my @files=&Apache::lonnet::dirlist('userfiles',$cdom,$cname,
 				    &Apache::loncommon::propath($cdom,$cname));
-    $result.="<option></option>";
-    foreach my $filename (@files) {
+    my @possiblenames;
+    foreach my $filename (sort(@files)) {
 	($filename)=split(/&/,$filename);
 	if ($filename!~/^scantron_orig_/) { next ; }
 	$filename=~s/^scantron_orig_//;
+	push(@possiblenames,$filename);
+    }
+    return @possiblenames;
+}
+
+sub scantron_uploads {
+    my $result=	'<select name="scantron_selectfile">';
+    $result.="<option></option>";
+    foreach my $filename (sort(&scantron_filenames())) {
 	$result.="<option>$filename</option>\n";
     }
     $result.="</select>";
@@ -3457,7 +3501,7 @@ sub scantron_CODElist {
     my $cnum = $ENV{'course.'.$ENV{'request.course.id'}.'.num'};
     my @names=&Apache::lonnet::getkeys('CODEs',$cdom,$cnum);
     my $namechoice='<option></option>';
-    foreach my $name (@names) {
+    foreach my $name (sort(@names)) {
 	if ($name =~ /^error: 2 /) { next; }
 	$namechoice.='<option value="'.$name.'">'.$name.'</option>';
     }
@@ -3496,7 +3540,7 @@ sub scantron_selectphase {
     <tr>
       <td bgcolor="#777777">
        <form method="post" enctype="multipart/form-data" action="/adm/grades" name="scantron_process">
-       <input type="hidden" name="command" value="scantron_validate" />
+       <input type="hidden" name="command" value="scantron_warning" />
         $default_form_data
         <table width="100%" border="0">
           <tr bgcolor="#e6ffff">
@@ -3602,18 +3646,8 @@ SCANTRONFORM
               <td> Filename of scoring office file: </td><td> $file_selector </td>
             </tr>
             <tr bgcolor="#ffffe6">
-	      <td>
-                Records to download
-              </td>
-              <td>
-                  <input type="radio" name="scantron_options" value="download_skipped"/> Skipped Records <br />
-                  <input type="radio" name="scantron_options" value="download_corrected"/> Corrected Records <br />
-                  <input checked="on" type="radio" name="scantron_options" value="dowload_orig"/> Original Records
-              </td>
-            </tr>
-            <tr bgcolor="#ffffe6">
               <td colspan="2">
-                <input type="submit" value="Validate Scantron Records" />
+                <input type="submit" value="Show List of Files" />
               </td>
             </tr>
           </table>
@@ -3928,6 +3962,60 @@ sub check_for_error {
     }
 }
 
+sub scantron_warning_screen {
+    my ($button_text)=@_;
+    my $title=&Apache::lonnet::gettitle($ENV{'form.selectpage'});
+    return (<<STUFF);
+<p>
+<font color="red">Please double check the information
+                 below before clicking on '$button_text'</font>
+</p>
+<table>
+<tr><td><b>Sequence To be Graded:</b></td><td>$title</td></tr>
+<tr><td><b>Data File that will be used:</b></td><td><tt>$ENV{'form.scantron_selectfile'}</tt></td></tr>
+</table>
+</font>
+<br />
+<p> If this information is correct, please click on '$button_text'.</p>
+<p> If something is incorrect, please click the 'Grading Menu' button to start over.</p>
+
+<br />
+STUFF
+}
+
+sub scantron_do_warning {
+    my ($r)=@_;
+    my ($symb,$url)=&get_symb_and_url($r);
+    if (!$symb) {return '';}
+    my $default_form_data=&defaultFormData($symb,$url);
+    $r->print(&scantron_form_start().$default_form_data);
+    my $warning=&scantron_warning_screen('Validate Records');
+    $r->print(<<STUFF);
+$warning
+<input type="submit" name="submit" value="Validate Records" />
+<input type="hidden" name="command" value="scantron_validate" />
+</form>
+STUFF
+    $r->print("<br />".&show_grading_menu_form($symb,$url)."</body></html>");
+    return '';
+}
+
+sub scantron_form_start {
+    my ($max_bubble)=@_;
+    my $result= <<SCANTRONFORM;
+<form method="post" enctype="multipart/form-data" action="/adm/grades" name="scantronupload">
+  <input type="hidden" name="selectpage" value="$ENV{'form.selectpage'}" />
+  <input type="hidden" name="scantron_format" value="$ENV{'form.scantron_format'}" />
+  <input type="hidden" name="scantron_selectfile" value="$ENV{'form.scantron_selectfile'}" />
+  <input type="hidden" name="scantron_maxbubble" value="$max_bubble'" />
+  <input type="hidden" name="scantron_CODElist" value="$ENV{'form.scantron_CODElist'}" />
+  <input type="hidden" name="scantron_CODEunique" value="$ENV{'form.scantron_CODEunique'}" />
+  <input type="hidden" name="scantron_options_redo" value="$ENV{'form.scantron_options_redo'}" />
+  <input type="hidden" name="scantron_options_ignore" value="$ENV{'form.scantron_options_ignore'}" />
+SCANTRONFORM
+    return $result;
+}
+
 sub scantron_validate_file {
     my ($r) = @_;
     my ($symb,$url)=&get_symb_and_url($r);
@@ -3956,21 +4044,10 @@ sub scantron_validate_file {
 	&scantron_process_corrections($r);
     }
     $r->print("<p>Gathering neccessary info.</p>");$r->rflush();
-    my $max_bubble=&scantron_get_maxbubble($r);
     #get the student pick code ready
     $r->print(&Apache::loncommon::studentbrowser_javascript());
-    my $result= <<SCANTRONFORM;
-<form method="post" enctype="multipart/form-data" action="/adm/grades" name="scantronupload">
-  <input type="hidden" name="selectpage" value="$ENV{'form.selectpage'}" />
-  <input type="hidden" name="scantron_format" value="$ENV{'form.scantron_format'}" />
-  <input type="hidden" name="scantron_selectfile" value="$ENV{'form.scantron_selectfile'}" />
-  <input type="hidden" name="scantron_maxbubble" value="$max_bubble'" />
-  <input type="hidden" name="scantron_CODElist" value="$ENV{'form.scantron_CODElist'}" />
-  <input type="hidden" name="scantron_CODEunique" value="$ENV{'form.scantron_CODEunique'}" />
-  <input type="hidden" name="scantron_options_redo" value="$ENV{'form.scantron_options_redo'}" />
-  <input type="hidden" name="scantron_options_ignore" value="$ENV{'form.scantron_options_ignore'}" />
-  $default_form_data
-SCANTRONFORM
+    my $max_bubble=&scantron_get_maxbubble($r);
+    my $result=&scantron_form_start($max_bubble).$default_form_data;
     $r->print($result);
     
     my @validate_phases=( 'ID',
@@ -3993,9 +4070,14 @@ SCANTRONFORM
 	}
     }
     if (!$stop) {
-	$r->print("Validation process complete.<br />");
-	$r->print('<input type="submit" name="submit" value="Start Grading" />');
-	$r->print('<input type="hidden" name="command" value="scantron_process" />');
+	my $warning=&scantron_warning_screen('Start Grading');
+	$r->print(<<STUFF);
+Validation process complete.<br />
+$warning
+<input type="submit" name="submit" value="Start Grading" />
+<input type="hidden" name="command" value="scantron_process" />
+STUFF
+
     } else {
 	$r->print('<input type="hidden" name="command" value="scantron_validate" />');
 	$r->print("<input type='hidden' name='validatepass' value='".$currentphase."' />");
@@ -4673,6 +4755,50 @@ sub scantron_upload_scantron_data_save {
     return '';
 }
 
+sub valid_file {
+    my ($requested_file)=@_;
+    foreach my $filename (sort(&scantron_filenames())) {
+	&Apache::lonnet::logthis("$requested_file  $filename");
+	if ($requested_file eq $filename) { return 1; }
+    }
+    return 0;
+}
+
+sub scantron_download_scantron_data {
+    my ($r)=@_;
+    my $default_form_data=&defaultFormData(&get_symb_and_url($r,1));
+    my $cname=$ENV{'course.'.$ENV{'request.course.id'}.'.num'};
+    my $cdom=$ENV{'course.'.$ENV{'request.course.id'}.'.domain'};
+    my $file=$ENV{'form.scantron_selectfile'};
+    if (! &valid_file($file)) {
+	$r->print(<<ERROR);
+	<p>
+	    The requested file name was invalid.
+        </p>
+ERROR
+	$r->print(&show_grading_menu_form(&get_symb_and_url($r,1)));
+	return;
+    }
+    my $orig='/uploaded/'.$cdom.'/'.$cname.'/scantron_orig_'.$file;
+    my $corrected='/uploaded/'.$cdom.'/'.$cname.'/scantron_corrected_'.$file;
+    my $skipped='/uploaded/'.$cdom.'/'.$cname.'/scantron_skipped_'.$file;
+    &Apache::lonnet::allowuploaded('/adm/grades',$orig);
+    &Apache::lonnet::allowuploaded('/adm/grades',$corrected);
+    &Apache::lonnet::allowuploaded('/adm/grades',$skipped);
+    $r->print(<<DOWNLOAD);
+    <p>
+	<a href="$orig">Original</a> file as uploaded by the scantron office.
+    </p>
+    <p>
+	<a href="$corrected">Corrections</a>, a file of corrected records that were used in grading.
+    </p>
+    <p>
+	<a href="$skipped">Skipped</a>, a file of records that were skipped.
+    </p>
+DOWNLOAD
+    $r->print(&show_grading_menu_form(&get_symb_and_url($r,1)));
+    return '';
+}
 
 #-------- end of section for handling grading scantron forms -------
 #
@@ -4787,9 +4913,6 @@ GRADINGMENUJS
 
     $result.=&mt('Student Status').':</b>'.&Apache::lonhtmlcommon::StatusOptions($saveStatus,undef,1,undef);
 
-    if (ref($sections) && (grep /no/,@$sections)) {
-	$result.='&nbsp;(Section "no" implies the students were not assigned a section.)<br />';
-    }
     $result.='</td></tr>';
 
     $result.='<tr bgcolor="#ffffe6"valign="top"><td>'.
@@ -4950,8 +5073,8 @@ sub handler {
 	    }
 	} elsif ($command eq 'scantron_selectphase' && $perm{'mgr'}) {
 	    $request->print(&scantron_selectphase($request));
- 	} elsif ($command eq 'scantron_validate' && $perm{'mgr'}) {
- 	    $request->print(&scantron_validate_file($request));
+ 	} elsif ($command eq 'scantron_warning' && $perm{'mgr'}) {
+ 	    $request->print(&scantron_do_warning($request));
 	} elsif ($command eq 'scantron_validate' && $perm{'mgr'}) {
 	    $request->print(&scantron_validate_file($request));
 	} elsif ($command eq 'scantron_process' && $perm{'mgr'}) {
@@ -4964,7 +5087,7 @@ sub handler {
  		 (&Apache::lonnet::allowed('usc',$ENV{'request.role.domain'})||
 		  &Apache::lonnet::allowed('usc',$ENV{'request.course.id'}))) {
  	    $request->print(&scantron_upload_scantron_data_save($request));
- 	} elsif ($command eq 'scantrondownload' &&
+ 	} elsif ($command eq 'scantron_download' &&
 		 &Apache::lonnet::allowed('usc',$ENV{'request.course.id'})) {
  	    $request->print(&scantron_download_scantron_data($request));
 	} elsif ($command) {