[LON-CAPA-cvs] cvs: loncom /homework default_homework.lcpm

ng lon-capa-cvs@mail.lon-capa.org
Fri, 01 Apr 2005 13:58:25 -0000


ng		Fri Apr  1 08:58:25 2005 EDT

  Modified files:              
    /loncom/homework	default_homework.lcpm 
  Log:
  variable $result should be declared outside block or &format does not work.
  
  
  
Index: loncom/homework/default_homework.lcpm
diff -u loncom/homework/default_homework.lcpm:1.98 loncom/homework/default_homework.lcpm:1.99
--- loncom/homework/default_homework.lcpm:1.98	Thu Mar 31 12:12:37 2005
+++ loncom/homework/default_homework.lcpm	Fri Apr  1 08:58:25 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA 
 # used by lonxml::xmlparse() as input variable $safeinit to Apache::run::run()
 #
-# $Id: default_homework.lcpm,v 1.98 2005/03/31 17:12:37 albertel Exp $
+# $Id: default_homework.lcpm,v 1.99 2005/04/01 13:58:25 ng Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -518,11 +518,12 @@
     #if ($options =~ /\$/) { $dollamode=1; }
     #if ($options =~ /,/)  { $commamode=1; }
     if ($options =~ /\./) { $alwaysperiod=1; }
+    my $result;
     if ($fmt=~/s$/i) {
 	$result=&format_significant_figures($value,$fmt);
     } else {
 	$fmt=~s/e/E/g;
-	my $result=sprintf('%.'.$fmt,$value);
+	$result=sprintf('%.'.$fmt,$value);
 	if ($alwaysperiod && $fmt eq '0f') { $result .='.'; }
 	$result=~s/(E[+-]*)0/$1/;
     }