--- loncom/interface/lonnavmaps.pm 2002/10/14 16:43:58 1.77 +++ loncom/interface/lonnavmaps.pm 2002/10/15 20:05:35 1.83 @@ -2,7 +2,7 @@ # The LearningOnline Network with CAPA # Navigate Maps Handler # -# $Id: lonnavmaps.pm,v 1.77 2002/10/14 16:43:58 bowersj2 Exp $ +# $Id: lonnavmaps.pm,v 1.83 2002/10/15 20:05:35 bowersj2 Exp $ # # Copyright Michigan State University Board of Trustees # @@ -823,7 +823,7 @@ sub new_handle { # Initialize the nav map my $navmap = Apache::lonnavmaps::navmap->new( $ENV{"request.course.fn"}.".db", - $ENV{"request.course.fn"}."_parms.db", 1); + $ENV{"request.course.fn"}."_parms.db", 1, 1); if (!defined($navmap)) { @@ -977,6 +977,7 @@ sub new_handle { my $now = time(); my $in24Hours = $now + 24 * 60 * 60; my $depth = 1; + my $displayedHereMarker = 0; # We know the first thing is a BEGIN_MAP (see "$self->{STARTED}" # code in iterator->next), so ignore the first one @@ -1079,6 +1080,13 @@ sub new_handle { # with only one part without loss } + # Is it a multipart problem with a single part, now in + # @parts with "0" filtered out? If so, forget it's a multi-part + # problem and treat it like a single-part problem. + if ( scalar(@parts) == 1 ) { + $multipart = 0; + } + # Display one part, in event of network error. # If this is a single part, we can at least show the correct # status, but if it's multipart, we're lost. @@ -1103,6 +1111,10 @@ sub new_handle { 'symb='.&Apache::lonnet::escape($curRes->symb()). '"'; my $title = $curRes->title(); + if (!$title) { + $title = $curRes->src(); + $title = substr ($title, rindex($title, "/") + 1); + } my $partLabel = ""; my $newBranchText = ""; @@ -1130,7 +1142,8 @@ sub new_handle { # Display the correct icon, link to open or shut map if ($curRes->is_map()) { my $mapId = $curRes->map_pc(); - my $nowOpen = !defined($filterHash{$mapId}); + my $nowOpen = (!defined($filterHash{$mapId})); + if ($condition) {$nowOpen = !$nowOpen;} $icon = $nowOpen ? "navmap.folder.closed.gif" : "navmap.folder.open.gif"; $icon = "\"\""; @@ -1155,6 +1168,14 @@ sub new_handle { $curRes->duedate() > time()) { $color = $hurryUpColor; } + # Special case: If this is the last try, and there is + # more then one available, give a bit of urgency + my $tries = $curRes->tries($part); + my $maxtries = $curRes->maxtries($part); + if ($tries && $maxtries && $maxtries > 1 && + $maxtries - $tries == 1) { + $color = $hurryUpColor; + } if ($color ne "") { $colorizer = "bgcolor=\"$color\""; } @@ -1178,9 +1199,10 @@ sub new_handle { my $curMarkerEnd = ""; # Is this the current resource? - if ($curRes->src() eq $currenturl) { + if ($curRes->src() eq $currenturl && !$displayedHereMarker) { $curMarkerBegin = '> '; $curMarkerEnd = ' <'; + $displayedHereMarker = 1; } if ($curRes->is_problem() && $part ne "0" && !$condensed) { @@ -1330,7 +1352,7 @@ sub getDescription { return "Open " . timeToHumanString($res->opendate($part)); } if ($status == $res->OPEN) { - if ($res->duedate()) { + if ($res->duedate($part)) { return "Due " . timeToHumanString($res->duedate($part)); } else { return "Open, no due date"; @@ -1352,9 +1374,15 @@ sub getDescription { return "Not yet graded."; } if ($status == $res->TRIES_LEFT) { - my $tries = $res->tries(); - my $maxtries = $res->maxtries(); - my $triesString = "($tries of $maxtries tries used)"; + my $tries = $res->tries($part); + my $maxtries = $res->maxtries($part); + my $triesString = ""; + if ($tries && $maxtries) { + $triesString = "($tries of $maxtries tries used)"; + if ($maxtries > 1 && $maxtries - $tries == 1) { + $triesString = "$triesString"; + } + } if ($res->duedate()) { return "Due " . timeToHumanString($res->duedate($part)) . " $triesString"; @@ -2561,25 +2589,27 @@ sub extractParts { $self->{PARTS} = []; - # Retrieve part count - my $metadata = &Apache::lonnet::metadata($self->src(), 'allpossiblekeys'); - if (!$metadata) { - $self->{RESOURCE_ERROR} = 1; - $self->{PARTS} = []; - return; - } - - foreach (split(/\,/,$metadata)) { - if ($_ =~ /^parameter\_(.*)\_opendate$/) { - push @{$self->{PARTS}}, $1; + # Retrieve part count, if this is a problem + if ($self->is_problem()) { + my $metadata = &Apache::lonnet::metadata($self->src(), 'allpossiblekeys'); + if (!$metadata) { + $self->{RESOURCE_ERROR} = 1; + $self->{PARTS} = []; + return; + } + + foreach (split(/\,/,$metadata)) { + if ($_ =~ /^parameter\_(.*)\_opendate$/) { + push @{$self->{PARTS}}, $1; + } } + + + # Is this possible to do in one line? - Jeremy + my @sortedParts = sort @{$self->{PARTS}}; + $self->{PARTS} = \@sortedParts; } - - # Is this possible to do in one line? - Jeremy - my @sortedParts = sort @{$self->{PARTS}}; - $self->{PARTS} = \@sortedParts; - return; } @@ -2828,7 +2858,7 @@ sub status { # If it's WRONG... if ($completionStatus == INCORRECT || $completionStatus == INCORRECT_BY_OVERRIDE) { # and there are TRIES LEFT: - if ($self->tries() < $self->maxtries()) { + if ($self->tries($part) < $self->maxtries($part) || !$self->maxtries($part)) { return TRIES_LEFT; } return INCORRECT; # otherwise, return orange; student can't fix this