[LON-CAPA-cvs] cvs: loncom /interface lonnavmaps.pm lonparmset.pm
bowersj2
lon-capa-cvs@mail.lon-capa.org
Thu, 13 Mar 2003 20:46:36 -0000
This is a MIME encoded message
--bowersj21047588396
Content-Type: text/plain
bowersj2 Thu Mar 13 15:46:36 2003 EDT
Modified files:
/loncom/interface lonnavmaps.pm lonparmset.pm
Log:
Should fix the "jump" behavior, so the user is taken straight to their
current location, or to the map they just opened.
--bowersj21047588396
Content-Type: text/plain
Content-Disposition: attachment; filename="bowersj2-20030313154636.txt"
Index: loncom/interface/lonnavmaps.pm
diff -u loncom/interface/lonnavmaps.pm:1.158 loncom/interface/lonnavmaps.pm:1.159
--- loncom/interface/lonnavmaps.pm:1.158 Thu Mar 13 14:57:10 2003
+++ loncom/interface/lonnavmaps.pm Thu Mar 13 15:46:36 2003
@@ -2,7 +2,7 @@
# The LearningOnline Network with CAPA
# Navigate Maps Handler
#
-# $Id: lonnavmaps.pm,v 1.158 2003/03/13 19:57:10 bowersj2 Exp $
+# $Id: lonnavmaps.pm,v 1.159 2003/03/13 20:46:36 bowersj2 Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -550,7 +550,7 @@
=item * B<condenseParts>: A flag. If yes (default), if all parts of the problem have the same status and that status is Nothing Set, Correct, or Network Failure, then only one line will be displayed for that resource anyhow. If no, all parts will always be displayed. If showParts is 0, this is ignored.
-=item * B<jumpCount>: A string identifying the URL to place the anchor 'curloc' at. Default to no anchor at all. It is the responsibility of the renderer user to ensure that the #curloc is in the URL. By default, determined through the use of the ENV{} 'jump' and 'jumpType' information.
+=item * B<jumpCount>: A string identifying the URL to place the anchor 'curloc' at. Default to no anchor at all. It is the responsibility of the renderer user to ensure that the #curloc is in the URL. By default, determined through the use of the ENV{} 'jump' information, and should normally "just work" correctly.
=item * B<here>: A Symb identifying where to place the 'here' marker. Default empty, which means no marker.
@@ -651,7 +651,7 @@
$linkopen .= "&condition=" . $it->{CONDITION} . '&hereType='
. $params->{'hereType'} . '&here=' .
&Apache::lonnet::escape($params->{'here'}) .
- '&jumpType=' . SYMB() . '&jump=' .
+ '&jump=' .
&Apache::lonnet::escape($resource->symb()) .
"&folderManip=1'>";
} else {
@@ -839,12 +839,8 @@
my $r = $args->{'r'};
my $queryString = $args->{'queryString'};
- my $jumpToURL = $args->{'jumpToURL'};
- my $jumpToSymb = $args->{'jumpToSymb'};
- my $jumpType;
+ my $jump = $args->{'jump'};
my $here = $args->{'here'};
- my $jump;
- my $currentJumpIndex = setDefault($args->{'currentJumpIndex'}, 0);
my $suppressNavmap = setDefault($args->{'suppressNavmap'}, 0);
my $currentJumpDelta = 2; # change this to change how many resources are displayed
# before the current resource when using #current
@@ -879,10 +875,6 @@
# Step two: Locate what kind of here marker is necessary
# Determine where the "here" marker is and where the screen jumps to.
- # We're coming from the remote. We have either a url, a symb, or nothing,
- # and we need to figure out what.
- # Preference: Symb
-
if ($ENV{'form.symb'}) {
$here = $jump = $ENV{'form.symb'};
} elsif ($ENV{'form.postdata'}) {
@@ -899,7 +891,6 @@
my $depth = 1;
$mapIterator->next(); # discard the first BEGIN_MAP
my $curRes = $mapIterator->next();
- my $counter = 0;
my $found = 0;
# We only need to do this if we need to open the maps to show the
@@ -925,34 +916,8 @@
$curRes = $mapIterator->next();
}
-
- # Since we changed the folders, (re-)locate the jump point, if any
- $mapIterator = $navmap->getIterator(undef, undef, $filterHash, 0);
- $depth = 1;
- $mapIterator->next();
- $curRes = $mapIterator->next();
- my $foundJump = 0;
-
- while ($depth > 0 && !$foundJump) {
- if ($curRes == $mapIterator->BEGIN_MAP()) { $depth++; }
- if ($curRes == $mapIterator->END_MAP()) { $depth--; }
- if (ref($curRes)) { $counter++; }
-
- if (ref($curRes) &&
- (($jumpType == SYMB() && $curRes->symb() eq $jump) ||
- ($jumpType == URL() && $curRes->src() eq $jump))) {
-
- # This is why we have to use the main iterator instead of the
- # potentially faster DFS: The count has to be the same, so
- # the order has to be the same, which DFS won't give us.
- $currentJumpIndex = $counter;
- $foundJump = 1;
- }
-
- $curRes = $mapIterator->next();
- }
-
}
+
if ( !defined($args->{'iterator'}) && $ENV{'form.folderManip'} ) { # we came from a user's manipulation of the nav page
# If this is a click on a folder or something, we want to preserve the "here"
# from the querystring, and get the new "jump" marker
@@ -987,6 +952,31 @@
}
}
+ # (re-)Locate the jump point, if any
+ my $mapIterator = $navmap->getIterator(undef, undef, $filterHash, 0);
+ my $depth = 1;
+ $mapIterator->next();
+ my $curRes = $mapIterator->next();
+ my $foundJump = 0;
+ my $counter = 0;
+
+ while ($depth > 0 && !$foundJump) {
+ if ($curRes == $mapIterator->BEGIN_MAP()) { $depth++; }
+ if ($curRes == $mapIterator->END_MAP()) { $depth--; }
+ if (ref($curRes)) { $counter++; }
+
+ if (ref($curRes) && $jump eq $curRes->symb()) {
+
+ # This is why we have to use the main iterator instead of the
+ # potentially faster DFS: The count has to be the same, so
+ # the order has to be the same, which DFS won't give us.
+ $args->{'currentJumpIndex'} = $counter;
+ $foundJump = 1;
+ }
+
+ $curRes = $mapIterator->next();
+ }
+
my $showParts = setDefault($args->{'showParts'}, 1);
my $condenseParts = setDefault($args->{'condenseParts'}, 1);
# keeps track of when the current resource is found,
@@ -1059,9 +1049,9 @@
my $displayedJumpMarker = 0;
# Set up iteration.
- my $depth = 1;
+ $depth = 1;
$it->next(); # discard initial BEGIN_MAP
- my $curRes = $it->next();
+ $curRes = $it->next();
my $now = time();
my $in24Hours = $now + 24 * 60 * 60;
my $rownum = 0;
@@ -1218,8 +1208,14 @@
}
# Print out the part that jumps to #curloc if it exists
+ # delay needed because the browser is processing the jump before
+ # it finishes rendering, so it goes to the wrong place!
+ # onload might be better, but this routine has no access to that.
+ # On mozilla, the 0-millisecond timeout seems to prevent this;
+ # it's quite likely this might fix other browsers, too, and
+ # certainly won't hurt anything.
if ($displayedJumpMarker) {
- $result .= "<script>location += \"#curloc\";</script>\n";
+ $result .= "<script>setTimeout(\"location += '#curloc';\", 0)</script>\n";
}
$result .= "</table>";
Index: loncom/interface/lonparmset.pm
diff -u loncom/interface/lonparmset.pm:1.82 loncom/interface/lonparmset.pm:1.83
--- loncom/interface/lonparmset.pm:1.82 Sun Jan 19 06:55:14 2003
+++ loncom/interface/lonparmset.pm Thu Mar 13 15:46:36 2003
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set parameters for assessments
#
-# $Id: lonparmset.pm,v 1.82 2003/01/19 11:55:14 www Exp $
+# $Id: lonparmset.pm,v 1.83 2003/03/13 20:46:36 bowersj2 Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1562,7 +1562,7 @@
=pod
-=item handler
+=item * handler
Main handler. Calls &assessparms and &crsenv subroutines.
@@ -1570,6 +1570,7 @@
##################################################
##################################################
+ use Data::Dumper;
sub handler {
my $r=shift;
@@ -1579,6 +1580,16 @@
return OK;
}
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'});
+
+ $r->content_type('text/html');
+ $r->send_http_header;
+ $r->print("\n\n");
+ # Temp for reverse-engineering purposes.
+ for (keys %ENV) {
+ if ($_ =~ /^form\./) {
+ $r->print($_ . " " . Dumper($ENV{$_}) . "<br />\n");
+ }
+ }
# ----------------------------------------------------- Needs to be in a course
if (($ENV{'request.course.id'}) &&
--bowersj21047588396--