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

albertel lon-capa-cvs@mail.lon-capa.org
Wed, 28 Dec 2005 21:26:21 -0000


albertel		Wed Dec 28 16:26:21 2005 EDT

  Modified files:              
    /loncom/homework/caparesponse	caparesponse.pm 
  Log:
  - BUG#4525, was improperly sending formulas through format_number
  
  
Index: loncom/homework/caparesponse/caparesponse.pm
diff -u loncom/homework/caparesponse/caparesponse.pm:1.185 loncom/homework/caparesponse/caparesponse.pm:1.186
--- loncom/homework/caparesponse/caparesponse.pm:1.185	Tue Dec  6 05:16:56 2005
+++ loncom/homework/caparesponse/caparesponse.pm	Wed Dec 28 16:26:21 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # caparesponse definition
 #
-# $Id: caparesponse.pm,v 1.185 2005/12/06 10:16:56 albertel Exp $
+# $Id: caparesponse.pm,v 1.186 2005/12/28 21:26:21 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -191,17 +191,22 @@
 						    $safeeval);
 	    for (my $i=0; $i <= $#answers; $i++) {
 		my $answer=$answers[$i];
-		my $format;
-		if ($#formats > 0) {
-		    $format=$formats[$i];
+		if ( scalar(@$tagstack)
+		     && $tagstack->[-1] ne 'numericalresponse') {
+		    $answertxt.=$answer.',';
 		} else {
-		    $format=$formats[0];
+		    my $format;
+		    if ($#formats > 0) {
+			$format=$formats[$i];
+		    } else {
+			$format=$formats[0];
+		    }
+		    if ($unit=~/\$/) { $format="\$".$format; $unit=~s/\$//g; }
+		    if ($unit=~/\,/) { $format="\,".$format; $unit=~s/\,//g; }
+		    my $formatted=&format_number($answer,$format,$target,
+						 $safeeval);
+		    $answertxt.=$formatted.',';
 		}
-		if ($unit=~/\$/) { $format="\$".$format; $unit=~s/\$//g; }
-		if ($unit=~/\,/) { $format="\,".$format; $unit=~s/\,//g; }
-		my $formatted=&format_number($answer,$format,$target,
-					     $safeeval);
-		$answertxt.=$formatted.',';
 	    }
 	    chop $answertxt;
 	    if ($target eq 'web') {