--- loncom/homework/default_homework.lcpm 2005/08/02 18:47:24 1.102 +++ loncom/homework/default_homework.lcpm 2005/11/16 22:18:22 1.104 @@ -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.102 2005/08/02 18:47:24 albertel Exp $ +# $Id: default_homework.lcpm,v 1.104 2005/11/16 22:18:22 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -193,7 +193,7 @@ sub caparesponse_check_list { my $type = $LONCAPA::CAPAresponse_args{'type'}; $result.="Got type :$type:\n"; if ($type ne '' && $#list > 0) { - (@responselist)=split /,/,$response; + (@responselist)=split(/,/,$response); } else { (@responselist)=($response); } @@ -217,18 +217,23 @@ sub caparesponse_check_list { $result.="trying answer :$list[$i]:\n"; my $thisanswer=$list[$i]; $result.="trying answer :$thisanswer:\n"; - if ($unit eq '') { - ($aresult,$msg)=&caparesponse_check($thisanswer,$responselist[$i]); + if (defined($list[$i])) { + if ($unit eq '') { + ($aresult,$msg)=&caparesponse_check($thisanswer, + $responselist[$i]); + } else { + ($aresult,$msg)=&caparesponse_check($thisanswer, + $responselist[$i]." $unit"); + } } else { - ($aresult,$msg)=&caparesponse_check($thisanswer, - $responselist[$i]." $unit"); + $aresult='ERROR'; } - my ($temp)=split /:/, $aresult; + my ($temp)=split(/:/, $aresult); $awards.="$temp,"; $result.=$aresult; push(@msgs,$msg); } - chop $awards; + chop($awards); return ("$awards:\n$result",@msgs); } @@ -451,14 +456,14 @@ sub random_negative_binomial { return @retArray; } -sub abs { abs(shift) } -sub sin { sin(shift) } -sub cos { cos(shift) } -sub exp { exp(shift) } -sub int { int(shift) } -sub log { log(shift) } -sub atan2 { atan2($_[0],$_[1]) } -sub sqrt { sqrt(shift) } +sub abs { CORE::abs(shift) } +sub sin { CORE::sin(shift) } +sub cos { CORE::cos(shift) } +sub exp { CORE::exp(shift) } +sub int { CORE::int(shift) } +sub log { CORE::log(shift) } +sub atan2 { CORE::atan2($_[0],$_[1]) } +sub sqrt { CORE::sqrt(shift) } sub tan { CORE::sin($_[0]) / CORE::cos($_[0]) } #sub atan { atan2($_[0], 1); }