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

albertel lon-capa-cvs@mail.lon-capa.org
Fri, 30 Jun 2006 00:30:01 -0000


albertel		Thu Jun 29 20:30:01 2006 EDT

  Modified files:              
    /loncom/homework	grades.pm 
  Log:
  - making is so the handed back file is .2. and the copy is .1. BUG#4865
  - making it so multiple files work correctly for the handback message
  
  
Index: loncom/homework/grades.pm
diff -u loncom/homework/grades.pm:1.366 loncom/homework/grades.pm:1.367
--- loncom/homework/grades.pm:1.366	Tue Jun 27 16:37:42 2006
+++ loncom/homework/grades.pm	Thu Jun 29 20:30:00 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # The LON-CAPA Grading handler
 #
-# $Id: grades.pm,v 1.366 2006/06/27 20:37:42 albertel Exp $
+# $Id: grades.pm,v 1.367 2006/06/30 00:30:00 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -2390,7 +2390,6 @@
 	    }
 	    $newrecord{'resource.'.$new_part.'.regrader'}=
 		"$env{'user.name'}:$env{'user.domain'}";
-            &handback_files($request,$symb,$stuname,$domain,$newflg,$new_part,\%newrecord);
 	}
 	# unless problem has been graded, set flag to version the submitted files
 	unless ($record{'resource.'.$new_part.'.solved'} =~ /^correct_/  || 
@@ -2408,6 +2407,10 @@
             my @changed_keys = &version_portfiles(\%record, \@parts_graded, 
                                 $env{'request.course.id'}, $symb, $domain, $stuname, \@version_parts);
 	    @newrecord{@changed_keys} = @record{@changed_keys};
+	    foreach my $new_part (@version_parts) {
+		&handback_files($request,$symb,$stuname,$domain,$newflg,
+				$new_part,\%newrecord);
+	    }
         }
 	&Apache::lonnet::cstore(\%newrecord,$symb,
 				$env{'request.course.id'},$domain,$stuname);
@@ -2439,6 +2442,7 @@
             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;
+		my $file_msg;
                 while ($env{'form.'.$newflg.'_'.$part_resp.'_returndoc'.$file_counter}) {
                     my $fname=$env{'form.'.$newflg.'_'.$part_resp.'_returndoc'.$file_counter.'.filename'};
                     my ($directory,$answer_file) = 
@@ -2461,21 +2465,27 @@
                         my @files = ($save_file_name);
                         my @what = ($symb,'handback');
                         &Apache::lonnet::mark_as_readonly($domain,$stuname,\@files,\@what);
-                        $$newrecord{"resource.$new_part.$resp_id.handback"} = $save_file_name;
-                        my $subject = "File Handed Back by Instructor ";
-                        my $message = "A file has been returned that was originally submitted in reponse to: <br />";
-                        $message .= "<strong>".&Apache::lonnet::gettitle($symb)."</strong><br />";
-                        $message .= ' The returned file is named: <br /><span class="LC_filename"><a href="/uploaded/'."$domain/$stuname/".$save_file_name.'">'.$save_file_name."</a></span><br />";
-                        $message .= " and can be found in your portfolio space.";
-			my $url = (&Apache::lonnet::decode_symb($symb))[2];
-			$url = &Apache::lonnet::declutter($url);
-                        my $msgstatus = &Apache::lonmsg::user_normal_msg($stuname,$domain,
-				        $subject.' (File Returned) ['.$url.']',$message);                    
+			if (exists($$newrecord{"resource.$new_part.$resp_id.handback"})) {
+			    $$newrecord{"resource.$new_part.$resp_id.handback"}.=',';
+			}
+                        $$newrecord{"resource.$new_part.$resp_id.handback"} .= $save_file_name;
+			$file_msg.= "\n".'<br /><span class="LC_filename"><a href="/uploaded/'."$domain/$stuname/".$save_file_name.'">'.$save_file_name."</a></span><br />";
+
                     }
                     $request->print("<br />".$fname." will be the uploaded file name");
                     $request->print(" ".$env{'form.'.$newflg.'_'.$part_resp.'_origdoc'.$file_counter});
                     $file_counter++;
                 }
+		my $subject = "File Handed Back by Instructor ";
+		my $message = "A file has been returned that was originally submitted in reponse to: <br />";
+		$message .= "<strong>".&Apache::lonnet::gettitle($symb)."</strong><br />";
+		$message .= ' The returned file(s) are named: '. $file_msg;
+		$message .= " and can be found in your portfolio space.";
+		my $url = (&Apache::lonnet::decode_symb($symb))[2];
+		$url = &Apache::lonnet::declutter($url);
+		my $msgstatus = &Apache::lonmsg::user_normal_msg($stuname,$domain,
+								 $subject.' (File Returned) ['.$url.']',$message);                    
+
             }
         }
     return;
@@ -2567,7 +2577,7 @@
         my $new_portfiles;
         if ($key =~ /^resource\.($version_parts)\./ && $key =~ /\.portfiles$/ ) {
             my @versioned_portfiles;
-            my @portfiles = split(/,/,$$record{$key});
+            my @portfiles = split(/\s*,\s*/,$$record{$key});
             foreach my $file (@portfiles) {
                 &Apache::lonnet::unmark_as_readonly($domain,$stu_name,[$symb,$env{'request.course.id'}],$file);
                 my ($directory,$answer_file) =($file =~ /^(.*?)([^\/]*)$/);
@@ -2579,7 +2589,7 @@
                 if ($new_answer ne 'problem getting file') {
                     push(@versioned_portfiles, $directory.$new_answer);
                     &Apache::lonnet::mark_as_readonly($domain,$stu_name,
-                        ['/portfolio'.$directory.$new_answer],
+                        [$directory.$new_answer],
                         [$symb,$env{'request.course.id'},'graded']);
                 }
             }