version 1.16, 2000/12/04 21:53:07
|
version 1.21, 2000/12/19 23:22:22
|
Line 6 use strict;
|
Line 6 use strict;
|
use capa; |
use capa; |
|
|
sub BEGIN { |
sub BEGIN { |
&Apache::lonxml::register('Apache::caparesponse',('caparesponse')); |
&Apache::lonxml::register('Apache::caparesponse',('caparesponse','numericalresponse')); |
} |
} |
|
|
$Apache::caparesponse::result=''; |
$Apache::caparesponse::result=''; |
sub start_caparesponse { |
sub start_caparesponse { |
my ($target,$token,$parstack,$parser,$safeeval)=@_; |
my ($target,$token,$parstack,$parser,$safeeval)=@_; |
my $args =''; |
my $id = &Apache::response::start_response($parstack,$safeeval); |
if ( $#$parstack > -1 ) { $args=$$parstack[$#$parstack]; } |
|
my $id = &Apache::run::run("{$args;".'return $id}',$safeeval); |
|
if ($id eq '') { $id = $Apache::lonxml::curdepth; } |
|
push (@Apache::inputtags::response,$id); |
|
push (@Apache::inputtags::responselist,$id); |
|
return ''; |
return ''; |
#my $envkey; |
|
#foreach $envkey (sort keys %ENV) { |
|
# Apache::lonxml::debug("$envkey ---- $ENV{$envkey}<br>"); |
|
#} |
|
#Apache::lonxml::debug("\n<br>\nreal caparesponse<br>\n"); |
|
} |
} |
|
|
sub end_caparesponse { |
sub end_caparesponse { |
Line 33 sub end_caparesponse {
|
Line 23 sub end_caparesponse {
|
if ( defined $ENV{'form.submit'}) { |
if ( defined $ENV{'form.submit'}) { |
$Apache::caparesponse::result=''; |
$Apache::caparesponse::result=''; |
$safeeval->share_from('capa',['&caparesponse_capa_check_answer']); |
$safeeval->share_from('capa',['&caparesponse_capa_check_answer']); |
my $response = $ENV{'form.HWVAL'.$Apache::inputtags::curvalue}; |
my $response = $ENV{'form.HWVAL'.$Apache::inputtags::response['-1']}; |
$Apache::lonhomework::results{"resource.submission.$Apache::inputtags::part.$Apache::inputtags::response['-1']"}=$response; |
if ( $response =~ /[^\s]/) { |
&Apache::lonxml::debug("submitted a $response<br>\n"); |
#check_for_previous($response,$id,$response); |
&Apache::lonxml::debug($$parstack[$#$parstack] . "\n<br>"); |
$Apache::lonhomework::results{"resource.$Apache::inputtags::part.$Apache::inputtags::response['-1'].submission"}=$response; |
my $expression="&caparesponse_check('".$response."','". |
&Apache::lonxml::debug("submitted a $response<br>\n"); |
$$parstack[$#$parstack]. |
&Apache::lonxml::debug($$parstack[$#$parstack] . "\n<br>"); |
';my $tol="'.$Apache::inputtags::params{'tol'}.'"'. |
my $expression="&caparesponse_check('".$response."','". |
';my $sig="'.$Apache::inputtags::params{'sig'}.'"'. |
$$parstack[$#$parstack]. |
"');"; |
';my $tol="'.$Apache::inputtags::params{'tol'}.'"'. |
$result = &Apache::run::run($expression,$safeeval); |
';my $sig="'.$Apache::inputtags::params{'sig'}.'"'. |
my ($ad) = split /:/ , $result; |
"');"; |
$Apache::lonhomework::results{"resource.awarddetail.$Apache::inputtags::part.$Apache::inputtags::response['-1']"}=$ad; |
$result = &Apache::run::run($expression,$safeeval); |
&Apache::lonxml::debug("$expression"); |
my ($ad) = split /:/ , $result; |
&Apache::lonxml::debug("\n<br>result:$Apache::caparesponse::result:$result:$Apache::lonxml::curdepth<br>\n"); |
$Apache::lonhomework::results{"resource.$Apache::inputtags::part.$Apache::inputtags::response['-1'].awarddetail"}=$ad; |
|
&Apache::lonxml::debug("$expression"); |
|
&Apache::lonxml::debug("\n<br>result:$Apache::caparesponse::result:$result:$Apache::lonxml::curdepth<br>\n"); |
|
} |
} |
} |
} else { |
} else { |
$result .= "The correct answer is ".&Apache::run::run("{$$parstack['-1'];".'return $answer}',$safeeval)."\n"; |
#$result .= "The correct answer is ".&Apache::run::run("{$$parstack['-1'];".'return $answer}',$safeeval)."\n"; |
} |
} |
#Apache::lonxml::debug("\n<br>\nreal end caparesponse<br>\n"); |
#Apache::lonxml::debug("\n<br>\nreal end caparesponse<br>\n"); |
pop @Apache::inputtags::response; |
&Apache::response::end_response; |
return $result; |
return $result; |
} |
} |
|
|
|
sub start_numericalresponse { |
|
} |
|
|
|
sub end_numericalresponse { |
|
} |
|
|
1; |
1; |
__END__ |
__END__ |
|
|