[LON-CAPA-cvs] cvs: loncom /interface lonnavmaps.pm
bowersj2
lon-capa-cvs@mail.lon-capa.org
Mon, 05 May 2003 17:44:03 -0000
bowersj2 Mon May 5 13:44:03 2003 EDT
Modified files:
/loncom/interface lonnavmaps.pm
Log:
Should fix bug 1347 "Students want to jump to first do-able homework
assignment."
Speed note: In ADV205, the huge course with tons of maps that have 100 choose
10 resources, it takes 12 seconds to scan the entire course and conclude that
there are no currently completable homework problems.
There may be some interaction with multi-part problems and/or essay response
problems that have to be graded by an instructor. I'm looking into that.
Index: loncom/interface/lonnavmaps.pm
diff -u loncom/interface/lonnavmaps.pm:1.183 loncom/interface/lonnavmaps.pm:1.184
--- loncom/interface/lonnavmaps.pm:1.183 Fri Apr 25 14:54:36 2003
+++ loncom/interface/lonnavmaps.pm Mon May 5 13:44:03 2003
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Navigate Maps Handler
#
-# $Id: lonnavmaps.pm,v 1.183 2003/04/25 18:54:36 bowersj2 Exp $
+# $Id: lonnavmaps.pm,v 1.184 2003/05/05 17:44:03 bowersj2 Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -199,6 +199,52 @@
}
}
+ # Check to see if the student is jumping to next open, do-able problem
+ if ($ENV{QUERY_STRING} eq 'jumpToFirstHomework') {
+ # 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 (($status == $curRes->OPEN ||
+ $status == $curRes->TRIES_LEFT()) &&
+ $curRes->getCompletionStatus() != $curRes->ATTEMPTED()) {
+ $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("<font size='+2'>All homework assignments have been completed.</font><br /><br />");
+ }
+ } else {
+ $r->print("<a href='navmaps?jumpToFirstHomework'>" .
+ "Go To My First Homework Problem</a><br />");
+ }
+
# renderer call
my $render = render({ 'cols' => [0,1,2,3],
'url' => '/adm/navmaps',
@@ -3069,7 +3115,16 @@
return scalar(@{$parts}) + $delta;
}
-# Private function: Extracts the parts information and saves it
+sub partType {
+ my $self = shift;
+ my $part = shift;
+
+ $self->extractParts();
+ return $self->{PART_TYPE}->{$part};
+}
+
+# Private function: Extracts the parts information, both part names and
+# part types, and saves it
sub extractParts {
my $self = shift;
@@ -3086,6 +3141,7 @@
if (!$metadata) {
$self->{RESOURCE_ERROR} = 1;
$self->{PARTS} = [];
+ $self->{PART_TYPE} = {};
return;
}
foreach (split(/\,/,$metadata)) {