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

www lon-capa-cvs-allow@mail.lon-capa.org
Wed, 05 Mar 2008 18:05:07 -0000


www		Wed Mar  5 13:05:07 2008 EDT

  Modified files:              
    /loncom/homework	default_homework.lcpm 
  Log:
  Bug #3991:
  * correctly split off units
  * then apply implicit multiplication rules
  
  
  
Index: loncom/homework/default_homework.lcpm
diff -u loncom/homework/default_homework.lcpm:1.127 loncom/homework/default_homework.lcpm:1.128
--- loncom/homework/default_homework.lcpm:1.127	Wed Mar  5 11:06:39 2008
+++ loncom/homework/default_homework.lcpm	Wed Mar  5 13:05:05 2008
@@ -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.127 2008/03/05 16:06:39 www Exp $
+# $Id: default_homework.lcpm,v 1.128 2008/03/05 18:05:05 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -310,9 +310,11 @@
     my $unit;
     if ($type eq '' || $type eq 'float') {
 	#for numerical problems split off the unit
-	if ( $responses->[0][-1]=~ /(.*[^\s])\s+([^\s]+)/ ) {
+#	if ( $responses->[0][-1]=~ /(.*[^\s])\s+([^\s]+)/ ) {
+        if ( $responses->[0][-1]=~ /^([\d\.\,\s\$]*(?:(?:[xX\*]10[\^\*]*|[eE]*)[\+\-]*\d*)*(?:^|\S)\d)([\w\s][\$\s\w\^\*\/\(\)\+\-]*)$/ ) {
 	    $responses->[0][-1]=$1;
-	    $unit=$2;
+	    $unit=&capa_formula_fix($2);
+            &LONCAPA_INTERNAL_DEBUG("Found unit :$unit:");
 	}
     }
     &LONCAPA_INTERNAL_DEBUG("Final final response :$responses->[0][-1]:$unit:");