--- loncom/homework/imageresponse.pm 2003/06/09 22:42:49 1.31 +++ loncom/homework/imageresponse.pm 2003/07/31 20:38:12 1.32 @@ -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 @@ sub end_image { 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;