--- rat/lonpageflip.pm 2002/04/11 01:57:36 1.19 +++ rat/lonpageflip.pm 2002/04/11 19:21:52 1.22 @@ -2,7 +2,7 @@ # # Page flip handler # -# $Id: lonpageflip.pm,v 1.19 2002/04/11 01:57:36 www Exp $ +# $Id: lonpageflip.pm,v 1.22 2002/04/11 19:21:52 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -156,7 +156,6 @@ sub handler { my $redirecturl=''; my $next=''; my @possibilities=(); - if (($ENV{'form.postdata'})&&($ENV{'request.course.fn'})) { $ENV{'form.postdata'}=~/(\w+)\:(.*)/; my $direction=$1; @@ -204,30 +203,33 @@ sub handler { my $position; if ($position=Apache::lonnet::symbread($currenturl)) { # ------------------------------------------------------------------------- Yes - my ($mapurl,$mapnum,$thisurl)=split(/\_\_\_/,$position); - $cachehash{$mapurl}{$thisurl}=$mapnum; + my ($startoutmap,$mapnum,$thisurl)=split(/\_\_\_/,$position); + $cachehash{$startoutmap}{$thisurl}=$mapnum; + $cachehash{$startoutmap}{'last_known'}=&Apache::lonnet::declutter($currenturl); + # ============================================================ Tie the big hash if (tie(%hash,'GDBM_File',$ENV{'request.course.fn'}.'.db', &GDBM_READER,0640)) { - my $rid=$hash{'map_pc_/res/'.$mapurl}.'.'.$mapnum; + my $rid=$hash{'map_pc_/res/'.$startoutmap}.'.'.$mapnum; # ------------------------------------------------- Move forward, backward, etc - - ($next,$mapurl)=&move($rid,$mapurl,$direction); + my $endupmap; + ($next,$endupmap)=&move($rid,$startoutmap,$direction); # -------------------------------------- Do we have one and only one empty URL? my $safecount=0; while (($next) && ($next!~/\,/) && (!$hash{'src_'.$next}) && ($safecount<25)) { - ($next,$mapurl)=&move($next,$mapurl,$direction); + ($next,$endupmap)=&move($next,$endupmap,$direction); $safecount++; } +# We are now at at least one non-empty URL # ----------------------------------------------------- Check out possibilities if ($next) { @possibilities=split(/\,/,$next); if ($#possibilities==0) { # ---------------------------------------------- Only one possibility, redirect $redirecturl=$hash{'src_'.$next}; - $cachehash{$mapurl} + $cachehash{$endupmap} {&Apache::lonnet::declutter($redirecturl)} =(split(/\./,$next))[1]; } else { @@ -237,12 +239,14 @@ sub handler { $multichoicehash{'src_'.$_}=$hash{'src_'.$_}; $multichoicehash{'title_'.$_}=$hash{'title_'.$_}; $multichoicehash{'type_'.$_}=$hash{'type_'.$_}; - $cachehash{$mapurl} - {&Apache::lonnet::declutter( + my ($choicemap,$choiceres)=split(/\./,$_); + $cachehash + {&Apache::lonnet::declutter($hash{'src_'.$choicemap})} + {&Apache::lonnet::declutter( $multichoicehash {'src_'.$_} )} - =(split(/\./,$_))[1]; + =$choiceres; } @possibilities; } } else { @@ -252,11 +256,9 @@ sub handler { # ----------------- The program must come past this point to untie the big hash untie(%hash); # --------------------------------------------------------- Store position info - $cachehash{$mapurl}{'last_direction'}=$direction; - $cachehash{$mapurl}{'last_known'}= - &Apache::lonnet::declutter($currenturl); + $cachehash{$startoutmap}{'last_direction'}=$direction; foreach my $thismap (keys %cachehash) { - &Apache::lonnet::symblist($thismap,%{$cachehash{$thisurl}}); + &Apache::lonnet::symblist($thismap,%{$cachehash{$thismap}}); } # ============================================== Do not return before this line if ($redirecturl) {