[LON-CAPA-cvs] cvs: loncom /homework imageresponse.pm
ng
lon-capa-cvs@mail.lon-capa.org
Thu, 31 Jul 2003 20:38:12 -0000
ng Thu Jul 31 16:38:12 2003 EDT
Modified files:
/loncom/homework imageresponse.pm
Log:
Draws a red X at the spot where a user has clicked on an image.
Index: loncom/homework/imageresponse.pm
diff -u loncom/homework/imageresponse.pm:1.31 loncom/homework/imageresponse.pm:1.32
--- loncom/homework/imageresponse.pm:1.31 Mon Jun 9 18:42:49 2003
+++ loncom/homework/imageresponse.pm Thu Jul 31 16:38:12 2003
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# image click response style
#
-# $Id: imageresponse.pm,v 1.31 2003/06/09 22:42:49 albertel Exp $
+# $Id: imageresponse.pm,v 1.32 2003/07/31 20:38:12 ng Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -318,7 +318,35 @@
my $name = $Apache::imageresponse::curname;
if ($target eq 'web') {
my $image = &Apache::lonxml::endredirection;
- &Apache::lonxml::debug("out is $image");
+ &Apache::lonxml::debug("original image is $image");
+ my $id=$Apache::inputtags::response['-1'];
+ my $temp=1;
+ my $x=$ENV{"form.HWVAL_$id:$temp.x"};
+ my $y=$ENV{"form.HWVAL_$id:$temp.y"};
+ if (defined ($x) && defined ($y)) {
+ &Apache::lonxml::debug("x and y defined as $x,$y");
+ my $magickImage = Image::Magick->new;
+ my $currentImage = $magickImage->Read('/home/httpd/html'.$image);
+ my $length = 6;
+ $currentImage = $magickImage->Draw(primitive=>'line',
+ stroke=>'red',
+ points=>($x-$length).','.($y-$length).' '.
+ ($x+$length).','.($y+$length));
+ $currentImage = $magickImage->Draw(primitive=>'line',
+ stroke=>'red',
+ points=>($x-$length).','.($y+$length).' '.
+ ($x+$length).','.($y-$length));
+ binmode STDOUT;
+ my ($graphExt) = ($image =~ /.*\.(.*)$/);
+ &Apache::lonxml::debug("graph mime type $graphExt");
+ my $webImageName = "/prtspool/$ENV{'user.name'}_$ENV{'user.domain'}_".(time).'.'.$graphExt; #needs to be more random
+ my $newImageName = '/home/httpd'.$webImageName;
+
+ $currentImage = $magickImage->Write($graphExt.':'.$newImageName);
+ undef $magickImage;
+ $image = $webImageName;
+ }
+ &Apache::lonxml::debug("out image is $image");
if ( $Apache::imageresponse::conceptgroup
&& !&Apache::response::showallfoils()) {
$Apache::response::conceptgroup{"$name.image"} = $image;