--- loncom/homework/default_homework.lcpm 2004/03/12 16:55:35 1.70 +++ loncom/homework/default_homework.lcpm 2004/03/13 00:36:11 1.72 @@ -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.70 2004/03/12 16:55:35 albertel Exp $ +# $Id: default_homework.lcpm,v 1.72 2004/03/13 00:36:11 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -55,6 +55,9 @@ sub caparesponse_check { #type's definitons come from capaParser.h my $message=''; #remove leading and trailing whitespace + if (!defined($response)) { + $response=''; + } if ($response=~ /^\s|\s$/) { $response=~ s:^\s+|\s+$::g; $message .="Removed ws now :$response:\n"; @@ -109,11 +112,13 @@ sub caparesponse_check { } if (!defined($sig_ubound)) { $sig_ubound=$sig_lbound; } } + my $reterror=""; my $result = &caparesponse_capa_check_answer($response,$answer,$type, $tol_type,$tol, $sig_lbound,$sig_ubound, $ans_fmt,$unit,$calc,$id_list, - $points,$external::randomseed); + $points,$external::randomseed, + \$reterror); if ($result == '1') { $result='EXACT_ANS'; } elsif ($result == '2') { $result='APPROX_ANS'; } @@ -129,7 +134,7 @@ sub caparesponse_check { elsif ($result =='12') { $result='WANTED_NUMERIC'; } else {$result = "ERROR: Unknown Result:$result:$@:";} - return "$result:\nError $error:\nAnswer $answer:\nResponse $response:\n type-$type|$tol|$tol_type|$sig:$sig_lbound:$sig_ubound|$unit|\n$message$expr"; + return ("$result:\nRetError $reterror:\nError $error:\nAnswer $answer:\nResponse $response:\n type-$type|$tol|$tol_type|$sig:$sig_lbound:$sig_ubound|$unit|\n$message$expr",$reterror); } sub get_array_args { @@ -186,25 +191,29 @@ sub caparesponse_check_list { $unit=~s/\s//; my $i=0; my $awards=''; + my @msgs; for ($i=0; $i<@list;$i++) { + my $msg; $result.="trying answer :$list[$i]:\n"; my $thisanswer=$list[$i]; # $thisanswer=~ s/\\/\\\\/g; # $thisanswer =~ s/\'/\\\'/g; $result.="trying answer :$thisanswer:\n"; if ($unit eq '') { - $aresult=&caparesponse_check($thisanswer,$responselist[$i], - $expr); + ($aresult,$msg)=&caparesponse_check($thisanswer,$responselist[$i], + $expr); } else { - $aresult=&caparesponse_check($thisanswer,$responselist[$i]." $unit", - $expr); + ($aresult,$msg)=&caparesponse_check($thisanswer, + $responselist[$i]." $unit", + $expr); } my ($temp)=split /:/, $aresult; $awards.="$temp,"; $result.=$aresult; + push(@msgs,$msg); } chop $awards; - return "$awards:\n$result"; + return ("$awards:\n$result",@msgs); } sub tex {