--- loncom/homework/imageresponse.pm 2004/02/24 18:57:43 1.50 +++ 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.50 2004/02/24 18:57:43 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; } @@ -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 [_1] appears more than once. Foil names need to be unique.",$name)); + } if ( $Apache::imageresponse::conceptgroup && !&Apache::response::showallfoils()) { push(@{ $Apache::response::conceptgroup{'names'} }, $name);