# The LearningOnline Network with CAPA # Navigate Maps Handler # # $Id: lonnavmaps.pm,v 1.522 2016/07/18 19:28:57 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # # This file is part of the LearningOnline Network with CAPA (LON-CAPA). # # LON-CAPA is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # LON-CAPA is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with LON-CAPA; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # /home/httpd/html/adm/gpl.txt # # http://www.lon-capa.org/ # ### =pod =head1 NAME Apache::lonnavmaps - Subroutines to handle and render the navigation =head1 SYNOPSIS Handles navigational maps. The main handler generates the navigational listing for the course, the other objects export this information in a usable fashion for other modules. This is part of the LearningOnline Network with CAPA project described at http://www.lon-capa.org. =head1 OVERVIEW 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 resources are being chosen to not show to the student (for random selection), and a lot of other things that can take a lot of time to compute due to the amount of data that needs to be collected and processed. Apache::lonnavmaps provides an object model for manipulating this information in a higher-level fashion than directly manipulating the hash. It also provides access to several auxilary functions that aren't necessarily stored in the Big Hash, but are a per- resource sort of value, like whether there is any feedback on a given resource. Apache::lonnavmaps also abstracts away branching, and someday, conditions, for the times where you don't really care about those things. Apache::lonnavmaps also provides fairly powerful routines for rendering navmaps, and last but not least, provides the navmaps view for when the user clicks the NAV button. B: Apache::lonnavmaps I works for the "currently logged in user"; if you want things like "due dates for another student" lonnavmaps can not directly retrieve information like that. You need the EXT function. This module can still help, because many things, such as the course structure, are constant between users, and Apache::lonnavmaps can help by providing symbs for the EXT call. The rest of this file will cover the provided rendering routines, which can often be used without fiddling with the navmap object at all, then documents the Apache::lonnavmaps::navmap object, which is the key to accessing the Big Hash information, covers the use of the Iterator (which provides the logic for traversing the somewhat-complicated Big Hash data structure), documents the Apache::lonnavmaps::Resource objects that are returned by =head1 Subroutine: render The navmap renderer package provides a sophisticated rendering of the standard navigation maps interface into HTML. The provided nav map handler is actually just a glorified call to this. Because of the large number of parameters this function accepts, instead of passing it arguments as is normal, pass it in an anonymous hash with the desired options. The package provides a function called 'render', called as Apache::lonnavmaps::render({}). =head2 Overview of Columns The renderer will build an HTML table for the navmap and return it. The table consists of several columns, and a row for each resource (or possibly each part). You tell the renderer how many columns to create and what to place in each column, optionally using one or more of the prepared columns, and the renderer will assemble the table. Any additional generally useful column types should be placed in the renderer code here, so anybody can use it anywhere else. Any code specific to the current application (such as the addition of elements in a column) should be placed in the code of the thing using the renderer. At the core of the renderer is the array reference COLS (see Example section below for how to pass this correctly). The COLS array will consist of entries of one of two types of things: Either an integer representing one of the pre-packaged column types, or a sub reference that takes a resource reference, a part number, and a reference to the argument hash passed to the renderer, and returns a string that will be inserted into the HTML representation as it. All other parameters are ways of either changing how the columns are printing, or which rows are shown. The pre-packaged column names are refered to by constants in the Apache::lonnavmaps namespace. The following currently exist: =over 4 =item * B: The general info about the resource: Link, icon for the type, etc. The first column in the standard nav map display. This column provides the indentation effect seen in the B