--- loncom/homework/imageresponse.pm 2002/02/04 17:30:53 1.17 +++ loncom/homework/imageresponse.pm 2002/05/03 20:44:46 1.18 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # image click response style # -# $Id: imageresponse.pm,v 1.17 2002/02/04 17:30:53 albertel Exp $ +# $Id: imageresponse.pm,v 1.18 2002/05/03 20:44:46 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -69,6 +69,7 @@ sub getfoilcounts { my $max = &Apache::lonxml::get_param('max',$parstack,$safeeval,'-2'); # +1 since instructors will count from 1 my $count = $#{ $Apache::response::foilgroup{'names'} }+1; + if (&Apache::response::showallfoils()) { $max=$count; } return ($count,$max); } @@ -79,7 +80,12 @@ sub whichfoils { my @whichopt =(); while ((($#whichopt+1) < $max) && ($#names > -1)) { &Apache::lonxml::debug("Have $#whichopt max is $max"); - my $aopt=int(rand($#names+1)); + my $aopt; + if (&Apache::response::showallfoils()) { + $aopt=0; + } else { + $aopt=int(rand($#names+1)); + } &Apache::lonxml::debug("From $#names elms, picking $aopt"); $aopt=splice(@names,$aopt,1); &Apache::lonxml::debug("Picked $aopt"); @@ -200,7 +206,8 @@ sub start_foil { if ($target eq 'web' || $target eq 'grade') { my $name = &Apache::lonxml::get_param('name',$parstack,$safeeval); if ($name eq '') { $name=$Apache::lonxml::curdepth; } - if ( $Apache::imageresponse::conceptgroup ) { + if ( $Apache::imageresponse::conceptgroup + && !&Apache::response::showallfoils()) { push(@{ $Apache::response::conceptgroup{'names'} }, $name); } else { push(@{ $Apache::response::foilgroup{'names'} }, $name); @@ -225,7 +232,8 @@ sub end_text { my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; if ($target eq 'web') { my $name = $Apache::imageresponse::curname; - if ( $Apache::imageresponse::conceptgroup ) { + if ( $Apache::imageresponse::conceptgroup + && !&Apache::response::showallfoils() ) { $Apache::response::conceptgroup{"$name.text"} = &Apache::lonxml::endredirection; } else { $Apache::response::foilgroup{"$name.text"} = &Apache::lonxml::endredirection; @@ -246,7 +254,8 @@ sub end_image { my $name = $Apache::imageresponse::curname; my $image = &Apache::lonxml::endredirection; &Apache::lonxml::debug("out is $image"); - if ( $Apache::imageresponse::conceptgroup ) { + if ( $Apache::imageresponse::conceptgroup + && !&Apache::response::showallfoils()) { $Apache::response::conceptgroup{"$name.image"} = $image; } else { $Apache::response::foilgroup{"$name.image"} = $image; @@ -284,7 +293,8 @@ sub end_rectangle { my $name = $Apache::imageresponse::curname; my $area = &Apache::lonxml::endredirection; &Apache::lonxml::debug("out is $area for $name"); - if ( $Apache::imageresponse::conceptgroup ) { + if ( $Apache::imageresponse::conceptgroup + && !&Apache::response::showallfoils()) { push @{ $Apache::response::conceptgroup{"$name.area"} },"rectangle:$area"; } else { push @{ $Apache::response::foilgroup{"$name.area"} },"rectangle:$area";