--- loncom/homework/hint.pm 2004/08/24 15:56:13 1.55 +++ loncom/homework/hint.pm 2005/04/07 06:56:21 1.59 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # implements the tags that control the hints # -# $Id: hint.pm,v 1.55 2004/08/24 15:56:13 albertel Exp $ +# $Id: hint.pm,v 1.59 2005/04/07 06:56:21 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -29,7 +29,7 @@ package Apache::hinttags; use strict; -use Apache::lonnet(); +use Apache::lonnet; use capa; use Apache::lonlocal; @@ -54,7 +54,7 @@ sub start_hintgroup { $Apache::lonhomework::history{"resource.$id.solved"}; my $showoncorrect=lc(&Apache::lonxml::get_param('showoncorrect',$parstack,$safeeval)); &Apache::lonxml::debug("onc orrect $showoncorrect, $gradestatus"); - if ( ($showoncorrect ne 'yes' && $gradestatus =~ /^correct/) || + if ( ($showoncorrect ne 'yes' && &Apache::response::show_answer()) || ( $numtries < $hinttries) ) { &Apache::lonxml::debug("Grabbin all"); &Apache::lonxml::get_all_text("/hintgroup",$parser); @@ -64,7 +64,7 @@ sub start_hintgroup { $result .= '\keephidden{'; } elsif ($target eq 'edit') { $result.=&Apache::edit::tag_start($target,$token); - $result.=&Apache::edit::select_arg('Show hint even if problem Correct:','showoncorrect',[['no',&mt('No')],['yes',&mt('Yes')]]); + $result.=&Apache::edit::select_arg('Show hint even if problem Correct:','showoncorrect',[['no',&mt('No')],['yes',&mt('Yes')]],$token); $result.=&Apache::edit::end_row().&Apache::edit::start_spanning_row(); } elsif ($target eq 'modified') { my $constructtag=&Apache::edit::get_new_args($token,$parstack,$safeeval,'showoncorrect'); @@ -267,7 +267,14 @@ sub end_stringhint { my ($ad,$msg); if ($type eq 're' ) { ${$safeeval->varglob('LONCAPA::response')}=$response; - $result = &Apache::run::run('return $LONCAPA::response=~m'.$answer,$safeeval); + my $compare='='; + if ($answer=~/^\s*NOT\s*/) { + $answer=~s/^\s*NOT\s*//; + $compare='!'; + } + my $test='$LONCAPA::response'.$compare.'~m'.$answer; + &Apache::lonxml::debug("test $test"); + $result = &Apache::run::run("return $test",$safeeval); &Apache::lonxml::debug("current $response"); &Apache::lonxml::debug("current $answer"); $ad = ($result) ? 'APPROX_ANS' : 'INCORRECT';