--- loncom/homework/default_homework.lcpm 2009/06/23 03:01:15 1.145 +++ loncom/homework/default_homework.lcpm 2010/10/14 04:59:08 1.148 @@ -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.145 2009/06/23 03:01:15 www Exp $ +# $Id: default_homework.lcpm,v 1.148 2010/10/14 04:59:08 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -326,14 +326,26 @@ sub caparesponse_check_list { $element =~ s/\s//g; } my $appendunit=$unit; - if (($unit=~/\%/) && ($answerunit ne '%')) { - $element=$element/100; - $appendunit=~s/\%//; - } +# 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; } - $element .= " $appendunit"; + if ($appendunit ne '') { + $element .= " $appendunit"; + } &LONCAPA_INTERNAL_DEBUG("Made response element :$element:"); } }