--- loncom/homework/optionresponse.pm 2001/02/22 00:49:03 1.4 +++ loncom/homework/optionresponse.pm 2001/03/01 00:59:33 1.5 @@ -24,6 +24,8 @@ sub end_optionresponse { %Apache::response::foilgroup={}; sub start_foilgroup { %Apache::response::foilgroup={}; + $Apache::optionresponse::conceptgroup=0; + &setrandomnumber(); return ''; } @@ -34,6 +36,7 @@ sub setrandomnumber { +&Apache::lonnet::numval($Apache::inputtags::part) +&Apache::lonnet::numval($Apache::inputtags::response['-1']); srand($rndseed); + &Apache::lonxml::debug("randseed $rndseed"); return ''; } @@ -43,7 +46,6 @@ sub end_foilgroup { my $result; if ($target ne 'meta') { my $name; - &setrandomnumber(); my ($count,$max) = &getfoilcounts($parstack,$safeeval); if ($count>$max) { $count=$max } &Apache::lonxml::debug("Count is $count from $max"); @@ -137,10 +139,30 @@ sub displayfoils { return $result."
"; } + 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.value"} = $Apache::response::conceptgroup{"$name.value"}; + $Apache::response::foilgroup{"$name.text"} = $Apache::response::conceptgroup{"$name.text"}; + 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 ''; } sub start_foil { @@ -159,9 +181,15 @@ sub end_foil { my $value = &Apache::run::run("{$args;".'return $value}',$safeeval); if ($value ne 'unused') { my $name = &Apache::run::run("{$args;".'return $name}',$safeeval); - push @{ $Apache::response::foilgroup{'names'} }, $name; - $Apache::response::foilgroup{"$name.value"} = $value; - $Apache::response::foilgroup{"$name.text"} = $text; + if ( $Apache::optionresponse::conceptgroup ) { + push @{ $Apache::response::conceptgroup{'names'} }, $name; + $Apache::response::conceptgroup{"$name.value"} = $value; + $Apache::response::conceptgroup{"$name.text"} = $text; + } else { + push @{ $Apache::response::foilgroup{'names'} }, $name; + $Apache::response::foilgroup{"$name.value"} = $value; + $Apache::response::foilgroup{"$name.text"} = $text; + } } } return ''; 500 Internal Server Error

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator at root@localhost to inform them of the time this error occurred, and the actions you performed just before this error.

More information about this error may be available in the server error log.