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

banghart lon-capa-cvs@mail.lon-capa.org
Tue, 07 Feb 2006 13:38:18 -0000


banghart		Tue Feb  7 08:38:18 2006 EDT

  Modified files:              
    /loncom/homework	grades.pm 
  Log:
  	Replace $_
  	Relocate code to handle return of document to student (from processHandGrade
  	to saveHandGrade).
  	Not working yet.
  
  
Index: loncom/homework/grades.pm
diff -u loncom/homework/grades.pm:1.309 loncom/homework/grades.pm:1.310
--- loncom/homework/grades.pm:1.309	Mon Feb  6 18:39:44 2006
+++ loncom/homework/grades.pm	Tue Feb  7 08:38:16 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # The LON-CAPA Grading handler
 #
-# $Id: grades.pm,v 1.309 2006/02/06 23:39:44 albertel Exp $
+# $Id: grades.pm,v 1.310 2006/02/07 13:38:16 banghart Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1812,7 +1812,8 @@
 			        $file_counter ++;
 				&Apache::lonnet::allowuploaded('/adm/grades',$file);
 				$lastsubonly.='<br /><a href="'.$file.'" target="lonGRDs"><img src="'.&Apache::loncommon::icon($file).'" border=0"> '.$file.'</a>';
-				$lastsubonly.='Return commented document to student. <input type="file" name="returndoc'.$file_counter.'" />'."\n";
+				$lastsubonly.=' Return commented document to student. <input type="file" name="part'.$partid.'_returndoc';
+				$lastsubonly.=$file_counter.'" />'."\n";
 				$lastsubonly.='<input type="hidden" name="returndocorig'.$file_counter.'" value="'.$file.'" />';
 
 			    }
@@ -2029,32 +2030,21 @@
 		my @collabstrs=&Apache::loncommon::get_env_multiple("form.collaborator$ctr");
 		foreach my $collabstr (@collabstrs) {
 		    my ($part,@collaborators) = split(/:/,$collabstr);
-		    foreach (@collaborators) {
+		    foreach my $collaborator (@collaborators) {
 			my ($errorflag,$pts,$wgt) = 
-			    &saveHandGrade($request,$url,$symb,$_,$udom,$ctr,
+			    &saveHandGrade($request,$url,$symb,$collaborator,$udom,$ctr,
 					   $env{'form.unamedom'.$ctr},$part);
 			if ($errorflag eq 'not_allowed') {
-			    $request->print("<font color=\"red\">Not allowed to modify grades for $_:$udom</font>");
+			    $request->print("<font color=\"red\">Not allowed to modify grades for $collaborator:$udom</font>");
 			    next;
 			} else {
 			    if ($message ne '') {
-				$msgstatus = &Apache::lonmsg::user_normal_msg($_,$udom,$env{'form.msgsub'},$message);
+				$msgstatus = &Apache::lonmsg::user_normal_msg($collaborator,$udom,$env{'form.msgsub'},$message);
 			    }
-			    
 			}
 		    }
 		}
 	    }
-	    if ($env{'form.returndoc1'}) {
-	        # if multiple files are uploaded names will be 'returndoc2', 'returndoc3'
-	        my $file_counter = 1;
-	        while ($env{'form.returndoc'.$file_counter}) {
-	            my $fname=$env{'form.returndoc'.$file_counter.'.filename'};
-	            $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 ++;
-	        }
-	    }
 	    $ctr++;
 	}
     }
@@ -2234,6 +2224,7 @@
     my @parts = split(/:/,$env{'form.partlist'.$newflg});
     foreach my $new_part (@parts) {
 	#collaborator may vary for different parts
+	$request->print('form.part'.$new_part.'_returndoc1');
 	if ($submitter && $new_part ne $part) { next; }
 	my $dropMenu = $env{'form.GD_SEL'.$newflg.'_'.$new_part};
 	if ($dropMenu eq 'excused') {
@@ -2302,6 +2293,25 @@
 	    $newrecord{'resource.'.$new_part.'.regrader'}=
 		"$env{'user.name'}:$env{'user.domain'}";
 	}
+	$request->print('form.part'.$new_part.'_returndoc1');
+        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;
+            while ($env{'form.'.$new_part.'_returndoc'.$file_counter}) {
+                my $fname=$env{'form.returndoc'.$file_counter.'.filename'};
+                $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++;
+            }
+        }
+	
 	# unless problem has been graded, set flag to version the submitted files
 	unless ($record{'resource.'.$new_part.'.solved'} =~ /^correct_/  || 
 	        $record{'resource.'.$new_part.'.solved'} eq 'incorrect_by_override' ||