--- loncom/homework/rankresponse.pm 2004/02/10 17:01:20 1.29 +++ loncom/homework/rankresponse.pm 2004/03/08 23:23:04 1.30 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # rank style response # -# $Id: rankresponse.pm,v 1.29 2004/02/10 17:01:20 albertel Exp $ +# $Id: rankresponse.pm,v 1.30 2004/03/08 23:23:04 albertel Exp $ # Copyright Michigan State University Board of Trustees # # This file is part of the LearningOnline Network with CAPA (LON-CAPA). @@ -28,7 +28,8 @@ package Apache::rankresponse; use strict; use HTML::Entities(); -use Apache::optionresponse; +use Apache::optionresponse(); +use Apache::lonlocal; BEGIN { &Apache::lonxml::register('Apache::rankresponse',('rankresponse')); @@ -43,6 +44,7 @@ sub start_rankresponse { push (@Apache::lonxml::namespace,'rankresponse'); my $id = &Apache::response::start_response($parstack,$safeeval); %Apache::hint::rank=(); + undef(%Apache::response::foilnames); if ($target eq 'meta') { $result=&Apache::response::meta_package_write('rankresponse'); } elsif ($target eq 'edit' ) { @@ -77,6 +79,7 @@ sub end_rankresponse { pop @Apache::lonxml::namespace; &Apache::lonxml::deregister('Apache::rankresponse', ('foilgroup','foil','conceptgroup')); + undef(%Apache::response::foilnames); return $result; } @@ -406,10 +409,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::rankresponse::conceptgroup && !&Apache::response::showallfoils() ) { push @{ $Apache::response::conceptgroup{'names'} }, $name;