[LON-CAPA-cvs] cvs: loncom(version_0_6_1) /interface lonnavmaps.pm
albertel
lon-capa-cvs@mail.lon-capa.org
Thu, 20 Mar 2003 20:40:42 -0000
albertel Thu Mar 20 15:40:42 2003 EDT
Modified files: (Branch: version_0_6_1)
/loncom/interface lonnavmaps.pm
Log:
- part ) and other display fixes bakorted from previous versions
Index: loncom/interface/lonnavmaps.pm
diff -u loncom/interface/lonnavmaps.pm:1.129.2.1 loncom/interface/lonnavmaps.pm:1.129.2.2
--- loncom/interface/lonnavmaps.pm:1.129.2.1 Sat Feb 1 14:55:00 2003
+++ loncom/interface/lonnavmaps.pm Thu Mar 20 15:40:42 2003
@@ -2,7 +2,7 @@
# The LearningOnline Network with CAPA
# Navigate Maps Handler
#
-# $Id: lonnavmaps.pm,v 1.129.2.1 2003/02/01 19:55:00 albertel Exp $
+# $Id: lonnavmaps.pm,v 1.129.2.2 2003/03/20 20:40:42 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -403,7 +403,7 @@
# just display first
if (!$curRes->opendate("0")) {
# no parts are open, display as one part
- @parts = ("0");
+ @parts = ();
$condensed = 1;
} else {
# Otherwise, only display part 0 if we want to
@@ -441,23 +441,19 @@
if (($statusAllSame && defined($condenseStatuses{$status})) ||
($dueAllSame && $status == $curRes->OPEN && $statusAllSame)||
($openAllSame && $status == $curRes->OPEN_LATER && $statusAllSame) ){
- @parts = ($parts[1]);
+ @parts = ();
$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) == 1 ) {
+ if ( scalar(@parts) == 0 ) {
$multipart = 0;
}
@@ -466,13 +462,16 @@
# 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 = ("0");
+ @parts = ();
}
# Step Two: Print the actual data.
# For each part we intend to display...
- foreach my $part (@parts) {
+ foreach my $part ('', @parts) {
+ if ($part eq '0') {
+ next;
+ }
my $nonLinkedText = ""; # unlinked stuff after title
@@ -507,7 +506,7 @@
my $icon = "<img src=\"/adm/lonIcons/html.gif\" alt=\"\" border=\"0\" />";
if ($curRes->is_problem()) {
- if ($part eq "0" || $condensed) {
+ if ($part eq "" || $condensed) {
$icon = '<img src="/adm/lonIcons/problem.gif" alt="" border=\"0\" />';
} else {
$icon = $indentString;
@@ -584,11 +583,11 @@
$displayedHereMarker = 1;
}
- if ($curRes->is_problem() && $part ne "0" && !$condensed) {
+ if ($curRes->is_problem() && $part ne "" && !$condensed) {
$partLabel = " (Part $part)";
$title = "";
}
- if ($multipart && $condensed) {
+ if ($condensed && $curRes->countParts() > 1) {
$nonLinkedText .= ' (' . $curRes->countParts() . ' parts)';
}
@@ -2288,14 +2287,16 @@
my $self = shift;
my $parts = $self->parts();
+ my $delta = 0;
+ for my $part (@$parts) {
+ if ($part eq '0') { $delta--; }
+ }
if ($self->{RESOURCE_ERROR}) {
return 0;
}
- if (scalar(@{$parts}) < 2) { return 1;}
-
- return scalar(@{$parts}) - 1;
+ return scalar(@{$parts}) + $delta;
}
# Private function: Extracts the parts information and saves it
@@ -2309,7 +2310,7 @@
# Retrieve part count, if this is a problem
if ($self->is_problem()) {
- my $metadata = &Apache::lonnet::metadata($self->src(), 'allpossiblekeys');
+ my $metadata = &Apache::lonnet::metadata($self->src(), 'packages');
if (!$metadata) {
$self->{RESOURCE_ERROR} = 1;
$self->{PARTS} = [];
@@ -2317,7 +2318,7 @@
}
foreach (split(/\,/,$metadata)) {
- if ($_ =~ /^parameter\_(.*)\_opendate$/) {
+ if ($_ =~ /^part_(.*)$/) {
push @{$self->{PARTS}}, $1;
}
}