--- loncom/homework/imageresponse.pm 2003/11/11 00:25:24 1.41 +++ loncom/homework/imageresponse.pm 2004/01/15 22:25:31 1.42.2.1 @@ -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.2.1 2004/01/15 22:25:31 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 { @@ -445,7 +459,11 @@ sub end_image { my $filename = "/home/httpd/prtspool/$ENV{'user.name'}_$ENV{'user.domain'}_printout.dat"; $temp_file = Apache::File->new('>>'.$filename); print $temp_file "$src\n"; - $Apache::response::foilgroup{"$name.image"} ='\vskip 0 mm \graphicspath{{/home/httpd/prtspool/}}\includegraphics[width='.$width_param.' mm]{'.$file.'} '; + $newsrc=~s/\/home\/httpd\/html\/res//; + $newsrc=~s/\/home\/([^\/]*)\/public_html\//\/$1\//; + $newsrc=~s/\/\.\//\//; + $newsrc=~s/\/([^\/]+)\.(ps|eps)/\//; + $Apache::response::foilgroup{"$name.image"} ='\vskip 0 mm \graphicspath{{/home/httpd/prtspool'.$newsrc.'}}\includegraphics[width='.$width_param.' mm]{'.$file.'} '; } } return $result;