[LON-CAPA-cvs] cvs: loncom /interface lonnavmaps.pm
bowersj2
lon-capa-cvs@mail.lon-capa.org
Thu, 24 Oct 2002 18:38:26 -0000
bowersj2 Thu Oct 24 14:38:26 2002 EDT
Modified files:
/loncom/interface lonnavmaps.pm
Log:
Misc little changes, getting me back in sync with the repository:
* Attempted, but not completed, problems now show the "Open" arrow correctly
* Dropped table's 'width="100%"' setting. Don't really like the table
without it, don't like it with it, dislike it without it less.
* Minor change in human time, when talking about the next five days, also
show the month and date. Avoids problems with "Due next wednesday" when
today is Tuesday; too many of us think "Due next wednesday" under that
circumstance means "a week from tommorow", rather then "Tommorow". Crazy,
but true.
* Trying a fix for the feedback icon; don't know if it will work.
* Started writing the code to walk the nav hash backwards, so my New Improved
Iterator will work correctly.
Index: loncom/interface/lonnavmaps.pm
diff -u loncom/interface/lonnavmaps.pm:1.84 loncom/interface/lonnavmaps.pm:1.85
--- loncom/interface/lonnavmaps.pm:1.84 Thu Oct 17 15:25:27 2002
+++ loncom/interface/lonnavmaps.pm Thu Oct 24 14:38:26 2002
@@ -2,7 +2,7 @@
# The LearningOnline Network with CAPA
# Navigate Maps Handler
#
-# $Id: lonnavmaps.pm,v 1.84 2002/10/17 19:25:27 bowersj2 Exp $
+# $Id: lonnavmaps.pm,v 1.85 2002/10/24 18:38:26 bowersj2 Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -890,7 +890,7 @@
$res->TRIES_LEFT => 'navmap.open.gif',
$res->INCORRECT => 'navmap.wrong.gif',
$res->OPEN => 'navmap.open.gif',
- $res->ATTEMPTED => '' );
+ $res->ATTEMPTED => 'navmap.open.gif' );
my %iconAltTags =
( 'navmap.correct.gif' => 'Correct',
@@ -925,7 +925,7 @@
# Begin the HTML table
# four cols: resource + indent, chat+feedback, icon, text string
- $r->print('<table cellspacing="0" cellpadding="3" width="100%" border="0" bgcolor="#FFFFFF">' ."\n");
+ $r->print('<table cellspacing="0" cellpadding="3" border="0" bgcolor="#FFFFFF">' ."\n");
my $condition = 0;
if ($ENV{'form.condition'}) {
@@ -1218,7 +1218,7 @@
my $discussionHTML = ""; my $feedbackHTML = "";
- # SECOND COL: Is there text or feedback?
+ # SECOND COL: Is there text, feedback, errors??
if ($curRes->hasDiscussion()) {
$discussionHTML = $linkopen .
'<img border="0" src="/adm/lonMisc/chat.gif" />' .
@@ -1473,7 +1473,7 @@
# Less then 5 days away, display day of the week and
# HH:MM
if ( $delta < $day * 5 ) {
- my $timeStr = strftime("%A at %I:%M %P", localtime($time));
+ my $timeStr = strftime("%A, %b %e at %I:%M %P", localtime($time));
$timeStr =~ s/12:00 am/midnight/;
$timeStr =~ s/12:00 pm/noon/;
return ($inPast ? "last " : "next ") .
@@ -2270,7 +2270,9 @@
# These info functions can be used directly, as they don't return
# resource information.
+sub comesfrom { my $self=shift; return $self->navHash("comesfrom_", 1); }
sub ext { my $self=shift; return $self->navHash("ext_", 1) eq 'true:'; }
+sub from { my $self=shift; return $self->navHash("from_", 1); }
sub goesto { my $self=shift; return $self->navHash("goesto_", 1); }
sub kind { my $self=shift; return $self->navHash("kind_", 1); }
sub randomout { my $self=shift; return $self->navHash("randomout_", 1); }
@@ -2554,7 +2556,7 @@
sub getFeedback {
my $self = shift;
- return $self->{NAV_MAP}->getFeedback($self->symb());
+ return $self->{NAV_MAP}->getFeedback($self->src());
}
=pod
@@ -2884,20 +2886,18 @@
=over 4
-=item * B<getNext>(): Gets the next resource in the navmap after this one.
+=item * B<getNext>($alreadySeenHashRef): Retreive an array of the possible next resources after this one. Always returns an array, even in the one- or zero-element case. The "alreadySeenHashRef" is an optional parameter that can be passed in to the method. If $$alreadySeenHashRef{$res->id()} is true in that hash, getNext will not return it in the list. In other words, you can use it to suppress resources you've already seen in the getNext method directly.
-=cut
+=item * B<getPrevious>($alreadySeenHashRef): Retreive an array of the possible previous resources from this one. Always returns an array, even in the one- or zero-element case. $alreadySeenHashRef is the same as in getNext.
-# For the simple single-link case, to get from a resource to the next
-# resource, you need to look up the "to_" link in the nav hash, then
-# follow that with the "goesto_" link.
+=cut
sub getNext {
my $self = shift;
my $alreadySeenHash = shift;
my @branches;
my $to = $self->to();
- foreach my $branch ( split(/\,/, $to) ) {
+ foreach my $branch ( split(/,/, $to) ) {
my $choice = $self->{NAV_MAP}->getById($branch);
my $next = $choice->goesto();
$next = $self->{NAV_MAP}->getById($next);
@@ -2910,6 +2910,28 @@
($browsePriv ne '2' && $browsePriv ne 'F')) {
push @branches, $next;
}
+ }
+ return \@branches;
+}
+
+sub getPrevious {
+ my $self = shift;
+ my @alreadySeen = shift;
+ my @branches;
+ my $from = $self->from();
+ foreach my $branch ( split /,/, $from) {
+ my $choice = $self->{NAV_MAP}->getById($branch);
+ my $prev = $choice->comesfrom();
+ $prev = $self->{NAV_MAP}->getById($prev);
+
+ # Skip it if we've already seen it or the user doesn't have
+ # browse privs
+ my $browsePriv = &Apache::lonnet::allowed('bre', $self->src);
+ if (!defined($alreadySeenHash) ||
+ !defined($alreadySeenHash->{$next->{ID}}) ||
+ ($browsePriv ne '2' && $browsePriv ne 'F')) {
+ push @branches, $next;
+ }
}
return \@branches;
}