--- loncom/interface/lonnavmaps.pm 2003/07/17 18:40:49 1.216 +++ loncom/interface/lonnavmaps.pm 2003/07/21 20:25:42 1.217 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Navigate Maps Handler # -# $Id: lonnavmaps.pm,v 1.216 2003/07/17 18:40:49 bowersj2 Exp $ +# $Id: lonnavmaps.pm,v 1.217 2003/07/21 20:25:42 bowersj2 Exp $ # # Copyright Michigan State University Board of Trustees # @@ -552,7 +552,8 @@ sub timeToHumanString { =head1 NAME -Apache::lonnavmap - Subroutines to handle and render the navigation maps +Apache::lonnavmap - Subroutines to handle and render the navigation + maps =head1 SYNOPSIS @@ -562,12 +563,12 @@ other modules. =head1 OVERVIEW -When a user enters a course, LON-CAPA examines the course structure -and caches it in what is often referred to as the "big hash". You -can see it if you are logged into LON-CAPA, in a course, by going -to /adm/test. (You may need to tweak the /home/httpd/lonTabs/htpasswd -file to view it.) The content of the hash will be under the heading -"Big Hash". +X When a user enters a course, LON-CAPA examines the + course structure and caches it in what is often referred to as the + "big hash" X. You can see it if you are logged into + LON-CAPA, in a course, by going to /adm/test. (You may need to + tweak the /home/httpd/lonTabs/htpasswd file to view it.) The + content of the hash will be under the heading "Big Hash". Big Hash contains, among other things, how resources are related to each other (next/previous), what resources are maps, which @@ -716,9 +717,7 @@ to override vertical and horizontal alig =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 +Minimally, 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 @@ -1605,14 +1604,50 @@ package Apache::lonnavmaps::navmap; =head1 Object: Apache::lonnavmaps::navmap -You must obtain resource objects through the navmap object. +=head2 Overview -=head2 Creation +The navmap object's job is to provide access to the resources +in the course as Apache::lonnavmaps::resource objects, and to +query and manage the relationship between those resource objects. + +Generally, you'll use the navmap object in one of three basic ways. +In order of increasing complexity and power: + +=over 4 + +=item * C<$navmap-EgetByX>, where X is B, B, B or B. This provides + various ways to obtain resource objects, based on various identifiers. + Use this when you want to request information about one object or + a handful of resources you already know the identities of, from some + other source. For more about Ids, Symbs, and MapPcs, see the + Resource documentation. Note that Url should be a B, + not your first choice; it only works when there is only one + instance of the resource in the course, which only applies to + maps, and even that may change in the future. + +=item * CretrieveResources(args)>. This + retrieves resources matching some criterion and returns them + in a flat array, with no structure information. Use this when + you are manipulating a series of resources, based on what map + the are in, but do not care about branching, or exactly how + the maps and resources are related. This is the most common case. + +=item * C<$it = $navmap-EgetIterator(args)>. This allows you traverse + the course's navmap in various ways without writing the traversal + code yourself. See iterator documentation below. Use this when + you need to know absolutely everything about the course, including + branches and the precise relationship between maps and resources. + +=back + +=head2 Creation And Destruction + +To create a navmap object, use the following function: =over 4 -=item * B(navHashFile, parmHashFile, genCourseAndUserOptions, - genMailDiscussStatus, getUserData): +=item * Bnew>(navHashFile, parmHashFile, + genCourseAndUserOptions, genMailDiscussStatus, getUserData): Binds a new navmap object to the compiled nav map hash and parm hash given as filenames. genCourseAndUserOptions is a flag saying whether @@ -1628,6 +1663,16 @@ retreive the user's performance data for =back +Once you have the $navmap object, call ->init() on it when you are ready +to use it. This allows you to check if the course map is defined (see +B below) before engaging in potentially expensive +initialization routines for the genCourseAndUserOptions and +genMailDiscussStatus option. + +When you are done with the $navmap object, you I call +$navmap->untieHashes(), or you'll prevent the current user from using that +course until the web server is restarted. (!) + =head2 Methods =over 4 @@ -1810,6 +1855,15 @@ sub navhash { return $self->{NAV_HASH}->{$key}; } +=pod + +=item * B(): Returns true if the course map is defined, + false otherwise. Undefined course maps indicate an error somewhere in + LON-CAPA, and you will not be able to proceed with using the navmap. + See the B