--- loncom/interface/lonnavmaps.pm 2002/10/14 18:22:45 1.79
+++ loncom/interface/lonnavmaps.pm 2002/10/17 19:25:27 1.84
@@ -2,7 +2,7 @@
# The LearningOnline Network with CAPA
# Navigate Maps Handler
#
-# $Id: lonnavmaps.pm,v 1.79 2002/10/14 18:22:45 bowersj2 Exp $
+# $Id: lonnavmaps.pm,v 1.84 2002/10/17 19:25:27 bowersj2 Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -823,7 +823,7 @@ sub new_handle {
# Initialize the nav map
my $navmap = Apache::lonnavmaps::navmap->new(
$ENV{"request.course.fn"}.".db",
- $ENV{"request.course.fn"}."_parms.db", 1);
+ $ENV{"request.course.fn"}."_parms.db", 1, 1);
if (!defined($navmap)) {
@@ -849,10 +849,6 @@ sub new_handle {
$r->print(' Discussions'.
'
New message (click to open)
');
}
- #if (($currenturl=~/^\/res/) &&
- # ($currenturl!~/^\/res\/adm/)) {
- # $r->print('Current Location
');
- #}
# Check that it's defined
if (!($navmap->courseMapDefined())) {
@@ -929,7 +925,7 @@ sub new_handle {
# Begin the HTML table
# four cols: resource + indent, chat+feedback, icon, text string
- $r->print('
' ."\n");
+ $r->print('' ."\n");
my $condition = 0;
if ($ENV{'form.condition'}) {
@@ -944,7 +940,7 @@ sub new_handle {
if ($currenturl && !$ENV{'form.alreadyHere'}) {
# Give me every resource...
my $mapIterator = $navmap->getIterator(undef, undef, {}, 1);
- my $found != 0;
+ my $found = 0;
my $depth = 1;
$mapIterator->next(); # discard the first BEGIN_MAP
my $curRes = $mapIterator->next();
@@ -1075,11 +1071,18 @@ sub new_handle {
}
} else {
- @parts[0] = "0"; # this is to get past foreach loop below
+ $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
}
+ # 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) == 1 ) {
+ $multipart = 0;
+ }
+
# Display one part, in event of network error.
# If this is a single part, we can at least show the correct
# status, but if it's multipart, we're lost.
@@ -1104,6 +1107,10 @@ sub new_handle {
'symb='.&Apache::lonnet::escape($curRes->symb()).
'"';
my $title = $curRes->title();
+ if (!$title) {
+ $title = $curRes->src();
+ $title = substr ($title, rindex($title, "/") + 1);
+ }
my $partLabel = "";
my $newBranchText = "";
@@ -1131,7 +1138,8 @@ sub new_handle {
# Display the correct icon, link to open or shut map
if ($curRes->is_map()) {
my $mapId = $curRes->map_pc();
- my $nowOpen = !defined($filterHash{$mapId});
+ my $nowOpen = (!defined($filterHash{$mapId}));
+ if ($condition) {$nowOpen = !$nowOpen;}
$icon = $nowOpen ?
"navmap.folder.closed.gif" : "navmap.folder.open.gif";
$icon = "";
@@ -1174,7 +1182,7 @@ sub new_handle {
}
# FIRST COL: The resource indentation, branch icon, and name
- $r->print(" \n");
+ $r->print(" |
\n");
# print indentation
for (my $i = 0; $i < $indentLevel - $deltalevel; $i++) {
@@ -1205,7 +1213,7 @@ sub new_handle {
if ($curRes->{RESOURCE_ERROR}) {
$r->print(&Apache::loncommon::help_open_topic ("Navmap_Host_Down",
- 'Host down'));
+ 'Host down'));
}
my $discussionHTML = ""; my $feedbackHTML = "";
@@ -1229,7 +1237,7 @@ sub new_handle {
}
}
- $r->print(" | $discussionHTML$feedbackHTML | ");
+ $r->print("$discussionHTML$feedbackHTML | ");
# Is this the first displayed part of a multi-part problem
# that has not been condensed, so we should suppress these two
@@ -1242,12 +1250,12 @@ sub new_handle {
my $icon = $statusIconMap{$curRes->status($part)};
my $alt = $iconAltTags{$icon};
if ($icon) {
- $r->print("$linkopen$linkclose | \n");
+ $r->print("$linkopen$linkclose | \n");
} else {
- $r->print(" | \n");
+ $r->print(" | \n");
}
} else { # not problem, no icon
- $r->print(" | \n");
+ $r->print(" | \n");
}
# FOURTH COL: Text description
@@ -1262,7 +1270,7 @@ sub new_handle {
$r->print('(randomly select ' . $curRes->randompick() .')');
}
- $r->print("
\n");
+ $r->print(" \n");
}
}
$curRes = $mapIterator->next();
@@ -1657,6 +1665,8 @@ sub new {
$self->{EMAIL_STATUS} = \%emailstatus;
}
+
+ $self->{PARM_CACHE} = {};
bless($self);
@@ -1778,6 +1788,21 @@ sub finishResource {
sub parmval {
my $self = shift;
my ($what,$symb)=@_;
+ my $hashkey = $what."|||".$symb;
+
+ if (defined($self->{PARM_CACHE}->{$hashkey})) {
+ return $self->{PARM_CACHE}->{$hashkey};
+ }
+
+ my $result = $self->parmval_real($what, $symb);
+ $self->{PARM_CACHE}->{$hashkey} = $result;
+ return $result;
+}
+
+sub parmval_real {
+ my $self = shift;
+ my ($what,$symb) = @_;
+
my $cid=$ENV{'request.course.id'};
my $csec=$ENV{'request.course.sec'};
my $uname=$ENV{'user.name'};
@@ -2239,8 +2264,6 @@ These are methods that help you retrieve
=item * B: Returns the "to" value from the compiled nav map. (It is likely you want to use B instead.)
-=item * B: Returns the type of the resource, "start", "normal", or "finish".
-
=back
=cut
@@ -2270,7 +2293,6 @@ sub symb {
}
sub title { my $self=shift; return $self->navHash("title_", 1); }
sub to { my $self=shift; return $self->navHash("to_", 1); }
-sub type { my $self=shift; return $self->navHash("type_", 1); }
=pod
@@ -2486,7 +2508,7 @@ sub getReturnHash {
my $self = shift;
if (!defined($self->{RETURN_HASH})) {
- my %tmpHash = &Apache::lonnet::restore($self->symb());
+ my %tmpHash = &Apache::lonnet::restore($self->symb());
$self->{RETURN_HASH} = \%tmpHash;
}
}
@@ -2577,25 +2599,27 @@ sub extractParts {
$self->{PARTS} = [];
- # Retrieve part count
- my $metadata = &Apache::lonnet::metadata($self->src(), 'allpossiblekeys');
- if (!$metadata) {
- $self->{RESOURCE_ERROR} = 1;
- $self->{PARTS} = [];
- return;
- }
-
- foreach (split(/\,/,$metadata)) {
- if ($_ =~ /^parameter\_(.*)\_opendate$/) {
- push @{$self->{PARTS}}, $1;
+ # Retrieve part count, if this is a problem
+ if ($self->is_problem()) {
+ my $metadata = &Apache::lonnet::metadata($self->src(), 'allpossiblekeys');
+ if (!$metadata) {
+ $self->{RESOURCE_ERROR} = 1;
+ $self->{PARTS} = [];
+ return;
}
+
+ foreach (split(/\,/,$metadata)) {
+ if ($_ =~ /^parameter\_(.*)\_opendate$/) {
+ push @{$self->{PARTS}}, $1;
+ }
+ }
+
+
+ # Is this possible to do in one line? - Jeremy
+ my @sortedParts = sort @{$self->{PARTS}};
+ $self->{PARTS} = \@sortedParts;
}
-
- # Is this possible to do in one line? - Jeremy
- my @sortedParts = sort @{$self->{PARTS}};
- $self->{PARTS} = \@sortedParts;
-
return;
}