--- rat/lonuserstate.pm 2002/06/24 14:09:49 1.29 +++ rat/lonuserstate.pm 2002/07/15 12:22:32 1.34 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Construct and maintain state and binary representation of course for user # -# $Id: lonuserstate.pm,v 1.29 2002/06/24 14:09:49 www Exp $ +# $Id: lonuserstate.pm,v 1.34 2002/07/15 12:22:32 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -277,7 +277,7 @@ sub traceroute { $sofar=simplify($sofar); unless ($beenhere=~/\&$rid\&/) { $beenhere.=$rid.'&'; - if ($retfurl eq '') { + if (($retfurl eq '') && ($hash{'src_'.$rid})) { my ($mapid,$resid)=split(/\./,$rid); $retfurl=$hash{'src_'.$rid}.'?symb='. &Apache::lonnet::symbclean( @@ -409,6 +409,7 @@ sub accinit { # ------------------------------------- Selectively delete from randompick maps sub pickrandom { + my $randomoutentry=''; foreach my $rid (keys %randompick) { my $rndpick=$randompick{$rid}; my $mpc=$hash{'map_pc_'.$hash{'src_'.$rid}}; @@ -422,7 +423,7 @@ sub pickrandom { next if ($#currentrids<$rndpick); # -------------------------------- randomly eliminate the ones that should stay srand(&Apache::lonnet::rndseed($rid)); # use rid instead of symb - for (my $i=1;$i<=$#currentrids+1-$rndpick;$i++) { + for (my $i=1;$i<=$rndpick;$i++) { while (1) { my $randomidx=int(rand($#currentrids+1)); if ($currentrids[$randomidx]) { @@ -435,9 +436,19 @@ sub pickrandom { for (my $k=0; $k<=$#currentrids; $k++) { if ($currentrids[$k]) { $hash{'randomout_'.$currentrids[$k]}=1; + my ($mapid,$resid)=split(/\./,$currentrids[$k]); + $randomoutentry.='&'. + &Apache::lonnet::symbclean( + &Apache::lonnet::declutter($hash{'map_id_'.$mapid}). + '___'.$resid.'___'. + &Apache::lonnet::declutter($hash{'src_'.$currentrids[$k]}) + ).'&'; } } } + if ($randomoutentry) { + &Apache::lonnet::appenv('acc.randomout' => $randomoutentry); + } } # ---------------------------------------------------- Read map and all submaps @@ -467,6 +478,11 @@ sub readmap { %parmhash=(); $errtext=''; $pc=0; + my $furi='/res/'.&Apache::lonnet::declutter($uri); + $hash{'src_0.0'}=$furi; + $hash{'title_0.0'}=&Apache::lonnet::metadata($uri,'title'); + $hash{'ids_'.$furi}='0.0'; + $hash{'is_map_0.0'}=1; loadmap($uri); if (defined($hash{'map_start_'.$uri})) { &traceroute('0',$hash{'map_start_'.$uri},'&');