--- loncom/interface/lonnavmaps.pm 2002/10/17 19:25:27 1.84
+++ loncom/interface/lonnavmaps.pm 2002/10/24 18:38:26 1.85
@@ -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 @@ sub new_handle {
$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 @@ sub new_handle {
# Begin the HTML table
# four cols: resource + indent, chat+feedback, icon, text string
- $r->print('
' ."\n");
+ $r->print('' ."\n");
my $condition = 0;
if ($ENV{'form.condition'}) {
@@ -1218,7 +1218,7 @@ sub new_handle {
my $discussionHTML = ""; my $feedbackHTML = "";
- # SECOND COL: Is there text or feedback?
+ # SECOND COL: Is there text, feedback, errors??
if ($curRes->hasDiscussion()) {
$discussionHTML = $linkopen .
'
' .
@@ -1473,7 +1473,7 @@ sub timeToHumanString {
# 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 are methods that help you retrieve
# 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 hasDiscussion {
sub getFeedback {
my $self = shift;
- return $self->{NAV_MAP}->getFeedback($self->symb());
+ return $self->{NAV_MAP}->getFeedback($self->src());
}
=pod
@@ -2884,20 +2886,18 @@ sub status {
=over 4
-=item * B(): Gets the next resource in the navmap after this one.
+=item * B($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($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);
@@ -2913,6 +2913,28 @@ sub getNext {
}
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;
+}
=pod