[LON-CAPA-cvs] cvs: loncom(version_1_2_X) /homework grades.pm

albertel lon-capa-cvs@mail.lon-capa.org
Tue, 09 Nov 2004 20:20:56 -0000


albertel		Tue Nov  9 15:20:56 2004 EDT

  Modified files:              (Branch: version_1_2_X)
    /loncom/homework	grades.pm 
  Log:
  - backport 1.209
  
  
Index: loncom/homework/grades.pm
diff -u loncom/homework/grades.pm:1.204.2.8 loncom/homework/grades.pm:1.204.2.9
--- loncom/homework/grades.pm:1.204.2.8	Fri Nov  5 20:22:11 2004
+++ loncom/homework/grades.pm	Tue Nov  9 15:20:56 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # The LON-CAPA Grading handler
 #
-# $Id: grades.pm,v 1.204.2.8 2004/11/06 01:22:11 albertel Exp $
+# $Id: grades.pm,v 1.204.2.9 2004/11/09 20:20:56 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -3470,10 +3470,11 @@
 }
 
 sub scantron_uploads {
+    my ($file2grade) = @_;
     my $result=	'<select name="scantron_selectfile">';
     $result.="<option></option>";
     foreach my $filename (sort(&scantron_filenames())) {
-	$result.="<option>$filename</option>\n";
+	$result.="<option".($filename eq $file2grade ? ' selected="on"':'').">$filename</option>\n";
     }
     $result.="</select>";
     return $result;
@@ -3519,13 +3520,13 @@
 }
 
 sub scantron_selectphase {
-    my ($r) = @_;
+    my ($r,$file2grade) = @_;
     my ($symb,$url)=&get_symb_and_url($r);
     if (!$symb) {return '';}
     my $sequence_selector=&getSequenceDropDown($r,$symb);
     my $default_form_data=&defaultFormData($symb,$url);
     my $grading_menu_button=&show_grading_menu_form($symb,$url);
-    my $file_selector=&scantron_uploads();
+    my $file_selector=&scantron_uploads($file2grade);
     my $format_selector=&scantron_scantab();
     my $CODE_selector=&scantron_CODElist();
     my $CODE_unique=&scantron_CODEunique();
@@ -4728,7 +4729,7 @@
 	}
 	return '';
     }
-    $r->print("Doing upload to ".$ENV{'form.courseid'}." <br />");
+#    $r->print("Doing upload to ".$ENV{'form.courseid'}." <br />");
     my $home=&Apache::lonnet::homeserver($ENV{'form.courseid'},
 					 $ENV{'form.domainid'});
     my $fname=$ENV{'form.upfile.filename'};
@@ -4745,19 +4746,23 @@
     $fname=~s/[^\w\.\-]//g;
     # See if there is anything left
     unless ($fname) { return 'error: no uploaded file'; }
+    my $uploadedfile=$fname;
     $fname='scantron_orig_'.$fname;
     if (length($ENV{'form.upfile'}) < 2) {
 	$r->print("<font color='red'>Error:</font> The file you attempted to upload, <tt>".&HTML::Entities::encode($ENV{'form.upfile.filename'},'<>&"')."</tt>, contained no information. Please check that you entered the correct filename.");
     } else {
 	my $result=&Apache::lonnet::finishuserfileupload($ENV{'form.courseid'},$ENV{'form.domainid'},$home,'upfile',$fname);
-	if ($result =~ m|^/uploaded/|) {
-	    $r->print("<font color='green'>Success:</font> Successfully uploaded ".(length($ENV{'form.upfile'})-1)." bytes of data into location <tt>".$result."</tt>");
-	} else {
-	    $r->print("<font color='red'>Error:</font> An error (".$result.") occured when attempting to upload the file, <tt>".&HTML::Entities::encode($ENV{'form.upfile.filename'},'<>&"')."</tt>");
+#	if ($result =~ m|^/uploaded/|) {
+	if ($result !~ m|^/uploaded/|) {
+#	    $r->print("<font color='green'>Success:</font> Successfully uploaded ".(length($ENV{'form.upfile'})-1)." bytes of data into location <tt>".$result."</tt>");
+#	} else {
+	    $r->print("<font color='red'>Error:</font> An error (".$result.") occurred when attempting to upload the file, <tt>".&HTML::Entities::encode($ENV{'form.upfile.filename'},'<>&"')."</tt>");
 	}
     }
     if ($symb) {
-	$r->print(&show_grading_menu_form($symb,$url));
+#	$r->print(&show_grading_menu_form($symb,$url));
+	$r->print(&scantron_selectphase($r,$uploadedfile));
+
     } else {
 	$r->print($doanotherupload);
     }