--- loncom/interface/lonnavmaps.pm 2002/10/24 18:38:26 1.85
+++ loncom/interface/lonnavmaps.pm 2002/10/28 20:48:29 1.89
@@ -2,7 +2,7 @@
# The LearningOnline Network with CAPA
# Navigate Maps Handler
#
-# $Id: lonnavmaps.pm,v 1.85 2002/10/24 18:38:26 bowersj2 Exp $
+# $Id: lonnavmaps.pm,v 1.89 2002/10/28 20:48:29 bowersj2 Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -876,7 +876,7 @@ sub new_handle {
$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 = "#FFCCCC";
+ my $hurryUpColor = "#FF0000";
my %statusIconMap =
( $res->NETWORK_FAILURE => '',
@@ -910,6 +910,11 @@ sub new_handle {
}
}
+ # Is this a new-style course? If so, we want to suppress showing the top-level
+ # maps in their own folders, in favor of "inlining" them.
+ my $topResource = $navmap->getById("0.0");
+ my $inlineTopLevelMaps = $topResource->src() =~ m|^/uploaded/.*default\.sequence$|;
+
my $currenturl = $ENV{'form.postdata'};
$currenturl=~s/^http\:\/\///;
$currenturl=~s/^[^\/]+//;
@@ -936,35 +941,53 @@ sub new_handle {
# instead of uris. The changes to this and the main rendering
# loop should be obvious.
# Here's a simple example of the iterator.
- # If there is a current resource
- if ($currenturl && !$ENV{'form.alreadyHere'}) {
- # Give me every resource...
- my $mapIterator = $navmap->getIterator(undef, undef, {}, 1);
- my $found = 0;
- my $depth = 1;
- $mapIterator->next(); # discard the first BEGIN_MAP
- my $curRes = $mapIterator->next();
-
- while ($depth > 0 && !$found) {
- if (ref($curRes) && $curRes->src() eq $currenturl) {
- # If this is the correct resource, be sure to
- # show it by making sure the containing maps
- # are open.
-
- my $mapStack = $mapIterator->getStack();
- for my $map (@{$mapStack}) {
- if ($condition) {
- undef $filterHash{$map->map_pc()};
- } else {
- $filterHash{$map->map_pc()} = 1;
- }
+ # Preprocess the map: Look for current URL, force inlined maps to display
+
+ my $mapIterator = $navmap->getIterator(undef, undef, {}, 1);
+ my $found = 0;
+ my $depth = 1;
+ $mapIterator->next(); # discard the first BEGIN_MAP
+ my $curRes = $mapIterator->next();
+
+ while ($depth > 0) {
+ if ($curRes == $mapIterator->BEGIN_MAP()) {
+ $depth++;
+ }
+ if ($curRes == $mapIterator->END_MAP()) {
+ $depth--;
+ }
+
+ my $mapStack = $mapIterator->getStack();
+ if ($currenturl && !$ENV{'form.alreadyHere'} && ref($curRes) &&
+ $curRes->src() eq $currenturl) {
+ # If this is the correct resource, be sure to
+ # show it by making sure the containing maps
+ # are open.
+
+ for my $map (@{$mapStack}) {
+ if ($condition) {
+ undef $filterHash{$map->map_pc()};
+ } else {
+ $filterHash{$map->map_pc()} = 1;
}
- $found = 1;
}
- $curRes = $mapIterator->next();
+ $ENV{'form.alreadyHere'} = 1;
+ }
+
+ # Preprocessing: If we're inlining nav maps into the top-level display,
+ # make sure we show this map!
+ if ($inlineTopLevelMaps && ref($curRes) && $curRes->is_map &&
+ scalar(@{$mapStack}) == 1) {
+ if ($condition) {
+ undef $filterHash{$curRes->map_pc()};
+ } else {
+ $filterHash{$curRes->map_pc()} = 1;
+ }
}
- }
+ $curRes = $mapIterator->next();
+ }
+
undef $res; # so we don't accidentally use it later
my $indentLevel = 0;
my $indentString = "";
@@ -972,17 +995,33 @@ sub new_handle {
my $isNewBranch = 0;
my $now = time();
my $in24Hours = $now + 24 * 60 * 60;
- my $depth = 1;
my $displayedHereMarker = 0;
-
+
# We know the first thing is a BEGIN_MAP (see "$self->{STARTED}"
# code in iterator->next), so ignore the first one
- my $mapIterator = $navmap->getIterator(undef, undef, \%filterHash,
+ $mapIterator = $navmap->getIterator(undef, undef, \%filterHash,
$condition);
$mapIterator->next();
- my $curRes = $mapIterator->next();
+ $curRes = $mapIterator->next();
+ my $deltadepth = 0;
+
+ my @backgroundColors = ("#FFFFFF", "#F6F6F6");
+ my $rowNum = 0;
while ($depth > 0) {
+ # If we're in a new style course, and this is a BEGIN_MAP, END_MAP, or
+ # map resource and the stack depth is only one, just plain ignore this resource
+ # entirely. (This has the effect of inlining the resources in that map
+ # in the nav map.)
+ if ($inlineTopLevelMaps && scalar(@{$mapIterator->getStack()}) == 1 &&
+ ref($curRes) && $curRes->is_map()) {
+ # We let the normal depth stuff occur, but we need to shift everything
+ # over by one to the left to make it look right.
+ $deltadepth = -1;
+ $curRes = $mapIterator->next();
+ next;
+ }
+
if ($curRes == $mapIterator->BEGIN_MAP() ||
$curRes == $mapIterator->BEGIN_BRANCH()) {
$indentLevel++;
@@ -1001,6 +1040,9 @@ sub new_handle {
$depth--;
}
+ if ($depth == 1) { $deltadepth = 0; } # we're done shifting, because we're
+ # out of the inlined map
+
# Is this resource being blotted out?
if (ref($curRes) && !advancedUser() && $curRes->randomout()) {
$curRes = $mapIterator->next();
@@ -1153,23 +1195,27 @@ sub new_handle {
}
my $colorizer = "";
+ my $color;
if ($curRes->is_problem()) {
my $status = $curRes->status($part);
- my $color = $colormap{$status};
+ $color = $colormap{$status};
# Special case in the navmaps: If in less then
# 24 hours, give it a bit of urgency
- if ($status == $curRes->OPEN() && $curRes->duedate() &&
+ if (($status == $curRes->OPEN() || $status == $curRes->ATTEMPTED() ||
+ $status == $curRes->TRIES_LEFT())
+ && $curRes->duedate() &&
$curRes->duedate() < time()+(24*60*60) &&
$curRes->duedate() > time()) {
$color = $hurryUpColor;
}
# Special case: If this is the last try, and there is
- # more then one available, give a bit of urgency
+ # more then one available, and it's not due yet, give a bit of urgency
my $tries = $curRes->tries($part);
my $maxtries = $curRes->maxtries($part);
if ($tries && $maxtries && $maxtries > 1 &&
- $maxtries - $tries == 1) {
+ $maxtries - $tries == 1 && $curRes->duedate() &&
+ $curRes->duedate() > time()) {
$color = $hurryUpColor;
}
if ($color ne "") {
@@ -1181,11 +1227,14 @@ sub new_handle {
$nonLinkedText .= ' (hidden) ';
}
+ $rowNum++;
+ my $backgroundColor = $backgroundColors[$rowNum % scalar(@backgroundColors)];
+
# FIRST COL: The resource indentation, branch icon, and name
- $r->print("