Annotation of loncom/homework/caparesponse/caparesponse.pm, revision 1.11
1.3 albertel 1: # The LearningOnline Network with CAPA
2: # caparesponse definition
3:
4: package Apache::caparesponse;
5: use strict;
1.4 albertel 6: use capa;
1.3 albertel 7:
8: sub BEGIN {
9: &Apache::lonxml::register('Apache::caparesponse',('caparesponse'));
10: }
11:
1.7 albertel 12: $Apache::caparesponse::result='';
1.3 albertel 13: sub start_caparesponse {
1.7 albertel 14: my $envkey;
15:
1.8 albertel 16: #foreach $envkey (sort keys %ENV) {
17: # Apache::lonxml::debug("$envkey ---- $ENV{$envkey}<br>");
18: #}
1.7 albertel 19:
1.8 albertel 20: #Apache::lonxml::debug("\n<br>\nreal caparesponse<br>\n");
1.3 albertel 21: }
22:
23: sub end_caparesponse {
1.7 albertel 24: my ($target,$token,$parstack,$parser,$safeeval,$style)=@_;
25: if ( defined $ENV{'form.'.$ENV{'form.request.prefix'}.'submit'}) {
26: $Apache::caparesponse::result='';
1.11 ! albertel 27: $safeeval->share_from('capa',['&caparesponse_capa_check_answer']);
1.7 albertel 28: my $response = $ENV{'form.'.$ENV{'form.request.prefix'}.'HWVAL'.$Apache::inputtags::curvalue};
1.11 ! albertel 29: &Apache::lonxml::debug("submitted a $response<br>\n");
! 30: &Apache::lonxml::debug($$parstack[$#$parstack] . "\n<br>");
! 31: my $expression="&caparesponse_check('".$response."','".$$parstack[$#$parstack]."');";
! 32: my $result = &Apache::run::run($expression,$safeeval);
1.7 albertel 33:
1.11 ! albertel 34: &Apache::lonxml::debug("\n<br>result:$Apache::caparesponse::result:$result<br>\n");
1.8 albertel 35: } else {
36: #return "The correct answer is ".&Apache::run::run("{$$parstack['-1'];".'return $answer}',$safeeval)."\n";
1.7 albertel 37: }
38: #Apache::lonxml::debug("\n<br>\nreal end caparesponse<br>\n");
1.8 albertel 39: return '';
1.3 albertel 40: }
41:
1.1 albertel 42: 1;
1.3 albertel 43: __END__
44:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>