Annotation of loncom/homework/caparesponse/caparesponse.pm, revision 1.8
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='';
27: $safeeval->share('&caparesponse_capa_check_answer');
28: $safeeval->share('$Apache::caparesponse::result');
29: my $response = $ENV{'form.'.$ENV{'form.request.prefix'}.'HWVAL'.$Apache::inputtags::curvalue};
30: Apache::lonxml::debug("submitted a $response<br>\n");
31: Apache::lonxml::debug($$parstack[$#$parstack] . "\n<br>");
32: my $expression="caparesponse_check $response $$parstack[$#$parstack];";
33: &Apache::run::run($expression,$safeeval);
34:
35: &Apache::lonxml::debug("\n<br>result:$Apache::caparesponse::result:<br>\n");
1.8 ! albertel 36: } else {
! 37: #return "The correct answer is ".&Apache::run::run("{$$parstack['-1'];".'return $answer}',$safeeval)."\n";
1.7 albertel 38: }
39: #Apache::lonxml::debug("\n<br>\nreal end caparesponse<br>\n");
1.8 ! albertel 40: return '';
1.3 albertel 41: }
42:
1.1 albertel 43: 1;
1.3 albertel 44: __END__
45:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>