--- loncom/interface/lonnavdisplay.pm 2010/03/29 14:50:46 1.17 +++ loncom/interface/lonnavdisplay.pm 2013/08/08 01:54:24 1.24 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Navigate Maps Handler # -# $Id: lonnavdisplay.pm,v 1.17 2010/03/29 14:50:46 raeburn Exp $ +# $Id: lonnavdisplay.pm,v 1.24 2013/08/08 01:54:24 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -37,6 +37,7 @@ use Apache::lonnavmaps(); use Apache::lonhtmlcommon(); use Apache::lonnet; use Apache::lonlocal; +use Apache::londocs(); use Time::HiRes qw( gettimeofday tv_interval ); sub handler { @@ -100,6 +101,7 @@ sub real_handler { } $r->print($start_page. ''); + &startContentScreen($r,'navmaps'); $r->rflush(); # Check that it's defined @@ -111,21 +113,31 @@ sub real_handler { return OK; } - # See if there's only one map in the top-level, if we don't - # already have a filter... if so, automatically display it - # (older code; should use retrieveResources) - if ($ENV{QUERY_STRING} !~ /filter/) { - my $iterator = $navmap->getIterator(undef, undef, undef, 0); - my $curRes; - my $sequenceCount = 0; - my $sequenceId; - while ($curRes = $iterator->next()) { - if (ref($curRes) && $curRes->is_sequence()) { + my @resources = $navmap->retrieveResources(); + my $sequenceCount = 0; + my $problemCount = 0; + my $notaprobCount = 0; + my $sequenceId; + my $notools; + foreach my $curRes (@resources) { + if (ref($curRes)) { + if ($curRes->is_sequence()) { $sequenceCount++; $sequenceId = $curRes->map_pc(); + } elsif ($curRes->is_problem()) { + $problemCount ++; + } else { + $notaprobCount ++; } } - + } + if (($sequenceCount == 1) && (!$problemCount) && ($notaprobCount <= 1)) { + $notools = 1; + } + + # If there's only one map in the top-level and we don't + # already have a filter, automatically display it + if ($ENV{QUERY_STRING} !~ /filter/) { if ($sequenceCount == 1) { # The automatic iterator creation in the render call # will pick this up. We know the condition because @@ -181,9 +193,11 @@ sub real_handler { if ($env{'form.register'}) { $link .= '&register='.$env{'form.register'}; } - &Apache::lonnavmaps::add_linkitem(\%toplinkitems,'firsthomework', - 'location.href="'.$link.'"', - "Show my first due problem"); + unless ($notools) { + &Apache::lonnavmaps::add_linkitem(\%toplinkitems,'firsthomework', + 'location.href="'.$link.'"', + "Show my first due problem"); + } } my $suppressEmptySequences = 0; @@ -214,17 +228,22 @@ sub real_handler { if ($env{'form.register'}) { $link .= '&register='.$env{'form.register'}; } - &Apache::lonnavmaps::add_linkitem(\%toplinkitems,'uncompleted', - 'location.href="'.$link.'"', - 'Show only uncompleted problems'); + unless ($notools) { + &Apache::lonnavmaps::add_linkitem(\%toplinkitems,'uncompleted', + 'location.href="'.$link.'"', + 'Show only uncompleted problems'); + } } my %selected=($env{'form.sort'} => ' selected="selected"'); - my $sort_html=('
+ my $sort_html; + unless ($notools) { + $sort_html=( + ' '.&mt('Sort by:').' - @@ -233,6 +252,7 @@ sub real_handler {
'); + } # renderer call my $renderArgs = { 'cols' => [0,1,2,3], 'sort' => $env{'form.sort'}, @@ -245,7 +265,9 @@ sub real_handler { 'sort_html'=> $sort_html, 'r' => $r, 'caller' => 'navmapsdisplay', - 'linkitems' => \%toplinkitems}; + 'linkitems' => \%toplinkitems, + 'notools' => $notools}; + my $render = &Apache::lonnavmaps::render($renderArgs); # If no resources were printed, print a reassuring message so the @@ -259,13 +281,39 @@ sub real_handler { } #my $td=&tv_interval($t0); #$r->print("
$td"); - + &endContentScreen($r); $r->print(&Apache::loncommon::end_page()); $r->rflush(); return OK; } +sub startContentScreen { + my ($r,$mode)=@_; + + $r->print("\n".''."\n"); + $r->print('
'); +} + +sub endContentScreen { + my ($r)=@_; + $r->print('
'); +} + 1; __END__