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

banghart lon-capa-cvs@mail.lon-capa.org
Mon, 27 Feb 2006 20:32:39 -0000


banghart		Mon Feb 27 15:32:39 2006 EDT

  Modified files:              
    /loncom/homework	grades.pm 
  Log:
  	Saving work in progress. Progress in handback of commented files
  	in essay grading.
  
  
Index: loncom/homework/grades.pm
diff -u loncom/homework/grades.pm:1.320 loncom/homework/grades.pm:1.321
--- loncom/homework/grades.pm:1.320	Mon Feb 27 14:40:21 2006
+++ loncom/homework/grades.pm	Mon Feb 27 15:32:38 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # The LON-CAPA Grading handler
 #
-# $Id: grades.pm,v 1.320 2006/02/27 19:40:21 albertel Exp $
+# $Id: grades.pm,v 1.321 2006/02/27 20:32:38 banghart Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1480,12 +1480,14 @@
     my $files=&get_submitted_files($udom,$uname,$partid,$respid,$record);
     my $result;
     if (@$files) {
-        my $file_counter = 0;
+        my $file_counter = 1;
 	foreach my $file (@$files) {
-            $result.=' Return commented document to student. <input type="file" name="part'.$partid.'_returndoc';
+	    $file =~ /.+\/(.+$)/;
+	    my $file_disp = $1;
+            $result.=' Return commented version of <span class="filename">'.$file_disp.' </span>to student. <input type="file" name="'.$partid.'_'.$respid.'_returndoc';
             $result.=$file_counter.'" />'."\n";
-            $result.='<input type="hidden" name="respid" value="'.$respid.'" />';
-            $result.='<input type="hidden" name="returndocorig'.$file_counter.'" value="'.$file.'" /><br />';
+            $result.='<input type="hidden" name="'.$partid.'_'.$respid.'_origdoc'.$file_counter.'" value="'.$file.'" /><br />';
+            $file_counter++;
         }
     }
     return $result;    
@@ -2316,25 +2318,22 @@
 	    $newrecord{'resource.'.$new_part.'.regrader'}=
 		"$env{'user.name'}:$env{'user.domain'}";
 	}
-        if ($env{'form.part'.$new_part.'_returndoc1'}) {
-            # if multiple files are uploaded names will be 'returndoc2','returndoc3'
-           
-            my $portfolio_root = &Apache::loncommon::propath($domain,
-    					 $stuname).
-    					'/userfiles/portfolio';
-                $request->print('<br>'.$portfolio_root.'<br>');
-                
-    #                my $result=&Apache::lonnet::userfileupload('uploaddoc','',
-    #	        	 'portfolio'.$env{'form.currentpath'});
-    
-            my $file_counter = 1;
-            my $respid = $env{'form.respid'};
-            while ($env{'form.part'.$new_part.'_returndoc'.$file_counter}) {
-                my $fname=$env{'form.returndoc'.$file_counter.'.filename'};
-                $newrecord{"resource.$new_part.$respid.handback"} = $env{'form.returndocorig'.$file_counter};
-                $request->print("<br />".$fname." will be the uploaded file name");
-                $request->print("<font color=\"red\">Will upload document</font>".$env{'form.returndocorig'.$file_counter});
-                $file_counter++;
+	my ($partlist,$handgrade,$responseType) = &response_type($url,$symb);
+	my $portfolio_root = &Apache::loncommon::propath($domain,
+        					 $stuname).
+        					'/userfiles/portfolio';
+	foreach my $part_resp(sort(keys(%$handgrade))) {
+	    my ($part_id, $resp_id) = split(/_/,$part_resp);
+            if ($env{'form.'.$part_resp.'_returndoc1'} && ($new_part eq $part_id)) {
+                # if multiple files are uploaded names will be 'returndoc2','returndoc3'
+                my $file_counter = 1;
+                while ($env{'form.'.$part_resp.'_returndoc'.$file_counter}) {
+                    my $fname=$env{'form.returndoc'.$file_counter.'.filename'};
+                    $newrecord{"resource.$new_part.$resp_id.handback"} = $env{'form.returndocorig'.$file_counter};
+                    $request->print("<br />".$fname." will be the uploaded file name");
+                    $request->print("<font color=\"red\">Will upload document</font>".$env{'form.returndocorig'.$file_counter});
+                    $file_counter++;
+                }
             }
         }