[LON-CAPA-cvs] cvs: rat / lonsequence.pm

raeburn lon-capa-cvs@mail.lon-capa.org
Tue, 06 Jul 2004 15:27:01 -0000


raeburn		Tue Jul  6 11:27:01 2004 EDT

  Modified files:              
    /rat	lonsequence.pm 
  Log:
  Fix bug #3087 ("Next arrow from test.page fails to go to next resource .... Rather it goes to a sequence and stops there).
  
  
Index: rat/lonsequence.pm
diff -u rat/lonsequence.pm:1.17 rat/lonsequence.pm:1.18
--- rat/lonsequence.pm:1.17	Fri May 21 16:16:40 2004
+++ rat/lonsequence.pm	Tue Jul  6 11:27:00 2004
@@ -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.18 2004/07/06 15:27:00 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -246,6 +246,8 @@
 # ------------------------------------------------------------ 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 @@
 	       $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,
@@ -286,6 +294,8 @@
                    $dismapid=(split(/\./,$disid))[1];
                }
  	   }
+           $exitdisid = $disid;
+           $arrow_dir = $direction;
 
 # --------------------------------------- Untie hash, make sure to come by here
            untie(%bighash);
@@ -293,7 +303,6 @@
    }
 
 # 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 +313,38 @@
    } else {
        &Apache::loncommon::content_type($r,'text/html');
        $r->send_http_header;
-       &viewmap($r,$requrl);
+       if ($exitdisid eq '') {
+           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(&mt('emfo'));
+           $r->print(<<ENDNONE);
+<head><title>$lt{'emfo'}</title></head>
+$bodytag
+<h3>$lt{'nere'}</h3>
+<p>$warnmsg</p>
+<ul>
+  <li><a href="javascript:history.go(-1)">$lt{'goba'}</a></li>
+  <li><a href="/adm/navmaps">$lt{'nacc'}</a></li>
+</ul>
+</body>
+ </html>
+ENDNONE
+       } else {
+           &viewmap($r,$requrl);
+       }
        return OK;
    }
 }