Annotation of loncom/homework/caparesponse/caparesponse.pm, revision 1.19
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.12 albertel 14: my ($target,$token,$parstack,$parser,$safeeval)=@_;
1.19 ! albertel 15: my $id = &Apache::response::start_response($parstack,$safeeval);
1.13 albertel 16: return '';
1.3 albertel 17: }
18:
19: sub end_caparesponse {
1.7 albertel 20: my ($target,$token,$parstack,$parser,$safeeval,$style)=@_;
1.12 albertel 21: my $result = '';
1.16 albertel 22: if ( $target eq 'grade' ) {
23: if ( defined $ENV{'form.submit'}) {
24: $Apache::caparesponse::result='';
25: $safeeval->share_from('capa',['&caparesponse_capa_check_answer']);
1.19 ! albertel 26: my $response = $ENV{'form.HWVAL'.$Apache::inputtags::response['-1']};
1.18 albertel 27: if ( $response =~ /[^\s]/) {
1.19 ! albertel 28: #check_for_previous($response,$id,$response);
1.18 albertel 29: $Apache::lonhomework::results{"resource.submission.$Apache::inputtags::part.$Apache::inputtags::response['-1']"}=$response;
30: &Apache::lonxml::debug("submitted a $response<br>\n");
31: &Apache::lonxml::debug($$parstack[$#$parstack] . "\n<br>");
32: my $expression="&caparesponse_check('".$response."','".
33: $$parstack[$#$parstack].
34: ';my $tol="'.$Apache::inputtags::params{'tol'}.'"'.
35: ';my $sig="'.$Apache::inputtags::params{'sig'}.'"'.
36: "');";
37: $result = &Apache::run::run($expression,$safeeval);
38: my ($ad) = split /:/ , $result;
39: $Apache::lonhomework::results{"resource.awarddetail.$Apache::inputtags::part.$Apache::inputtags::response['-1']"}=$ad;
40: &Apache::lonxml::debug("$expression");
41: &Apache::lonxml::debug("\n<br>result:$Apache::caparesponse::result:$result:$Apache::lonxml::curdepth<br>\n");
42: }
1.16 albertel 43: }
1.8 albertel 44: } else {
1.17 albertel 45: #$result .= "The correct answer is ".&Apache::run::run("{$$parstack['-1'];".'return $answer}',$safeeval)."\n";
1.7 albertel 46: }
47: #Apache::lonxml::debug("\n<br>\nreal end caparesponse<br>\n");
1.19 ! albertel 48: &Apache::response::end_response;
1.16 albertel 49: return $result;
1.3 albertel 50: }
51:
1.1 albertel 52: 1;
1.3 albertel 53: __END__
54:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>