--- loncom/interface/lonnavmaps.pm 2008/01/03 22:49:56 1.407
+++ loncom/interface/lonnavmaps.pm 2008/12/21 16:27:26 1.415.2.3
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Navigate Maps Handler
#
-# $Id: lonnavmaps.pm,v 1.407 2008/01/03 22:49:56 raeburn Exp $
+# $Id: lonnavmaps.pm,v 1.415.2.3 2008/12/21 16:27:26 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -198,7 +198,7 @@ sub getDescription {
return &mt("Not currently assigned.");
}
if ($status == $res->OPEN_LATER) {
- return "Open " .timeToHumanString($open,'start');
+ return &mt("Open ") .timeToHumanString($open,'start');
}
if ($status == $res->OPEN) {
if ($due) {
@@ -236,7 +236,7 @@ sub getDescription {
my $maxtries = $res->maxtries($part);
my $triesString = "";
if ($tries && $maxtries) {
- $triesString = "($tries of $maxtries tries used)";
+ $triesString = '('.&mt('[_1] of [quant,_2,try,tries] used',$tries,$maxtries).')';
if ($maxtries > 1 && $maxtries - $tries == 1) {
$triesString = "$triesString";
}
@@ -854,7 +854,10 @@ sub render_resource {
if (!$resource->condval()) {
$nonLinkedText .= ' ('.&mt('conditionally hidden').') ';
}
-
+ if (($resource->is_practice()) && ($resource->is_raw_problem())) {
+ $nonLinkedText .=' '.&mt('not graded').'';
+ }
+
# We're done preparing and finally ready to start the rendering
my $result = "
";
@@ -1179,7 +1182,7 @@ sub render {
if (!defined($navmap)) {
$navmap = Apache::lonnavmaps::navmap->new();
if (!defined($navmap)) {
- # no londer in course
+ # no longer in course
return ''.&mt('No course selected').'
'.&mt('Select a course').' ';
}
@@ -1247,6 +1250,11 @@ sub render {
# Step 1: Check to see if we have a navmap
if (!defined($navmap)) {
$navmap = Apache::lonnavmaps::navmap->new();
+ if (!defined($navmap)) {
+ # no longer in course
+ return ''.&mt('No course selected').'
+ '.&mt('Select a course').' ';
+ }
}
# See if we're being passed a specific map
@@ -1738,7 +1746,7 @@ ENDBLOCK
$result.='}
| '."\n";
+ '."\n";
return $result;
}
@@ -2299,17 +2307,22 @@ sub parmval {
my $hashkey = $what."|||".$symb;
if (defined($self->{PARM_CACHE}->{$hashkey})) {
- if (wantarray) {
- return @{$self->{PARM_CACHE}->{$hashkey}};
- } else {
- return $self->{PARM_CACHE}->{$hashkey}->[0];
- }
+ if (ref($self->{PARM_CACHE}->{$hashkey}) eq 'ARRAY') {
+ if (defined($self->{PARM_CACHE}->{$hashkey}->[0])) {
+ if (wantarray) {
+ return @{$self->{PARM_CACHE}->{$hashkey}};
+ } else {
+ return $self->{PARM_CACHE}->{$hashkey}->[0];
+ }
+ }
+ } else {
+ return $self->{PARM_CACHE}->{$hashkey};
+ }
}
-
my $result = $self->parmval_real($what, $symb, $recurse);
$self->{PARM_CACHE}->{$hashkey} = $result;
if (wantarray) {
- return @{$result};
+ return @{$result};
}
return $result->[0];
}
@@ -3440,11 +3453,13 @@ sub kind { my $self=shift; return $self-
sub randomout { my $self=shift; return $self->navHash("randomout_", 1); }
sub randompick {
my $self = shift;
- return $self->parmval('randompick');
+ my $randompick = $self->parmval('randompick');
+ return $randompick;
}
sub randomorder {
my $self = shift;
- return ($self->parmval('randomorder') =~ /^yes$/i);
+ my $randomorder = $self->parmval('randomorder');
+ return ($randomorder =~ /^yes$/i);
}
sub link {
my $self=shift;
@@ -3565,7 +3580,8 @@ sub retrieveResources {
sub is_exam {
my ($self,$part) = @_;
- if ($self->parmval('type',$part) eq 'exam') {
+ my $type = $self->parmval('type',$part);
+ if ($type eq 'exam') {
return 1;
}
if ($self->src() =~ /\.(exam)$/) {
@@ -3588,7 +3604,8 @@ sub is_page {
sub is_practice {
my $self=shift;
my ($part) = @_;
- if ($self->parmval('type',$part) eq 'practice') {
+ my $type = $self->parmval('type',$part);
+ if ($type eq 'practice') {
return 1;
}
return 0;
@@ -3601,6 +3618,15 @@ sub is_problem {
}
return 0;
}
+sub is_raw_problem {
+ my $self=shift;
+ my $src = $self->src();
+ if ($src =~ /\.(problem|exam|quiz|assess|survey|form|library|task)$/) {
+ return 1;
+ }
+ return 0;
+}
+
sub contains_problem {
my $self=shift;
if ($self->is_page()) {
@@ -3626,7 +3652,8 @@ sub is_sequence {
sub is_survey {
my $self = shift();
my $part = shift();
- if ($self->parmval('type',$part) eq 'survey') {
+ my $type = $self->parmval('type',$part);
+ if ($type eq 'survey') {
return 1;
}
if ($self->src() =~ /\.(survey)$/) {
@@ -3802,16 +3829,19 @@ Get the weight for the problem.
sub acc {
(my $self, my $part) = @_;
- return $self->parmval("acc", $part);
+ my $acc = $self->parmval("acc", $part);
+ return $acc;
}
sub answerdate {
(my $self, my $part) = @_;
# Handle intervals
- if ($self->parmval("answerdate.type", $part) eq 'date_interval') {
- return $self->duedate($part) +
- $self->parmval("answerdate", $part);
+ my $answerdatetype = $self->parmval("answerdate.type", $part);
+ my $answerdate = $self->parmval("answerdate", $part);
+ my $duedate = $self->parmval("duedate", $part);
+ if ($answerdatetype eq 'date_interval') {
+ $answerdate = $duedate + $answerdate;
}
- return $self->parmval("answerdate", $part);
+ return $answerdate;
}
sub awarded {
my $self = shift; my $part = shift;
@@ -3845,39 +3875,46 @@ sub handgrade {
my @response_ids = $self->responseIds($part);
if (@response_ids) {
foreach my $response_id (@response_ids) {
- if (lc($self->parmval("handgrade",$part.'_'.$response_id))
- eq 'yes') {
+ my $handgrade = $self->parmval("handgrade",$part.'_'.$response_id);
+ if (lc($handgrade) eq 'yes') {
return 'yes';
}
}
}
- return $self->parmval("handgrade", $part);
+ my $handgrade = $self->parmval("handgrade", $part);
+ return $handgrade;
}
sub maxtries {
(my $self, my $part) = @_;
- return $self->parmval("maxtries", $part);
+ my $maxtries = $self->parmval("maxtries", $part);
+ return $maxtries;
}
sub opendate {
(my $self, my $part) = @_;
- if ($self->parmval("opendate.type", $part) eq 'date_interval') {
- return $self->duedate($part) -
- $self->parmval("opendate", $part);
+ my $opendatetype = $self->parmval("opendate.type", $part);
+ my $opendate = $self->parmval("opendate", $part);
+ if ($opendatetype eq 'date_interval') {
+ my $duedate = $self->duedate($part);
+ $opendate = $duedate - $opendate;
}
- return $self->parmval("opendate");
+ return $opendate;
}
sub problemstatus {
(my $self, my $part) = @_;
- return lc $self->parmval("problemstatus", $part);
+ my $problemstatus = $self->parmval("problemstatus", $part);
+ return lc($problemstatus);
}
sub sig {
(my $self, my $part) = @_;
- return $self->parmval("sig", $part);
+ my $sig = $self->parmval("sig", $part);
+ return $sig;
}
sub tol {
(my $self, my $part) = @_;
- return $self->parmval("tol", $part);
+ my $tol = $self->parmval("tol", $part);
+ return $tol;
}
-sub tries {
+sub tries {
my $self = shift;
my $tries = $self->queryRestoreHash('tries', shift);
if (!defined($tries)) { return '0';}
@@ -3885,15 +3922,17 @@ sub tries {
}
sub type {
(my $self, my $part) = @_;
- return $self->parmval("type", $part);
+ my $type = $self->parmval("type", $part);
+ return $type;
}
sub weight {
my $self = shift; my $part = shift;
if (!defined($part)) { $part = '0'; }
- return &Apache::lonnet::EXT('resource.'.$part.'.weight',
- $self->symb(), $env{'user.domain'},
- $env{'user.name'},
- $env{'request.course.sec'});
+ my $weight = &Apache::lonnet::EXT('resource.'.$part.'.weight',
+ $self->symb(), $env{'user.domain'},
+ $env{'user.name'},
+ $env{'request.course.sec'});
+ return $weight;
}
sub part_display {
my $self= shift(); my $partID = shift();
@@ -4567,7 +4606,11 @@ sub status {
#if ($self->{RESOURCE_ERROR}) { return NETWORK_FAILURE; }
if ($completionStatus == NETWORK_FAILURE) { return NETWORK_FAILURE; }
- my $suppressFeedback = $self->problemstatus($part) eq 'no';
+ my $suppressFeedback = 0;
+ if (($self->problemstatus($part) eq 'no') ||
+ ($self->problemstatus($part) eq 'no_feedback_ever')) {
+ $suppressFeedback = 1;
+ }
# If there's an answer date and we're past it, don't
# suppress the feedback; student should know
if ($self->duedate($part) && $self->duedate($part) < time() &&