--- loncom/homework/matchresponse.pm 2004/02/10 17:01:20 1.36 +++ loncom/homework/matchresponse.pm 2004/03/08 23:23:04 1.37 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Full matching style response # -# $Id: matchresponse.pm,v 1.36 2004/02/10 17:01:20 albertel Exp $ +# $Id: matchresponse.pm,v 1.37 2004/03/08 23:23:04 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -30,7 +30,8 @@ package Apache::matchresponse; use strict; use HTML::Entities(); use Math::Random(); -use Apache::optionresponse; +use Apache::optionresponse(); +use Apache::lonlocal; BEGIN { &Apache::lonxml::register('Apache::matchresponse',('matchresponse')); @@ -46,6 +47,7 @@ sub start_matchresponse { push (@Apache::lonxml::namespace,'matchresponse'); my $id = &Apache::response::start_response($parstack,$safeeval); %Apache::hint::match=(); + undef(%Apache::response::foilnames); if ($target eq 'meta') { $result=&Apache::response::meta_package_write('matchresponse'); } elsif ($target eq 'edit' ) { @@ -80,6 +82,7 @@ sub end_matchresponse { pop @Apache::lonxml::namespace; &Apache::lonxml::deregister('Apache::matchresponse', ('foilgroup','foil','conceptgroup')); + undef(%Apache::response::foilnames); return $result; } @@ -592,10 +595,14 @@ sub end_foil { my $value = &Apache::lonxml::get_param('value',$parstack,$safeeval); if ($value ne 'unused') { my $name = &Apache::lonxml::get_param('name',$parstack,$safeeval); - my $location =&Apache::lonxml::get_param('location',$parstack,$safeeval); &Apache::lonxml::debug("Got a name of :$name:"); if (!$name) { $name=$Apache::lonxml::curdepth; } &Apache::lonxml::debug("Using a name of :$name:"); + if (defined($Apache::response::foilnames{$name})) { + &Apache::lonxml::error(&mt("Foil name [_1] appears more than once. Foil names need to be unique.",$name)); + } + my $location =&Apache::lonxml::get_param('location',$parstack, + $safeeval); if ( $Apache::matchresponse::conceptgroup && !&Apache::response::showallfoils() ) { push @{ $Apache::response::conceptgroup{'names'} }, $name;