--- loncom/interface/lonnavmaps.pm 2004/08/13 20:12:11 1.275
+++ loncom/interface/lonnavmaps.pm 2004/08/20 20:14:27 1.277
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Navigate Maps Handler
#
-# $Id: lonnavmaps.pm,v 1.275 2004/08/13 20:12:11 albertel Exp $
+# $Id: lonnavmaps.pm,v 1.277 2004/08/20 20:14:27 matthew Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -100,7 +100,7 @@ sub launch_win {
}
if ($mode eq 'link') {
$result.=''
- .&mt("Launch navigation in separate window")." ";
+ .&mt("Launch navigation window")." ";
}
return $result;
}
@@ -206,7 +206,7 @@ ENDSUBM
$r->print("
\n");
$r->print("".&mt('Navigate Course Contents')."");
# ------------------------------------------------------------ Get query string
- &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['register','sort']);
+ &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['register','sort','showOnlyHomework']);
# ----------------------------------------------------- Force menu registration
my $addentries='';
@@ -286,7 +286,7 @@ ENDSUBM
if ($ENV{'environment.remotenavmap'} eq 'on') {
# $r->print("" .
$r->print("" .
- &mt("Close separate navigation window").
+ &mt("Close navigation window").
" ");
}
@@ -335,30 +335,33 @@ ENDSUBM
# Display only due homework.
my $showOnlyHomework = 0;
- if ($ENV{QUERY_STRING} eq 'showOnlyHomework') {
+ if ($ENV{'form.showOnlyHomework'} eq "1") {
$showOnlyHomework = 1;
$suppressEmptySequences = 1;
$filterFunc = sub { my $res = shift;
return $res->completable() || $res->is_map();
};
+ $r->print("" .
+ &mt("Show Everything")." ");
$r->print("".&mt("Uncompleted Homework")."
");
$ENV{'form.filter'} = '';
$ENV{'form.condition'} = 1;
$resource_no_folder_link = 1;
} else {
- $r->print("" .
+ $r->print("" .
&mt("Show Only Uncompleted Homework")." ");
}
- $r->print("");
# renderer call
@@ -370,6 +373,7 @@ ENDSUBM
'suppressEmptySequences' => $suppressEmptySequences,
'filterFunc' => $filterFunc,
'resource_no_folder_link' => $resource_no_folder_link,
+ 'sort_html'=> $sort_html,
'r' => $r};
my $render = render($renderArgs);
$navmap->untieHashes();
@@ -1381,10 +1385,7 @@ 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);
@@ -1539,6 +1540,9 @@ END
$result .= '
';
}
}
+
+ if ($args->{'sort_html'}) { $result.=$args->{'sort_html'}; }
+
$result .= "
\n";
if ($r) {
$r->print($result);
@@ -1614,8 +1618,14 @@ END
my @resources;
my $code='';# sub { !(shift->is_map();) };
if ($args->{'sort'} eq 'title') {
- @resources=$navmap->retrieveResources(undef,
- sub { !shift->is_map(); });
+ my $oldFilterFunc = $filterFunc;
+ my $filterFunc=
+ sub {
+ my ($res)=@_;
+ if ($res->is_map()) { return 0;}
+ return &$oldFilterFunc($res);
+ };
+ @resources=$navmap->retrieveResources(undef,$filterFunc);
@resources= sort {lc($a->compTitle) cmp lc($b->compTitle)} @resources;
} elsif ($args->{'sort'} eq 'duedate') {
@resources=$navmap->retrieveResources(undef,
@@ -1628,8 +1638,12 @@ END
lc($a->compTitle) cmp lc($b->compTitle)
}
} @resources;
+ } else {
+ #unknow sort mechanism or default
+ undef($args->{'sort'});
}
+
while (1) {
if ($args->{'sort'}) {
$curRes = shift(@resources);
@@ -2222,9 +2236,14 @@ sub getById {
sub getBySymb {
my $self = shift;
my $symb = shift;
+
my ($mapUrl, $id, $filename) = &Apache::lonnet::decode_symb($symb);
my $map = $self->getResourceByUrl($mapUrl);
- return $self->getById($map->map_pc() . '.' . $id);
+ my $returnvalue = undef;
+ if (ref($map)) {
+ $returnvalue = $self->getById($map->map_pc() .'.'.$id);
+ }
+ return $returnvalue;
}
sub getByMapPc {
@@ -2418,6 +2437,7 @@ in the filter function.
=cut
+
sub getResourceByUrl {
my $self = shift;
my $resUrl = shift;