--- loncom/homework/rankresponse.pm 2004/02/09 19:38:00 1.28 +++ loncom/homework/rankresponse.pm 2004/08/25 19:38:58 1.35 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # rank style response # -# $Id: rankresponse.pm,v 1.28 2004/02/09 19:38:00 albertel Exp $ +# $Id: rankresponse.pm,v 1.35 2004/08/25 19:38:58 sakharuk 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; } @@ -86,7 +89,7 @@ sub start_foilgroup { my $result; %Apache::response::foilgroup=(); $Apache::rankresponse::conceptgroup=0; - &Apache::response::setrandomnumber(); + &Apache::response::pushrandomnumber(); return $result; } @@ -115,6 +118,7 @@ sub end_foilgroup { } elsif ($target eq 'edit') { $result=&Apache::edit::end_table(); } + &Apache::response::poprandomnumber(); return $result; } @@ -256,7 +260,7 @@ sub displayfoils { } } else { my $i = 0; - my $temp=0; + my $temp=1; my $id=$Apache::inputtags::response[-1]; my $part=$Apache::inputtags::part; my $lastresponse=$Apache::lonhomework::history{"resource.$part.$id.submission"}; @@ -295,8 +299,8 @@ sub displayfoils { } } else { if ($Apache::lonhomework::type eq 'exam') { - $result.='\vskip 0 mm '.$text.' \vskip -3 mm '."\n"; - $result.='\vskip -5 mm\begin{enumerate}\item[\textbf{'.$internal_counter.'}.]\parbox{\textwidth - 5 mm}{'.&Apache::optionresponse::bubbles(\@alp,\@whichopt).'}\end{enumerate} \vskip -5 mm \strut '; + $result.='\vskip 0 mm '.$text.' \vskip 0 mm '."\n"; + $result.='\vskip -1 mm\noindent\begin{enumerate}\item[\textbf{'.$internal_counter.'}.]'.&Apache::optionresponse::bubbles(\@alp,\@whichopt,'rankresponce').'\end{enumerate} \vskip -8 mm \strut '; $internal_counter++; } else { $result.=' \vskip 0mm \framebox[5 mm][s]{\tiny\strut} '.$text."\n"; @@ -406,10 +410,15 @@ 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)); + } + $Apache::response::foilnames{$name}++; + my $location =&Apache::lonxml::get_param('location',$parstack, + $safeeval); if ( $Apache::rankresponse::conceptgroup && !&Apache::response::showallfoils() ) { push @{ $Apache::response::conceptgroup{'names'} }, $name;