version 1.52, 2004/03/16 22:00:51
|
version 1.59, 2005/04/07 06:56:21
|
Line 31 package Apache::hinttags;
|
Line 31 package Apache::hinttags;
|
use strict; |
use strict; |
use Apache::lonnet; |
use Apache::lonnet; |
use capa; |
use capa; |
|
use Apache::lonlocal; |
|
|
BEGIN { |
BEGIN { |
&Apache::lonxml::register('Apache::hinttags',('hintgroup','hintpart','numericalhint','stringhint','formulahint','optionhint','radiobuttonhint')); |
&Apache::lonxml::register('Apache::hinttags',('hintgroup','hintpart','numericalhint','stringhint','formulahint','optionhint','radiobuttonhint')); |
Line 49 sub start_hintgroup {
|
Line 50 sub start_hintgroup {
|
if ( $numtries eq '') { $numtries = 0; } |
if ( $numtries eq '') { $numtries = 0; } |
my $hinttries=&Apache::response::get_response_param($id,"hinttries",1); |
my $hinttries=&Apache::response::get_response_param($id,"hinttries",1); |
&Apache::lonxml::debug("found :$id:$numtries:$hinttries:"); |
&Apache::lonxml::debug("found :$id:$numtries:$hinttries:"); |
my $gradestatus=$Apache::lonhomework::history{"resource.$id.solved"}; |
my $gradestatus= |
if ( $numtries < $hinttries || $gradestatus =~ /^correct/) { |
$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' && &Apache::response::show_answer()) || |
|
( $numtries < $hinttries) ) { |
|
&Apache::lonxml::debug("Grabbin all"); |
&Apache::lonxml::get_all_text("/hintgroup",$parser); |
&Apache::lonxml::get_all_text("/hintgroup",$parser); |
} |
} |
&Apache::lonxml::startredirection; |
&Apache::lonxml::startredirection; |
} elsif ($target eq 'tex') { |
} elsif ($target eq 'tex') { |
$result .= '\keephidden{'; |
$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')]],$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'); |
|
if ($constructtag) { |
|
$result =&Apache::edit::rebuild_tag($token); |
|
$result.=&Apache::edit::handle_insert(); |
|
} |
} |
} |
@Apache::hint::which=(); |
@Apache::hint::which=(); |
return $result; |
return $result; |
Line 151 sub end_numericalhint {
|
Line 167 sub end_numericalhint {
|
my $response = $Apache::lonhomework::history{ |
my $response = $Apache::lonhomework::history{ |
"resource.$partid.$submitid.submission"}; |
"resource.$partid.$submitid.submission"}; |
&Apache::lonxml::debug("hintgroup is using $response<br />\n"); |
&Apache::lonxml::debug("hintgroup is using $response<br />\n"); |
my $hideunit=&Apache::response::get_response_param($submitid.'_'.$id, |
my $hideunit=&Apache::response::get_response_param($partid.'_'.$submitid,'turnoffunit'); |
'turnoffunit'); |
|
my $args_ref= \%{$safeeval->varglob('LONCAPA::CAPAresponse_args')}; |
my $args_ref= \%{$safeeval->varglob('LONCAPA::CAPAresponse_args')}; |
$$args_ref{'response'}=$response; |
$$args_ref{'response'}=$response; |
#need to get all possible parms |
#need to get all possible parms |
Line 252 sub end_stringhint {
|
Line 267 sub end_stringhint {
|
my ($ad,$msg); |
my ($ad,$msg); |
if ($type eq 're' ) { |
if ($type eq 're' ) { |
${$safeeval->varglob('LONCAPA::response')}=$response; |
${$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 $response"); |
&Apache::lonxml::debug("current $answer"); |
&Apache::lonxml::debug("current $answer"); |
$ad = ($result) ? 'APPROX_ANS' : 'INCORRECT'; |
$ad = ($result) ? 'APPROX_ANS' : 'INCORRECT'; |