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

banghart lon-capa-cvs@mail.lon-capa.org
Sun, 28 May 2006 16:47:05 -0000


banghart		Sun May 28 12:47:05 2006 EDT

  Modified files:              
    /loncom/homework	grades.pm 
  Log:
  	Finally saving handed back file with proper versioning. 
  
  
Index: loncom/homework/grades.pm
diff -u loncom/homework/grades.pm:1.354 loncom/homework/grades.pm:1.355
--- loncom/homework/grades.pm:1.354	Thu May 18 17:39:27 2006
+++ loncom/homework/grades.pm	Sun May 28 12:47:02 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # The LON-CAPA Grading handler
 #
-# $Id: grades.pm,v 1.354 2006/05/18 21:39:27 albertel Exp $
+# $Id: grades.pm,v 1.355 2006/05/28 16:47:02 banghart Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -2442,20 +2442,20 @@
                         ($env{'form.'.$newflg.'_'.$part_resp.'_origdoc'.$file_counter} =~ /^(.*?)([^\/]*)$/);
                     my ($answer_name,$answer_ver,$answer_ext) =
 		        &file_name_version_ext($answer_file);
-		    $directory =~ /^.+$stuname\/portfolio(.*)/;
-		    my $portfolio_path = $1;
+		    my ($portfolio_path) = ($directory =~ /^.+$stuname\/portfolio(.*)/);
 		    my @dir_list = &Apache::lonnet::dirlist($portfolio_path,$domain,$stuname,$portfolio_root);
 		    my $version = &get_next_version($answer_name, $answer_ext, \@dir_list);
 		    my $new_answer = &version_selected_portfile($domain, $stuname, $portfolio_path, $answer_file, $version);
                     $$newrecord{"resource.$new_part.$resp_id.handback"} = $new_answer;
-                    # 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);
+                    $version++;
+                    # fix file name
+                    my ($save_file_name) = (($directory.$answer_name.".$version.".$answer_ext) =~ /^.+\/${stuname}\/(.*)/);
+                    my $result=&Apache::lonnet::finishuserfileupload($stuname,$domain,
+            	                                $newflg.'_'.$part_resp.'_returndoc'.$file_counter,
+            	                                $save_file_name);
                     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'));
+                        ') while trying to upload '.$newflg.'_'.$part_resp.'_returndoc'.$file_counter.'</font><br />');
                     }
                     $request->print("<br />".$fname." will be the uploaded file name");
                     $request->print(" ".$env{'form.'.$newflg.'_'.$part_resp.'_origdoc'.$file_counter});