');
- for ($i=0;$i<=$#rows;$i++) {
- if ($rows[$i]) {
- $r->print("\n");
- my @colcont=split(/\&/,$rows[$i]);
- my $avespan=$lcm/($#colcont+1);
- for ($j=0;$j<=$#colcont;$j++) {
- my $rid=$colcont[$j];
- my $add=' ';
- if ($rid=~/^h(.+)/) {
- $rid=$1;
- $add=' | ';
- }
- $r->print($add.''.
- $hash{'title_'.$rid}.'');
- $r->print('');
- }
- $r->print(' |
');
- }
+ $r->print("\n");
+ $r->print("".&mt('Navigate Course Contents')."");
+# ------------------------------------------------------------ Get query string
+ &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['register','sort','showOnlyHomework','postsymb']);
+
+# ----------------------------------------------------- Force menu registration
+ my $addentries='';
+ my $more_unload;
+ my $body_only='';
+ if ($ENV{'environment.remotenavmap'} eq 'on') {
+ $r->print('');
+# FIXME need to be smarter to only catch window close events
+# $more_unload="collapse()"
+ $body_only=1;
+ }
+ if ($ENV{'form.register'}) {
+ $addentries=' onLoad="'.&Apache::lonmenu::loadevents().
+ '" onUnload="'.&Apache::lonmenu::unloadevents().';'.
+ $more_unload.'"';
+ $r->print(&Apache::lonmenu::registerurl(1));
+ } else {
+ $addentries=' onUnload="'.$more_unload.'"';
+ }
+
+ # Header
+ $r->print(''.
+ &Apache::loncommon::bodytag('Navigate Course Contents','',
+ $addentries,$body_only,'',
+ $ENV{'form.register'}));
+ $r->print('');
+
+ $r->rflush();
+
+ # Check that it's defined
+ if (!($navmap->courseMapDefined())) {
+ $r->print(&Apache::loncommon::help_open_menu('','Navigation Screen','Navigation_Screen','',undef,'RAT'));
+ $r->print('Coursemap undefined.' .
+ '');
+ 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()) {
+ $sequenceCount++;
+ $sequenceId = $curRes->map_pc();
+ }
+ }
+
+ if ($sequenceCount == 1) {
+ # The automatic iterator creation in the render call
+ # will pick this up. We know the condition because
+ # the defined($ENV{'form.filter'}) also ensures this
+ # is a fresh call.
+ $ENV{'form.filter'} = "$sequenceId";
+ }
+ }
+
+ if ($ENV{QUERY_STRING} eq 'launchExternal') {
+ $r->print('
+ ');
+ $r->print('
+ ');
+ }
+
+ if ($ENV{'environment.remotenavmap'} ne 'on') {
+ $r->print(&launch_win('link','yes',\%toplinkitems));
+ }
+ if ($ENV{'environment.remotenavmap'} eq 'on') {
+ &add_linkitem(\%toplinkitems,'closenav','collapse()',
+ "Close navigation window");
+ }
+
+ my $jumpToFirstHomework = 0;
+ # Check to see if the student is jumping to next open, do-able problem
+ if ($ENV{QUERY_STRING} =~ /^jumpToFirstHomework/) {
+ $jumpToFirstHomework = 1;
+ # Find the next homework problem that they can do.
+ my $iterator = $navmap->getIterator(undef, undef, undef, 1);
+ my $curRes;
+ my $foundDoableProblem = 0;
+ my $problemRes;
+
+ while (($curRes = $iterator->next()) && !$foundDoableProblem) {
+ if (ref($curRes) && $curRes->is_problem()) {
+ my $status = $curRes->status();
+ if ($curRes->completable()) {
+ $problemRes = $curRes;
+ $foundDoableProblem = 1;
+
+ # Pop open all previous maps
+ my $stack = $iterator->getStack();
+ pop @$stack; # last resource in the stack is the problem
+ # itself, which we don't need in the map stack
+ my @mapPcs = map {$_->map_pc()} @$stack;
+ $ENV{'form.filter'} = join(',', @mapPcs);
+
+ # Mark as both "here" and "jump"
+ $ENV{'form.postsymb'} = $curRes->symb();
+ }
+ }
+ }
+
+ # If we found no problems, print a note to that effect.
+ if (!$foundDoableProblem) {
+ $r->print("All homework assignments have been completed.
");
+ }
+ } else {
+ &add_linkitem(\%toplinkitems,'firsthomework',
+ 'location.href="navmaps?jumpToFirstHomework"',
+ "Show Me My First Homework Problem");
+ }
+
+ 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();
+ };
+ &add_linkitem(\%toplinkitems,'everything',
+ 'location.href="navmaps?sort='.$ENV{'form.sort'}.'"',
+ "Show Everything");
+ $r->print("".&mt("Uncompleted Homework")."
");
+ $ENV{'form.filter'} = '';
+ $ENV{'form.condition'} = 1;
+ $resource_no_folder_link = 1;
+ } else {
+ &add_linkitem(\%toplinkitems,'uncompleted',
+ 'location.href="navmaps?sort='.$ENV{'form.sort'}.
+ '&showOnlyHomework=1"',
+ "Show Only Uncompleted Homework");
+ }
+
+ my %selected=($ENV{'form.sort'} => 'selected=on');
+ my $sort_html=("");
+ # renderer call
+ my $renderArgs = { 'cols' => [0,1,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,
+ 'caller' => 'navmapsdisplay',
+ 'linkitems' => \%toplinkitems};
+ my $render = render($renderArgs);
+
+ # 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("