--- rat/lonpage.pm 2004/03/22 20:37:06 1.56 +++ rat/lonpage.pm 2004/08/29 18:34:36 1.57 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Page Handler # -# $Id: lonpage.pm,v 1.56 2004/03/22 20:37:06 sakharuk Exp $ +# $Id: lonpage.pm,v 1.57 2004/08/29 18:34:36 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -45,6 +45,7 @@ use Apache::Constants qw(:common :http); use Apache::lonnet(); use Apache::loncommon(); use Apache::lonxml(); +use Apache::lonlocal; use Apache::lonmenu; use HTML::TokeParser; use GDBM_File; @@ -72,66 +73,70 @@ sub euclid { sub tracetable { my ($sofar,$rid,$beenhere)=@_; my $further=$sofar; + my $randomout=0; + if ($ENV{'request.role'} =~ /^st/) { + $randomout = $hash{'randomout_'.$rid}; + } unless ($beenhere=~/\&$rid\&/) { - $beenhere.=$rid.'&'; - - if (defined($hash{'is_map_'.$rid})) { - if ((defined($hash{'map_start_'.$hash{'src_'.$rid}})) && - (defined($hash{'map_finish_'.$hash{'src_'.$rid}}))) { - my $frid=$hash{'map_finish_'.$hash{'src_'.$rid}}; - $sofar= - &tracetable($sofar,$hash{'map_start_'.$hash{'src_'.$rid}}, - '&'.$frid.'&'); - $sofar++; - if ($hash{'src_'.$frid}) { - my $brepriv=&Apache::lonnet::allowed('bre',$hash{'src_'.$frid}); - if (($brepriv eq '2') || ($brepriv eq 'F')) { - if (defined($rows[$sofar])) { - $rows[$sofar].='&'.$frid; - } else { - $rows[$sofar]=$frid; - } - } - } - } - } else { - $sofar++; - if ($hash{'src_'.$rid}) { - my $brepriv=&Apache::lonnet::allowed('bre',$hash{'src_'.$rid}); - if (($brepriv eq '2') || ($brepriv eq 'F')) { - if (defined($rows[$sofar])) { - $rows[$sofar].='&'.$rid; - } else { - $rows[$sofar]=$rid; - } - } - } - } - - if (defined($hash{'to_'.$rid})) { - my $mincond=1; - my $next=''; - foreach (split(/\,/,$hash{'to_'.$rid})) { - my $thiscond= + $beenhere.=$rid.'&'; + unless ($randomout) { + if (defined($hash{'is_map_'.$rid})) { + if ((defined($hash{'map_start_'.$hash{'src_'.$rid}})) && + (defined($hash{'map_finish_'.$hash{'src_'.$rid}}))) { + my $frid=$hash{'map_finish_'.$hash{'src_'.$rid}}; + $sofar= + &tracetable($sofar,$hash{'map_start_'.$hash{'src_'.$rid}}, + '&'.$frid.'&'); + $sofar++; + if ($hash{'src_'.$frid}) { + my $brepriv=&Apache::lonnet::allowed('bre',$hash{'src_'.$frid}); + if (($brepriv eq '2') || ($brepriv eq 'F')) { + if (defined($rows[$sofar])) { + $rows[$sofar].='&'.$frid; + } else { + $rows[$sofar]=$frid; + } + } + } + } + } else { + $sofar++; + if ($hash{'src_'.$rid}) { + my $brepriv=&Apache::lonnet::allowed('bre',$hash{'src_'.$rid}); + if (($brepriv eq '2') || ($brepriv eq 'F')) { + if (defined($rows[$sofar])) { + $rows[$sofar].='&'.$rid; + } else { + $rows[$sofar]=$rid; + } + } + } + } + } + + if (defined($hash{'to_'.$rid})) { + my $mincond=1; + my $next=''; + foreach (split(/\,/,$hash{'to_'.$rid})) { + my $thiscond= &Apache::lonnet::directcondval($hash{'condid_'.$hash{'undercond_'.$_}}); - if ($thiscond>=$mincond) { - if ($next) { - $next.=','.$_.':'.$thiscond; - } else { - $next=$_.':'.$thiscond; - } - if ($thiscond>$mincond) { $mincond=$thiscond; } - } - } - foreach (split(/\,/,$next)) { - my ($linkid,$condval)=split(/\:/,$_); - if ($condval>=$mincond) { - my $now=&tracetable($sofar,$hash{'goesto_'.$linkid},$beenhere); - if ($now>$further) { $further=$now; } - } - } - - } + if ($thiscond>=$mincond) { + if ($next) { + $next.=','.$_.':'.$thiscond; + } else { + $next=$_.':'.$thiscond; + } + if ($thiscond>$mincond) { $mincond=$thiscond; } + } + } + foreach (split(/\,/,$next)) { + my ($linkid,$condval)=split(/\:/,$_); + if ($condval>=$mincond) { + my $now=&tracetable($sofar,$hash{'goesto_'.$linkid},$beenhere); + if ($now>$further) { $further=$now; } + } + } + } } return $further; }