--- loncom/homework/default_homework.lcpm 2004/02/18 22:49:32 1.69 +++ loncom/homework/default_homework.lcpm 2004/03/12 21:06:19 1.71 @@ -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.69 2004/02/18 22:49:32 albertel Exp $ +# $Id: default_homework.lcpm,v 1.71 2004/03/12 21:06:19 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -44,7 +44,7 @@ sub caparesponse_check { #not to be used: $ans_fmt my ($type,$tol,$sig,$ans_fmt,$unit,$calc,$samples) = eval $_[2]. - ';return ($type,$tol,$sig,$ans_fmt,$unit,$calc,$samples);'; + ';return ($__LC__type,$__LC__tol,$__LC__sig,$__LC__ans_fmt,$__LC__unit,$__LC__calc,$__LC__samples);'; my $tol_type=''; # gets it's value from whether tol has a % or not done my $sig_lbound=''; #done @@ -109,11 +109,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 +131,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 { @@ -165,7 +167,8 @@ sub caparesponse_check_list { my $answers=join(':',@list); $result.="Got response :$answers:\n"; my @responselist; - my $type =eval $expr.';return $type;'; + my $type =eval $expr.';return $__LC__type;'; + $result.="Got type :$type:\n"; if ($type ne '' && $#list > 0) { (@responselist)=split /,/,$response; } else { @@ -185,25 +188,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 {