--- loncom/homework/imageresponse.pm	2006/03/09 01:33:57	1.75
+++ loncom/homework/imageresponse.pm	2006/11/06 11:56:23	1.79
@@ -2,7 +2,7 @@
 # The LearningOnline Network with CAPA
 # image click response style
 #
-# $Id: imageresponse.pm,v 1.75 2006/03/09 01:33:57 albertel Exp $
+# $Id: imageresponse.pm,v 1.79 2006/11/06 11:56:23 foxr Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -37,6 +37,9 @@ use Apache::londefdef();
 use Apache::Constants qw(:common :http);
 use Apache::lonlocal;
 use Apache::lonnet;
+use lib '/home/httpd/lib/perl/';
+use LONCAPA;
+ 
 
 BEGIN {
     &Apache::lonxml::register('Apache::imageresponse',('imageresponse'));
@@ -70,7 +73,8 @@ sub end_imageresponse {
     my $result;
     if ($target eq 'edit') {
 	$result=&Apache::edit::end_table();
-    } elsif ($target eq 'tex') {
+    } elsif ($target eq 'tex'
+	     && $Apache::lonhomework::type eq 'exam') {
 	$result=&Apache::inputtags::exam_score_line($target);
     }
 
@@ -130,7 +134,7 @@ sub prep_image {
     my $respid=$Apache::inputtags::response['-1'];
     my $id=&Apache::loncommon::get_cgi_id();
     my (%x,$i);
-    $x{"cgi.$id.BGIMG"}=&Apache::lonnet::escape($image);
+    $x{"cgi.$id.BGIMG"}=&escape($image);
     my ($x,$y)=split(/:/,$Apache::lonhomework::history{"resource.$part.$respid.submission"});
     #draws 2 xs on the image at the clicked location
     #one in white and then one in red on top of the one in white
@@ -347,7 +351,8 @@ sub end_foilgroup {
 	} elsif ( $target eq 'analyze') {
 	    &Apache::response::analyze_store_foilgroup(\@whichopt,
 						      ['text','image','area']);
-	} elsif ($target eq 'answer') {
+	} elsif ($target eq 'answer'
+		 && $env{'form.answer_output_mode'} ne 'tex') {
 	    $result=&display_answers($target,\@whichopt);
 	}
 
@@ -539,6 +544,7 @@ sub end_image {
 	    $graphinclude =~ s/^$commentline//;
 	} else {
 	    my ($path,$file) = &Apache::londefdef::get_eps_image($src);
+	    $file =~ s/\ /\_/g;
 	    my ($height_param,$width_param)=
 		&Apache::londefdef::image_size($src,0.3,$parstack,$safeeval);
 	    $graphinclude = '\graphicspath{{'.$path.'}}\includegraphics[width='.$width_param.' mm]{'.$file.'}';