--- loncom/interface/lonnavmaps.pm 2003/01/30 21:36:57 1.132
+++ loncom/interface/lonnavmaps.pm 2003/02/06 21:26:21 1.138
@@ -2,7 +2,7 @@
# The LearningOnline Network with CAPA
# Navigate Maps Handler
#
-# $Id: lonnavmaps.pm,v 1.132 2003/01/30 21:36:57 bowersj2 Exp $
+# $Id: lonnavmaps.pm,v 1.138 2003/02/06 21:26:21 bowersj2 Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -49,6 +49,51 @@ use POSIX qw (floor strftime);
my %navmaphash;
my %parmhash;
+# symbolic constants
+sub SYMB { return 1; }
+sub URL { return 2; }
+sub NOTHING { return 3; }
+
+# Some data
+
+# Keep these mappings in sync with lonquickgrades, which uses the colors
+# instead of the icons.
+my %statusIconMap =
+ ( Apache::lonnavmaps::resource->NETWORK_FAILURE => '',
+ Apache::lonnavmaps::resource->NOTHING_SET => '',
+ Apache::lonnavmaps::resource->CORRECT => 'navmap.correct.gif',
+ Apache::lonnavmaps::resource->EXCUSED => 'navmap.correct.gif',
+ Apache::lonnavmaps::resource->PAST_DUE_NO_ANSWER => 'navmap.wrong.gif',
+ Apache::lonnavmaps::resource->PAST_DUE_ANSWER_LATER => 'navmap.wrong.gif',
+ Apache::lonnavmaps::resource->ANSWER_OPEN => 'navmap.wrong.gif',
+ Apache::lonnavmaps::resource->OPEN_LATER => '',
+ Apache::lonnavmaps::resource->TRIES_LEFT => 'navmap.open.gif',
+ Apache::lonnavmaps::resource->INCORRECT => 'navmap.wrong.gif',
+ Apache::lonnavmaps::resource->OPEN => 'navmap.open.gif',
+ Apache::lonnavmaps::resource->ATTEMPTED => 'navmap.open.gif' );
+
+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 =
+ ( Apache::lonnavmaps::resource->NETWORK_FAILURE => '',
+ Apache::lonnavmaps::resource->CORRECT => '',
+ Apache::lonnavmaps::resource->EXCUSED => '#3333FF',
+ Apache::lonnavmaps::resource->PAST_DUE_ANSWER_LATER => '',
+ Apache::lonnavmaps::resource->PAST_DUE_NO_ANSWER => '',
+ Apache::lonnavmaps::resource->ANSWER_OPEN => '#006600',
+ Apache::lonnavmaps::resource->OPEN_LATER => '',
+ Apache::lonnavmaps::resource->TRIES_LEFT => '',
+ Apache::lonnavmaps::resource->INCORRECT => '',
+ Apache::lonnavmaps::resource->OPEN => '',
+ Apache::lonnavmaps::resource->NOTHING_SET => '' );
+# 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 cleanup {
if (tied(%navmaphash)){
&Apache::lonnet::logthis('Cleanup navmaps: navmaphash');
@@ -145,10 +190,9 @@ sub real_handler {
}
# Determine where the "here" marker is and where the screen jumps to.
- my $SYMB = 1; my $URL = 2; my $NOTHING = 3; # symbolic constants
- my $hereType; # the type of marker, $SYMB, $URL, or $NOTHING
+ 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 $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
@@ -156,7 +200,7 @@ sub real_handler {
# from the querystring, and get the new "jump" marker
$hereType = $ENV{'form.hereType'};
$here = $ENV{'form.here'};
- $jumpType = $ENV{'form.jumpType'} || $NOTHING;
+ $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,
@@ -164,7 +208,7 @@ sub real_handler {
# Preference: Symb
if ($ENV{'form.symb'}) {
- $hereType = $jumpType = $SYMB;
+ $hereType = $jumpType = SYMB();
$here = $jump = $ENV{'form.symb'};
} elsif ($ENV{'form.postdata'}) {
# couldn't find a symb, is there a URL?
@@ -172,11 +216,11 @@ sub real_handler {
$currenturl=~s/^http\:\/\///;
$currenturl=~s/^[^\/]+//;
- $hereType = $jumpType = $URL;
+ $hereType = $jumpType = URL;
$here = $jump = $currenturl;
} else {
# Nothing
- $hereType = $jumpType = $NOTHING;
+ $hereType = $jumpType = NOTHING();
}
}
@@ -215,44 +259,6 @@ sub real_handler {
# These are some data tables, which make it easy to change some of
# of the specific visualization parameters if desired.
- # Defines a status->color mapping, null string means don't color
- my %colormap =
- ( $res->NETWORK_FAILURE => '',
- $res->CORRECT => '',
- $res->EXCUSED => '#3333FF',
- $res->PAST_DUE_ANSWER_LATER => '',
- $res->PAST_DUE_NO_ANSWER => '',
- $res->ANSWER_OPEN => '#006600',
- $res->OPEN_LATER => '',
- $res->TRIES_LEFT => '',
- $res->INCORRECT => '',
- $res->OPEN => '',
- $res->NOTHING_SET => '' );
- # 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";
-
- # Keep these mappings in sync with lonquickgrades, which uses the colors
- # instead of the icons.
- my %statusIconMap =
- ( $res->NETWORK_FAILURE => '',
- $res->NOTHING_SET => '',
- $res->CORRECT => 'navmap.correct.gif',
- $res->EXCUSED => 'navmap.correct.gif',
- $res->PAST_DUE_NO_ANSWER => 'navmap.wrong.gif',
- $res->PAST_DUE_ANSWER_LATER => 'navmap.wrong.gif',
- $res->ANSWER_OPEN => 'navmap.wrong.gif',
- $res->OPEN_LATER => '',
- $res->TRIES_LEFT => 'navmap.open.gif',
- $res->INCORRECT => 'navmap.wrong.gif',
- $res->OPEN => 'navmap.open.gif',
- $res->ATTEMPTED => 'navmap.open.gif' );
-
- my %iconAltTags =
- ( 'navmap.correct.gif' => 'Correct',
- 'navmap.wrong.gif' => 'Incorrect',
- 'navmap.open.gif' => 'Open' );
-
my %condenseStatuses =
( $res->NETWORK_FAILURE => 1,
$res->NOTHING_SET => 1,
@@ -291,7 +297,7 @@ sub real_handler {
$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 $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
@@ -302,8 +308,8 @@ sub real_handler {
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)) {
+ ($hereType == SYMB() && $curRes->symb() eq $here) ||
+ (ref($curRes) && $hereType == URL() && $curRes->src() eq $here)) {
my $mapStack = $mapIterator->getStack();
# Ensure the parent maps are open
@@ -332,8 +338,8 @@ sub real_handler {
if (ref($curRes)) { $counter++; }
if (ref($curRes) &&
- (($jumpType == $SYMB && $curRes->symb() eq $jump) ||
- ($jumpType == $URL && $curRes->src() eq $jump))) {
+ (($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.
@@ -542,13 +548,12 @@ sub real_handler {
removeFromFilter(\%filterHash, $mapId);
$linkopen .= "&condition=$condition&$queryAdd" .
"&hereType=$hereType&here=" .
- Apache::lonnet::escape($here) . "&jumpType=$SYMB&" .
+ Apache::lonnet::escape($here) . "&jumpType=".SYMB()."&" .
"jump=" . Apache::lonnet::escape($curRes->symb()) ."\">";
$linkclose = "";
}
- my $colorizer = "";
my $color;
if ($curRes->is_problem()) {
$color = $colormap{$curRes->status};
@@ -557,10 +562,6 @@ sub real_handler {
lastTry($curRes, $part)) {
$color = $hurryUpColor;
}
-
- if ($color ne "") {
- $colorizer = "bgcolor=\"$color\"";
- }
}
if ($curRes->randomout()) {
@@ -591,8 +592,8 @@ sub real_handler {
# Is this the current resource?
if (!$displayedHereMarker &&
- (($hereType == $SYMB && $curRes->symb eq $here) ||
- ($hereType == $URL && $curRes->src eq $here))) {
+ (($hereType == SYMB() && $curRes->symb eq $here) ||
+ ($hereType == URL() && $curRes->src eq $here))) {
$curMarkerBegin = '> ';
$curMarkerEnd = ' <';
$displayedHereMarker = 1;
@@ -700,9 +701,17 @@ sub real_handler {
$r->print('');
}
+ # renderer call
+ $mapIterator = $navmap->getIterator(undef, undef, \%filterHash, 0);
+ my $render = render({ 'cols' => [0,1,2,3], 'iterator' => $mapIterator,
+ 'url' => '/adm/navmaps',
+ 'queryString' => 'alreadyHere=1' });
+ $r->print('|' . $render . '|');
+
$navmap->untieHashes();
$r->print("