--- loncom/interface/lonnavmaps.pm 2003/04/22 17:54:27 1.178
+++ loncom/interface/lonnavmaps.pm 2003/06/10 15:45:16 1.195
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Navigate Maps Handler
#
-# $Id: lonnavmaps.pm,v 1.178 2003/04/22 17:54:27 bowersj2 Exp $
+# $Id: lonnavmaps.pm,v 1.195 2003/06/10 15:45:16 bowersj2 Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -47,6 +47,7 @@ use Apache::Constants qw(:common :http);
use Apache::loncommon();
use Apache::lonmenu();
use POSIX qw (floor strftime);
+use Data::Dumper; # for debugging, not always used
# symbolic constants
sub SYMB { return 1; }
@@ -71,7 +72,8 @@ my %statusIconMap =
$resObj->TRIES_LEFT => 'navmap.open.gif',
$resObj->INCORRECT => 'navmap.wrong.gif',
$resObj->OPEN => 'navmap.open.gif',
- $resObj->ATTEMPTED => 'navmap.open.gif' );
+ $resObj->ATTEMPTED => 'navmap.open.gif',
+ $resObj->ANSWER_SUBMITTED => '' );
my %iconAltTags =
( 'navmap.correct.gif' => 'Correct',
@@ -171,7 +173,7 @@ sub real_handler {
# See if there's only one map in the top-level, if we don't
# already have a filter... if so, automatically display it
- if (!defined($ENV{'form.filter'})) {
+ if ($ENV{QUERY_STRING} !~ /filter/) {
my $iterator = $navmap->getIterator(undef, undef, undef, 0);
my $depth = 1;
$iterator->next();
@@ -185,7 +187,7 @@ sub real_handler {
if (ref($curRes) && $curRes->is_sequence()) {
$sequenceCount++;
$sequenceId = $curRes->map_pc();
- }
+ }
$curRes = $iterator->next();
}
@@ -199,15 +201,91 @@ sub real_handler {
}
}
- # renderer call
- my $render = render({ 'cols' => [0,1,2,3],
- 'url' => '/adm/navmaps',
- 'navmap' => $navmap,
- 'suppressNavmap' => 1,
- 'r' => $r});
+ 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 $foundDoableProblem = 0;
+ my $problemRes;
+
+ while ($depth > 0 && !$foundDoableProblem) {
+ if ($curRes == $iterator->BEGIN_MAP()) { $depth++; }
+ if ($curRes == $iterator->END_MAP()) { $depth--; }
+
+ 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();
+ }
+ }
+ } continue {
+ $curRes = $iterator->next();
+ }
+
+ # If we found no problems, print a note to that effect.
+ if (!$foundDoableProblem) {
+ $r->print("All homework assignments have been completed.
");
+ }
+ } else {
+ $r->print("" .
+ "Go To My First Homework Problem
");
+ }
+
+ my $suppressEmptySequences = 0;
+ my $filterFunc = undef;
+ # Display only due homework.
+ my $showOnlyHomework = 0;
+ if ($ENV{QUERY_STRING} eq 'showOnlyHomework') {
+ $showOnlyHomework = 1;
+ $suppressEmptySequences = 1;
+ $filterFunc = sub { my $res = shift;
+ return $res->completable() || $res->is_sequence();
+ };
+ $r->print("
Uncompleted Homework
"); + $ENV{'form.filter'} = ''; + $ENV{'form.condition'} = 1; + } else { + $r->print("" . + "Show Only Uncompleted HomeworkAll homework is currently completed.
"); + } else { # both jumpToFirstHomework and normal use the same: course must be empty + $r->print("This course is empty.
"); + } + } + $r->print("