--- loncom/homework/randomlabel.pm 2001/08/29 09:23:26 1.1 +++ loncom/homework/randomlabel.pm 2001/08/29 19:48:26 1.2 @@ -4,7 +4,7 @@ # 8/10/2001 Isaac Tsai # SYNTAX: # -# +# # # # @@ -63,7 +63,9 @@ sub start_labelgroup { my $result=''; my $name = &Apache::lonxml::get_param('name',$parstack,$safeeval); my $type = &Apache::lonxml::get_param('type',$parstack,$safeeval); + $type =~tr/A-Z/a-z/; $Apache::randomlabel::groupname=$name; + $Apache::randomlabel::type=$type; @Apache::randomlabel::xcoord = (); @Apache::randomlabel::ycoord = (); @Apache::randomlabel::label_arr = (); @@ -75,31 +77,46 @@ sub end_labelgroup { my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; my $gname = $Apache::randomlabel::groupname; my $count = $#Apache::randomlabel::label_arr + 1; + my $type = $Apache::randomlabel::type; my $code; my $out; my $label; my $x; my $y; - my $text= ""; - + my $text; + my $str; + my $xstr; + my $ystr; + + if( $type eq 'text') { + $text= ""; + $str = 'LB'; + $xstr = 'X'; + $ystr = 'Y'; + } + if( $type eq 'image') { + $text= ""; + $str = 'IMG'; + $xstr = 'IX'; + $ystr = 'IY'; + } my @idx_arr = (0 .. $#Apache::randomlabel::label_arr); &Apache::structuretags::shuffle(\@idx_arr); for(0 .. $#Apache::randomlabel::label_arr) { $label = "$Apache::randomlabel::label_arr[ $idx_arr[$_] ]"; $x = pop @Apache::randomlabel::xcoord; $y = pop @Apache::randomlabel::ycoord; - $text .= ""; - $text .= " "; - $text .= ""; + $text .= ""; + $text .= " "; + $text .= ""; $code = "push(\@$gname, $label);" ; - # print("CODE=$code"); - # $out=Apache::run::run($code,$safeeval,$$parstack[$#$parstack]); $out=Apache::run::run($code,$safeeval); } return $text; } +# sub start_location { my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; my $x= &Apache::lonxml::get_param('x',$parstack,$safeeval); @@ -114,6 +131,7 @@ sub end_location { return ''; } +# sub start_label { my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; my $ltext=&Apache::lonxml::get_all_text("/label",$$parser[$#$parser]);