--- loncom/interface/lonnavmaps.pm 2004/07/21 20:19:01 1.269 +++ loncom/interface/lonnavmaps.pm 2004/07/23 22:38:10 1.270 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Navigate Maps Handler # -# $Id: lonnavmaps.pm,v 1.269 2004/07/21 20:19:01 albertel Exp $ +# $Id: lonnavmaps.pm,v 1.270 2004/07/23 22:38:10 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -100,7 +100,7 @@ sub launch_win { } if ($mode eq 'link') { $result.='' - .&mt("Launch Navmaps in seperate window").""; + .&mt("Launch Navmaps in seperate window")." "; } return $result; } @@ -119,6 +119,19 @@ window.status='Done.'; ENDCLOSE } +sub update { + if ($ENV{'environment.remotenavmap'} ne 'on') { return ''; } + if (!$ENV{'request.course.id'}) { return ''; } + if ($ENV{'REQUEST_URI'}=~m|^/adm/navmaps|) { return ''; } + return(< + +ENDUPDATE +} sub handler { my $r = shift; @@ -182,7 +195,7 @@ ENDSUBM $r->print("\n"); $r->print("".&mt('Navigate Course Contents').""); # ------------------------------------------------------------ Get query string - &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['register']); + &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['register','sort']); # ----------------------------------------------------- Force menu registration my $addentries=''; @@ -326,8 +339,20 @@ ENDSUBM &mt("Show Only Uncompleted Homework")."    "); } + $r->print("
+ + Sort by: + + + +
"); # renderer call - my $renderArgs = { 'cols' => [0,1,2,3], + my $renderArgs = { 'cols' => [0,2,3], + 'sort' => $ENV{'form.sort'}, 'url' => '/adm/navmaps', 'navmap' => $navmap, 'suppressNavmap' => 1, @@ -1347,7 +1372,10 @@ sub render { #$currenturl=~s/^[^\/]+//; $here = $jump = &Apache::lonnet::symbread($currenturl); - } + } else { + &Apache::lonnet::logthis("Hrrm,"); + + } # Step three: Ensure the folders are open my $mapIterator = $navmap->getIterator(undef, undef, undef, 1); @@ -1574,7 +1602,33 @@ END $args->{'here'} = $here; $args->{'indentLevel'} = -1; # first BEGIN_MAP takes this to 0 - while ($curRes = $it->next($closeAllPages)) { + my @resources; + my $code='';# sub { !(shift->is_map();) }; + if ($args->{'sort'} eq 'title') { + @resources=$navmap->retrieveResources(undef, + sub { !shift->is_map(); }); + @resources= sort {lc($a->compTitle) cmp lc($b->compTitle)} @resources; + } elsif ($args->{'sort'} eq 'duedate') { + @resources=$navmap->retrieveResources(undef, + sub { shift->is_problem(); }); + @resources= sort + { + if ($a->duedate ne $b->duedate) { + return $a->duedate cmp $b->duedate; + } else { + lc($a->compTitle) cmp lc($b->compTitle) + } + } @resources; + } + + while (1) { + if ($args->{'sort'}) { + $curRes = shift(@resources); + } else { + $curRes = $it->next($closeAllPages); + } + if (!$curRes) { last; } + # Maintain indentation level. if ($curRes == $it->BEGIN_MAP() || $curRes == $it->BEGIN_BRANCH() ) { @@ -1688,10 +1742,15 @@ END # Set up some data about the parts that the cols might want my $filter = $it->{FILTER}; - my $stack = $it->getStack(); - my $src = getLinkForResource($stack); + my $src; + if ($args->{'sort'}) { + $src = $curRes->src(); # FIXME this is wrong for .pages + } else { + my $stack = $it->getStack(); + $src=getLinkForResource($stack); + } my $anchor=''; - if ($src=~s/(\#.*$)//) { + if ($src=~s/(\#.*)$//) { $anchor=$1; } my $srcHasQuestion = $src =~ /\?/; @@ -1699,7 +1758,7 @@ END ($srcHasQuestion?'&':'?') . 'symb=' . &Apache::lonnet::escape($curRes->symb()). $anchor; - + # Now, display each column. foreach my $col (@$cols) { my $colHTML = '';