--- loncom/homework/imageresponse.pm 2003/11/11 00:25:24 1.41
+++ loncom/homework/imageresponse.pm 2003/11/11 00:39:33 1.42
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# image click response style
#
-# $Id: imageresponse.pm,v 1.41 2003/11/11 00:25:24 albertel Exp $
+# $Id: imageresponse.pm,v 1.42 2003/11/11 00:39:33 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -104,7 +104,7 @@ sub whichfoils {
}
sub prep_image {
- my ($image)=@_;
+ my ($image,$mode,$name)=@_;
my $part=$Apache::inputtags::part;
my $respid=$Apache::inputtags::response['-1'];
my $id=&Apache::loncommon::get_cgi_id();
@@ -131,6 +131,20 @@ sub prep_image {
join(':',(($x-$length),($y+$length),($x+$length),($y-$length),
"FF0000",($width)));
}
+ if ($mode eq 'answer') {
+ my $width = 1;
+ my $extrawidth = 2;
+ my @areas = @{ $Apache::response::foilgroup{"$name.area"} };
+ foreach my $area (@areas) {
+ my ($x1,$y1,$x2,$y2)=
+ ($area=~m/rectangle:\(([0-9]+),([0-9]+)\)\-\(([0-9]+),([0-9]+)\)/);
+ my $i=$x{"cgi.$id.BOXCOUNT"}++;
+ $x{"cgi.$id.BOX$i"}=join(':',($x1,$y1,$x2,$y2,"FFFFFF",
+ ($width+$extrawidth)));
+ $i=$x{"cgi.$id.BOXCOUNT"}++;
+ $x{"cgi.$id.BOX$i"}=join(':',($x1,$y1,$x2,$y2,"00FF00",$width));
+ }
+ }
&Apache::lonnet::appenv(%x);
return $id;
}
@@ -157,7 +171,7 @@ sub displayfoils {
if ($target eq 'tex') {
$result.=$Apache::response::foilgroup{"$name.image"}."\\vskip 0 mm \n";
} else {
- my $token=&prep_image($image);
+ my $token=&prep_image($image,'answer',$name);
$result.="
\n";
}
} else {