--- loncom/homework/rankresponse.pm 2003/11/15 06:28:02 1.27 +++ loncom/homework/rankresponse.pm 2004/04/05 19:52:25 1.32 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # rank style response # -# $Id: rankresponse.pm,v 1.27 2003/11/15 06:28:02 albertel Exp $ +# $Id: rankresponse.pm,v 1.32 2004/04/05 19:52:25 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; } @@ -191,7 +194,7 @@ sub grade_response { if (!defined($ENV{'form.submitted'})) { return; } my %responsehash; my %grade; - my ($temp,$right,$wrong,$ignored)=(0,0,0,0); + my ($temp,$right,$wrong,$ignored)=(1,0,0,0); my @correctorder=&get_correct_order($tol,@whichfoils); foreach my $name (@whichfoils) { my $response = &Apache::response::getresponse($temp); @@ -256,7 +259,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"}; @@ -296,7 +299,7 @@ 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 -5 mm\begin{enumerate}\item[\textbf{'.$internal_counter.'}.]\parbox{\textwidth - 5 mm}{\vskip 2 mm '.&Apache::optionresponse::bubbles(\@alp,\@whichopt).'}\end{enumerate} \vskip -5 mm \strut '; $internal_counter++; } else { $result.=' \vskip 0mm \framebox[5 mm][s]{\tiny\strut} '.$text."\n"; @@ -406,10 +409,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;