1: # The LearningOnline Network with CAPA
2: # iimage click response style
3:
4: package Apache::imageresponse;
5: use strict;
6:
7: sub BEGIN {
8: &Apache::lonxml::register('Apache::imageresponse',('imageresponse'));
9: }
10:
11: sub start_imageresponse {
12: my ($target,$token,$parstack,$parser,$safeeval,$style)=@_;
13: #when in a radiobutton response use these
14: &Apache::lonxml::register('Apache::imageresponse',('foilgroup','foil','text','image','rectangle'));
15: my $id = &Apache::response::start_response($parstack,$safeeval);
16: return '';
17: }
18:
19: sub end_imageresponse {
20: &Apache::response::end_response;
21: return '';
22: }
23:
24: %Apache::response::foilgroup={};
25: sub start_foilgroup {
26: %Apache::response::foilgroup={};
27: return '';
28: }
29:
30: sub setrandomnumber {
31: my $rndseed=&Apache::lonnet::rndseed();
32: $rndseed=unpack("%32i",$rndseed);
33: $rndseed=$rndseed
34: +&Apache::lonnet::numval($Apache::inputtags::part)
35: +&Apache::lonnet::numval($Apache::inputtags::response['-1']);
36: srand($rndseed);
37: return '';
38: }
39:
40: sub end_foilgroup {
41: my ($target,$token,$parstack,$parser,$safeeval,$style)=@_;
42:
43: }
44:
45: sub start_conceptgroup {
46: }
47:
48: sub end_conceptgroup {
49: }
50:
51: $Apache::imageresponse::curname='';
52: sub start_foil {
53: my ($target,$token,$parstack,$parser,$safeeval,$style)=@_;
54: if ($target eq 'web' || $target eq 'grade') {
55: my $args ='';
56: if ( $#$parstack > -1 ) { $args=$$parstack[$#$parstack]; }
57: my $name = &Apache::run::run("{$args;".'return $name}',$safeeval);
58: push @{ $Apache::response::foilgroup{'names'} }, $name;
59: $Apache::imageresponse::curname=$name;
60: }
61: return '';
62: }
63:
64: sub end_foil {
65: my ($target,$token,$parstack,$parser,$safeeval,$style)=@_;
66: return '';
67: }
68:
69: sub start_text {
70: my ($target,$token,$parstack,$parser,$safeeval,$style)=@_;
71: if ($target eq 'web') {
72: $Apache::lonxml::redirection--;
73: }
74: return '';
75: }
76:
77: sub end_text {
78: my ($target,$token,$parstack,$parser,$safeeval,$style)=@_;
79: if ($target eq 'web') {
80: my $name = $Apache::imageresponse::curname;
81: $Apache::response::foilgroup{"$name.text"} = $Apache::lonxml::outputstack;
82: if ($target eq 'web' ) {
83: $Apache::lonxml::redirection++;
84: if ($Apache::lonxml::redirection == 1) {
85: $Apache::lonxml::outputstack='';
86: }
87: }
88: }
89: return '';
90: }
91:
92: sub start_image {
93: my ($target,$token,$parstack,$parser,$safeeval,$style)=@_;
94:
95: }
96:
97: sub end_image {
98: my ($target,$token,$parstack,$parser,$safeeval,$style)=@_;
99: }
100:
101: sub start_rectangle {
102: my ($target,$token,$parstack,$parser,$safeeval,$style)=@_;
103: }
104:
105: sub end_rectangle {
106: my ($target,$token,$parstack,$parser,$safeeval,$style)=@_;
107: }
108: 1;
109: __END__
110:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>