version 1.73, 2002/10/11 18:39:55
|
version 1.82, 2002/10/15 19:51:25
|
Line 823 sub new_handle {
|
Line 823 sub new_handle {
|
# Initialize the nav map |
# Initialize the nav map |
my $navmap = Apache::lonnavmaps::navmap->new( |
my $navmap = Apache::lonnavmaps::navmap->new( |
$ENV{"request.course.fn"}.".db", |
$ENV{"request.course.fn"}.".db", |
$ENV{"request.course.fn"}."_parms.db", 1); |
$ENV{"request.course.fn"}."_parms.db", 1, 1); |
|
|
|
|
if (!defined($navmap)) { |
if (!defined($navmap)) { |
Line 917 sub new_handle {
|
Line 917 sub new_handle {
|
my $currenturl = $ENV{'form.postdata'}; |
my $currenturl = $ENV{'form.postdata'}; |
$currenturl=~s/^http\:\/\///; |
$currenturl=~s/^http\:\/\///; |
$currenturl=~s/^[^\/]+//; |
$currenturl=~s/^[^\/]+//; |
my $queryAdd = "postdata=" . &Apache::lonnet::escape($currenturl); |
# alreadyHere allows us to only open the maps necessary to view |
|
# the current location once, while at the same time remembering |
|
# the current location. Without that check, the user would never |
|
# be able to close those maps; the user would close it, and the |
|
# currenturl scan would re-open it. |
|
my $queryAdd = "postdata=" . &Apache::lonnet::escape($currenturl) . |
|
"&alreadyHere=1"; |
|
|
$r->print('<a href="navmaps?condition=1&filter=">Show All Resources</a><br /><br />'); |
$r->print('<a href="navmaps?condition=1&filter=">Show All Resources</a><br /><br />'); |
|
|
Line 930 sub new_handle {
|
Line 936 sub new_handle {
|
$condition = 1; |
$condition = 1; |
} |
} |
|
|
my $mapIterator = $navmap->getIterator(undef, undef, \%filterHash, $condition); |
# This needs to be updated to use symbs from the remote, |
|
# instead of uris. The changes to this and the main rendering |
|
# loop should be obvious. |
|
# Here's a simple example of the iterator. |
|
# If there is a current resource |
|
if ($currenturl && !$ENV{'form.alreadyHere'}) { |
|
# Give me every resource... |
|
my $mapIterator = $navmap->getIterator(undef, undef, {}, 1); |
|
my $found != 0; |
|
my $depth = 1; |
|
$mapIterator->next(); # discard the first BEGIN_MAP |
|
my $curRes = $mapIterator->next(); |
|
|
|
while ($depth > 0 && !$found) { |
|
if (ref($curRes) && $curRes->src() eq $currenturl) { |
|
# If this is the correct resource, be sure to |
|
# show it by making sure the containing maps |
|
# are open. |
|
|
|
my $mapStack = $mapIterator->getStack(); |
|
for my $map (@{$mapStack}) { |
|
if ($condition) { |
|
undef $filterHash{$map->map_pc()}; |
|
} else { |
|
$filterHash{$map->map_pc()} = 1; |
|
} |
|
} |
|
$found = 1; |
|
} |
|
$curRes = $mapIterator->next(); |
|
} |
|
} |
|
|
undef $res; # so we don't accidentally use it later |
undef $res; # so we don't accidentally use it later |
my $indentLevel = 0; |
my $indentLevel = 0; |
my $indentString = "<img src=\"/adm/lonIcons/whitespace1.gif\" width=\"25\" height=\"1\" alt=\"\" border=\"0\" />"; |
my $indentString = "<img src=\"/adm/lonIcons/whitespace1.gif\" width=\"25\" height=\"1\" alt=\"\" border=\"0\" />"; |
Line 939 sub new_handle {
|
Line 977 sub new_handle {
|
my $now = time(); |
my $now = time(); |
my $in24Hours = $now + 24 * 60 * 60; |
my $in24Hours = $now + 24 * 60 * 60; |
my $depth = 1; |
my $depth = 1; |
|
my $displayedHereMarker = 0; |
|
|
# We know the first thing is a BEGIN_MAP (see "$self->{STARTED}" |
# We know the first thing is a BEGIN_MAP (see "$self->{STARTED}" |
# code in iterator->next), so ignore the first one |
# code in iterator->next), so ignore the first one |
|
my $mapIterator = $navmap->getIterator(undef, undef, \%filterHash, |
|
$condition); |
$mapIterator->next(); |
$mapIterator->next(); |
my $curRes = $mapIterator->next(); |
my $curRes = $mapIterator->next(); |
|
|
Line 1036 sub new_handle {
|
Line 1077 sub new_handle {
|
} else { |
} else { |
@parts[0] = "0"; # this is to get past foreach loop below |
@parts[0] = "0"; # this is to get past foreach loop below |
# you can consider a non-problem resource as a resource |
# you can consider a non-problem resource as a resource |
# with only one part without loss |
# with only one part without loss |
} |
} |
|
|
# Display one part, in event of network error. |
# Display one part, in event of network error. |
Line 1063 sub new_handle {
|
Line 1104 sub new_handle {
|
'symb='.&Apache::lonnet::escape($curRes->symb()). |
'symb='.&Apache::lonnet::escape($curRes->symb()). |
'"'; |
'"'; |
my $title = $curRes->title(); |
my $title = $curRes->title(); |
|
if (!$title) { |
|
$title = $curRes->src(); |
|
$title = substr ($title, rindex($title, "/") + 1); |
|
} |
my $partLabel = ""; |
my $partLabel = ""; |
my $newBranchText = ""; |
my $newBranchText = ""; |
|
|
Line 1090 sub new_handle {
|
Line 1135 sub new_handle {
|
# Display the correct icon, link to open or shut map |
# Display the correct icon, link to open or shut map |
if ($curRes->is_map()) { |
if ($curRes->is_map()) { |
my $mapId = $curRes->map_pc(); |
my $mapId = $curRes->map_pc(); |
my $nowOpen = !defined($filterHash{$mapId}); |
my $nowOpen = (!defined($filterHash{$mapId})); |
|
if ($condition) {$nowOpen = !$nowOpen;} |
$icon = $nowOpen ? |
$icon = $nowOpen ? |
"folder_closed.gif" : "folder_opened.gif"; |
"navmap.folder.closed.gif" : "navmap.folder.open.gif"; |
$icon = "<img src=\"/adm/lonIcons/$icon\" alt=\"\" border=\"0\" />"; |
$icon = "<img src=\"/adm/lonIcons/$icon\" alt=\"\" border=\"0\" />"; |
$linkopen = "<a href=\"/adm/navmaps?filter="; |
$linkopen = "<a href=\"/adm/navmaps?filter="; |
$linkopen .= ($nowOpen xor $condition) ? |
$linkopen .= ($nowOpen xor $condition) ? |
Line 1107 sub new_handle {
|
Line 1153 sub new_handle {
|
if ($curRes->is_problem()) { |
if ($curRes->is_problem()) { |
my $status = $curRes->status($part); |
my $status = $curRes->status($part); |
my $color = $colormap{$status}; |
my $color = $colormap{$status}; |
|
|
|
# Special case in the navmaps: If in less then |
|
# 24 hours, give it a bit of urgency |
|
if ($status == $curRes->OPEN() && $curRes->duedate() && |
|
$curRes->duedate() < time()+(24*60*60) && |
|
$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 "") { |
if ($color ne "") { |
$colorizer = "bgcolor=\"$color\""; |
$colorizer = "bgcolor=\"$color\""; |
} |
} |
Line 1117 sub new_handle {
|
Line 1179 sub new_handle {
|
} |
} |
|
|
# FIRST COL: The resource indentation, branch icon, and name |
# FIRST COL: The resource indentation, branch icon, and name |
$r->print(" <tr><td align=\"left\" valign=\"bottom\">\n"); |
$r->print(" <tr><td align=\"left\" valign=\"center\">\n"); |
|
|
# print indentation |
# print indentation |
for (my $i = 0; $i < $indentLevel - $deltalevel; $i++) { |
for (my $i = 0; $i < $indentLevel - $deltalevel; $i++) { |
Line 1126 sub new_handle {
|
Line 1188 sub new_handle {
|
|
|
$r->print(" ${newBranchText}${linkopen}$icon${linkclose}\n"); |
$r->print(" ${newBranchText}${linkopen}$icon${linkclose}\n"); |
|
|
|
my $curMarkerBegin = ""; |
|
my $curMarkerEnd = ""; |
|
|
|
# Is this the current resource? |
|
if ($curRes->src() eq $currenturl && !$displayedHereMarker) { |
|
$curMarkerBegin = '<a name="curloc" /><font color="red" size="+2">> </font>'; |
|
$curMarkerEnd = '<font color="red" size="+2"> <</font>'; |
|
$displayedHereMarker = 1; |
|
} |
|
|
if ($curRes->is_problem() && $part ne "0" && !$condensed) { |
if ($curRes->is_problem() && $part ne "0" && !$condensed) { |
$partLabel = " (Part $part)"; |
$partLabel = " (Part $part)"; |
$title = ""; |
$title = ""; |
} |
} |
if ($multipart && $condensed) { |
if ($multipart && $condensed && $curRes->countParts > 1) { |
$nonLinkedText .= ' (' . $curRes->countParts() . ' parts)'; |
$nonLinkedText .= ' (' . $curRes->countParts() . ' parts)'; |
} |
} |
|
|
$r->print(" <a href=\"$link\">$title$partLabel</a> $nonLinkedText"); |
$r->print(" $curMarkerBegin<a href=\"$link\">$title$partLabel</a> $curMarkerEnd $nonLinkedText"); |
|
|
if ($curRes->{RESOURCE_ERROR}) { |
if ($curRes->{RESOURCE_ERROR}) { |
$r->print(&Apache::loncommon::help_open_topic ("Navmap_Host_Down", |
$r->print(&Apache::loncommon::help_open_topic ("Navmap_Host_Down", |
Line 1162 sub new_handle {
|
Line 1234 sub new_handle {
|
} |
} |
} |
} |
|
|
$r->print("<td align=\"left\" valign=\"bottom\">$discussionHTML$feedbackHTML</td>"); |
$r->print("<td align=\"left\" valign=\"center\">$discussionHTML$feedbackHTML</td>"); |
|
|
# Is this the first displayed part of a multi-part problem |
# Is this the first displayed part of a multi-part problem |
# that has not been condensed, so we should suppress these two |
# that has not been condensed, so we should suppress these two |
Line 1175 sub new_handle {
|
Line 1247 sub new_handle {
|
my $icon = $statusIconMap{$curRes->status($part)}; |
my $icon = $statusIconMap{$curRes->status($part)}; |
my $alt = $iconAltTags{$icon}; |
my $alt = $iconAltTags{$icon}; |
if ($icon) { |
if ($icon) { |
$r->print("<td valign=\"bottom\" width=\"50\" align=\"right\">$linkopen<img src=\"/adm/lonIcons/$icon\" border=\"0\" alt=\"$alt\" />$linkclose</td>\n"); |
$r->print("<td valign=\"center\" width=\"50\" align=\"right\">$linkopen<img src=\"/adm/lonIcons/$icon\" border=\"0\" alt=\"$alt\" />$linkclose</td>\n"); |
} else { |
} else { |
$r->print("<td></td>\n"); |
$r->print("<td></td>\n"); |
} |
} |
Line 1184 sub new_handle {
|
Line 1256 sub new_handle {
|
} |
} |
|
|
# FOURTH COL: Text description |
# FOURTH COL: Text description |
$r->print("<td $colorizer align=\"right\" valign=\"bottom\">\n"); |
$r->print("<td $colorizer align=\"right\" valign=\"center\">\n"); |
|
|
if ($curRes->kind() eq "res" && |
if ($curRes->kind() eq "res" && |
$curRes->is_problem() && |
$curRes->is_problem() && |
Line 1273 sub getDescription {
|
Line 1345 sub getDescription {
|
return "Open " . timeToHumanString($res->opendate($part)); |
return "Open " . timeToHumanString($res->opendate($part)); |
} |
} |
if ($status == $res->OPEN) { |
if ($status == $res->OPEN) { |
if ($res->duedate()) { |
if ($res->duedate($part)) { |
return "Due " . timeToHumanString($res->duedate($part)); |
return "Due " . timeToHumanString($res->duedate($part)); |
} else { |
} else { |
return "Open, no due date"; |
return "Open, no due date"; |
Line 1295 sub getDescription {
|
Line 1367 sub getDescription {
|
return "Not yet graded."; |
return "Not yet graded."; |
} |
} |
if ($status == $res->TRIES_LEFT) { |
if ($status == $res->TRIES_LEFT) { |
my $tries = $res->tries(); |
my $tries = $res->tries($part); |
my $maxtries = $res->maxtries(); |
my $maxtries = $res->maxtries($part); |
my $triesString = "($tries of $maxtries tries used)"; |
my $triesString = ""; |
|
if ($tries && $maxtries) { |
|
$triesString = "<font size=\"-1\"><i>($tries of $maxtries tries used)</i></font>"; |
|
if ($maxtries > 1 && $maxtries - $tries == 1) { |
|
$triesString = "<b>$triesString</b>"; |
|
} |
|
} |
if ($res->duedate()) { |
if ($res->duedate()) { |
return "Due " . timeToHumanString($res->duedate($part)) . |
return "Due " . timeToHumanString($res->duedate($part)) . |
" $triesString"; |
" $triesString"; |
Line 2504 sub extractParts {
|
Line 2582 sub extractParts {
|
|
|
$self->{PARTS} = []; |
$self->{PARTS} = []; |
|
|
# Retrieve part count |
# Retrieve part count, if this is a problem |
my $metadata = &Apache::lonnet::metadata($self->src(), 'allpossiblekeys'); |
if ($self->is_problem()) { |
if (!$metadata) { |
my $metadata = &Apache::lonnet::metadata($self->src(), 'allpossiblekeys'); |
$self->{RESOURCE_ERROR} = 1; |
if (!$metadata) { |
$self->{PARTS} = []; |
$self->{RESOURCE_ERROR} = 1; |
return; |
$self->{PARTS} = []; |
} |
return; |
|
|
foreach (split(/\,/,$metadata)) { |
|
if ($_ =~ /^parameter\_(.*)\_opendate$/) { |
|
push @{$self->{PARTS}}, $1; |
|
} |
} |
|
|
|
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; |
return; |
} |
} |
|
|
Line 2771 sub status {
|
Line 2851 sub status {
|
# If it's WRONG... |
# If it's WRONG... |
if ($completionStatus == INCORRECT || $completionStatus == INCORRECT_BY_OVERRIDE) { |
if ($completionStatus == INCORRECT || $completionStatus == INCORRECT_BY_OVERRIDE) { |
# and there are TRIES LEFT: |
# and there are TRIES LEFT: |
if ($self->tries() < $self->maxtries()) { |
if ($self->tries($part) < $self->maxtries($part) || !$self->maxtries($part)) { |
return TRIES_LEFT; |
return TRIES_LEFT; |
} |
} |
return INCORRECT; # otherwise, return orange; student can't fix this |
return INCORRECT; # otherwise, return orange; student can't fix this |