--- loncom/homework/caparesponse/caparesponse.pm 2005/07/14 05:50:33 1.176 +++ loncom/homework/caparesponse/caparesponse.pm 2005/09/08 17:49:22 1.180 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # caparesponse definition # -# $Id: caparesponse.pm,v 1.176 2005/07/14 05:50:33 albertel Exp $ +# $Id: caparesponse.pm,v 1.180 2005/09/08 17:49:22 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -389,6 +389,7 @@ sub end_numericalresponse { if ($unit=~/\$/) { $fmt="\$".$fmt; $unit=~s/\$//g; } if ($unit=~/\,/) { $fmt="\,".$fmt; $unit=~s/\,//g; } $ans = &format_number($ans,$fmt,$target,$safeeval); + if ($fmt=~/\$/ && $unit!~/\$/) { $ans=~s/\$//; } } push(@fmt_ans,$ans); } @@ -421,7 +422,7 @@ sub end_numericalresponse { if ($sigline ne '') { $error=&mt('Computer\'s answer is incorrect ("[_1]"). It is likely that the tolerance range [_2] or significant figures [_3] need to be adjusted.',$response,$tolline,$sigline); } else { - $error=&mt('Computer\'s answer is incorrect ("[_1]"). It is likely that the tolerance range [_1] needs to be adjusted.',$response,$tolline); + $error=&mt('Computer\'s answer is incorrect ("[_1]"). It is likely that the tolerance range [_2] needs to be adjusted.',$response,$tolline); } } if ($ad ne 'EXACT_ANS' && $ad ne 'APPROX_ANS') { @@ -699,7 +700,7 @@ sub end_stringresponse { # $answer=$token->[2]->{'answer'}; # } ${$safeeval->varglob('LONCAPA::response')}=$response; - $result = &Apache::run::run('return $LONCAPA::response=~m'.$answer,$safeeval); + $result = &Apache::run::run('if ($LONCAPA::response=~m'.$answer.') { return 1; } else { return 0; }',$safeeval); &Apache::lonxml::debug("current $response"); &Apache::lonxml::debug("current $answer"); $ad = ($result) ? 'APPROX_ANS' : 'INCORRECT'; @@ -760,6 +761,10 @@ sub end_stringresponse { # foreach my $ans (@answers) { if ($target eq 'answer') { $result.=&Apache::response::answer_part('stringresponse',$answer); + if ($type eq 're') { + $result.=&Apache::response::answer_part('stringresponse', + $answerdisplay); + } } elsif ($target eq 'analyze') { push (@{ $Apache::lonhomework::analyze{"$part.$id.answer"} }, $answer);