--- loncom/interface/lonnavmaps.pm 2003/03/20 20:40:42 1.129.2.2
+++ loncom/interface/lonnavmaps.pm 2003/01/31 22:46:50 1.133
@@ -2,7 +2,7 @@
# The LearningOnline Network with CAPA
# Navigate Maps Handler
#
-# $Id: lonnavmaps.pm,v 1.129.2.2 2003/03/20 20:40:42 albertel Exp $
+# $Id: lonnavmaps.pm,v 1.133 2003/01/31 22:46:50 bowersj2 Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -46,6 +46,32 @@ use Apache::Constants qw(:common :http);
use Apache::loncommon();
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
+
+
+sub cleanup {
+ if (tied(%navmaphash)){
+ &Apache::lonnet::logthis('Cleanup navmaps: navmaphash');
+ unless (untie(%navmaphash)) {
+ &Apache::lonnet::logthis('Failed cleanup navmaps: navmaphash');
+ }
+ }
+ if (tied(%parmhash)){
+ &Apache::lonnet::logthis('Cleanup navmaps: parmhash');
+ unless (untie(%parmhash)) {
+ &Apache::lonnet::logthis('Failed cleanup navmaps: parmhash');
+ }
+ }
+}
+
sub handler {
my $r = shift;
real_handler($r);
@@ -127,10 +153,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
@@ -138,7 +163,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,
@@ -146,7 +171,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?
@@ -154,11 +179,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();
}
}
@@ -273,7 +298,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
@@ -284,8 +309,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
@@ -314,8 +339,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.
@@ -332,7 +357,7 @@ sub real_handler {
undef $res; # so we don't accidentally use it later
my $indentLevel = 0;
- my $indentString = "";
+ my $indentString = "";
my $isNewBranch = 0;
my $now = time();
@@ -370,13 +395,6 @@ sub real_handler {
if (ref($curRes)) { $counter++; }
- # Is this resource being ignored because it is in a random-out
- # map and it was not selected?
- if (ref($curRes) && !advancedUser() && $curRes->randomout()) {
- $curRes = $mapIterator->next();
- next; # if yes, then just ignore this resource
- }
-
if (ref($curRes)) {
my $deltalevel = $isNewBranch? 1 : 0; # reserves space for branch icon
@@ -403,12 +421,15 @@ sub real_handler {
# just display first
if (!$curRes->opendate("0")) {
# no parts are open, display as one part
- @parts = ();
+ @parts = ("0");
$condensed = 1;
} else {
# Otherwise, only display part 0 if we want to
# attach feedback or email information to it
if ($curRes->hasDiscussion() || $curRes->getFeedback()) {
+ # Is this right? I think this will toss it
+ # if it DOES have discussion, not if it doesn't?
+ # - Jeremy (yes, commenting on his own code)
shift @parts;
} else {
# Now, we decide whether to condense the
@@ -431,7 +452,7 @@ sub real_handler {
}
}
- # $allSame is true if all the statuses were
+ # $*allSame is true if all the statuses were
# the same. Now, if they are all the same and
# match one of the statuses to condense, or they
# are all open with the same due date, or they are
@@ -441,19 +462,23 @@ sub real_handler {
if (($statusAllSame && defined($condenseStatuses{$status})) ||
($dueAllSame && $status == $curRes->OPEN && $statusAllSame)||
($openAllSame && $status == $curRes->OPEN_LATER && $statusAllSame) ){
- @parts = ();
+ @parts = ($parts[1]);
$condensed = 1;
}
}
}
}
+ } else {
+ $parts[0] = "0"; # this is to get past foreach loop below
+ # you can consider a non-problem resource as a resource
+ # with only one part without loss, and it simplifies the looping
}
# Is it a multipart problem with a single part, now in
# @parts with "0" filtered out? If so, 'forget' it's a multi-part
# problem and treat it like a single-part problem.
- if ( scalar(@parts) == 0 ) {
+ if ( scalar(@parts) == 1 ) {
$multipart = 0;
}
@@ -462,16 +487,13 @@ sub real_handler {
# status, but if it's multipart, we're lost, since we can't
# retreive the metadata to count the parts
if ($curRes->{RESOURCE_ERROR}) {
- @parts = ();
+ @parts = ("0");
}
# Step Two: Print the actual data.
# For each part we intend to display...
- foreach my $part ('', @parts) {
- if ($part eq '0') {
- next;
- }
+ foreach my $part (@parts) {
my $nonLinkedText = ""; # unlinked stuff after title
@@ -506,7 +528,7 @@ sub real_handler {
my $icon = "";
if ($curRes->is_problem()) {
- if ($part eq "" || $condensed) {
+ if ($part eq "0" || $condensed) {
$icon = '';
} else {
$icon = $indentString;
@@ -527,7 +549,7 @@ 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 = "";
@@ -576,18 +598,18 @@ 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;
}
- if ($curRes->is_problem() && $part ne "" && !$condensed) {
+ if ($curRes->is_problem() && $part ne "0" && !$condensed) {
$partLabel = " (Part $part)";
$title = "";
}
- if ($condensed && $curRes->countParts() > 1) {
+ if ($multipart && $condensed) {
$nonLinkedText .= ' (' . $curRes->countParts() . ' parts)';
}
@@ -685,6 +707,13 @@ 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("