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

albertel lon-capa-cvs-allow@mail.lon-capa.org
Mon, 10 Sep 2007 23:03:38 -0000


albertel		Mon Sep 10 19:03:38 2007 EDT

  Modified files:              
    /loncom/homework	grades.pm 
    /loncom/interface	loncommon.pm 
  Log:
  - BUG#5409, multi-entry numerical/formula response submissions were not displaying correctly in the PGRD view
  
  
  
Index: loncom/homework/grades.pm
diff -u loncom/homework/grades.pm:1.439 loncom/homework/grades.pm:1.440
--- loncom/homework/grades.pm:1.439	Thu Sep  6 20:07:30 2007
+++ loncom/homework/grades.pm	Mon Sep 10 19:03:35 2007
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # The LON-CAPA Grading handler
 #
-# $Id: grades.pm,v 1.439 2007/09/07 00:07:30 albertel Exp $
+# $Id: grades.pm,v 1.440 2007/09/10 23:03:35 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -349,7 +349,10 @@
 	    $result.='</ul>';
 	    return $result;
 	}
-       
+    } elsif ( $response =~ m/(?:numerical|formula)/) {
+	$answer = 
+	    &Apache::loncommon::format_previous_attempt_value('submission',
+							      $answer);
     }
     return $answer;
 }
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.580 loncom/interface/loncommon.pm:1.581
--- loncom/interface/loncommon.pm:1.580	Fri Sep  7 15:51:41 2007
+++ loncom/interface/loncommon.pm	Mon Sep 10 19:03:38 2007
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.580 2007/09/07 19:51:41 raeburn Exp $
+# $Id: loncommon.pm,v 1.581 2007/09/10 23:03:38 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -2637,25 +2637,15 @@
 	for ($version=1;$version<=$returnhash{'version'};$version++) {
 	  $prevattempts.='</tr><tr bgcolor="#ffffe6"><td>Transaction '.$version.'</td>';
 	    foreach my $key (sort(keys(%lasthash))) {
-	       my $value;
-	       if ($key =~ /timestamp/) {
-		  $value=scalar(localtime($returnhash{$version.':'.$key}));
-	       } else {
-		  $value=$returnhash{$version.':'.$key};
-	       }
-	       $prevattempts.='<td>'.&unescape($value).'&nbsp;</td>';   
+		my $value = &format_previous_attempt_value($key,
+							   $returnhash{$version.':'.$key});
+		$prevattempts.='<td>'.$value.'&nbsp;</td>';   
 	    }
 	 }
       }
       $prevattempts.='</tr><tr bgcolor="#ffffe6"><td>Current</td>';
       foreach my $key (sort(keys(%lasthash))) {
-	my $value;
-	if ($key =~ /timestamp/) {
-	  $value=scalar(localtime($lasthash{$key}));
-	} else {
-	  $value=$lasthash{$key};
-	}
-	$value=&unescape($value);
+	my $value = &format_previous_attempt_value($key,$lasthash{$key});
 	if ($key =~/$regexp$/ && (defined &$gradesub)) {$value = &$gradesub($value)}
 	$prevattempts.='<td>'.$value.'&nbsp;</td>';
       }
@@ -2668,6 +2658,19 @@
   }
 }
 
+sub format_previous_attempt_value {
+    my ($key,$value) = @_;
+    if ($key =~ /timestamp/) {
+	$value = &Apache::lonlocal::locallocaltime($value);
+    } elsif (ref($value) eq 'ARRAY') {
+	$value = '('.join(', ', @{ $value }).')';
+    } else {
+	$value = &unescape($value);
+    }
+    return $value;
+}
+
+
 sub relative_to_absolute {
     my ($url,$output)=@_;
     my $parser=HTML::TokeParser->new(\$output);