--- loncom/homework/imageresponse.pm 2007/09/25 23:47:59 1.87 +++ loncom/homework/imageresponse.pm 2007/09/25 23:58:32 1.88 @@ -2,7 +2,7 @@ # The LearningOnline Network with CAPA # image click response style # -# $Id: imageresponse.pm,v 1.87 2007/09/25 23:47:59 albertel Exp $ +# $Id: imageresponse.pm,v 1.88 2007/09/25 23:58:32 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -62,6 +62,16 @@ sub start_imageresponse { push (@{ $Apache::lonhomework::analyze{"parts"} },$part_id); push (@{ $Apache::lonhomework::analyze{"$part_id.bubble_lines"} }, 1); + } elsif ( $target eq 'edit' ) { + $result .= &Apache::edit::tag_start($target,$token). + &Apache::edit::text_arg('Max Number Of Shown Foils:', + 'max',$token,'4'). + &Apache::edit::end_row(). + &Apache::edit::start_spanning_row(); + } elsif ( $target eq 'modified' ) { + my $constructtag= + &Apache::edit::get_new_args($token,$parstack,$safeeval,'max'); + if ($constructtag) { $result = &Apache::edit::rebuild_tag($token); } } return $result; } @@ -105,27 +115,27 @@ 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; } + if (&Apache::response::showallfoils()) { $max=$count; } return ($count,$max); } sub whichfoils { my ($max)=@_; - if (!defined(@{ $Apache::response::foilgroup{'names'} })) { return; } + return if (!defined(@{ $Apache::response::foilgroup{'names'} })); my @names = @{ $Apache::response::foilgroup{'names'} }; - my @whichopt =(); + my @whichopt; while ((($#whichopt+1) < $max) && ($#names > -1)) { &Apache::lonxml::debug("Have $#whichopt max is $max"); my $aopt; -# if (&Apache::response::showallfoils()) { -# $aopt=0; -# } else { + if (&Apache::response::showallfoils()) { + $aopt=0; + } else { $aopt=int(&Math::Random::random_uniform() * ($#names+1)); -# } + } &Apache::lonxml::debug("From $#names elms, picking $aopt"); $aopt=splice(@names,$aopt,1); &Apache::lonxml::debug("Picked $aopt"); - push (@whichopt,$aopt); + push(@whichopt,$aopt); } return @whichopt; } @@ -280,7 +290,7 @@ sub format_prior_response { sub display_answers { my ($target,$whichopt)=@_; - my $result; + my $result=&Apache::response::answer_header('imageresponse'); foreach my $name (@$whichopt) { my $image=$Apache::response::foilgroup{"$name.image"}; &Apache::lonxml::debug("image is $image"); @@ -289,10 +299,9 @@ sub display_answers { } my $token=&prep_image($image,'answeronly',$name); - $result.=&Apache::response::answer_header('imageresponse'); $result.=&Apache::response::answer_part('imageresponse',"
\n"); - $result.=&Apache::response::answer_footer('imageresponse'); } + $result.=&Apache::response::answer_footer('imageresponse'); return $result; } @@ -482,7 +491,7 @@ sub start_foil { } $Apache::response::foilnames{$name}++; if ( $Apache::imageresponse::conceptgroup - #&& !&Apache::response::showallfoils() + && !&Apache::response::showallfoils() ) { push(@{ $Apache::response::conceptgroup{'names'} }, $name); } else { @@ -535,7 +544,7 @@ sub end_text { || $target eq 'answer') { my $name = $Apache::imageresponse::curname; if ( $Apache::imageresponse::conceptgroup - #&& !&Apache::response::showallfoils() + && !&Apache::response::showallfoils() ) { $Apache::response::conceptgroup{"$name.text"} = &Apache::lonxml::endredirection; } else { @@ -578,7 +587,7 @@ sub end_image { my $image = &Apache::lonxml::endredirection(); &Apache::lonxml::debug("original image is $image"); if ( $Apache::imageresponse::conceptgroup - #&& !&Apache::response::showallfoils() + && !&Apache::response::showallfoils() ) { $Apache::response::conceptgroup{"$name.image"} = $image; } else { @@ -587,7 +596,7 @@ sub end_image { } elsif ($target eq 'analyze') { my $image = &Apache::lonxml::endredirection(); if ( $Apache::imageresponse::conceptgroup - #&& !&Apache::response::showallfoils() + && !&Apache::response::showallfoils() ) { $Apache::response::conceptgroup{"$name.image"} = $image; } else { @@ -667,7 +676,7 @@ sub end_rectangle { $area=~s/\s//g; &Apache::lonxml::debug("out is $area for $name"); if ( $Apache::imageresponse::conceptgroup - #&& !&Apache::response::showallfoils() + && !&Apache::response::showallfoils() ) { push @{ $Apache::response::conceptgroup{"$name.area"} },"rectangle:$area"; } else { @@ -748,7 +757,7 @@ sub end_polygon { $area=~s/\s*//g; &Apache::lonxml::debug("out is $area for $name"); if ( $Apache::imageresponse::conceptgroup - #&& !&Apache::response::showallfoils() + && !&Apache::response::showallfoils() ) { push @{ $Apache::response::conceptgroup{"$name.area"} },"polygon:$area"; } else {