--- loncom/interface/lonnavmaps.pm 2002/10/01 19:39:11 1.60 +++ loncom/interface/lonnavmaps.pm 2002/10/03 19:08:14 1.61 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Navigate Maps Handler # -# $Id: lonnavmaps.pm,v 1.60 2002/10/01 19:39:11 bowersj2 Exp $ +# $Id: lonnavmaps.pm,v 1.61 2002/10/03 19:08:14 bowersj2 Exp $ # # Copyright Michigan State University Board of Trustees # @@ -878,8 +878,7 @@ sub new_handle { my %condenseStatuses = ( $res->NETWORK_FAILURE => 1, $res->NOTHING_SET => 1, - $res->CORRECT => 1, - $res->OPEN => 1 ); + $res->CORRECT => 1 ); my %filterHash; # Figure out what we're not displaying @@ -897,7 +896,7 @@ sub new_handle { my $curRes = $mapIterator->next(); undef $res; # so we don't accidentally use it later my $indentLevel = -1; - my $indentString = ""; + my $indentString = "\"\""; my $isNewBranch = 0; my $now = time(); @@ -919,13 +918,13 @@ sub new_handle { if (ref($curRes) && $curRes->src()) { # Step one: Decide which parts to show - my @parts; + my @parts = @{$curRes->parts()}; + my $multipart = scalar(@parts) > 1; + my $condensed = 0; + if ($curRes->is_problem()) { # Is it multipart? - @parts = @{$curRes->parts()}; - my $multipart = scalar(@parts) > 1; - if ($multipart) { # If it's multipart, see if part 0 is "open" # if it is, display all parts, if it isn't, @@ -935,7 +934,7 @@ sub new_handle { } else { # Otherwise, only display part 0 if we want to # attach feedback or email information to it - if (!$curRes->hasDiscussion() && !$curRes->getFeedback()) { + if ($curRes->hasDiscussion() || $curRes->getFeedback()) { shift @parts; } else { # If there's discussion or feedback, that counts @@ -943,20 +942,36 @@ sub new_handle { # Now, we decide whether to condense the # parts due to similarity - my $status = $curRes->status($parts[0]); - my $allSame = 1; - for (my $i = 1; $i < scalar(@parts); $i++) { + my $status = $curRes->status($parts[1]); + my $due = $curRes->duedate($parts[1]); + my $open = $curRes->opendaute($parts[1]); + my $statusAllSame = 1; + my $dueAllSame = 1; + my $openAllSame = 1; + for (my $i = 2; $i < scalar(@parts); $i++) { if ($curRes->status($parts[$i]) != $status){ - $allSame = 0; + $statusAllSame = 0; + } + if ($curRes->duedate($parts[$i]) != $due ) { + $dueAllSame = 0; + } + if ($curRes->opendate($parts[$i]) != $open) { + $openAllSame = 0; } } # $allSame is true if all the statuses were # the same. Now, if they are all the same and - # match one of the statuses to condense, then - # only display part 0. - if ($allSame && defined($condenseStatuses{$status})){ - @parts = ("0"); + # match one of the statuses to condense, or they + # are all open with the same due date, or they are + # all OPEN_LATER with the same open date, display the + # status of the first non-zero part (to get the 'correct' + # status right, since 0 is never 'correct' or 'open'). + if (($statusAllSame && defined($condenseStatuses{$status})) || + ($dueAllSame && $status == $curRes->OPEN && $statusAllSame)|| + ($openAllSame && $status == $curRes->OPEN_LATER && $statusAllSame) ){ + @parts = ($parts[1]); + $condensed = 1; } } } @@ -999,9 +1014,13 @@ sub new_handle { my $linkopen = ""; my $linkclose = ""; - my $icon = "html.gif"; + my $icon = "\"\""; if ($curRes->is_problem()) { - $icon = "problem.gif"; + if ($part eq "0" || $condensed) { + $icon = ''; + } else { + $icon = $indentString; + } } # Display the correct icon, link to open or shut map @@ -1010,6 +1029,7 @@ sub new_handle { my $nowOpen = !defined($filterHash{$mapId}); $icon = $nowOpen ? "folder_opened.gif" : "folder_closed.gif"; + $icon = "\"\""; $linkopen = "print($indentString); } - $r->print(" ${newBranchText}${linkopen}\"\"${linkclose}\n"); + $r->print(" ${newBranchText}${linkopen}$icon${linkclose}\n"); - if ($curRes->is_problem() && $part != "0") { $partLabel = " (Part $part)"; } + if ($curRes->is_problem() && $part != "0" && !$condensed) { + $partLabel = " (Part $part)"; + $title = ""; + } $r->print(" $title$partLabel"); @@ -1066,9 +1088,15 @@ sub new_handle { $r->print("$discussionHTML$feedbackHTML"); + # Is this the first displayed part of a multi-part problem + # that has not been condensed, so we should suppress these two + # columns? + my $firstDisplayed = !$condensed && $multipart && $part eq "0"; + # THIRD ROW: Problem status icon - if ($curRes->is_problem()) { - my $icon = $statusIconMap{$curRes->status()}; + if ($curRes->is_problem() && + !$firstDisplayed) { + my $icon = $statusIconMap{$curRes->status($part)}; if ($icon) { $r->print("$linkopen$linkclose\n"); } else { @@ -1081,8 +1109,9 @@ sub new_handle { # FOURTH ROW: Text description $r->print("\n"); - if ($curRes->kind() eq "res" and - $curRes->is_problem() ) { + if ($curRes->kind() eq "res" && + $curRes->is_problem() && + !$firstDisplayed) { $r->print (getDescription($curRes, $part)); } @@ -2509,9 +2538,12 @@ sub getNext { my $next = $choice->goesto(); $next = $self->{NAV_MAP}->getById($next); - # Don't remember it if we've already seen it + # Don't remember it if we've already seen it or if + # the student doesn't have browse priviledges + my $browsePriv = &Apache::lonnet::allowed('bre', $self->src); if (!defined($alreadySeenHash) || - !defined($alreadySeenHash->{$next->{ID}})) { + !defined($alreadySeenHash->{$next->{ID}}) || + ($browsePriv ne '2' && $browsePriv ne 'F')) { push @branches, $next; } }