[LON-CAPA-cvs] cvs: loncom /interface lonnavmaps.pm
bowersj2
lon-capa-cvs@mail.lon-capa.org
Thu, 03 Oct 2002 19:08:14 -0000
bowersj2 Thu Oct 3 15:08:14 2002 EDT
Modified files:
/loncom/interface lonnavmaps.pm
Log:
Condensing logic added:
* If a multipart problem is all correct, all OPEN_LATER with the same
open date, or all OPEN with the same due date, only show one line
for the multi-part problem on the nav map. Otherwise, show all
parts independently, with the title listed first, and the parts
listed seperately underneath, slightly indented, without the
title repeating for each part.
Check to see if student has browse priviledges for the resource. If not,
don't display it.
Index: loncom/interface/lonnavmaps.pm
diff -u loncom/interface/lonnavmaps.pm:1.60 loncom/interface/lonnavmaps.pm:1.61
--- loncom/interface/lonnavmaps.pm:1.60 Tue Oct 1 15:39:11 2002
+++ loncom/interface/lonnavmaps.pm Thu Oct 3 15:08:14 2002
@@ -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 @@
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 @@
my $curRes = $mapIterator->next();
undef $res; # so we don't accidentally use it later
my $indentLevel = -1;
- my $indentString = "<img src=\"/adm/lonIcons/whitespace1.gif\" width=\"25\" height=\"1\"/>";
+ my $indentString = "<img src=\"/adm/lonIcons/whitespace1.gif\" width=\"25\" height=\"1\" alt=\"\" border=\"0\" />";
my $isNewBranch = 0;
my $now = time();
@@ -919,13 +918,13 @@
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 @@
} 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 @@
# 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 @@
my $linkopen = "<a href=\"$link\">";
my $linkclose = "</a>";
- my $icon = "html.gif";
+ my $icon = "<img src=\"/adm/lonIcons/html.gif\" alt=\"\" border=\"0\" />";
if ($curRes->is_problem()) {
- $icon = "problem.gif";
+ if ($part eq "0" || $condensed) {
+ $icon = '<img src="/adm/lonIcons/problem.gif" alt="" border=\"0\" />';
+ } else {
+ $icon = $indentString;
+ }
}
# Display the correct icon, link to open or shut map
@@ -1010,6 +1029,7 @@
my $nowOpen = !defined($filterHash{$mapId});
$icon = $nowOpen ?
"folder_opened.gif" : "folder_closed.gif";
+ $icon = "<img src=\"/adm/lonIcons/$icon\" alt=\"\" border=\"0\" />";
$linkopen = "<a href=\"/adm/navmaps?filter=";
$linkopen .= $nowOpen ?
addToFilter(\%filterHash, $mapId) :
@@ -1036,10 +1056,12 @@
$r->print($indentString);
}
- $r->print(" ${newBranchText}${linkopen}<img border=\"0\" src=\"" .
- "/adm/lonIcons/$icon\" alt=\"\">${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(" <a href=\"$link\">$title$partLabel</a></td>");
@@ -1066,9 +1088,15 @@
$r->print("<td align=\"left\">$discussionHTML$feedbackHTML</td>");
+ # 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("<td width=\"50\" align=\"right\">$linkopen<img src=\"/adm/lonIcons/$icon\" border=\"0\" />$linkclose</td>\n");
} else {
@@ -1081,8 +1109,9 @@
# FOURTH ROW: Text description
$r->print("<td $colorizer align=\"right\">\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 @@
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;
}
}