--- loncom/interface/lonnavmaps.pm 2003/03/08 20:52:41 1.154 +++ loncom/interface/lonnavmaps.pm 2003/03/13 17:05:36 1.156 @@ -2,7 +2,7 @@ # The LearningOnline Network with CAPA # Navigate Maps Handler # -# $Id: lonnavmaps.pm,v 1.154 2003/03/08 20:52:41 bowersj2 Exp $ +# $Id: lonnavmaps.pm,v 1.156 2003/03/13 17:05:36 bowersj2 Exp $ # # Copyright Michigan State University Board of Trustees # @@ -188,6 +188,32 @@ sub real_handler { return OK; } + # See if there's only one map in the top-level... if so, + # automatically display it + my $iterator = $navmap->getIterator(undef, undef, undef, 0); + my $depth = 1; + $iterator->next(); + my $curRes = $iterator->next(); + my $sequenceCount = 0; + my $sequenceId; + while ($depth > 0) { + if ($curRes == $iterator->BEGIN_MAP()) { $depth++; } + if ($curRes == $iterator->END_MAP()) { $depth--; } + + if (ref($curRes) && $curRes->is_sequence()) { + $sequenceCount++; + $sequenceId = $curRes->map_pc(); + } + + $curRes = $iterator->next(); + } + + if ($sequenceCount == 1) { + # The automatic iterator creation in the render call + # will pick this up. + $ENV{'form.filter'} = "$sequenceId"; + } + # renderer call my $render = render({ 'cols' => [0,1,2,3], 'url' => '/adm/navmaps', @@ -594,7 +620,7 @@ sub render_resource { my $icon = ""; if ($resource->is_problem()) { - if ($part eq "0" || $params->{'condensed'}) { + if ($part eq "" || $params->{'condensed'}) { $icon = ''; } else { $icon = $params->{'indentString'}; @@ -666,7 +692,7 @@ sub render_resource { $curMarkerEnd = '<'; } - if ($resource->is_problem() && $part ne "0" && + if ($resource->is_problem() && $part ne "" && !$params->{'condensed'}) { $partLabel = " (Part $part)"; $title = ""; @@ -1081,14 +1107,12 @@ sub render { # If this has been filtered out, continue on if (!(&$filterFunc($curRes))) { - $curRes = $it->next(); $args->{'isNewBranch'} = 0; # Don't falsely remember this next; } # If we're suppressing navmaps and this is a navmap, continue on if ($suppressNavmap && $curRes->src() =~ /^\/adm\/navmaps/) { - $curRes = $it->next(); next; } @@ -1142,28 +1166,19 @@ sub render { } } - - } else { - # Not showing parts - @parts = ("0"); # show main part only } - + # If the multipart problem was condensed, "forget" it was multipart if (scalar(@parts) == 1) { $args->{'multipart'} = 0; } - # In the event of a network error, display one part. - # If this is a single part, we can at least show the correct - # 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"); - } - # Now, we've decided what parts to show. Loop through them and # show them. - foreach my $part (@parts) { + foreach my $part ('', @parts) { + if ($part eq '0') { + next; + } $rownum ++; my $backgroundColor = $backgroundColors[$rownum % scalar(@backgroundColors)]; @@ -1209,7 +1224,7 @@ sub render { $result = ""; $r->rflush(); } - + } continue { $curRes = $it->next(); } @@ -2730,11 +2745,6 @@ sub extractParts { $self->{PARTS} = \@sortedParts; } - # Ensure part 0 is included at the beginning. - if ($self->{PARTS}->[0] ne '0') { - unshift @{$self->{PARTS}}, '0'; - } - return; }