--- loncom/homework/imageresponse.pm	2004/02/23 23:55:40	1.49
+++ loncom/homework/imageresponse.pm	2004/03/08 23:23:04	1.51
@@ -2,7 +2,7 @@
 # The LearningOnline Network with CAPA
 # image click response style
 #
-# $Id: imageresponse.pm,v 1.49 2004/02/23 23:55:40 albertel Exp $
+# $Id: imageresponse.pm,v 1.51 2004/03/08 23:23:04 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -31,10 +31,11 @@
 
 package Apache::imageresponse;
 use strict;
-use Image::Magick;
-use Apache::randomlylabel;
-use Apache::londefdef;
+use Image::Magick();
+use Apache::randomlylabel();
+use Apache::londefdef();
 use Apache::Constants qw(:common :http);
+use Apache::lonlocal;
 
 BEGIN {
     &Apache::lonxml::register('Apache::imageresponse',('imageresponse'));
@@ -49,6 +50,7 @@ sub start_imageresponse {
 			       'polygon','conceptgroup'));
     push (@Apache::lonxml::namespace,'imageresponse');
     my $id = &Apache::response::start_response($parstack,$safeeval);
+    undef(%Apache::response::foilnames);
     if ($target eq 'meta') {
 	$result=&Apache::response::meta_package_write('imageresponse');
     } elsif ($target eq 'analyze') {
@@ -65,6 +67,7 @@ sub end_imageresponse {
     &Apache::lonxml::deregister('Apache::imageresponse',('foilgroup','foil','text','image','rectangle','conceptgroup'));
     my $result;
     if ($target eq 'edit') { $result=&Apache::edit::end_table(); }
+    undef(%Apache::response::foilnames);
     return $result;
 }
 
@@ -215,7 +218,7 @@ sub displayfoils {
 sub clean_up_image {
     my ($image)=@_;
     if ($image =~ /\s*<img\s*/) {
-	($image) = ($image =~ /src\s*=\s*\"([^\"]+)\"/i);
+	($image) = ($image =~ /src\s*=\s*[\"\']([^\"\']+)[\"\']/i);
 	if ($image !~ /^http:/) {
 	    $image=&Apache::lonnet::hreflocation('',$image);
 	}
@@ -335,6 +338,9 @@ sub start_foil {
 	$target eq 'analyze') {
 	my $name = &Apache::lonxml::get_param('name',$parstack,$safeeval);
 	if ($name eq '') { $name=$Apache::lonxml::curdepth; }
+	if (defined($Apache::response::foilnames{$name})) {
+	    &Apache::lonxml::error(&mt("Foil name <b><tt>[_1]</tt></b> appears more than once. Foil names need to be unique.",$name));
+	}
 	if ( $Apache::imageresponse::conceptgroup
 	     && !&Apache::response::showallfoils()) {
 	    push(@{ $Apache::response::conceptgroup{'names'} }, $name);