--- loncom/interface/lonnavmaps.pm 2003/01/31 22:46:50 1.133 +++ loncom/interface/lonnavmaps.pm 2003/02/04 16:37:51 1.136 @@ -2,7 +2,7 @@ # The LearningOnline Network with CAPA # Navigate Maps Handler # -# $Id: lonnavmaps.pm,v 1.133 2003/01/31 22:46:50 bowersj2 Exp $ +# $Id: lonnavmaps.pm,v 1.136 2003/02/04 16:37:51 bowersj2 Exp $ # # Copyright Michigan State University Board of Trustees # @@ -56,6 +56,43 @@ sub NOTHING { return 3; } # Some data +# Keep these mappings in sync with lonquickgrades, which uses the colors +# instead of the icons. +my %statusIconMap = + ( Apache::lonnavmaps::resource->NETWORK_FAILURE => '', + Apache::lonnavmaps::resource->NOTHING_SET => '', + Apache::lonnavmaps::resource->CORRECT => 'navmap.correct.gif', + Apache::lonnavmaps::resource->EXCUSED => 'navmap.correct.gif', + Apache::lonnavmaps::resource->PAST_DUE_NO_ANSWER => 'navmap.wrong.gif', + Apache::lonnavmaps::resource->PAST_DUE_ANSWER_LATER => 'navmap.wrong.gif', + Apache::lonnavmaps::resource->ANSWER_OPEN => 'navmap.wrong.gif', + Apache::lonnavmaps::resource->OPEN_LATER => '', + Apache::lonnavmaps::resource->TRIES_LEFT => 'navmap.open.gif', + Apache::lonnavmaps::resource->INCORRECT => 'navmap.wrong.gif', + Apache::lonnavmaps::resource->OPEN => 'navmap.open.gif', + Apache::lonnavmaps::resource->ATTEMPTED => 'navmap.open.gif' ); + +my %iconAltTags = + ( 'navmap.correct.gif' => 'Correct', + 'navmap.wrong.gif' => 'Incorrect', + 'navmap.open.gif' => 'Open' ); + +# Defines a status->color mapping, null string means don't color +my %colormap = + ( Apache::lonnavmaps::resource->NETWORK_FAILURE => '', + Apache::lonnavmaps::resource->CORRECT => '', + Apache::lonnavmaps::resource->EXCUSED => '#3333FF', + Apache::lonnavmaps::resource->PAST_DUE_ANSWER_LATER => '', + Apache::lonnavmaps::resource->PAST_DUE_NO_ANSWER => '', + Apache::lonnavmaps::resource->ANSWER_OPEN => '#006600', + Apache::lonnavmaps::resource->OPEN_LATER => '', + Apache::lonnavmaps::resource->TRIES_LEFT => '', + Apache::lonnavmaps::resource->INCORRECT => '', + Apache::lonnavmaps::resource->OPEN => '', + Apache::lonnavmaps::resource->NOTHING_SET => '' ); +# And a special case in the nav map; what to do when the assignment +# is not yet done and due in less then 24 hours +my $hurryUpColor = "#FF0000"; sub cleanup { if (tied(%navmaphash)){ @@ -222,44 +259,6 @@ sub real_handler { # These are some data tables, which make it easy to change some of # of the specific visualization parameters if desired. - # Defines a status->color mapping, null string means don't color - my %colormap = - ( $res->NETWORK_FAILURE => '', - $res->CORRECT => '', - $res->EXCUSED => '#3333FF', - $res->PAST_DUE_ANSWER_LATER => '', - $res->PAST_DUE_NO_ANSWER => '', - $res->ANSWER_OPEN => '#006600', - $res->OPEN_LATER => '', - $res->TRIES_LEFT => '', - $res->INCORRECT => '', - $res->OPEN => '', - $res->NOTHING_SET => '' ); - # And a special case in the nav map; what to do when the assignment - # is not yet done and due in less then 24 hours - my $hurryUpColor = "#FF0000"; - - # Keep these mappings in sync with lonquickgrades, which uses the colors - # instead of the icons. - my %statusIconMap = - ( $res->NETWORK_FAILURE => '', - $res->NOTHING_SET => '', - $res->CORRECT => 'navmap.correct.gif', - $res->EXCUSED => 'navmap.correct.gif', - $res->PAST_DUE_NO_ANSWER => 'navmap.wrong.gif', - $res->PAST_DUE_ANSWER_LATER => 'navmap.wrong.gif', - $res->ANSWER_OPEN => 'navmap.wrong.gif', - $res->OPEN_LATER => '', - $res->TRIES_LEFT => 'navmap.open.gif', - $res->INCORRECT => 'navmap.wrong.gif', - $res->OPEN => 'navmap.open.gif', - $res->ATTEMPTED => 'navmap.open.gif' ); - - my %iconAltTags = - ( 'navmap.correct.gif' => 'Correct', - 'navmap.wrong.gif' => 'Incorrect', - 'navmap.open.gif' => 'Open' ); - my %condenseStatuses = ( $res->NETWORK_FAILURE => 1, $res->NOTHING_SET => 1, @@ -555,7 +554,6 @@ sub real_handler { } - my $colorizer = ""; my $color; if ($curRes->is_problem()) { $color = $colormap{$curRes->status}; @@ -564,10 +562,6 @@ sub real_handler { lastTry($curRes, $part)) { $color = $hurryUpColor; } - - if ($color ne "") { - $colorizer = "bgcolor=\"$color\""; - } } if ($curRes->randomout()) { @@ -717,6 +711,7 @@ sub real_handler { $navmap->untieHashes(); $r->print(""); + $r->rflush(); return OK; } @@ -1060,39 +1055,15 @@ sub long_status { return 3; } # Data for render_resource -my $resObj = 'Apache::lonnavmaps::resource'; -# Defines a status->color mapping, null string means don't color -my %colormap = - ( $resObj->NETWORK_FAILURE => '', - $resObj->CORRECT => '', - $resObj->EXCUSED => '#3333FF', - $resObj->PAST_DUE_ANSWER_LATER => '', - $resObj->PAST_DUE_NO_ANSWER => '', - $resObj->ANSWER_OPEN => '#006600', - $resObj->OPEN_LATER => '', - $resObj->TRIES_LEFT => '', - $resObj->INCORRECT => '', - $resObj->OPEN => '', - $resObj->NOTHING_SET => '' ); -# And a special case in the nav map; what to do when the assignment -# is not yet done and due in less then 24 hours -my $hurryUpColor = "#FF0000"; - sub render_resource { my ($resource, $part, $params) = @_; my $nonLinkedText = ''; # stuff after resource title not in link - my $it = $params->{'iterator'}; + my $link = $params->{"resourceLink"}; + my $src = $resource->src(); + my $it = $params->{"iterator"}; my $filter = $it->{FILTER}; - my $stack = $it->getStack(); - my $src = getLinkForResource($stack); - - my $srcHasQuestion = $src =~ /\?/; - my $link = $src. - ($srcHasQuestion?'&':'?') . - 'symb=' . &Apache::lonnet::escape($resource->symb()). - '"'; my $title = $resource->compTitle(); if ($src =~ /^\/uploaded\//) { @@ -1184,22 +1155,107 @@ sub render_resource { $nonLinkedText .= ' (' . $resource->countParts() . ' parts)'; } - $result .= " $curMarkerBegin$title$partLabel$curMarkerEnd $nonLinkedText"; + $result .= " $curMarkerBegin$title$partLabel$curMarkerEnd $nonLinkedText"; return $result; } sub render_communication_status { my ($resource, $part, $params) = @_; - return "comm_status"; + my $discussionHTML = ""; my $feedbackHTML = ""; my $errorHTML = ""; + + my $link = $params->{"resourceLink"}; + my $linkopen = ""; + my $linkclose = ""; + + if ($resource->hasDiscussion()) { + $discussionHTML = $linkopen . + '' . + $linkclose; + } + + if ($resource->getFeedback()) { + my $feedback = $resource->getFeedback(); + foreach (split(/\,/, $feedback)) { + if ($_) { + $feedbackHTML .= ' ' + . ''; + } + } + } + + if ($resource->getErrors()) { + my $errors = $resource->getErrors(); + foreach (split(/,/, $errors)) { + if ($_) { + $errorHTML .= ' ' + . ''; + } + } + } + + return "$discussionHTML$feedbackHTML$errorHTML "; + } sub render_quick_status { my ($resource, $part, $params) = @_; - return "quick_status"; + my $result = ""; + my $firstDisplayed = !$params->{'condensed'} && + $params->{'multipart'} && $part eq "0"; + + my $link = $params->{"resourceLink"}; + my $linkopen = ""; + my $linkclose = ""; + + if ($resource->is_problem() && + !$firstDisplayed) { + my $icon = $statusIconMap{$resource->status($part)}; + my $alt = $iconAltTags{$icon}; + if ($icon) { + $result .= "$linkopen$alt$linkclose\n"; + } else { + $result .= " \n"; + } + } else { # not problem, no icon + $result .= " \n"; + } + + return $result; } sub render_long_status { my ($resource, $part, $params) = @_; - return "long_status"; + my $result = "\n"; + my $firstDisplayed = !$params->{'condensed'} && + $params->{'multipart'} && $part eq "0"; + + my $color; + if ($resource->is_problem()) { + $color = $colormap{$resource->status}; + + if (dueInLessThen24Hours($resource, $part) || + lastTry($resource, $part)) { + $color = $hurryUpColor; + } + } + + if ($resource->kind() eq "res" && + $resource->is_problem() && + !$firstDisplayed) { + if ($color) {$result .= ""; } + $result .= getDescription($resource, $part); + if ($color) {$result .= ""; } + } + if ($resource->is_map() && advancedUser() && $resource->randompick()) { + $result .= '(randomly select ' . $resource->randompick() .')'; + } + + $result .= " \n"; + + return $result; } my @preparedColumns = (\&render_resource, \&render_communication_status, @@ -1380,10 +1436,20 @@ sub render { my $backgroundColor = $backgroundColors[$rownum % scalar(@backgroundColors)]; $result .= " \n"; + + # Set up some data about the parts that the cols might want + my $filter = $it->{FILTER}; + my $stack = $it->getStack(); + my $src = getLinkForResource($stack); + + my $srcHasQuestion = $src =~ /\?/; + $args->{"resourceLink"} = $src. + ($srcHasQuestion?'&':'?') . + 'symb=' . &Apache::lonnet::escape($curRes->symb()). + '"'; # Now, display each column. foreach my $col (@$cols) { - $result .= " "; # If this is the first column and it's time to print # the anchor, do so @@ -1401,7 +1467,6 @@ sub render { $result .= &{$preparedColumns[$col]}($curRes, $part, $args); } - $result .= "\n"; } $result .= " \n"; @@ -1411,6 +1476,11 @@ sub render { $curRes = $it->next(); } + # Print out the part that jumps to #curloc if it exists + if ($args->{"displayedJumpMarker"}) { + $result .= "\n"; + } + $result .= ""; return $result;