--- rat/lonsequence.pm 2002/05/23 10:19:30 1.8 +++ rat/lonsequence.pm 2002/05/23 15:07:55 1.11 @@ -2,7 +2,7 @@ # # Sequence Handler # -# $Id: lonsequence.pm,v 1.8 2002/05/23 10:19:30 www Exp $ +# $Id: lonsequence.pm,v 1.11 2002/05/23 15:07:55 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -44,6 +44,7 @@ use Apache::Constants qw(:common :http R use GDBM_File; use Apache::lonratedt; use Apache::lonratsrv; +use Apache::lonpageflip; # ----------------------------------------------------------- Could not resolve @@ -73,7 +74,7 @@ sub attemptread { # ---------------------------------------------------------------- View Handler sub viewmap { - my ($r,$url,$adv,$errtext)=@_; + my ($r,$url)=@_; $r->print(''); if ($ENV{'form.forceselect'}) { $r->print(< @@ -95,12 +96,10 @@ function queue(val) { } } - - ENDSCRIPT } - $r->print(''.&buttons($adv)); + $r->print(''); if ($ENV{'form.forceselect'}) { $r->print(< @@ -109,9 +108,6 @@ onClick="javascript:select_group()"> ENDSELECT } - if ($errtext) { - $r->print($errtext.'
'); - } my $idx=0; foreach (&attemptread(&Apache::lonnet::filelocation('',$url))) { if (defined($_)) { @@ -165,7 +161,10 @@ sub handler { my $requrl=$r->uri; # ------------------------------------------------------------ Tie symb db file - if ($ENV{'request.course.fn'}) { + my $disurl=''; + my $dismapid=''; + + if (($ENV{'request.course.fn'}) && (!$ENV{'form.forceselect'})) { my $last; if (tie(%hash,'GDBM_File',$ENV{'request.course.fn'}.'_symb.db', &GDBM_READER,0640)) { @@ -181,64 +180,48 @@ sub handler { if (tie(%bighash,'GDBM_File',$ENV{'request.course.fn'}.'.db', &GDBM_READER,0640)) { my $disid=''; - my $whatend=''; + if ($direction eq 'back') { $disid=$bighash{'map_finish_'.$requrl}; - $whatend='End'; } else { $disid=$bighash{'map_start_'.$requrl}; - $whatend='Beginning'; } - my $disurl=''; - my $dismapid=''; if ($disid) { $disurl=$bighash{'src_'.$disid}; $dismapid=(split(/\./,$disid))[1]; } - my $symb=''; - my $sequencetitle=''; - unless($disurl) { - if ($symb=&Apache::lonnet::symbread()) { - my ($mapurl,$mapid)=split(/\_\_\_/,$symb); - $sequencetitle=$bighash{'title_'. - $bighash{'map_pc_/res/'.$mapurl}.'.'. - $mapid}; +# ------------------------- If this is an empty one, skip to next non-empty one + if ((!$disurl) && ($disid)) { + $direction=($direction?$direction:'forward'); + ($disid,$requrl)= + &Apache::lonpageflip::fullmove($disid, + &Apache::lonnet::declutter($requrl),$direction); + if ($disid) { + $disurl=$bighash{'src_'.$disid}; + $dismapid=(split(/\./,$disid))[1]; } - } + } + # --------------------------------------- Untie hash, make sure to come by here untie(%bighash); - if ($disurl) { + } + } + +# now either disurl is set (going to first page), or we need another display + + if ($disurl) { # -------------------------------------------------- Has first or last resource - &Apache::lonnet::symblist($requrl,$disurl => $dismapid, + &Apache::lonnet::symblist($requrl,$disurl => $dismapid, 'last_known' => &Apache::lonnet::declutter($disurl)); - $r->content_type('text/html'); - $r->header_out(Location => 'http://'.$ENV{'HTTP_HOST'}.$disurl); - return REDIRECT; - } else { -# ---------- Does not have first or last resource, try to find out where we are - unless ($symb) { - $r->internal_redirect('/adm/ambiguous'); - } - $r->content_type('text/html'); - $r->send_http_header; - $r->print(< -

$whatend of

-

$sequencetitle

- -ENDSYMB - return OK - } - } else { - &getlost($r,'Could not access course structure.'); - return OK; - } + $r->content_type('text/html'); + $r->header_out(Location => 'http://'.$ENV{'HTTP_HOST'}.$disurl); + return REDIRECT; } else { - $ENV{'user.error.msg'}="$requrl:bre:0:0:Course not initialized"; - return HTTP_NOT_ACCEPTABLE; + $r->content_type('text/html'); + $r->send_http_header; + &viewmap($r,$requrl); + return OK; } - - return OK; } 1;