--- loncom/interface/lonnavmaps.pm 2003/09/17 18:15:54 1.229
+++ loncom/interface/lonnavmaps.pm 2004/02/10 22:12:46 1.245
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Navigate Maps Handler
#
-# $Id: lonnavmaps.pm,v 1.229 2003/09/17 18:15:54 www Exp $
+# $Id: lonnavmaps.pm,v 1.245 2004/02/10 22:12:46 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -25,20 +25,7 @@
#
# http://www.lon-capa.org/
#
-# (Page Handler
-#
-# (TeX Content Handler
-#
-# 05/29/00,05/30 Gerd Kortemeyer)
-# 08/30,08/31,09/06,09/14,09/15,09/16,09/19,09/20,09/21,09/23,
-# 10/02,10/10,10/14,10/16,10/18,10/19,10/31,11/6,11/14,11/16 Gerd Kortemeyer)
-#
-# 3/1/1,6/1,17/1,29/1,30/1,2/8,9/21,9/24,9/25 Gerd Kortemeyer
-# YEAR=2002
-# 1/1 Gerd Kortemeyer
-# Oct-Nov Jeremy Bowers
-# YEAR=2003
-# Jeremy Bowers ... lots of days
+###
package Apache::lonnavmaps;
@@ -107,9 +94,9 @@ sub real_handler {
# Handle header-only request
if ($r->header_only) {
if ($ENV{'browser.mathml'}) {
- $r->content_type('text/xml');
+ &Apache::loncommon::content_type($r,'text/xml');
} else {
- $r->content_type('text/html');
+ &Apache::loncommon::content_type($r,'text/html');
}
$r->send_http_header;
return OK;
@@ -117,9 +104,9 @@ sub real_handler {
# Send header, don't cache this page
if ($ENV{'browser.mathml'}) {
- $r->content_type('text/xml');
+ &Apache::loncommon::content_type($r,'text/xml');
} else {
- $r->content_type('text/html');
+ &Apache::loncommon::content_type($r,'text/html');
}
&Apache::loncommon::no_cache($r);
$r->send_http_header;
@@ -127,7 +114,6 @@ sub real_handler {
# Create the nav map
my $navmap = Apache::lonnavmaps::navmap->new();
-
if (!defined($navmap)) {
my $requrl = $r->uri;
$ENV{'user.error.msg'} = "$requrl:bre:0:0:Course not initialized";
@@ -372,7 +358,7 @@ sub getDescription {
$triesString = "$triesString";
}
}
- if ($res->duedate()) {
+ if ($res->duedate($part)) {
return &mt("Due")." " . timeToHumanString($res->duedate($part)) .
" $triesString";
} else {
@@ -394,8 +380,8 @@ sub dueInLessThen24Hours {
return ($status == $res->OPEN() ||
$status == $res->TRIES_LEFT()) &&
- $res->duedate() && $res->duedate() < time()+(24*60*60) &&
- $res->duedate() > time();
+ $res->duedate($part) && $res->duedate($part) < time()+(24*60*60) &&
+ $res->duedate($part) > time();
}
# Convenience function, so others can use it: Is there only one try remaining for the
@@ -407,8 +393,8 @@ sub lastTry {
my $tries = $res->tries($part);
my $maxtries = $res->maxtries($part);
return $tries && $maxtries && $maxtries > 1 &&
- $maxtries - $tries == 1 && $res->duedate() &&
- $res->duedate() > time();
+ $maxtries - $tries == 1 && $res->duedate($part) &&
+ $res->duedate($part) > time();
}
# This puts a human-readable name on the ENV variable.
@@ -432,8 +418,8 @@ sub timeToHumanString {
if (!$time) {
return &mt('never');
}
- unless (&Apache::loncommon::current_language()=~/^en/) {
- return localtime($time);
+ unless (&Apache::lonlocal::current_language()=~/^en/) {
+ return &Apache::lonlocal::locallocaltime($time);
}
my $now = time();
@@ -502,7 +488,7 @@ sub timeToHumanString {
# HH:MM
if ( $delta < $day * 5 ) {
my $timeStr = strftime("%A, %b %e at %I:%M %P", localtime($time));
- $timeStr =~ s/12:00 am/midnight/;
+ $timeStr =~ s/12:00 am/00:00/;
$timeStr =~ s/12:00 pm/noon/;
return ($inPast ? "last " : "next ") .
$timeStr;
@@ -512,14 +498,14 @@ sub timeToHumanString {
if ( $time[5] == $now[5]) {
# Return on Month Day, HH:MM meridian
my $timeStr = strftime("on %A, %b %e at %I:%M %P", localtime($time));
- $timeStr =~ s/12:00 am/midnight/;
+ $timeStr =~ s/12:00 am/00:00/;
$timeStr =~ s/12:00 pm/noon/;
return $timeStr;
}
# Not this year, so show the year
my $timeStr = strftime("on %A, %b %e %G at %I:%M %P", localtime($time));
- $timeStr =~ s/12:00 am/midnight/;
+ $timeStr =~ s/12:00 am/00:00/;
$timeStr =~ s/12:00 pm/noon/;
return $timeStr;
}
@@ -896,12 +882,8 @@ sub render_resource {
$icon = $params->{'indentString'};
}
} else {
- my $curfext= (split (/\./,$resource->src))[-1];
- my $embstyle = &Apache::loncommon::fileembstyle($curfext);
- # The unless conditional that follows is a bit of overkill
- if (!(!defined($embstyle) || $embstyle eq 'unk' || $embstyle eq 'hdn')) {
- $icon = "";
- }
+ $icon = "";
}
# Display the correct map icon to open or shut map
@@ -971,7 +953,11 @@ sub render_resource {
if ($resource->is_problem() && $part ne '0' &&
!$params->{'condensed'}) {
- $partLabel = " (Part $part)";
+ my $displaypart=&Apache::lonnet::EXT('resource.'.$part.'.display',
+ $resource->symb());
+ unless ($displaypart) { $displaypart=$part; }
+ $partLabel = " (Part: $displaypart)";
+ $link.='#'.&Apache::lonnet::escape($part);
$title = "";
}
@@ -1331,15 +1317,15 @@ sub render {
$result.='
Key: | ';
if ($navmap->{LAST_CHECK}) {
$result .=
- ' New discussion since '.
+ ' '.&mt('New discussion since').' '.
strftime("%A, %b %e at %I:%M %P", localtime($navmap->{LAST_CHECK})).
' '.
- ' New message (click to open) '.
+ ' '.&mt('New message (click to open)').' '.
' | ';
} else {
$result .= ' '.
- ' Discussions | '.
- ' New message (click to open)'.
+ ' '.&mt('Discussions').' | '.
+ ' '.&mt('New message (click to open)').
' | ';
}
@@ -1350,11 +1336,11 @@ sub render {
if ($condition) {
$result.="Close All Folders";
+ "\">".&mt('Close All Folders')."";
} else {
$result.="Open All Folders";
+ "\">".&mt('Open All Folders')."";
}
$result .= "
\n";
}
@@ -1587,7 +1573,6 @@ sub render {
# If we have the connection, make sure the user is still connected
my $c = $r->connection;
if ($c->aborted()) {
- Apache::lonnet::logthis("navmaps aborted");
# Who cares what we do, nobody will see it anyhow.
return '';
}
@@ -2347,6 +2332,8 @@ consisting entirely of empty resources e
ending resource, will cause a lot of BRANCH_STARTs and BRANCH_ENDs,
but only one resource will be returned.
+=back
+
=head2 Normal Usage
Normal usage of the iterator object is to do the following:
@@ -2367,8 +2354,6 @@ the depth of the iterator to see when it
code. It is difficult to get right and harder to understand then
this. They should be migrated to this new style.
-=back
-
=cut
# Here are the tokens for the iterator:
@@ -3369,7 +3354,7 @@ sub opendate {
}
sub problemstatus {
(my $self, my $part) = @_;
- return $self->parmval("problemstatus", $part);
+ return lc $self->parmval("problemstatus", $part);
}
sub sig {
(my $self, my $part) = @_;
@@ -3547,7 +3532,11 @@ sub responseType {
my $part = shift;
$self->extractParts();
- return $self->{RESPONSE_TYPES}->{$part};
+ if (defined($self->{RESPONSE_TYPES}->{$part})) {
+ return @{$self->{RESPONSE_TYPES}->{$part}};
+ } else {
+ return undef;
+ }
}
sub responseIds {
@@ -3555,7 +3544,11 @@ sub responseIds {
my $part = shift;
$self->extractParts();
- return $self->{RESPONSE_IDS}->{$part};
+ if (defined($self->{RESPONSE_IDS}->{$part})) {
+ return @{$self->{RESPONSE_IDS}->{$part}};
+ } else {
+ return undef;
+ }
}
# Private function: Extracts the parts information, both part names and
@@ -3572,32 +3565,44 @@ sub extractParts {
# Retrieve part count, if this is a problem
if ($self->is_problem()) {
+ my $partorder = &Apache::lonnet::metadata($self->src(), 'partorder');
my $metadata = &Apache::lonnet::metadata($self->src(), 'packages');
- if (!$metadata) {
- $self->{RESOURCE_ERROR} = 1;
- $self->{PARTS} = [];
- $self->{PART_TYPE} = {};
- return;
- }
- foreach (split(/\,/,$metadata)) {
- if ($_ =~ /^part_(.*)$/) {
- my $part = $1;
- # This floods the logs if it blows up
- if (defined($parts{$part})) {
- Apache::lonnet::logthis("$part multiply defined in metadata for " . $self->symb());
- }
-
- # check to see if part is turned off.
- if (!Apache::loncommon::check_if_partid_hidden($part, $self->symb())) {
- $parts{$part} = 1;
- }
- }
+ if ($partorder) {
+ my @parts;
+ for my $part (split (/,/,$partorder)) {
+ if (!Apache::loncommon::check_if_partid_hidden($part, $self->symb())) {
+ push @parts, $part;
+ $parts{$part} = 1;
+ }
+ }
+ $self->{PARTS} = \@parts;
+ } else {
+ if (!$metadata) {
+ $self->{RESOURCE_ERROR} = 1;
+ $self->{PARTS} = [];
+ $self->{PART_TYPE} = {};
+ return;
+ }
+ foreach (split(/\,/,$metadata)) {
+ if ($_ =~ /^part_(.*)$/) {
+ my $part = $1;
+ # This floods the logs if it blows up
+ if (defined($parts{$part})) {
+ &Apache::lonnet::logthis("$part multiply defined in metadata for " . $self->symb());
+ }
+
+ # check to see if part is turned off.
+
+ if (!Apache::loncommon::check_if_partid_hidden($part, $self->symb())) {
+ $parts{$part} = 1;
+ }
+ }
+ }
+ my @sortedParts = sort keys %parts;
+ $self->{PARTS} = \@sortedParts;
}
-
- my @sortedParts = sort keys %parts;
- $self->{PARTS} = \@sortedParts;
my %responseIdHash;
my %responseTypeHash;
@@ -3609,7 +3614,7 @@ sub extractParts {
}
# Now, the unfortunate thing about this is that parts, part name, and
- # response if are delimited by underscores, but both the part
+ # response id are delimited by underscores, but both the part
# name and response id can themselves have underscores in them.
# So we have to use our knowlege of part names to figure out
# where the part names begin and end, and even then, it is possible
@@ -3621,7 +3626,6 @@ sub extractParts {
my $partIdSoFar = '';
my @partChunks = split /_/, $partStuff;
my $i = 0;
-
for ($i = 0; $i < scalar(@partChunks); $i++) {
if ($partIdSoFar) { $partIdSoFar .= '_'; }
$partIdSoFar .= $partChunks[$i];
@@ -3629,13 +3633,11 @@ sub extractParts {
my @otherChunks = @partChunks[$i+1..$#partChunks];
my $responseId = join('_', @otherChunks);
push @{$responseIdHash{$partIdSoFar}}, $responseId;
- $responseTypeHash{$partIdSoFar} = $responseType;
- last;
+ push @{$responseTypeHash{$partIdSoFar}}, $responseType;
}
}
}
}
-
$self->{RESPONSE_IDS} = \%responseIdHash;
$self->{RESPONSE_TYPES} = \%responseTypeHash;
}
@@ -3948,7 +3950,12 @@ sub status {
#if ($self->{RESOURCE_ERROR}) { return NETWORK_FAILURE; }
if ($completionStatus == NETWORK_FAILURE) { return NETWORK_FAILURE; }
- my $suppressFeedback = lc($self->parmval("problemstatus", $part)) eq 'no';
+ my $suppressFeedback = $self->problemstatus($part) eq 'no';
+ # If there's an answer date and we're past it, don't
+ # suppress the feedback; student should know
+ if ($self->answerdate($part) && $self->answerdate($part) < time()) {
+ $suppressFeedback = 0;
+ }
# There are a few whole rows we can dispose of:
if ($completionStatus == CORRECT ||