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

albertel lon-capa-cvs@mail.lon-capa.org
Mon, 27 Feb 2006 21:23:54 -0000


albertel		Mon Feb 27 16:23:54 2006 EDT

  Modified files:              
    /loncom/homework	grades.pm 
  Log:
  - formattign and shoving the per response logic into handback_box
  
  
Index: loncom/homework/grades.pm
diff -u loncom/homework/grades.pm:1.321 loncom/homework/grades.pm:1.322
--- loncom/homework/grades.pm:1.321	Mon Feb 27 15:32:38 2006
+++ loncom/homework/grades.pm	Mon Feb 27 16:23:52 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # The LON-CAPA Grading handler
 #
-# $Id: grades.pm,v 1.321 2006/02/27 20:32:38 banghart Exp $
+# $Id: grades.pm,v 1.322 2006/02/27 21:23:52 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1413,7 +1413,7 @@
 
 #--- displays the grading box, used in essay type problem and grading by page/sequence
 sub gradeBox {
-    my ($request,$symb,$uname,$udom,$counter,$partid,$record,$respid) = @_;
+    my ($request,$symb,$uname,$udom,$counter,$partid,$record) = @_;
     my $checkIcon = '<img src="'.$request->dir_config('lonIconsURL').
 	'/check.gif" height="16" border="0" />';
     my $wgt    = &Apache::lonnet::EXT('resource.'.$partid.'.weight',$symb,$udom,$uname);
@@ -1423,7 +1423,6 @@
     my $score  = ($$record{'resource.'.$partid.'.awarded'} eq '' ?
 		  '' : &compute_points($$record{'resource.'.$partid.'.awarded'},$wgt));
     my $result='<input type="hidden" name="WGT'.$counter.'_'.$partid.'" value="'.$wgt.'" />'."\n";
-    $result.='<br />'.$partid.' - '.$respid.'<br />';
     my $display_part=&get_display_part($partid,undef,$symb);
     my %last_resets = &get_last_resets($symb,$env{'request.course.id'},
 				       [$partid]);
@@ -1472,23 +1471,26 @@
         '<input type="hidden" name="aggtries'.$counter.'_'.$partid.'" value="'.
         $aggtries.'" />'."\n";
     $result.='</td></tr></table>'."\n";
-    $result.=&handbackBox($uname,$udom,$counter,$partid,$record,$respid);
+    $result.=&handback_box($uname,$udom,$counter,$partid,$record);
     return $result;
 }
-sub handbackBox {
-    my ($uname,$udom,$counter,$partid,$record,$respid) = @_;
-    my $files=&get_submitted_files($udom,$uname,$partid,$respid,$record);
+
+sub handback_box {
+    my ($uname,$udom,$counter,$partid,$record) = @_;
     my $result;
-    if (@$files) {
-        my $file_counter = 1;
+    foreach my $respid (undef) {
+	my $prefix = $counter.'_'.$partid.'_'.$respid.'_';
+	my $files=&get_submitted_files($udom,$uname,$partid,$respid,$record);
+	next if (!@$files);
+	my $file_counter = 1;
 	foreach my $file (@$files) {
-	    $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="'.$partid.'_'.$respid.'_origdoc'.$file_counter.'" value="'.$file.'" /><br />';
-            $file_counter++;
-        }
+	    my ($file_disp) = ($file =~ m|.+/(.+)$|);
+	    $result.=&mt('Return commented version of [_1] to student.',
+			 '<span class="filename">'.$file_disp.'</span>');
+	    $result.='<input type="file"   name="'.$prefix.'_returndoc'.$file_counter.'" />'."\n";
+	    $result.='<input type="hidden" name="'.$prefix.'_origdoc'.$file_counter.'" value="'.$file.'" /><br />';
+	    $file_counter++;
+	}
     }
     return $result;    
 }
@@ -1916,18 +1918,14 @@
     my %seen = ();
     my @partlist;
     my @gradePartRespid;
-    for my $part_resp(sort keys(%$handgrade)) {
+    for my $part_resp (sort(keys(%$handgrade))) {
 	my ($partid,$respid) = split(/_/, $part_resp);
-	#next if ($seen{$partid} > 0);
-	if ($seen{$partid} > 0) {
-	    $request->print(&handbackBox($uname,$udom,$counter,$partid,\%record,$respid));
-	    next;
-	}
+	next if ($seen{$partid} > 0);
 	$seen{$partid}++;
 	next if ($$handgrade{$part_resp} =~ /:no$/ && $env{'form.lastSub'} =~ /^(hdgrade)$/);
 	push @partlist,$partid;
 	push @gradePartRespid,$partid.'.'.$respid;
-	$request->print(&gradeBox($request,$symb,$uname,$udom,$counter,$partid,\%record,$respid));
+	$request->print(&gradeBox($request,$symb,$uname,$udom,$counter,$partid,\%record));
     }
     $result='<input type="hidden" name="partlist'.$counter.
 	'" value="'.(join ":",@partlist).'" />'."\n";
@@ -2322,7 +2320,7 @@
 	my $portfolio_root = &Apache::loncommon::propath($domain,
         					 $stuname).
         					'/userfiles/portfolio';
-	foreach my $part_resp(sort(keys(%$handgrade))) {
+	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'
@@ -2373,6 +2371,7 @@
     }
     return ('',$pts,$wgt);
 }
+
 sub get_submitted_files {
     my ($udom,$uname,$partid,$respid,$record) = @_;
     my @files;
@@ -2387,6 +2386,7 @@
     }
     return (\@files);
 }
+
 # ----------- Provides number of tries since last reset.
 sub get_num_tries {
     my ($record,$last_reset,$part) = @_;