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

banghart lon-capa-cvs@mail.lon-capa.org
Tue, 07 Mar 2006 02:50:19 -0000


banghart		Mon Mar  6 21:50:19 2006 EDT

  Modified files:              
    /loncom/homework	grades.pm 
  Log:
  	Saving work in progress. Uploads handback file, names it appropriately,
  	overwrites existing file without warning!! 
  
  
Index: loncom/homework/grades.pm
diff -u loncom/homework/grades.pm:1.327 loncom/homework/grades.pm:1.328
--- loncom/homework/grades.pm:1.327	Fri Mar  3 16:50:44 2006
+++ loncom/homework/grades.pm	Mon Mar  6 21:50:15 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # The LON-CAPA Grading handler
 #
-# $Id: grades.pm,v 1.327 2006/03/03 21:50:44 albertel Exp $
+# $Id: grades.pm,v 1.328 2006/03/07 02:50:15 banghart Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -2316,14 +2316,21 @@
 	my ($partlist,$handgrade,$responseType) = &response_type($symb);
 	foreach my $part_resp (sort(keys(%$handgrade))) {
 	    my ($part_id, $resp_id) = split(/_/,$part_resp);
-	    &Apache::lonnet::logthis('form.'.$newflg.'_'.$part_resp.'_returndoc1');
-	    &Apache::lonnet::logthis("new part is $new_part and partid is $part_id");
             if (($env{'form.'.$newflg.'_'.$part_resp.'_returndoc1'}) && ($new_part == $part_id)) {
                 # if multiple files are uploaded names will be 'returndoc2','returndoc3'
                 my $file_counter = 1;
                 while ($env{'form.'.$newflg.'_'.$part_resp.'_returndoc'.$file_counter}) {
                     my $fname=$env{'form.'.$newflg.'_'.$part_resp.'_returndoc'.$file_counter.'.filename'};
                     $newrecord{"resource.$new_part.$resp_id.handback"} = $env{'form.returndocorig'.$file_counter};
+                    # set the filename to match the submitted file name
+                    $env{'form.'.$newflg.'_'.$part_resp.'_returndoc1.filename'} = $env{'form.'.$newflg.'_'.$part_resp.'_origdoc'.$file_counter};
+                    my $result=&Apache::lonnet::userfileupload($newflg.'_'.$part_resp.'_returndoc'.$file_counter,'',
+	        	 'portfolio',undef,undef,undef,$stuname,$domain);
+                   if ($result !~ m|^/uploaded/|) {
+                        $request->print('<font color="red"> An errror occured ('.$result.
+	                    ') while trying to upload '.&display_file().'</font><br />');
+	                # $request->print(&done('Back'));
+	            }
                     $request->print("<br />".$fname." will be the uploaded file name");
                     $request->print("<font color=\"red\">Will upload document</font>".$env{'form.'.$newflg.'_'.$part_resp.'_origdoc'.$file_counter});
                     $file_counter++;