--- loncom/interface/lonnavmaps.pm 2011/03/10 23:18:18 1.444.2.4
+++ loncom/interface/lonnavmaps.pm 2012/07/09 18:43:03 1.444.2.8
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Navigate Maps Handler
#
-# $Id: lonnavmaps.pm,v 1.444.2.4 2011/03/10 23:18:18 raeburn Exp $
+# $Id: lonnavmaps.pm,v 1.444.2.8 2012/07/09 18:43:03 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
@@ -509,7 +509,7 @@ my %statusIconMap =
my %iconAltTags = #texthash does not work here
( 'navmap.correct.gif' => 'Correct',
'navmap.wrong.gif' => 'Incorrect',
- 'navmap.open.gif' => 'Open',
+ 'navmap.open.gif' => 'Is Open',
'navmap.partial.gif' => 'Partially Correct',
'navmap.ellipsis.gif' => 'Attempted',
);
@@ -641,7 +641,7 @@ sub getDescription {
return &mt("Not currently assigned.");
}
if ($status == $res->OPEN_LATER) {
- return &mt("Open ") .timeToHumanString($open,'start');
+ return &mt("Open [_1]",&timeToHumanString($open,'start'));
}
if ($res->simpleStatus($part) == $res->OPEN) {
unless (&Apache::lonnet::allowed('mgr',$env{'request.course.id'})) {
@@ -675,22 +675,22 @@ sub getDescription {
if ($status == $res->OPEN) {
if ($due) {
if ($res->is_practice()) {
- return &mt("Closes ")." " .timeToHumanString($due,'start');
+ return &mt("Closes [_1]",&timeToHumanString($due,'start'));
} else {
- return &mt("Due")." " .timeToHumanString($due,'end');
+ return &mt("Due [_1]",&timeToHumanString($due,'end'));
}
} else {
return &mt("Open, no due date");
}
}
if ($status == $res->PAST_DUE_ANSWER_LATER) {
- return &mt("Answer open")." " .timeToHumanString($answer,'start');
+ return &mt("Answer open [_1]",&timeToHumanString($answer,'start'));
}
if ($status == $res->PAST_DUE_NO_ANSWER) {
if ($res->is_practice()) {
- return &mt("Closed")." " . timeToHumanString($due,'start');
+ return &mt("Closed [_1]",&timeToHumanString($due,'start'));
} else {
- return &mt("Was due")." " . timeToHumanString($due,'end');
+ return &mt("Was due [_1]",&timeToHumanString($due,'end'));
}
}
if (($status == $res->ANSWER_OPEN || $status == $res->PARTIALLY_CORRECT)
@@ -723,7 +723,7 @@ sub getDescription {
}
}
if ($due) {
- return &mt("Due")." " . timeToHumanString($due,'end') .
+ return &mt("Due [_1]",&timeToHumanString($due,'end')) .
" $triesString";
} else {
return &mt("No due date")." $triesString";
@@ -808,14 +808,31 @@ sub timeToHumanString {
# Less than an hour
if ( $delta < $hour ) {
- # If so, use minutes
+ # If so, use minutes; or minutes, seconds (if format requires)
my $minutes = floor($delta / 60);
+ if (($format ne '') && ($format =~ /\%(T|S)/)) {
+ my $display;
+ if ($minutes == 1) {
+ $display = "${prefix}1 minute";
+ } else {
+ $display = "$prefix$minutes minutes";
+ }
+ my $seconds = $delta % $minute;
+ if ($seconds == 0) {
+ $display .= $tense;
+ } elsif ($seconds == 1) {
+ $display .= ", 1 second$tense";
+ } else {
+ $display .= ", $seconds seconds$tense";
+ }
+ return $display;
+ }
if ($minutes == 1) { return "${prefix}1 minute$tense"; }
return "$prefix$minutes minutes$tense";
}
# Is it less than 24 hours away? If so,
- # display hours + minutes
+ # display hours + minutes, (and + seconds, if format specified it)
if ( $delta < $hour * 24) {
my $hours = floor($delta / $hour);
my $minutes = floor(($delta % $hour) / $minute);
@@ -830,15 +847,30 @@ sub timeToHumanString {
if ($minutes == 0) {
$minuteString = "";
}
+ if (($format ne '') && ($format =~ /\%(T|S)/)) {
+ my $display = "$prefix$hourString$minuteString";
+ my $seconds = $delta-(($hours * $hour)+($minutes * $minute));
+ if ($seconds == 0) {
+ $display .= $tense;
+ } elsif ($seconds == 1) {
+ $display .= ", 1 second$tense";
+ } else {
+ $display .= ", $seconds seconds$tense";
+ }
+ return $display;
+ }
return "$prefix$hourString$minuteString$tense";
}
+ # Date/time is more than 24 hours away
+
my $dt = DateTime->from_epoch(epoch => $time)
->set_time_zone(&Apache::lonlocal::gettimezone());
- # If there's a caller supplied format, use it.
+ # If there's a caller supplied format, use it, unless it only displays
+ # H:M:S or H:M.
- if ($format ne '') {
+ if (($format ne '') && ($format ne '%T') && ($format ne '%R')) {
my $timeStr = $dt->strftime($format);
return $timeStr.' ('.$dt->time_zone_short_name().')';
}
@@ -974,10 +1006,10 @@ sub render_resource {
}
if ($resource->randomout()) {
- $nonLinkedText .= ' ('.&mt('hidden').') ';
+ $nonLinkedText .= ' ('.&mt('hidden').') ';
}
if (!$resource->condval()) {
- $nonLinkedText .= ' ('.&mt('conditionally hidden').') ';
+ $nonLinkedText .= ' ('.&mt('conditionally hidden').') ';
}
if (($resource->is_practice()) && ($resource->is_raw_problem())) {
$nonLinkedText .=' '.&mt('not graded').'';
@@ -1132,7 +1164,7 @@ sub render_long_status {
}
if ($resource->kind() eq "res" &&
- ($resource->is_problem() || $resource->is_practice()) &&
+ $resource->is_raw_problem() &&
!$firstDisplayed) {
if ($color) {$result .= ""; }
$result .= getDescription($resource, $part);
@@ -3494,6 +3526,8 @@ sub new {
$self->{NAV_MAP}->{RESOURCE_CACHE}->{$self->{ID}} = $self;
$self->{RESOURCE_ERROR} = 0;
+ $self->{DUEDATE_CACHE} = undef;
+
# A hash that can be used by two-pass algorithms to store data
# about this resource in. Not used by the resource object
# directly.
@@ -4071,6 +4105,9 @@ sub checkedin {
# this should work exactly like the copy in lonhomework.pm
sub duedate {
(my $self, my $part) = @_;
+ if (defined ($self->{DUEDATE_CACHE}->{$part})) {
+ return $self->{DUEDATE_CACHE}->{$part};
+ }
my $date;
my @interval=$self->parmval("interval", $part);
my $due_date=$self->parmval("duedate", $part);
@@ -4087,6 +4124,7 @@ sub duedate {
} else {
$date = $due_date;
}
+ $self->{DUEDATE_CACHE}->{$part} = $date;
return $date;
}
sub handgrade {