[LON-CAPA-cvs] cvs: loncom /interface lonnavmaps.pm
bowersj2
lon-capa-cvs@mail.lon-capa.org
Fri, 16 May 2003 17:54:22 -0000
bowersj2 Fri May 16 13:54:22 2003 EDT
Modified files:
/loncom/interface lonnavmaps.pm
Log:
This should fix 1452, "multipart problem handling is a disaster".
'0' is now considered the only part 0.
Index: loncom/interface/lonnavmaps.pm
diff -u loncom/interface/lonnavmaps.pm:1.191 loncom/interface/lonnavmaps.pm:1.192
--- loncom/interface/lonnavmaps.pm:1.191 Fri May 16 10:17:08 2003
+++ loncom/interface/lonnavmaps.pm Fri May 16 13:54:21 2003
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Navigate Maps Handler
#
-# $Id: lonnavmaps.pm,v 1.191 2003/05/16 14:17:08 bowersj2 Exp $
+# $Id: lonnavmaps.pm,v 1.192 2003/05/16 17:54:21 bowersj2 Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -47,6 +47,7 @@
use Apache::loncommon();
use Apache::lonmenu();
use POSIX qw (floor strftime);
+use Data::Dumper; # for debugging, not always used
# symbolic constants
sub SYMB { return 1; }
@@ -838,7 +839,7 @@
my $icon = "<img src='/adm/lonIcons/html.gif' alt='' border='0' />";
if ($resource->is_problem()) {
- if ($part eq "" || $params->{'condensed'}) {
+ if ($part eq '0' || $params->{'condensed'}) {
$icon = '<img src="/adm/lonIcons/problem.gif" alt="" border="0" />';
} else {
$icon = $params->{'indentString'};
@@ -908,7 +909,7 @@
$params->{'displayedHereMarker'} = 1;
}
- if ($resource->is_problem() && $part ne "" &&
+ if ($resource->is_problem() && $part ne '0' &&
!$params->{'condensed'}) {
$partLabel = " (Part $part)";
$title = "";
@@ -1000,7 +1001,7 @@
$params->{'multipart'} && $part eq "0";
my $color;
- if ($resource->is_problem()) {
+ if ($resource->is_problem() && ($resource->countParts() <= 1 || $part ne '') ) {
$color = $colormap{$resource->status};
if (dueInLessThen24Hours($resource, $part) ||
@@ -1373,7 +1374,7 @@
# Decide what parts to show.
if ($curRes->is_problem() && $showParts) {
@parts = @{$curRes->parts()};
- $args->{'multipart'} = scalar(@parts) > 1;
+ $args->{'multipart'} = $curRes->multipart();
if ($condenseParts) { # do the condensation
if (!$curRes->opendate("0")) {
@@ -1382,13 +1383,13 @@
}
if (!$args->{'condensed'}) {
# Decide whether to condense based on similarity
- my $status = $curRes->status($parts[1]);
- my $due = $curRes->duedate($parts[1]);
- my $open = $curRes->opendate($parts[1]);
+ my $status = $curRes->status($parts[0]);
+ my $due = $curRes->duedate($parts[0]);
+ my $open = $curRes->opendate($parts[0]);
my $statusAllSame = 1;
my $dueAllSame = 1;
my $openAllSame = 1;
- for (my $i = 2; $i < scalar(@parts); $i++) {
+ for (my $i = 1; $i < scalar(@parts); $i++) {
if ($curRes->status($parts[$i]) != $status){
$statusAllSame = 0;
}
@@ -1409,7 +1410,7 @@
if (($statusAllSame && defined($condenseStatuses{$status})) ||
($dueAllSame && $status == $curRes->OPEN && $statusAllSame)||
($openAllSame && $status == $curRes->OPEN_LATER && $statusAllSame) ){
- @parts = ();
+ @parts = ($parts[0]);
$args->{'condensed'} = 1;
}
@@ -1420,14 +1421,14 @@
# If the multipart problem was condensed, "forget" it was multipart
if (scalar(@parts) == 1) {
$args->{'multipart'} = 0;
+ } else {
+ # Add part 0 so we display it correctly.
+ unshift @parts, '0';
}
# Now, we've decided what parts to show. Loop through them and
# show them.
- foreach my $part ('', @parts) {
- if ($part eq '0') {
- next;
- }
+ foreach my $part (@parts) {
$rownum ++;
my $backgroundColor = $backgroundColors[$rownum % scalar(@backgroundColors)];
@@ -3223,6 +3224,10 @@
B<parts> may return an array with more parts in it then countParts
might lead you to believe.
+=item * B<multipart>():
+
+Returns true if the problem is multipart, false otherwise.
+
=item * B<responseType>($part):
Returns the response type of the part, without the word "response" on the
@@ -3239,7 +3244,7 @@
sub parts {
my $self = shift;
- if ($self->ext) { return ['0']; }
+ if ($self->ext) { return []; }
$self->extractParts();
return $self->{PARTS};
@@ -3261,6 +3266,11 @@
}
return scalar(@{$parts}); # + $delta;
+}
+
+sub multipart {
+ my $self = shift;
+ return $self->countParts() > 1;
}
sub responseType {