version 1.10, 2006/04/13 18:49:29
|
version 1.14, 2008/03/12 02:46:53
|
Line 26 package Apache::imagechoice;
|
Line 26 package Apache::imagechoice;
|
use strict; |
use strict; |
use Apache::Constants qw(:common :http); |
use Apache::Constants qw(:common :http); |
use Apache::lonnet; |
use Apache::lonnet; |
|
use LONCAPA; |
|
|
|
|
sub deletedata { |
sub deletedata { |
my ($id)=@_; |
my ($id)=@_; |
Line 56 ENDSUBM
|
Line 58 ENDSUBM
|
my $end_page = |
my $end_page = |
&Apache::loncommon::end_page(); |
&Apache::loncommon::end_page(); |
|
|
my $js=<<"ENDSUBM"; |
$r->print(<<"ENDSUBM"); |
$start_page |
$start_page |
<h3>Position Selected</h3> |
<h3>Position Selected</h3> |
$display |
$display |
Line 122 sub getcoord {
|
Line 124 sub getcoord {
|
$heading='Select Second Coordinate on Image'; |
$heading='Select Second Coordinate on Image'; |
#$nextstage='<input type="hidden" name="type" value="pairthree" />'; |
#$nextstage='<input type="hidden" name="type" value="pairthree" />'; |
} else { |
} else { |
$heading='Select Finish to store selection.'; |
$heading='Select Finish to save selection.'; |
$nextstage='<input type="submit" name="finish" value="Finish" />'; |
$nextstage='<input type="submit" name="finish" value="Finish" />'; |
} |
} |
} elsif ($type eq 'polygon') { |
} elsif ($type eq 'polygon') { |
$heading='Enter Coordinate or click finish to close Polygon'; |
$heading='Enter Coordinate or click finish to close Polygon'; |
$nextstage='<input type="submit" name="finish" value="Finish" />'; |
$nextstage='<input type="submit" name="finish" value="Finish" />'; |
} elsif ($type eq 'point') { |
} elsif ($type eq 'point') { |
$heading='Click to select a Coordinate or click Finish to store current selection.'; |
$heading='Click to select a Coordinate or click Finish to save current selection.'; |
$nextstage='<input type="submit" name="finish" value="Finish" />'; |
$nextstage='<input type="submit" name="finish" value="Finish" />'; |
} |
} |
|
|
Line 163 sub savecoord {
|
Line 165 sub savecoord {
|
$data=join(':',($env{"imagechoice.$id.coords"}, |
$data=join(':',($env{"imagechoice.$id.coords"}, |
$env{"form.image.x"},$env{"form.image.y"})); |
$env{"form.image.x"},$env{"form.image.y"})); |
} |
} |
&Apache::lonnet::appenv("imagechoice.$id.coords"=>$data); |
&Apache::lonnet::appenv({"imagechoice.$id.coords"=>$data}); |
} |
} |
return int(scalar(split(':',$env{"imagechoice.$id.coords"}))/2); |
return int(scalar(split(':',$env{"imagechoice.$id.coords"}))/2); |
} |
} |
Line 235 sub drawimage {
|
Line 237 sub drawimage {
|
&drawX(\%data,$imid,$x,$y); |
&drawX(\%data,$imid,$x,$y); |
if ($type eq "polygon") { &drawPolygon(\%data,$id,$imid); } |
if ($type eq "polygon") { &drawPolygon(\%data,$id,$imid); } |
if ($type eq "box") { &drawBox(\%data,$id,$imid); } |
if ($type eq "box") { &drawBox(\%data,$id,$imid); } |
&Apache::lonnet::appenv(%data); |
&Apache::lonnet::appenv(\%data); |
return "/adm/randomlabel.png?token=$imid" |
return "/adm/randomlabel.png?token=$imid" |
} |
} |
|
|
Line 245 sub handler {
|
Line 247 sub handler {
|
$r->send_http_header; |
$r->send_http_header; |
my %data; |
my %data; |
my (undef,$id) = split(/=/,$ENV{'QUERY_STRING'}); |
my (undef,$id) = split(/=/,$ENV{'QUERY_STRING'}); |
my $filename = &Apache::lonnet::unescape($env{"imagechoice.$id.file"}); |
my $filename = &unescape($env{"imagechoice.$id.file"}); |
my $formname = $env{"imagechoice.$id.formname"}; |
my $formname = $env{"imagechoice.$id.formname"}; |
if ($env{'form.cancel'} eq 'Cancel') { |
if ($env{'form.cancel'} eq 'Cancel') { |
&deletedata($id); |
&deletedata($id); |