Diff for /loncom/interface/lonnavmaps.pm between versions 1.139 and 1.140

version 1.139, 2003/02/06 22:58:12 version 1.140, 2003/02/07 21:55:44
Line 56  sub NOTHING { return 3; } Line 56  sub NOTHING { return 3; }
   
 # Some data  # Some data
   
   my $resObj = "Apache::lonnavmaps::resource";
   
 # Keep these mappings in sync with lonquickgrades, which uses the colors  # Keep these mappings in sync with lonquickgrades, which uses the colors
 # instead of the icons.  # instead of the icons.
 my %statusIconMap =   my %statusIconMap = 
     ( Apache::lonnavmaps::resource->NETWORK_FAILURE    => '',      ( $resObj->NETWORK_FAILURE    => '',
       Apache::lonnavmaps::resource->NOTHING_SET        => '',        $resObj->NOTHING_SET        => '',
       Apache::lonnavmaps::resource->CORRECT            => 'navmap.correct.gif',        $resObj->CORRECT            => 'navmap.correct.gif',
       Apache::lonnavmaps::resource->EXCUSED            => 'navmap.correct.gif',        $resObj->EXCUSED            => 'navmap.correct.gif',
       Apache::lonnavmaps::resource->PAST_DUE_NO_ANSWER => 'navmap.wrong.gif',        $resObj->PAST_DUE_NO_ANSWER => 'navmap.wrong.gif',
       Apache::lonnavmaps::resource->PAST_DUE_ANSWER_LATER => 'navmap.wrong.gif',        $resObj->PAST_DUE_ANSWER_LATER => 'navmap.wrong.gif',
       Apache::lonnavmaps::resource->ANSWER_OPEN        => 'navmap.wrong.gif',        $resObj->ANSWER_OPEN        => 'navmap.wrong.gif',
       Apache::lonnavmaps::resource->OPEN_LATER         => '',        $resObj->OPEN_LATER         => '',
       Apache::lonnavmaps::resource->TRIES_LEFT         => 'navmap.open.gif',        $resObj->TRIES_LEFT         => 'navmap.open.gif',
       Apache::lonnavmaps::resource->INCORRECT          => 'navmap.wrong.gif',        $resObj->INCORRECT          => 'navmap.wrong.gif',
       Apache::lonnavmaps::resource->OPEN               => 'navmap.open.gif',        $resObj->OPEN               => 'navmap.open.gif',
       Apache::lonnavmaps::resource->ATTEMPTED          => 'navmap.open.gif' );        $resObj->ATTEMPTED          => 'navmap.open.gif' );
   
 my %iconAltTags =   my %iconAltTags = 
     ( 'navmap.correct.gif' => 'Correct',      ( 'navmap.correct.gif' => 'Correct',
Line 79  my %iconAltTags = Line 81  my %iconAltTags =
   
 # Defines a status->color mapping, null string means don't color  # Defines a status->color mapping, null string means don't color
 my %colormap =   my %colormap = 
     ( Apache::lonnavmaps::resource->NETWORK_FAILURE        => '',      ( $resObj->NETWORK_FAILURE        => '',
       Apache::lonnavmaps::resource->CORRECT                => '',        $resObj->CORRECT                => '',
       Apache::lonnavmaps::resource->EXCUSED                => '#3333FF',        $resObj->EXCUSED                => '#3333FF',
       Apache::lonnavmaps::resource->PAST_DUE_ANSWER_LATER  => '',        $resObj->PAST_DUE_ANSWER_LATER  => '',
       Apache::lonnavmaps::resource->PAST_DUE_NO_ANSWER     => '',        $resObj->PAST_DUE_NO_ANSWER     => '',
       Apache::lonnavmaps::resource->ANSWER_OPEN            => '#006600',        $resObj->ANSWER_OPEN            => '#006600',
       Apache::lonnavmaps::resource->OPEN_LATER             => '',        $resObj->OPEN_LATER             => '',
       Apache::lonnavmaps::resource->TRIES_LEFT             => '',        $resObj->TRIES_LEFT             => '',
       Apache::lonnavmaps::resource->INCORRECT              => '',        $resObj->INCORRECT              => '',
       Apache::lonnavmaps::resource->OPEN                   => '',        $resObj->OPEN                   => '',
       Apache::lonnavmaps::resource->NOTHING_SET            => ''        );        $resObj->NOTHING_SET            => '' );
 # And a special case in the nav map; what to do when the assignment  # And a special case in the nav map; what to do when the assignment
 # is not yet done and due in less then 24 hours  # is not yet done and due in less then 24 hours
 my $hurryUpColor = "#FF0000";  my $hurryUpColor = "#FF0000";
Line 117  sub handler { Line 119  sub handler {
 sub real_handler {  sub real_handler {
     my $r = shift;      my $r = shift;
   
     &Apache::loncommon::get_unprocessed_cgi($ENV{QUERY_STRING});  
   
     # Handle header-only request      # Handle header-only request
     if ($r->header_only) {      if ($r->header_only) {
         if ($ENV{'browser.mathml'}) {          if ($ENV{'browser.mathml'}) {
Line 164  sub real_handler { Line 164  sub real_handler {
     # Now that we've displayed some stuff to the user, init the navmap      # Now that we've displayed some stuff to the user, init the navmap
     $navmap->init();      $navmap->init();
   
     $r->print('<table border="0" cellpadding="2" cellspacing="0">');  
     my $date=localtime;  
     $r->print('<tr><td align="right" valign="bottom">Key:&nbsp;&nbsp;</td>');  
   
     # Print discussions and feedback header  
     if ($navmap->{LAST_CHECK}) {  
         $r->print('<td align="center" valign="bottom">&nbsp;&nbsp;'.  
                   '<img src="/adm/lonMisc/chat.gif"> New discussion since '.  
                   strftime("%A, %b %e at %I:%M %P", localtime($navmap->{LAST_CHECK})).  
                   '</td><td align="center" valign="bottom">&nbsp;&nbsp;'.  
                   '<img src="/adm/lonMisc/feedback.gif"> New message (click to open)<p>'.  
                   '</td>');   
     } else {  
         $r->print('<td align="center" valign="bottom">&nbsp;&nbsp;'.  
                   '<img src="/adm/lonMisc/chat.gif"> Discussions</td><td align="center" valign="bottom">'.  
                   '&nbsp;&nbsp;<img src="/adm/lonMisc/feedback.gif"> New message (click to open)'.  
                   '</td>');   
     }  
     $r->print('</tr></table>');  
   
     my $condition = 0;  
     if ($ENV{'form.condition'}) {  
         $condition = 1;  
     }  
   
     # Determine where the "here" marker is and where the screen jumps to.  
     my $hereType; # the type of marker, SYMB, URL, or NOTHING  
     my $here; # the actual URL or SYMB for the here marker  
     my $jumpType; # The type of the thing we have a jump for, SYMB or URL  
     my $jump; # the SYMB/URL of the resource we need to jump to  
   
     if ( $ENV{'form.alreadyHere'} ) { # we came from a user's manipulation of the nav page  
         # If this is a click on a folder or something, we want to preserve the "here"  
         # from the querystring, and get the new "jump" marker  
         $hereType = $ENV{'form.hereType'};  
         $here = $ENV{'form.here'};  
         $jumpType = $ENV{'form.jumpType'} || NOTHING();  
         $jump = $ENV{'form.jump'};  
     } else { # the user is visiting the nav map from the remote  
         # We're coming from the remote. We have either a url, a symb, or nothing,  
         # and we need to figure out what.  
         # Preference: Symb  
           
         if ($ENV{'form.symb'}) {  
             $hereType = $jumpType = SYMB();  
             $here = $jump = $ENV{'form.symb'};  
         } elsif ($ENV{'form.postdata'}) {  
             # couldn't find a symb, is there a URL?  
             my $currenturl = $ENV{'form.postdata'};  
             $currenturl=~s/^http\:\/\///;  
             $currenturl=~s/^[^\/]+//;  
   
             $hereType = $jumpType = URL;  
             $here = $jump = $currenturl;  
         } else {  
             # Nothing  
             $hereType = $jumpType = NOTHING();  
         }  
     }  
   
       
     # alreadyHere allows us to only open the maps necessary to view  
     # the current location once, while at the same time remembering  
     # the current location. Without that check, the user would never  
     # be able to close those maps; the user would close it, and the  
     # currenturl scan would re-open it.  
     my $queryAdd = "&alreadyHere=1";  
   
     if ($condition) {  
         $r->print("<a href=\"navmaps?condition=0&filter=&$queryAdd" .  
                   "&hereType=$hereType&here=" . Apache::lonnet::escape($here) .  
                   "\">Close All Folders</a>");  
     } else {  
         $r->print("<a href=\"navmaps?condition=1&filter=&$queryAdd" .  
                   "&hereType=$hereType&here=" . Apache::lonnet::escape($here) .   
                   "\">Open All Folders</a>");  
     }  
   
     $r->print('<br>&nbsp;');      $r->print('<br>&nbsp;');
     $r->rflush();      $r->rflush();
Line 252  sub real_handler { Line 175  sub real_handler {
         return OK;          return OK;
     }      }
   
     my $res = "Apache::lonnavmaps::resource";  
   
     my %filterHash;  
     # Figure out what we're not displaying  
     foreach (split(/\,/, $ENV{"form.filter"})) {  
         if ($_) {  
             $filterHash{$_} = "1";  
         }  
     }  
   
     # Begin the HTML table  
     # four cols: resource + indent, chat+feedback, icon, text string  
     $r->print('<table cellspacing="0" cellpadding="3" border="0" bgcolor="#FFFFFF">' ."\n");  
   
     # This needs to be updated to use symbs from the remote,   
     # instead of uris. The changes to this and the main rendering  
     # loop should be obvious.  
     # Here's a simple example of the iterator.  
     # Preprocess the map: Look for current URL, open necessary maps  
   
     my $mapIterator = $navmap->getIterator(undef, undef, undef, 1);  
     my $found = 0;  
     my $depth = 1;  
     my $currentJumpIndex = 0; # keeps track of when the current resource is found,  
                              # so we can back up a few and put the anchor above the  
                              # current resource  
     my $currentJumpDelta = 2; # change this to change how many resources are displayed  
                              # before the current resource when using #current  
     $mapIterator->next(); # discard the first BEGIN_MAP  
     my $curRes = $mapIterator->next();  
     my $counter = 0;  
     my $foundJump = ($jumpType == NOTHING()); # look for jump point if we have one  
     my $looped = 0;   
   
     # We only need to do this if we need to open the maps to show the  
     # current position. This will change the counter so we can't count  
     # for the jump marker with this loop.  
     while ($depth > 0 && !$ENV{'form.alreadyHere'}) {  
         if ($curRes == $mapIterator->BEGIN_MAP()) { $depth++; }  
         if ($curRes == $mapIterator->END_MAP()) { $depth--; }  
   
         if (ref($curRes) && !$ENV{'form.alreadyHere'} &&   
             ($hereType == SYMB() && $curRes->symb() eq $here) ||  
             (ref($curRes) && $hereType == URL() && $curRes->src() eq $here)) {  
             my $mapStack = $mapIterator->getStack();  
               
             # Ensure the parent maps are open  
             for my $map (@{$mapStack}) {  
                 if ($condition) {  
                     undef $filterHash{$map->map_pc()};  
                 } else {  
                     $filterHash{$map->map_pc()} = 1;  
                 }  
             }  
             $ENV{'form.alreadyHere'} = 1;  
         }  
         $looped = 1;  
   
         $curRes = $mapIterator->next();  
     }              
       
     $mapIterator = $navmap->getIterator(undef, undef, \%filterHash, 0);  
     $depth = 1;  
     $mapIterator->next();  
     $curRes = $mapIterator->next();  
   
     while ($depth > 0 && !$foundJump) {  
         if ($curRes == $mapIterator->BEGIN_MAP()) { $depth++; }  
         if ($curRes == $mapIterator->END_MAP()) { $depth--; }  
         if (ref($curRes)) { $counter++; }  
   
         if (ref($curRes) &&   
             (($jumpType == SYMB() && $curRes->symb() eq $jump) ||  
             ($jumpType == URL() && $curRes->src() eq $jump))) {  
             # If this is the correct resource, be sure to   
             # show it by making sure the containing maps  
             # are open.  
   
             # This is why we have to use the main iterator instead of the  
             # potentially faster DFS: The count has to be the same, so  
             # the order has to be the same, which DFS won't give us.  
             $currentJumpIndex = $counter;  
             $foundJump = 1;  
         }  
   
         $curRes = $mapIterator->next();  
     }  
       
     # renderer call      # renderer call
     $mapIterator = $navmap->getIterator(undef, undef, \%filterHash, 0);      my $render = render({ 'cols' => [0,1,2,3],
     my $render = render({ 'cols' => [0,1,2,3], 'iterator' => $mapIterator,                            'url' => '/adm/navmaps',
                           'url' => '/adm/navmaps',                             'printKey' => 1,
                           'queryString' => 'alreadyHere=1',                            'r' => $r});
                           'currentJumpIndex' => $currentJumpIndex});  
     $r->print($render);  
   
     $navmap->untieHashes();      $navmap->untieHashes();
   
Line 654  Note these functions are responsible for Line 487  Note these functions are responsible for
   
 =head2 Parameters  =head2 Parameters
   
   Most of these parameters are only useful if you are *not* using the folder interface (i.e., the default first column), which is probably the common case. If you are using this interface, then you should be able to get away with just using 'cols' (to specify the columns shown), 'url' (necessary for the folders to link to the current screen correctly), and possibly 'queryString' if your app calls for it. In that case, maintaining the state of the folders will be done automatically.
   
 =over 4  =over 4
   
 =item * B<iterator>: A reference to a fresh ::iterator to use from the navmaps. The rendering will reflect the options passed to the iterator, so you can use that to just render a certain part of the course, if you like.  =item * B<iterator>: A reference to a fresh ::iterator to use from the navmaps. The rendering will reflect the options passed to the iterator, so you can use that to just render a certain part of the course, if you like. If one is not passed, the renderer will attempt to construct one from ENV{'form.filter'} and ENV{'form.condition'} information.
   
   =item * B<navmap>: A reference to a navmap, used only if an iterator is not passed in. If this is necessary to make an iterator but it is not passed in, a new one will be constructed based on ENV info. This is useful to do basic error checking before passing it off to render.
   
 =item * B<cols>: An array reference  =item * B<cols>: An array reference
   
Line 664  Note these functions are responsible for Line 501  Note these functions are responsible for
   
 =item * B<condenseParts>: A flag. If yes (default), if all parts of the problem have the same status and that status is Nothing Set, Correct, or Network Failure, then only one line will be displayed for that resource anyhow. If no, all parts will always be displayed. If showParts is 0, this is ignored.  =item * B<condenseParts>: A flag. If yes (default), if all parts of the problem have the same status and that status is Nothing Set, Correct, or Network Failure, then only one line will be displayed for that resource anyhow. If no, all parts will always be displayed. If showParts is 0, this is ignored.
   
 =item * B<jumpCount>: A string identifying the URL to place the anchor 'curloc' at. Default to no anchor at all. It is the responsibility of the renderer user to ensure that the #curloc is in the URL.  =item * B<jumpCount>: A string identifying the URL to place the anchor 'curloc' at. Default to no anchor at all. It is the responsibility of the renderer user to ensure that the #curloc is in the URL. By default, determined through the use of the ENV{} 'jump' and 'jumpType' information.
   
 =item * B<hereURL>: A URL identifying where to place the 'here' marker.  =item * B<hereURL>: A URL identifying where to place the 'here' marker. By default, will pull this from the ENV{'form.here*'} info.
   
 =item * B<hereSymb>: A Symb identifying where to place the 'here' marker.  =item * B<hereSymb>: A Symb identifying where to place the 'here' marker. Default same as hereURL.
   
 =item * B<indentString>: A string identifying the indentation string to use. By default, this is a 25 pixel whitespace image with no alt text.  =item * B<indentString>: A string identifying the indentation string to use. By default, this is a 25 pixel whitespace image with no alt text.
   
Line 676  Note these functions are responsible for Line 513  Note these functions are responsible for
   
 =item * B<url>: The url the folders will link to, which should be the current page. Required if the resource info column is shown.  =item * B<url>: The url the folders will link to, which should be the current page. Required if the resource info column is shown.
   
 =item * B<currentJumpIndex>: Describes the currently-open row number to cause the browser to jump to, because the user just opened that folder.  =item * B<currentJumpIndex>: Describes the currently-open row number to cause the browser to jump to, because the user just opened that folder. By default, pulled from the Jump information in the ENV{'form.*'}.
   
 =item * B<r>: The standard Apache response object. If you pass this to the render, it will use it to flush the table every 20 rows and handle the rendering itself.  =item * B<r>: The standard Apache response object. If you pass this to the render, it will use it to flush the table every 20 rows and handle the rendering itself.
   
   =item * B<printKey>: If true, print the key that appears on the top of the standard navmaps. Default is false.
   
   =item * B<printCloseAll>: If true, print the "Close all folders" or "open all folders" links. Default is true.
   
 =back  =back
   
 =head2 Additional Info  =head2 Additional Info
Line 720  sub render_resource { Line 561  sub render_resource {
     # If this is a new branch, label it so      # If this is a new branch, label it so
     if ($params->{'isNewBranch'}) {      if ($params->{'isNewBranch'}) {
         $newBranchText = "<img src='/adm/lonIcons/branch.gif' border='0' />";          $newBranchText = "<img src='/adm/lonIcons/branch.gif' border='0' />";
         $params->{'isNewBranch'} = 0;  
     }      }
   
     # links to open and close the folder      # links to open and close the folder
Line 757  sub render_resource { Line 597  sub render_resource {
             . $params->{'hereType'} . '&here=' .              . $params->{'hereType'} . '&here=' .
             &Apache::lonnet::escape($params->{'here'}) .               &Apache::lonnet::escape($params->{'here'}) . 
             '&jumpType=' . SYMB() . '&jump=' .              '&jumpType=' . SYMB() . '&jump=' .
             &Apache::lonnet::escape($resource->symb()) . "'>";              &Apache::lonnet::escape($resource->symb()) . 
               "&folderManip=1'>";
     }      }
   
     if ($resource->randomout()) {      if ($resource->randomout()) {
Line 766  sub render_resource { Line 607  sub render_resource {
           
     # We're done preparing and finally ready to start the rendering      # We're done preparing and finally ready to start the rendering
     my $result = "<td align='left' valign='center'>";      my $result = "<td align='left' valign='center'>";
       
       my $indentLevel = $params->{'indentLevel'};
       if ($newBranchText) { $indentLevel--; }
   
     # print indentation      # print indentation
     for (my $i = 0; $i < $params->{'indentLevel'} -       for (my $i = 0; $i < $indentLevel; $i++) {
                          $params->{'deltaLevel'}; $i++) {  
         $result .= $params->{'indentString'};          $result .= $params->{'indentString'};
     }      }
   
Line 913  sub setDefault { Line 756  sub setDefault {
   
 sub render {  sub render {
     my $args = shift;      my $args = shift;
           &Apache::loncommon::get_unprocessed_cgi($ENV{QUERY_STRING});
       my $result = '';
   
     # Configure the renderer.      # Configure the renderer.
     my $cols = $args->{'cols'};      my $cols = $args->{'cols'};
     if (!defined($cols)) {      if (!defined($cols)) {
         # no columns, no nav maps.          # no columns, no nav maps.
         return '';          return '';
     }      }
     my $it = $args->{'iterator'};      my $mustCloseNavMap = 0;
     if (!defined($it)) {      my $navmap;
         # no iterator, no nav map.      if (defined($args->{'navmap'})) {
         return '';          $navmap = $args->{'navmap'};
     }      }
       
     my $showParts = setDefault($args->{'showParts'}, 1);      my $queryString = $args->{'queryString'};
     my $condenseParts = setDefault($args->{'condenseParts'}, 1);  
     my $jumpToURL = $args->{'jumpToURL'};      my $jumpToURL = $args->{'jumpToURL'};
     my $jumpToSymb = $args->{'jumpToSymb'};      my $jumpToSymb = $args->{'jumpToSymb'};
       my $jumpType;
     my $hereURL = $args->{'hereURL'};      my $hereURL = $args->{'hereURL'};
     my $hereSymb = $args->{'hereSymb'};      my $hereSymb = $args->{'hereSymb'};
     # keeps track of when the current resource is found,      my $hereType;
     # so we can back up a few and put the anchor above the      my $here;
     # current resource      my $jump;
     my $currentJumpIndex = setDefault($args->{'currentJumpIndex'}, 0);          my $currentJumpIndex = setDefault($args->{'currentJumpIndex'}, 0);    
     my $currentJumpDelta = 2; # change this to change how many resources are displayed      my $currentJumpDelta = 2; # change this to change how many resources are displayed
                              # before the current resource when using #current                               # before the current resource when using #current
     my $r = $args->{'r'};  
       # If we were passed 'here' information, we are not rendering
       # after a folder manipulation, and we were not passed an
       # iterator, make sure we open the folders to show the "here"
       # marker
       my $filterHash = {};
       # Figure out what we're not displaying
       foreach (split(/\,/, $ENV{"form.filter"})) {
           if ($_) {
               $filterHash->{$_} = "1";
           }
       }
   
       my $condition = 0;
       if ($ENV{'form.condition'}) {
           $condition = 1;
       }
   
       if (!$ENV{'form.folderManip'} && !defined($args->{'iterator'})) {
           # Step 1: Check to see if we have a navmap
           if (!defined($navmap)) {
               $navmap = Apache::lonnavmaps::navmap->new(
                           $ENV{"request.course.fn"}.".db",
                           $ENV{"request.course.fn"}."_parms.db", 1, 1);
               $mustCloseNavMap = 1;
           }
           $navmap->init();
   
           # Step two: Locate what kind of here marker is necessary
           # Determine where the "here" marker is and where the screen jumps to.
   
           # We're coming from the remote. We have either a url, a symb, or nothing,
           # and we need to figure out what.
           # Preference: Symb
           
           if ($ENV{'form.symb'}) {
               $hereType = $jumpType = SYMB();
               $here = $jump = $ENV{'form.symb'};
           } elsif ($ENV{'form.postdata'}) {
               # couldn't find a symb, is there a URL?
               my $currenturl = $ENV{'form.postdata'};
               $currenturl=~s/^http\:\/\///;
               $currenturl=~s/^[^\/]+//;
               
               $hereType = $jumpType = URL;
               $here = $jump = $currenturl;
           } else {
               # Nothing
               $hereType = $jumpType = NOTHING();
           }
           # Step three: Ensure the folders are open
           my $mapIterator = $navmap->getIterator(undef, undef, undef, 1);
           my $depth = 1;
           $mapIterator->next(); # discard the first BEGIN_MAP
           my $curRes = $mapIterator->next();
           my $counter = 0;
           my $found = 0;
           
           # We only need to do this if we need to open the maps to show the
           # current position. This will change the counter so we can't count
           # for the jump marker with this loop.
           while ($depth > 0 && !$found) {
               if ($curRes == $mapIterator->BEGIN_MAP()) { $depth++; }
               if ($curRes == $mapIterator->END_MAP()) { $depth--; }
               
               if (ref($curRes) && 
                   ($hereType == SYMB() && $curRes->symb() eq $here) ||
                   (ref($curRes) && $hereType == URL() && $curRes->src() eq $here)) {
                   my $mapStack = $mapIterator->getStack();
                   
                   # Ensure the parent maps are open
                   for my $map (@{$mapStack}) {
                       if ($condition) {
                           undef $filterHash->{$map->map_pc()};
                       } else {
                           $filterHash->{$map->map_pc()} = 1;
                       }
                   }
                   $found = 1;
               }
               
               $curRes = $mapIterator->next();
           }            
   
           # Since we changed the folders, (re-)locate the jump point, if any
           $mapIterator = $navmap->getIterator(undef, undef, $filterHash, 0);
           $depth = 1;
           $mapIterator->next();
           $curRes = $mapIterator->next();
           my $foundJump = 0;
           
           while ($depth > 0 && !$foundJump) {
               if ($curRes == $mapIterator->BEGIN_MAP()) { $depth++; }
               if ($curRes == $mapIterator->END_MAP()) { $depth--; }
               if (ref($curRes)) { $counter++; }
               
               if (ref($curRes) && 
                   (($jumpType == SYMB() && $curRes->symb() eq $jump) ||
                    ($jumpType == URL() && $curRes->src() eq $jump))) {
                   
                   # This is why we have to use the main iterator instead of the
                   # potentially faster DFS: The count has to be the same, so
                   # the order has to be the same, which DFS won't give us.
                   $currentJumpIndex = $counter;
                   $foundJump = 1;
               }
               
               $curRes = $mapIterator->next();
           }
           
       }        
       if ( !defined($args->{'iterator'}) && $ENV{'form.folderManip'} ) { # we came from a user's manipulation of the nav page
           # If this is a click on a folder or something, we want to preserve the "here"
           # from the querystring, and get the new "jump" marker
           $hereType = $ENV{'form.hereType'};
           $here = $ENV{'form.here'};
           $jumpType = $ENV{'form.jumpType'} || NOTHING();
           $jump = $ENV{'form.jump'};
       } 
           
                   my $it = $args->{'iterator'};
       if (!defined($it)) {
           # Construct a default iterator based on $ENV{'form.'} information
           
           # Step 1: Check to see if we have a navmap
           if (!defined($navmap)) {
               $navmap = Apache::lonnavmaps::navmap->new(
                           $ENV{"request.course.fn"}.".db",
                           $ENV{"request.course.fn"}."_parms.db", 1, 1);
               $mustCloseNavMap = 1;
           }
           # Paranoia: Make sure it's ready
           $navmap->init();
   
           $args->{'iterator'} = $it = $navmap->getIterator(undef, undef, $filterHash, $condition);
       }
       
       my $showParts = setDefault($args->{'showParts'}, 1);
       my $condenseParts = setDefault($args->{'condenseParts'}, 1);
       # keeps track of when the current resource is found,
       # so we can back up a few and put the anchor above the
       # current resource
       my $r = $args->{'r'};
       my $printKey = $args->{'printKey'};
       my $printCloseAll = $args->{'printCloseAll'};
       if (!defined($printCloseAll)) { $printCloseAll = 1; }
   
       # Print key?
       if ($printKey) {
           $result .= '<table border="0" cellpadding="2" cellspacing="0">';
           my $date=localtime;
           $result.='<tr><td align="right" valign="bottom">Key:&nbsp;&nbsp;</td>';
           if ($navmap->{LAST_CHECK}) {
               $result .= 
                   '<img src="/adm/lonMisc/chat.gif"> New discussion since '.
                   strftime("%A, %b %e at %I:%M %P", localtime($navmap->{LAST_CHECK})).
                   '</td><td align="center" valign="bottom">&nbsp;&nbsp;'.
                   '<img src="/adm/lonMisc/feedback.gif"> New message (click to open)<p>'.
                   '</td>'; 
           } else {
               $result .= '<td align="center" valign="bottom">&nbsp;&nbsp;'.
                   '<img src="/adm/lonMisc/chat.gif"> Discussions</td><td align="center" valign="bottom">'.
                   '&nbsp;&nbsp;<img src="/adm/lonMisc/feedback.gif"> New message (click to open)'.
                   '</td>'; 
           }
   
           $result .= '</tr></table>';
       }
   
       if ($printCloseAll) {
           if ($condition) {
               $result.="<a href=\"navmaps?condition=0&filter=&$queryString" .
                   "&hereType=$hereType&here=" . Apache::lonnet::escape($here) .
                   "\">Close All Folders</a>";
           } else {
               $result.="<a href=\"navmaps?condition=1&filter=&$queryString" .
                   "&hereType=$hereType&here=" . Apache::lonnet::escape($here) . 
                   "\">Open All Folders</a>";
           }
       }    
   
       if ($r) {
           $r->print($result);
           $r->rflush();
           $result = "";
       }
     # End parameter setting      # End parameter setting
                           
     # Data      # Data
     my $result .= '<table cellspacing="0" cellpadding="3" border="0" bgcolor="#FFFFFF">' ."\n";      $result .= '<table cellspacing="0" cellpadding="3" border="0" bgcolor="#FFFFFF">' ."\n";
     my $res = "Apache::lonnavmaps::resource";      my $res = "Apache::lonnavmaps::resource";
     my %condenseStatuses =      my %condenseStatuses =
         ( $res->NETWORK_FAILURE    => 1,          ( $res->NETWORK_FAILURE    => 1,
Line 995  sub render { Line 1022  sub render {
         }          }
   
         $args->{'counter'}++;          $args->{'counter'}++;
         # reserve space for branch symbol  
         $args->{'deltalevel'} = $args->{'isNewBranch'}? 1 : 0;   
         if ($args->{'indentLevel'} - $args->{'deltalevel'} < 0) {  
             # If this would be at a negative depth (top-level maps in  
             # new-style courses, we want to suppress their title display)  
             # then ignore it.  
             $curRes = $it->next();  
             next;  
         }  
   
         # Does it have multiple parts?          # Does it have multiple parts?
         $args->{'multipart'} = 0;          $args->{'multipart'} = 0;
Line 1114  sub render { Line 1132  sub render {
                 $result .= $colHTML . "\n";                  $result .= $colHTML . "\n";
             }              }
             $result .= "    </tr>\n";              $result .= "    </tr>\n";
               $args->{'isNewBranch'} = 0;
         }          }
                   
         if ($r && $rownum % 20 == 0) {          if ($r && $rownum % 20 == 0) {
Line 1131  sub render { Line 1150  sub render {
     }      }
   
     $result .= "</table>";      $result .= "</table>";
       
       if ($r) {
           $r->print($result);
           $result = "";
           $r->rflush();
       }
           
       if ($mustCloseNavMap) { $navmap->untieHashes(); } 
   
     return $result;      return $result;
 }  }
Line 1200  sub new { Line 1227  sub new {
     $self->{HASH_TIED} = 1;      $self->{HASH_TIED} = 1;
     $self->{NAV_HASH} = \%navmaphash;      $self->{NAV_HASH} = \%navmaphash;
     $self->{PARM_HASH} = \%parmhash;      $self->{PARM_HASH} = \%parmhash;
       $self->{INITED} = 0;
   
     bless($self);      bless($self);
                   
Line 1208  sub new { Line 1236  sub new {
   
 sub init {  sub init {
     my $self = shift;      my $self = shift;
       if ($self->{INITED}) { return; }
   
     # If the course opt hash and the user opt hash should be generated,      # If the course opt hash and the user opt hash should be generated,
     # generate them      # generate them
Line 1313  sub init { Line 1342  sub init {
     }          }    
   
     $self->{PARM_CACHE} = {};      $self->{PARM_CACHE} = {};
       $self->{INITED} = 1;
 }  }
   
 # Internal function: Takes a key to look up in the nav hash and implements internal  # Internal function: Takes a key to look up in the nav hash and implements internal
Line 1964  sub new { Line 1994  sub new {
   
     # A hash, used as a set, of resource already seen      # A hash, used as a set, of resource already seen
     $self->{ALREADY_SEEN} = shift;      $self->{ALREADY_SEEN} = shift;
     if (!defined($self->{ALREADY_SEEN})) { $self->{ALREADY_SEEN} = {} };       if (!defined($self->{ALREADY_SEEN})) { $self->{ALREADY_SEEN} = {} };
     $self->{CONDITION} = shift;      $self->{CONDITION} = shift;
     $self->{DIRECTION} = shift || FORWARD();      $self->{DIRECTION} = shift || FORWARD();
   
Line 2087  A resource object encapsulates a resourc Line 2117  A resource object encapsulates a resourc
   
 A resource only makes sense in the context of a navmap, as some of the data is stored in the navmap object.  A resource only makes sense in the context of a navmap, as some of the data is stored in the navmap object.
   
 You will probably never need to instantiate this object directly. Use Apache::lonnavmap::navmap, and use the "start" method to obtain the starting resource.  You will probably never need to instantiate this object directly. Use Apache::lonnavmaps::navmap, and use the "start" method to obtain the starting resource.
   
 =head2 Public Members  =head2 Public Members
   
Line 2218  These methods are shortcuts to deciding Line 2248  These methods are shortcuts to deciding
   
 =item * B<is_page>: Returns true if the resource is a page.  =item * B<is_page>: Returns true if the resource is a page.
   
 =item * B<is_problem>: Returns true if the resource is a problem.  
   
 =item * B<is_sequence>: Returns true if the resource is a sequence.  =item * B<is_sequence>: Returns true if the resource is a sequence.
   
 =back  =back

Removed from v.1.139  
changed lines
  Added in v.1.140


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>