--- loncom/homework/default_homework.lcpm 2011/10/06 17:20:37 1.152.2.2 +++ loncom/homework/default_homework.lcpm 2011/06/09 15:43:56 1.159 @@ -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.152.2.2 2011/10/06 17:20:37 raeburn Exp $ +# $Id: default_homework.lcpm,v 1.159 2011/06/09 15:43:56 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -253,8 +253,6 @@ sub caparesponse_check { elsif ($result =='15') { $result='UNIT_IRRECONCIBLE'; } else {$result = "ERROR: Unknown Result:$result:$@:";} -# &LONCAPA_INTERNAL_DEBUG("RetError $reterror: Answer $answer: Response $response: type-$type|$tol|$tol_type|$sig:$sig_lbound:$sig_ubound|$unit|"); -# &LONCAPA_INTERNAL_DEBUG(" $answer $response $result "); return ($result,$reterror); } @@ -265,7 +263,7 @@ sub caparesponse_check_list { my $type = $LONCAPA::CAPAresponse_args{'type'}; my $answerunit=$LONCAPA::CAPAresponse_args{'unit'}; &LONCAPA_INTERNAL_DEBUG("Got type :$type: answer unit :$answerunit:\n"); - + my $preprocess=$LONCAPA::CAPAresponse_args{'preprocess'}; $preprocess=~s/^\&//; @@ -309,9 +307,10 @@ sub caparesponse_check_list { my ($allowalgebra)=($LONCAPA::CAPAresponse_args{'allowalgebra'}=~/^(yes|1|on)$/i); if ($type eq 'float' || $type eq '') { #for numerical problems split off the unit - my ($part1,$part2); + my $part1; + my $part2; if ($allowalgebra) { - ($part1,$part2)=($responses->[0][-1]=~ /^(.*[^\s])\s+([^\s]+)$/); + ($part1,$part2)=($responses->[0][-1]=~ /^(.*[^\s])\s+([^\s]+)$/); } else { ($part1,$part2)=($responses->[0][-1]=~ /^([\d\.\,\s\$]*(?:(?:[xX\*]10[\^\*]*|[eE]*)[\+\-]*\d*)*(?:^|\S)\d+)([\$\s\w\^\*\/\(\)\+\-]*[^\d\.\s\,][\$\s\w\^\*\/\(\)\+\-]*)$/); } @@ -319,13 +318,11 @@ sub caparesponse_check_list { $responses->[0][-1]=$part1; $unit=&capa_formula_fix($part2); my $customunits=$LONCAPA::CAPAresponse_args{'customunits'}; - 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; - } + 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; } } } @@ -360,7 +357,7 @@ sub caparesponse_check_list { $appendunit='%'.$appendunit; } # Zero does not need a dimension - if (($element =~ /^[0\.]+$/) && ($unit!~/\w/) && ($answerunit=~/\w/)) { + if (($element==0) && ($unit!~/\w/) && ($answerunit=~/\w/)) { $appendunit=$answerunit; } # Do the math for the student if allowed @@ -1183,6 +1180,7 @@ sub middlename { $middlename = '' if $middlename eq ""; return $middlename; } + sub lastname { my $lastname = &EXT('environment.lastname');