--- loncom/homework/imageresponse.pm 2001/02/22 01:13:43 1.3 +++ loncom/homework/imageresponse.pm 2001/03/01 01:19:50 1.4 @@ -26,6 +26,8 @@ sub end_imageresponse { %Apache::response::foilgroup={}; sub start_foilgroup { %Apache::response::foilgroup={}; + $Apache::optionresponse::conceptgroup=0; + &setrandomnumber(); return ''; } @@ -122,7 +124,6 @@ sub end_foilgroup { my $result=''; my @whichopt; if ($target eq 'web' || $target eq 'grade') { - &setrandomnumber(); my ($count,$max) = &getfoilcounts($parstack,$safeeval); if ($count>$max) { $count=$max } &Apache::lonxml::debug("Count is $count from $max"); @@ -140,9 +141,29 @@ sub end_foilgroup { } sub start_conceptgroup { + $Apache::optionresponse::conceptgroup=1; + %Apache::response::conceptgroup={}; + return ''; } sub end_conceptgroup { + my ($target,$token,$parstack,$parser,$safeeval,$style)=@_; + $Apache::optionresponse::conceptgroup=0; + if ($target eq 'web' || $target eq 'grade') { + my @names = @{ $Apache::response::conceptgroup{'names'} }; + my $pick=int rand $#names+1; + my $name=$names[$pick]; + 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 $args; + if ( $#$parstack > -1 ) { $args=$$parstack[$#$parstack]; } + my $concept = &Apache::run::run("{$args;".'return $concept}',$safeeval); + $Apache::response::foilgroup{"$name.concept"} = $concept; + &Apache::lonxml::debug("Selecting $name in $concept"); + } + return ''; } $Apache::imageresponse::curname='';