--- loncom/interface/lonnavmaps.pm 2005/08/02 21:15:51 1.336 +++ loncom/interface/lonnavmaps.pm 2005/10/09 19:49:30 1.344 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Navigate Maps Handler # -# $Id: lonnavmaps.pm,v 1.336 2005/08/02 21:15:51 albertel Exp $ +# $Id: lonnavmaps.pm,v 1.344 2005/10/09 19:49:30 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -514,20 +514,20 @@ sub getDescription { return &mt("Not currently assigned."); } if ($status == $res->OPEN_LATER) { - return "Open " . timeToHumanString($res->opendate($part)); + return "Open " . timeToHumanString($res->opendate($part),'start'); } if ($status == $res->OPEN) { if ($res->duedate($part)) { - return &mt("Due")." " .timeToHumanString($res->duedate($part)); + return &mt("Due")." " .timeToHumanString($res->duedate($part),'end'); } else { return &mt("Open, no due date"); } } if ($status == $res->PAST_DUE_ANSWER_LATER) { - return &mt("Answer open")." " . timeToHumanString($res->answerdate($part)); + return &mt("Answer open")." " . timeToHumanString($res->answerdate($part),'start'); } if ($status == $res->PAST_DUE_NO_ANSWER) { - return &mt("Was due")." " . timeToHumanString($res->duedate($part)); + return &mt("Was due")." " . timeToHumanString($res->duedate($part),'end'); } if ($status == $res->ANSWER_OPEN || $status == $res->PARTIALLY_CORRECT) { return &mt("Answer available"); @@ -549,7 +549,7 @@ sub getDescription { } } if ($res->duedate($part)) { - return &mt("Due")." " . timeToHumanString($res->duedate($part)) . + return &mt("Due")." " . timeToHumanString($res->duedate($part),'end') . " $triesString"; } else { return &mt("No due date")." $triesString"; @@ -603,7 +603,7 @@ sub advancedUser { # Very, very, very, VERY English-only... goodness help a localizer on # this func... sub timeToHumanString { - my ($time) = @_; + my ($time,$type) = @_; # zero, '0' and blank are bad times if (!$time) { return &mt('never'); @@ -684,17 +684,23 @@ sub timeToHumanString { $timeStr; } + my $conjunction='on'; + if ($type eq 'start') { + $conjunction='at'; + } elsif ($type eq 'end') { + $conjunction='by'; + } # Is it this year? 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)); + my $timeStr = strftime("$conjunction %A, %b %e at %I:%M %P", localtime($time)); $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 %Y at %I:%M %P", localtime($time)); + my $timeStr = strftime("$conjunction %A, %b %e %Y at %I:%M %P", localtime($time)); $timeStr =~ s/12:00 am/00:00/; $timeStr =~ s/12:00 pm/noon/; return $timeStr; @@ -1127,6 +1133,9 @@ sub render_resource { if ($resource->randomout()) { $nonLinkedText .= ' (hidden) '; } + if (!$resource->condval()) { + $nonLinkedText .= ' (conditionally hidden) '; + } # We're done preparing and finally ready to start the rendering my $result = ""; @@ -1401,7 +1410,6 @@ sub render { # no columns, no nav maps. return ''; } - my $mustCloseNavMap = 0; my $navmap; if (defined($args->{'navmap'})) { $navmap = $args->{'navmap'}; @@ -1450,8 +1458,12 @@ sub render { # Step 1: Check to see if we have a navmap if (!defined($navmap)) { $navmap = Apache::lonnavmaps::navmap->new(); - $mustCloseNavMap = 1; - } + if (!defined($navmap)) { + # no londer in course + return 'No course selected
+ Select a course
'; + } + } # Step two: Locate what kind of here marker is necessary # Determine where the "here" marker is and where the screen jumps to. @@ -1515,7 +1527,6 @@ sub render { # Step 1: Check to see if we have a navmap if (!defined($navmap)) { $navmap = Apache::lonnavmaps::navmap->new(); - $mustCloseNavMap = 1; } # See if we're being passed a specific map @@ -1836,10 +1847,6 @@ END $args->{'multipart'} = $curRes->multipart(); if ($condenseParts) { # do the condensation - if (!$curRes->opendate("0")) { - @parts = (); - $args->{'condensed'} = 1; - } if (!$args->{'condensed'}) { # Decide whether to condense based on similarity my $status = $curRes->status($parts[0]); @@ -3573,7 +3580,19 @@ sub condition { my $condition=&Apache::lonnet::directcondval($condid); return $condition; } - +sub condval { + my $self=shift; + my $uri=&Apache::lonnet::deversion(&Apache::lonnet::declutter($self->src())); + my ($pathname,$filename)=($uri=~m|(.*)/([^/]*)|); + $pathname=~s/^adm\/wrapper\///; + + my $match=($env{'acc.res.'.$env{'request.course.id'}.'.'.$pathname}=~ + /\&\Q$filename\E\:([\d\|]+)\&/); + if ($match) { + return &Apache::lonnet::condval($1); + } + return 0; +} sub compTitle { my $self = shift; my $title = $self->title(); @@ -3639,7 +3658,7 @@ sub is_page { sub is_problem { my $self=shift; my $src = $self->src(); - return ($src =~ /\.(problem|exam|quiz|assess|survey|form|library)$/) + return ($src =~ /\.(problem|exam|quiz|assess|survey|form|library|task)$/) } sub contains_problem { my $self=shift; @@ -4143,7 +4162,7 @@ sub extractParts { return; } foreach (split(/\,/,$metadata)) { - if ($_ =~ /^part_(.*)$/) { + if ($_ =~ /^(?:part|Task)_(.*)$/) { my $part = $1; # This floods the logs if it blows up if (defined($parts{$part})) { @@ -4559,6 +4578,13 @@ sub status { return CORRECT; } + # If it's WRONG... and not open + if ( ($completionStatus == INCORRECT || + $completionStatus == INCORRECT_BY_OVERRIDE) + && (!$self->opendate($part) || $self->opendate($part) > time()) ) { + return INCORRECT; + } + if ($completionStatus == ATTEMPTED) { return ATTEMPTED; } @@ -4764,7 +4790,7 @@ sub getNext { my $to = $self->to(); foreach my $branch ( split(/,/, $to) ) { my $choice = $self->{NAV_MAP}->getById($branch); - if (!$choice->condition()) { next; } + #if (!$choice->condition()) { next; } my $next = $choice->goesto(); $next = $self->{NAV_MAP}->getById($next);