--- rat/lonsequence.pm 2004/05/21 20:16:40 1.17 +++ rat/lonsequence.pm 2004/10/16 01:14:28 1.21 @@ -2,7 +2,7 @@ # # Sequence Handler # -# $Id: lonsequence.pm,v 1.17 2004/05/21 20:16:40 raeburn Exp $ +# $Id: lonsequence.pm,v 1.21 2004/10/16 01:14:28 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -246,6 +246,8 @@ sub handler { # ------------------------------------------------------------ Tie symb db file my $disurl=''; my $dismapid=''; + my $exitdisid = ''; + my $arrow_dir = ''; if (($ENV{'request.course.fn'}) && (!$ENV{'form.forceselect'})) { my $last; @@ -269,14 +271,20 @@ sub handler { $disid=$bighash{'map_finish_'.$requrl}; } else { $disid=$bighash{'map_start_'.$requrl}; - } + } if ($disid) { $disurl=$bighash{'src_'.$disid}; $dismapid=(split(/\./,$disid))[1]; $randomout = $bighash{'randomout_'.$disid}; + } elsif (tie(%hash,'GDBM_File',$ENV{'request.course.fn'}.'_symb.db', + &GDBM_READER(),0640)) { + $last=$hash{'last_known'}; + untie(%hash); } + + # ----------- If this is an empty one, or hidden, skip to next non-empty or non-hidden one - if ( ((!$disurl) && ($disid)) || ($randomout && $disid) ) { + while ( ((!$disurl) && ($disid)) || ($randomout && $disid) ) { $direction=($direction?$direction:'forward'); ($disid,$requrl)= &Apache::lonpageflip::fullmove($disid, @@ -284,8 +292,11 @@ sub handler { if ($disid) { $disurl=$bighash{'src_'.$disid}; $dismapid=(split(/\./,$disid))[1]; + $randomout = $bighash{'randomout_'.$disid}; } } + $exitdisid = $disid; + $arrow_dir = $direction; # --------------------------------------- Untie hash, make sure to come by here untie(%bighash); @@ -293,7 +304,6 @@ sub handler { } # 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, @@ -304,7 +314,38 @@ sub handler { } else { &Apache::loncommon::content_type($r,'text/html'); $r->send_http_header; - &viewmap($r,$requrl); + if ($exitdisid eq '' && $arrow_dir ne '') { + my %lt =&Apache::lonlocal::texthash( + 'back' => 'beginning', + 'forward' => 'end', + 'emfo' => 'Empty Folder/Sequence', + 'nere' => 'Next resource could not be displayed', + 'goba' => 'Go Back', + 'nacc' => 'Navigate Course Content', + ); + my $warnmsg = 'As all folders and sequences '; + if ($arrow_dir eq 'forward') { + $warnmsg .= &mt('following the current resource were empty').','; + } elsif ($arrow_dir eq 'back') { + $warnmsg .= &mt('preceding the current resource were empty').','; + } + $warnmsg .= &mt('you have now reached the').' '.$lt{$arrow_dir}.' '.&mt('of the course.'); + my $bodytag=&Apache::loncommon::bodytag('Empty Folder/Sequence'); + $r->print(<$lt{'emfo'} +$bodytag +

$lt{'nere'}

+

$warnmsg

+ + + +ENDNONE + } else { + &viewmap($r,$requrl); + } return OK; } }