--- loncom/homework/optionresponse.pm 2001/05/21 19:45:28 1.8 +++ loncom/homework/optionresponse.pm 2001/05/31 22:34:33 1.9 @@ -11,11 +11,19 @@ sub BEGIN { sub start_optionresponse { my ($target,$token,$parstack,$parser,$safeeval,$style)=@_; + my $result=''; #when in a radiobutton response use these &Apache::lonxml::register('Apache::optionresponse',('foilgroup','foil','conceptgroup')); push (@Apache::lonxml::namespace,'optionresponse'); my $id = &Apache::response::start_response($parstack,$safeeval); - return ''; + if ($target eq 'edit') { + $result.=" +
Multiple Option Response QuestionDelete:". + &Apache::edit::deletelist($target,$token) +."
\n"; + } + + return $result; } sub end_optionresponse { @@ -35,7 +43,7 @@ sub insert_optionresponse { %Apache::response::foilgroup={}; sub start_foilgroup { %Apache::response::foilgroup={}; - $Apache::optionresponse::conceptgroup=0; + $Apache::optionresponse::conceptgroup=0; &Apache::response::setrandomnumber(); return ''; } @@ -94,7 +102,8 @@ sub getfoilcounts { my $rrargs =''; if ( $#$parstack > 0 ) { $rrargs=$$parstack['-2']; } my $max = &Apache::run::run("{$rrargs;".'return $max}',$safeeval); - my $count = $#{ $Apache::response::foilgroup{'names'} }; + # +1 since instructors will count from 1 + my $count = $#{ $Apache::response::foilgroup{'names'} }+1; return ($count,$max); } @@ -102,8 +111,9 @@ sub whichfoils { my ($max)=@_; my @names = @{ $Apache::response::foilgroup{'names'} }; my @whichopt =(); - while ((($#whichopt) < $max) && ($#names > -1)) { - my $aopt=int rand $#names; + while ((($#whichopt+1) < $max) && ($#names > -1)) { + &Apache::lonxml::debug("Have $#whichopt max is $max"); + my $aopt=int(rand($#names+1)); &Apache::lonxml::debug("From $#whichopt $max $#names elms, picking $aopt"); $aopt=splice(@names,$aopt,1); &Apache::lonxml::debug("Picked $aopt");