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

www www@source.lon-capa.org
Wed, 06 Jan 2010 16:59:30 -0000


www		Wed Jan  6 16:59:30 2010 EDT

  Modified files:              
    /loncom/homework	default_homework.lcpm 
  Log:
  Dealing with percentages if the author entered %, but the student did not.
  
  
Index: loncom/homework/default_homework.lcpm
diff -u loncom/homework/default_homework.lcpm:1.146 loncom/homework/default_homework.lcpm:1.147
--- loncom/homework/default_homework.lcpm:1.146	Sun Dec 27 19:40:42 2009
+++ loncom/homework/default_homework.lcpm	Wed Jan  6 16:59:30 2010
@@ -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.146 2009/12/27 19:40:42 www Exp $
+# $Id: default_homework.lcpm,v 1.147 2010/01/06 16:59:30 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -326,10 +326,20 @@
               $element =~ s/\s//g;
           }
           my $appendunit=$unit;
+# Deal with percentages
+# unit is unit entered by student, answerunit is unit by author
+# Deprecated: divide answer by 100 if student entered percent,
+# but author did not. Too much confusion
 #          if (($unit=~/\%/) && ($answerunit ne '%'))  {
 #             $element=$element/100;
 #             $appendunit=~s/\%//;
 #          }    
+# Author entered percent, student did not
+          if (($unit!~/\%/) && ($answerunit=~/\%/)) {
+             $element=$element*100;
+             $appendunit='%'.$appendunit;
+          }
+# Zero does not need a dimension
           if (($element==0) && ($unit!~/\w/) && ($answerunit=~/\w/)) {
              $appendunit=$answerunit;
           }