--- loncom/homework/imageresponse.pm 2003/09/24 19:20:58 1.36 +++ loncom/homework/imageresponse.pm 2003/10/27 19:27:09 1.37 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # image click response style # -# $Id: imageresponse.pm,v 1.36 2003/09/24 19:20:58 albertel Exp $ +# $Id: imageresponse.pm,v 1.37 2003/10/27 19:27:09 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -25,8 +25,6 @@ # # http://www.lon-capa.org/ # -# July,August 2003 H. K. Ng -# #FIXME LATER assumes multiple possible submissions but only one is possible #currently @@ -49,6 +47,9 @@ sub start_imageresponse { my $id = &Apache::response::start_response($parstack,$safeeval); if ($target eq 'meta') { $result=&Apache::response::meta_package_write('imageresponse'); + } elsif ($target eq 'analyze') { + my $part_id="$Apache::inputtags::part.$id"; + push (@{ $Apache::lonhomework::analyze{"parts"} },$part_id); } return $result; } @@ -183,7 +184,10 @@ sub end_foilgroup { $result=&displayfoils($target,@whichopt); } elsif ($target eq 'grade') { if ( defined $ENV{'form.submitted'}) { &gradefoils(@whichopt); } - } + } elsif ( $target eq 'analyze') { + &Apache::response::analyze_store_foilgroup(\@whichopt, + ['text','image','area']); + } } elsif ($target eq 'edit') { $result=&Apache::edit::end_table(); } @@ -200,21 +204,12 @@ sub end_conceptgroup { my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; $Apache::imageresponse::conceptgroup=0; my $result; - if ($target eq 'web' || $target eq 'grade' || $target eq 'tex') { - if (defined(@{ $Apache::response::conceptgroup{'names'} })) { - my @names = @{ $Apache::response::conceptgroup{'names'} }; - my $pick=int(&Math::Random::random_uniform() * ($#names+1)); - my $name=$names[$pick]; - if (defined(@{ $Apache::response::conceptgroup{"$name.area"} })) { - push @{ $Apache::response::foilgroup{'names'} }, $name; - $Apache::response::foilgroup{"$name.text"} = $Apache::response::conceptgroup{"$name.text"}; - $Apache::response::foilgroup{"$name.image"} = $Apache::response::conceptgroup{"$name.image"}; - push(@{ $Apache::response::foilgroup{"$name.area"} }, @{ $Apache::response::conceptgroup{"$name.area"} }); - my $concept = &Apache::lonxml::get_param('concept',$parstack,$safeeval); - $Apache::response::foilgroup{"$name.concept"} = $concept; - &Apache::lonxml::debug("Selecting $name in $concept"); - } - } + if ($target eq 'web' || $target eq 'grade' || $target eq 'tex' || + $target eq 'analyze') { + &Apache::response::pick_foil_for_concept($target, + ['area','text','image'], + \%Apache::hint::image, + $parstack,$safeeval); } elsif ($target eq 'edit') { $result=&Apache::edit::end_table(); } @@ -234,7 +229,8 @@ sub insert_foil { $Apache::imageresponse::curname=''; sub start_foil { my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; - if ($target eq 'web' || $target eq 'grade' || $target eq 'tex') { + if ($target eq 'web' || $target eq 'grade' || $target eq 'tex' || + $target eq 'analyze') { my $name = &Apache::lonxml::get_param('name',$parstack,$safeeval); if ($name eq '') { $name=$Apache::lonxml::curdepth; } if ( $Apache::imageresponse::conceptgroup @@ -260,7 +256,7 @@ sub end_foil { sub start_text { my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; my $result=''; - if ($target eq 'web' || $target eq 'tex') { + if ($target eq 'web' || $target eq 'tex' || $target eq 'analyze') { &Apache::lonxml::startredirection; } elsif ($target eq 'edit') { my $descr=&Apache::lonxml::get_all_text('/text',$parser); @@ -278,7 +274,7 @@ sub start_text { sub end_text { my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; my $result; - if ($target eq 'web' || $target eq 'tex') { + if ($target eq 'web' || $target eq 'tex' || $target eq 'analyze') { my $name = $Apache::imageresponse::curname; if ( $Apache::imageresponse::conceptgroup && !&Apache::response::showallfoils() ) { @@ -295,7 +291,7 @@ sub end_text { sub start_image { my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; my $result=''; - if ($target eq 'web' || $target eq 'tex') { + if ($target eq 'web' || $target eq 'tex' || $target eq 'analyze') { &Apache::lonxml::startredirection; } elsif ($target eq 'edit') { my $bgimg=&Apache::lonxml::get_all_text('/image',$parser); @@ -355,6 +351,14 @@ sub end_image { if ( $Apache::imageresponse::conceptgroup && !&Apache::response::showallfoils()) { $Apache::response::conceptgroup{"$name.image"} = $image; + } else { + $Apache::response::foilgroup{"$name.image"} = $image; + } + } elsif ($target eq 'analyze') { + my $image = &Apache::lonxml::endredirection; + if ( $Apache::imageresponse::conceptgroup + && !&Apache::response::showallfoils()) { + $Apache::response::conceptgroup{"$name.image"} = $image; } else { $Apache::response::foilgroup{"$name.image"} = $image; }