--- loncom/homework/structuretags.pm 2005/09/23 20:16:50 1.302 +++ loncom/homework/structuretags.pm 2005/09/23 20:39:35 1.303 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # definition of tags that give a structure to a document # -# $Id: structuretags.pm,v 1.302 2005/09/23 20:16:50 albertel Exp $ +# $Id: structuretags.pm,v 1.303 2005/09/23 20:39:35 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -1078,17 +1078,19 @@ sub start_randomlist { # print "END-TAG $b_tok->[1]
"; # } } - my @idx_arr = (0 .. $#randomlist); - &Apache::structuretags::shuffle(\@idx_arr); - my $bodytext = ''; - my $show=$#randomlist; - my $showarg=&Apache::lonxml::get_param('show',$parstack,$safeeval); - $showarg--; - if ( ($showarg >= 0) && ($showarg < $show) ) { $show = $showarg; } - for(0 .. $show) { - $bodytext .= "$randomlist[ $idx_arr[$_] ]"; + if (@randomlist) { + my @idx_arr = (0 .. $#randomlist); + &Apache::structuretags::shuffle(\@idx_arr); + my $bodytext = ''; + my $show=$#randomlist; + my $showarg=&Apache::lonxml::get_param('show',$parstack,$safeeval); + $showarg--; + if ( ($showarg >= 0) && ($showarg < $show) ) { $show = $showarg; } + for(0 .. $show) { + $bodytext .= "$randomlist[ $idx_arr[$_] ]"; + } + &Apache::lonxml::newparser($parser,\$bodytext); } - &Apache::lonxml::newparser($parser,\$bodytext); } elsif ($target eq 'edit' ) { $result .=&Apache::edit::tag_start($target,$token); $result .=&Apache::edit::text_arg('Maximum Tags to Show:','show', @@ -1105,7 +1107,7 @@ sub start_randomlist { sub shuffle { my $a=shift; my $i; - if (defined(@$a)) { + if (ref($a) eq 'ARRAY' && @$a) { &Apache::response::pushrandomnumber(); for($i=@$a;--$i;) { my $j=int(&Math::Random::random_uniform() * ($i+1));