+
+ENDUPDATE
+}
+
sub handler {
my $r = shift;
real_handler($r);
@@ -107,9 +161,9 @@ sub real_handler {
# Handle header-only request
if ($r->header_only) {
if ($ENV{'browser.mathml'}) {
- $r->content_type('text/xml');
+ &Apache::loncommon::content_type($r,'text/xml');
} else {
- $r->content_type('text/html');
+ &Apache::loncommon::content_type($r,'text/html');
}
$r->send_http_header;
return OK;
@@ -117,18 +171,48 @@ sub real_handler {
# Send header, don't cache this page
if ($ENV{'browser.mathml'}) {
- $r->content_type('text/xml');
+ &Apache::loncommon::content_type($r,'text/xml');
} else {
- $r->content_type('text/html');
+ &Apache::loncommon::content_type($r,'text/html');
}
&Apache::loncommon::no_cache($r);
$r->send_http_header;
- # Create the nav map
- my $navmap = Apache::lonnavmaps::navmap->new(
- $ENV{"request.course.fn"}.".db",
- $ENV{"request.course.fn"}."_parms.db", 1, 1);
+ if ($ENV{QUERY_STRING} eq 'collapseExternal') {
+ &Apache::lonnet::put('environment',{'remotenavmap' => 'off'});
+ &Apache::lonnet::appenv('environment.remotenavmap' => 'off');
+ my $menu=&Apache::lonmenu::reopenmenu();
+ my $navstatus=&Apache::lonmenu::get_nav_status();
+ if ($menu) {
+ $menu=(<');
+ $r->print('
+ ');
+ }
+
+ if ($ENV{'environment.remotenavmap'} ne 'on') {
+ $r->print(&launch_win('link','yes'));
+ }
+ if ($ENV{'environment.remotenavmap'} eq 'on') {
+# $r->print("" .
+ $r->print("" .
+ &mt("Close navigation window").
+ " ");
+ }
+
+ my $jumpToFirstHomework = 0;
# Check to see if the student is jumping to next open, do-able problem
if ($ENV{QUERY_STRING} eq 'jumpToFirstHomework') {
+ $jumpToFirstHomework = 1;
# Find the next homework problem that they can do.
my $iterator = $navmap->getIterator(undef, undef, undef, 1);
- my $depth = 1;
- $iterator->next();
- my $curRes = $iterator->next();
+ my $curRes;
my $foundDoableProblem = 0;
my $problemRes;
- while ($depth > 0 && !$foundDoableProblem) {
- if ($curRes == $iterator->BEGIN_MAP()) { $depth++; }
- if ($curRes == $iterator->END_MAP()) { $depth--; }
-
+ while (($curRes = $iterator->next()) && !$foundDoableProblem) {
if (ref($curRes) && $curRes->is_problem()) {
my $status = $curRes->status();
- if (($status == $curRes->OPEN ||
- $status == $curRes->TRIES_LEFT()) &&
- $curRes->getCompletionStatus() != $curRes->ATTEMPTED()) {
+ if ($curRes->completable()) {
$problemRes = $curRes;
$foundDoableProblem = 1;
@@ -233,8 +338,6 @@ sub real_handler {
$ENV{'form.postsymb'} = $curRes->symb();
}
}
- } continue {
- $curRes = $iterator->next();
}
# If we found no problems, print a note to that effect.
@@ -243,18 +346,68 @@ sub real_handler {
}
} else {
$r->print("" .
- "Go To My First Homework Problem
");
+ &mt("Go To My First Homework Problem")." ");
}
- # renderer call
- my $render = render({ 'cols' => [0,1,2,3],
- 'url' => '/adm/navmaps',
- 'navmap' => $navmap,
- 'suppressNavmap' => 1,
- 'r' => $r});
+ my $suppressEmptySequences = 0;
+ my $filterFunc = undef;
+ my $resource_no_folder_link = 0;
+
+ # Display only due homework.
+ my $showOnlyHomework = 0;
+ 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("" .
+ &mt("Show Only Uncompleted Homework")." ");
+ }
+ my %selected=($ENV{'form.sort'} => 'selected=on');
+ my $sort_html=("");
+ # renderer call
+ my $renderArgs = { 'cols' => [0,2,3],
+ 'sort' => $ENV{'form.sort'},
+ 'url' => '/adm/navmaps',
+ 'navmap' => $navmap,
+ 'suppressNavmap' => 1,
+ 'suppressEmptySequences' => $suppressEmptySequences,
+ 'filterFunc' => $filterFunc,
+ 'resource_no_folder_link' => $resource_no_folder_link,
+ 'sort_html'=> $sort_html,
+ 'r' => $r};
+ my $render = render($renderArgs);
$navmap->untieHashes();
+ # If no resources were printed, print a reassuring message so the
+ # user knows there was no error.
+ if ($renderArgs->{'counter'} == 0) {
+ if ($showOnlyHomework) {
+ $r->print("".&mt("All homework is currently completed").".
");
+ } else { # both jumpToFirstHomework and normal use the same: course must be empty
+ $r->print("This course is empty.
");
+ }
+ }
+
$r->print("