Annotation of loncom/homework/caparesponse/caparesponse.pm, revision 1.21
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 {
1.21 ! albertel 9: &Apache::lonxml::register('Apache::caparesponse',('caparesponse','numericalresponse'));
1.3 albertel 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.20 albertel 29: $Apache::lonhomework::results{"resource.$Apache::inputtags::part.$Apache::inputtags::response['-1'].submission"}=$response;
1.18 albertel 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;
1.20 albertel 39: $Apache::lonhomework::results{"resource.$Apache::inputtags::part.$Apache::inputtags::response['-1'].awarddetail"}=$ad;
1.18 albertel 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.21 ! albertel 50: }
! 51:
! 52: sub start_numericalresponse {
! 53: }
! 54:
! 55: sub end_numericalresponse {
1.3 albertel 56: }
57:
1.1 albertel 58: 1;
1.3 albertel 59: __END__
60:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>