# The LearningOnline Network with CAPA # Navigate Maps Handler # # $Id: lonnavmaps.pm,v 1.255 2004/03/22 22:17:40 albertel 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/ # ### package Apache::lonnavmaps; use strict; use Apache::Constants qw(:common :http); use Apache::loncommon(); use Apache::lonmenu(); use Apache::lonlocal; use POSIX qw (floor strftime); use Data::Dumper; # for debugging, not always used # symbolic constants sub SYMB { return 1; } sub URL { return 2; } sub NOTHING { return 3; } # Some data my $resObj = "Apache::lonnavmaps::resource"; # Keep these mappings in sync with lonquickgrades, which uses the colors # instead of the icons. my %statusIconMap = ( $resObj->CLOSED => '', $resObj->OPEN => 'navmap.open.gif', $resObj->CORRECT => 'navmap.correct.gif', $resObj->INCORRECT => 'navmap.wrong.gif', $resObj->ATTEMPTED => 'navmap.ellipsis.gif', $resObj->ERROR => '' ); my %iconAltTags = ( 'navmap.correct.gif' => 'Correct', 'navmap.wrong.gif' => 'Incorrect', 'navmap.open.gif' => 'Open' ); # Defines a status->color mapping, null string means don't color my %colormap = ( $resObj->NETWORK_FAILURE => '', $resObj->CORRECT => '', $resObj->EXCUSED => '#3333FF', $resObj->PAST_DUE_ANSWER_LATER => '', $resObj->PAST_DUE_NO_ANSWER => '', $resObj->ANSWER_OPEN => '#006600', $resObj->OPEN_LATER => '', $resObj->TRIES_LEFT => '', $resObj->INCORRECT => '', $resObj->OPEN => '', $resObj->NOTHING_SET => '', $resObj->ATTEMPTED => '', $resObj->ANSWER_SUBMITTED => '' ); # 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 my $hurryUpColor = "#FF0000"; sub handler { my $r = shift; real_handler($r); } sub real_handler { my $r = shift; # Handle header-only request if ($r->header_only) { if ($ENV{'browser.mathml'}) { &Apache::loncommon::content_type($r,'text/xml'); } else { &Apache::loncommon::content_type($r,'text/html'); } $r->send_http_header; return OK; } # Send header, don't cache this page if ($ENV{'browser.mathml'}) { &Apache::loncommon::content_type($r,'text/xml'); } else { &Apache::loncommon::content_type($r,'text/html'); } &Apache::loncommon::no_cache($r); $r->send_http_header; # Create the nav map my $navmap = Apache::lonnavmaps::navmap->new(); if (!defined($navmap)) { my $requrl = $r->uri; $ENV{'user.error.msg'} = "$requrl:bre:0:0:Course not initialized"; return HTTP_NOT_ACCEPTABLE; } $r->print("
\n"); $r->print("