--- rat/lonuserstate.pm 2002/06/24 14:09:49 1.29 +++ rat/lonuserstate.pm 2002/07/30 20:01:40 1.36 @@ -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.36 2002/07/30 20:01:40 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -277,9 +277,10 @@ 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='. + $retfurl=$hash{'src_'.$rid}. + (($hash{'src_'.$rid}=~/\?/)?'&':'?').'symb='. &Apache::lonnet::symbclean( &Apache::lonnet::declutter($hash{'map_id_'.$mapid}). '___'.$resid.'___'. @@ -409,6 +410,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 +424,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 +437,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 @@ -461,12 +473,17 @@ sub readmap { unlink($fn.'parms.db'); undef %randompick; $retfurl=''; - if ((tie(%hash,'GDBM_File',"$fn.db",&GDBM_WRCREAT,0640)) && - (tie(%parmhash,'GDBM_File',$fn.'_parms.db',&GDBM_WRCREAT,0640))) { + if ((tie(%hash,'GDBM_File',"$fn.db",&GDBM_WRCREAT(),0640)) && + (tie(%parmhash,'GDBM_File',$fn.'_parms.db',&GDBM_WRCREAT(),0640))) { %hash=(); %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},'&');