--- loncom/homework/imagechoice.pm 2004/01/14 22:59:18 1.3
+++ loncom/homework/imagechoice.pm 2004/02/24 00:14:01 1.5
@@ -1,4 +1,4 @@
-# $Id: imagechoice.pm,v 1.3 2004/01/14 22:59:18 albertel Exp $
+# $Id: imagechoice.pm,v 1.5 2004/02/24 00:14:01 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -33,7 +33,10 @@ sub deletedata {
}
sub closewindow {
- my ($r,$output,$filename)=@_;
+ my ($r,$output,$filename,$needimage)=@_;
+ if ($needimage) {
+ $needimage="";
+ }
$r->print(<<"ENDSUBM");
Position Selected
-
+$needimage
ENDSUBM
@@ -55,25 +58,24 @@ sub storedata {
my (undef,@coords)=split(':',$ENV{"imagechoice.$id.coords"});
- my $output;
+ my ($output,$needimage);
if ($ENV{"imagechoice.$id.formwidth"}) {
$output.='opener.document.forms.'.$ENV{"imagechoice.$id.formname"}.'.'.$ENV{"imagechoice.$id.formwidth"}.'.value=document.pickimg.width;';
+ $needimage=1;
}
if ($ENV{"imagechoice.$id.formheight"}) {
$output.='opener.document.forms.'.$ENV{"imagechoice.$id.formname"}.'.'.$ENV{"imagechoice.$id.formheight"}.'.value=document.pickimg.height;';
+ $needimage=1;
}
- if ((defined($ENV{"imagechoice.$id.x"})) && (defined($ENV{"imagechoice.$id.y"})) &&
- ($type ne 'pairtwo') && ($type ne 'pairthree')) {
- my $output='';
+ if ($type eq 'point') {
+ my (undef,$x,$y)=split(':',$ENV{"imagechoice.$id.coords"});
if ($ENV{"imagechoice.$id.formx"}) {
- $output.='opener.document.forms.'.$ENV{"imagechoice.$id.formname"}.'.'.$ENV{"imagechoice.$id.formx"}.
- '.value='.$ENV{"imagechoice.$id.x"}.';';
+ $output.='opener.document.forms.'.$ENV{"imagechoice.$id.formname"}.'.'.$ENV{"imagechoice.$id.formx"}.'.value='.$x.';';
}
if ($ENV{"imagechoice.$id.formy"}) {
- $output.='opener.document.forms.'.$ENV{"imagechoice.$id.formname"}.'.'.$ENV{"imagechoice.$id.formy"}.
- '.value='.$ENV{"imagechoice.$id.y"}.';';
+ $output.='opener.document.forms.'.$ENV{"imagechoice.$id.formname"}.'.'.$ENV{"imagechoice.$id.formy"}.'.value='.$y.';';
}
} elsif ($type eq 'polygon' or $type eq 'box') {
my $coordstr;
@@ -83,35 +85,39 @@ sub storedata {
chop($coordstr);
$output.='opener.document.forms.'.$ENV{"imagechoice.$id.formname"}.'.'.$ENV{"imagechoice.$id.formcoord"}.'.value="'.$coordstr.'";';
}
+
&deletedata($id);
- &closewindow($r,$output,$filename);
+ &closewindow($r,$output,$filename,$needimage);
}
sub getcoord {
my ($r,$type,$filename,$id)=@_;
- my $heading='Position';
+ my $heading='Select Position on Image';
my $nextstage='';
if ($type eq 'box') {
my (undef,@coords)=split(':',$ENV{"imagechoice.$id.coords"});
my $step=scalar(@coords)/2;
if ($step == 0) {
- $heading='First Coordinate';
+ $heading='Select First Coordinate on Image';
#$nextstage='';
} elsif ($step == 1) {
- $heading='Second Coordinate';
+ $heading='Select Second Coordinate on Image';
#$nextstage='';
} else {
- $heading='Finish or Cancel';
+ $heading='Select Finish to store selection.';
$nextstage='';
}
} elsif ($type eq 'polygon') {
$heading='Enter Coordinate or click finish to close Polygon';
$nextstage='';
+ } elsif ($type eq 'point') {
+ $heading='Click to select a Coordinate or click Finish to store current selection.';
+ $nextstage='';
}
$r->print(<<"END");
-