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

albertel lon-capa-cvs@mail.lon-capa.org
Fri, 19 Mar 2004 04:20:24 -0000


albertel		Thu Mar 18 23:20:24 2004 EDT

  Modified files:              
    /loncom/homework	grades.pm 
  Log:
  - BUG#2741, now checks if the file that is being uploaded has some data in it, and prints out more helpful info on success and on errors.
  
  
  
Index: loncom/homework/grades.pm
diff -u loncom/homework/grades.pm:1.182 loncom/homework/grades.pm:1.183
--- loncom/homework/grades.pm:1.182	Thu Mar 18 22:58:06 2004
+++ loncom/homework/grades.pm	Thu Mar 18 23:20:24 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # The LON-CAPA Grading handler
 #
-# $Id: grades.pm,v 1.182 2004/03/19 03:58:06 albertel Exp $
+# $Id: grades.pm,v 1.183 2004/03/19 04:20:24 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -4273,9 +4273,16 @@
     # See if there is anything left
     unless ($fname) { return 'error: no uploaded file'; }
     $fname='scantron_orig_'.$fname;
-    $r->print(&Apache::lonnet::finishuserfileupload($ENV{'form.courseid'},
-						    $ENV{'form.domainid'},
-						    $home,'upfile',$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 ($symb) {
 	$r->print(&show_grading_menu_form($symb,$url));
     } else {