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

raeburn raeburn at source.lon-capa.org
Thu Oct 6 13:15:40 EDT 2011


raeburn		Thu Oct  6 17:15:40 2011 EDT

  Modified files:              
    /loncom/homework	default_homework.lcpm 
  Log:
  - Check customunits contains other than white space before calling split().
  
  
Index: loncom/homework/default_homework.lcpm
diff -u loncom/homework/default_homework.lcpm:1.160 loncom/homework/default_homework.lcpm:1.161
--- loncom/homework/default_homework.lcpm:1.160	Wed Aug  3 03:14:29 2011
+++ loncom/homework/default_homework.lcpm	Thu Oct  6 17:15:40 2011
@@ -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.160 2011/08/03 03:14:29 raeburn Exp $
+# $Id: default_homework.lcpm,v 1.161 2011/10/06 17:15:40 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -318,11 +318,13 @@
 	    $responses->[0][-1]=$part1;
 	    $unit=&capa_formula_fix($part2);
             my $customunits=$LONCAPA::CAPAresponse_args{'customunits'};
-            foreach my $replacement (split(/\s*\,\s*/,$customunits)) {
-                my ($which,$what)=split(/\s*\=\s*/,$replacement);
-                if ((defined($which)) && (defined($what))) {
-                   $what=&capa_formula_fix($what);
-                   $unit=~s/$which/\($what\)/g;
+            if ($customunits =~ /\S/) {
+                foreach my $replacement (split(/\s*\,\s*/,$customunits)) {
+                    my ($which,$what)=split(/\s*\=\s*/,$replacement);
+                    if ((defined($which)) && (defined($what))) {
+                        $what=&capa_formula_fix($what);
+                        $unit=~s/$which/\($what\)/g;
+                    }
                 }
             }
 	}
@@ -1181,7 +1183,6 @@
     return $middlename;
 }
 
-                                                                                
 sub lastname {
     my $lastname = &EXT('environment.lastname');
     $lastname = '' if $lastname eq "";




More information about the LON-CAPA-cvs mailing list