--- rat/lonpageflip.pm 2000/10/07 22:30:30 1.3 +++ rat/lonpageflip.pm 2000/10/09 19:37:35 1.4 @@ -10,12 +10,12 @@ # 08/30,08/31,09/06,09/14,09/15,09/16,09/19,09/20,09/21,09/23, # 10/02 Gerd Kortemeyer) # -# 10/03,10/05,10/06,10/07 Gerd Kortemeyer +# 10/03,10/05,10/06,10/07,10/09 Gerd Kortemeyer package Apache::lonpageflip; use strict; -use Apache::Constants qw(:common :http); +use Apache::Constants qw(:common :http REDIRECT); use Apache::lonnet(); use HTML::TokeParser; use GDBM_File; @@ -25,12 +25,13 @@ use GDBM_File; my %hash; sub addrid { - my ($current,$new)=@_; + my ($current,$new,$condid)=@_; + unless ($condid) { $condid=0; } if (&Apache::lonnet::allowed('bre',$hash{'src_'.$new})) { if ($current) { - $current.=','.$new; + $current.=','.$new.':'.$condid; } else { - $current=''.$new; + $current=''.$new.':'.$condid; } } return $current; @@ -49,16 +50,10 @@ sub handler { return OK; } - -# --------BEGIN DEBUG ONLY TRASH - $r->content_type('text/html'); - $r->send_http_header; - - $r->print(''); -# --------END DEBUG ONLY TRASH - my %cachehash=(); - my $redir=0; + my $redirecturl=''; + my $next=''; + my @possibilities=(); if (($ENV{'form.postdata'})&&($ENV{'request.course.fn'})) { $ENV{'form.postdata'}=~/(\w+)\:(.*)/; @@ -79,23 +74,45 @@ sub handler { my $next=''; if ($direction eq 'forward') { map { - $next=&addrid($next,$hash{'goesto_'.$_}); + $next=&addrid($next,$hash{'goesto_'.$_}, + $hash{'condid_'.$hash{'undercond_'.$_}}); } split(/\,/,$hash{'to_'.$rid}); - my @possibilities=split(/,/,$next); - if ($#possibilities==1) { - my $goto=$possibilities[0]; - } } elsif ($direction eq 'back') { - } elsif ($direction eq 'up') { + map { + $next=&addrid($next,$hash{'comesfrom_'.$_}, + $hash{'condid_'.$hash{'undercond_'.$_}}); + } split(/\,/,$hash{'from_'.$rid}); + } elsif ($direction eq 'up') { } elsif ($direction eq 'down') { } + my $redirectid=''; +# ----------------------------------------------------- Check out possibilities + if ($next) { + @possibilities=split(/\,/,$next); + if ($#possibilities==0) { + $redirectid=(split(/\:/,$next))[0]; + } else { + } + } + if ($redirectid) { + $redirecturl=$hash{'src_'.$redirectid}; + } untie(%hash); - $r->print($rid.' - '.$next); + if ($redirecturl) { + $r->content_type('text/html'); + $r->header_out(Location => + 'http://'.$ENV{'HTTP_HOST'}.$redirecturl); + return REDIRECT; + } } - } else { -# -------------------------------------------------------------------------- No - $r->print('No idea '.$currenturl); } +# -------------------------------------------------------- No, could not decide + } + $r->content_type('text/html'); + $r->send_http_header; + + $r->print(''); + # -------------------------- Class was not initialized or page fliped strangely } else { $ENV{'user.error.msg'}="/adm/flip:bre:0:0:Choose Course";