--- loncom/interface/lonnavmaps.pm 2008/11/18 20:18:37 1.416 +++ loncom/interface/lonnavmaps.pm 2009/02/24 20:10:30 1.426 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Navigate Maps Handler # -# $Id: lonnavmaps.pm,v 1.416 2008/11/18 20:18:37 jms Exp $ +# $Id: lonnavmaps.pm,v 1.426 2009/02/24 20:10:30 droeschl Exp $ # # Copyright Michigan State University Board of Trustees # @@ -425,31 +425,45 @@ manner: Very, very, very, VERY English-only... goodness help a localizer on this func... -=item +=item resource() -=item +returns 0 -=item +=item communication_status() -=item +returns 1 -=item +=item quick_status() -=item +returns 2 -=item +=item long_status() -=item +returns 3 -=item +=item part_status_summary() -=item +returns 4 -=item +=item render_resource() -=item +=item render_communication_status() -=item +=item render_quick_status() + +=item render_long_status() + +=item render_parts_summary_status() + +=item setDefault() + +=item cmp_title() + +=item render() + +=item add_linkitem() + +=item show_linkitems() =back @@ -544,9 +558,7 @@ this.document.navform.submit(); ENDUPDATE } -# Convenience functions: Returns a string that adds or subtracts -# the second argument from the first hash, appropriate for the -# query string that determines which folders to recurse on + sub addToFilter { my $hashIn = shift; my $addition = shift; @@ -565,8 +577,6 @@ sub removeFromFilter { return join(",", keys(%hash)); } -# Convenience function: Given a stack returned from getStack on the iterator, -# return the correct src() value. sub getLinkForResource { my $stack = shift; my $res; @@ -604,11 +614,7 @@ sub getLinkForResource { return; } -# Convenience function: This separates the logic of how to create -# the problem text strings ("Due: DATE", "Open: DATE", "Not yet assigned", -# etc.) into a separate function. It takes a resource object as the -# first parameter, and the part number of the resource as the second. -# It's basically a big switch statement on the status of the resource. + sub getDescription { my $res = shift; @@ -664,7 +670,7 @@ sub getDescription { my $maxtries = $res->maxtries($part); my $triesString = ""; if ($tries && $maxtries) { - $triesString = '('.&mt('[_1] of [_2] tries used',$tries,$maxtries).')'; + $triesString = '('.&mt('[_1] of [quant,_2,try,tries] used',$tries,$maxtries).')'; if ($maxtries > 1 && $maxtries - $tries == 1) { $triesString = "$triesString"; } @@ -681,8 +687,6 @@ sub getDescription { } } -# Convenience function, so others can use it: Is the problem due in less than -# 24 hours, and still can be done? sub dueInLessThan24Hours { my $res = shift; @@ -695,8 +699,7 @@ sub dueInLessThan24Hours { $res->duedate($part) > time(); } -# Convenience function, so others can use it: Is there only one try remaining for the -# part, with more than one try to begin with, not due yet and still can be done? + sub lastTry { my $res = shift; my $part = shift; @@ -708,23 +711,11 @@ sub lastTry { $res->duedate($part) > time(); } -# This puts a human-readable name on the env variable. sub advancedUser { return $env{'request.role.adv'}; } - -# timeToHumanString takes a time number and converts it to a -# human-readable representation, meant to be used in the following -# manner: -# print "Due $timestring" -# print "Open $timestring" -# print "Answer available $timestring" -# Very, very, very, VERY English-only... goodness help a localizer on -# this func... - - sub timeToHumanString { my ($time,$type,$format) = @_; @@ -874,34 +865,32 @@ sub render_resource { my $location=&Apache::loncommon::lonhttpdurl("/adm/lonIcons"); # If this is a new branch, label it so if ($params->{'isNewBranch'}) { - $newBranchText = "Branch"; + $newBranchText = "Branch"; } # links to open and close the folder - - my $linkopen = ""; - - + my $whitespaceLocation = &Apache::loncommon::lonhttpdurl("/adm/lonIcons/whitespace_21_21.gif"); + my $linkopen = "".""; my $linkclose = ""; # Default icon: unknown page - my $icon = ""; + my $icon = ""; if ($resource->is_problem()) { if ($part eq '0' || $params->{'condensed'}) { - $icon = ''.&mt('Task');
 	    } else {
 		$icon .= 'problem.gif'; + $icon .='" />'; } else { $icon = $params->{'indentString'}; } } else { - $icon = "  "; + $icon = ""; } # Display the correct map icon to open or shut map @@ -911,15 +900,15 @@ sub render_resource { if ($it->{CONDITION}) { $nowOpen = !$nowOpen; } - + my $folderType = $resource->is_sequence() ? 'folder' : 'page'; my $title=$resource->title; - $title=~s/\"/\"/g; + $title=~s/\"/\&qout;/g; if (!$params->{'resource_no_folder_link'}) { $icon = "navmap.$folderType." . ($nowOpen ? 'closed' : 'open') . '.gif'; - $icon = "\""."; - + $icon = "" + ."\"""; $linkopen = "{'url'} . '?' . $params->{'queryString'} . '&filter='; $linkopen .= ($nowOpen xor $it->{CONDITION}) ? @@ -934,10 +923,8 @@ sub render_resource { } else { # Don't allow users to manipulate folder - $icon = "navmap.$folderType." . ($nowOpen ? 'closed' : 'open') . - '.nomanip.gif'; - $icon = "\""."; + $icon = "navmap.$folderType." . ($nowOpen ? 'closed' : 'open') . '.gif'; + $icon = ""."\"".($nowOpen"; $linkopen = ""; $linkclose = ""; @@ -953,10 +940,11 @@ sub render_resource { if (($resource->is_practice()) && ($resource->is_raw_problem())) { $nonLinkedText .=' '.&mt('not graded').''; } - - # We're done preparing and finally ready to start the rendering - my $result = ""; + # We're done preparing and finally ready to start the rendering + my $result = ''; + my $newfolderType = $resource->is_sequence() ? 'folder' : 'page'; + my $indentLevel = $params->{'indentLevel'}; if ($newBranchText) { $indentLevel--; } @@ -966,7 +954,6 @@ sub render_resource { } # Decide what to display - $result .= "$newBranchText$linkopen$icon$linkclose"; my $curMarkerBegin = ''; @@ -975,9 +962,9 @@ sub render_resource { # Is this the current resource? if (!$params->{'displayedHereMarker'} && $resource->symb() eq $params->{'here'} ) { - $curMarkerBegin = '>'; - $curMarkerEnd = '<'; - $params->{'displayedHereMarker'} = 1; + $curMarkerBegin = ''; + $curMarkerEnd = ''; + $params->{'displayedHereMarker'} = 1; } if ($resource->is_problem() && $part ne '0' && @@ -997,9 +984,9 @@ sub render_resource { $target=' target="loncapaclient" '; } if (!$params->{'resource_nolink'} && !$resource->is_sequence() && !$resource->is_empty_sequence) { - $result .= " $curMarkerBegin$title$partLabel$curMarkerEnd $nonLinkedText"; + $result .= "$curMarkerBegin$title$partLabel$curMarkerEnd$nonLinkedText"; } else { - $result .= " $curMarkerBegin$title$partLabel$curMarkerEnd $nonLinkedText"; + $result .= "$curMarkerBegin$linkopen$title$partLabel$curMarkerEnd$nonLinkedText"; } return $result; @@ -1019,7 +1006,7 @@ sub render_communication_status { my $location=&Apache::loncommon::lonhttpdurl("/adm/lonMisc"); if ($resource->hasDiscussion()) { $discussionHTML = $linkopen . - ''.&mt('New Discussion').'' . + ''.&mt('New Discussion').'' . $linkclose; } @@ -1029,8 +1016,7 @@ sub render_communication_status { if ($msgid) { $feedbackHTML .= ' ' - . ''.&mt('New Email').''; + . ''.&mt('New E-mail').''; } } } @@ -1044,8 +1030,7 @@ sub render_communication_status { $errorcount++; $errorHTML .= ' ' - . ''.&mt('New Error').''; + . ''.&mt('New Error').''; } } } @@ -1053,8 +1038,7 @@ sub render_communication_status { if ($params->{'multipart'} && $part != '0') { $discussionHTML = $feedbackHTML = $errorHTML = ''; } - - return "$discussionHTML$feedbackHTML$errorHTML "; + return "$discussionHTML$feedbackHTML$errorHTML "; } sub render_quick_status { @@ -1070,28 +1054,28 @@ sub render_quick_status { } my $linkopen = ""; my $linkclose = ""; - + + $result .= ''; if ($resource->is_problem() && !$firstDisplayed) { - my $icon = $statusIconMap{$resource->simpleStatus($part)}; my $alt = $iconAltTags{$icon}; if ($icon) { my $location= &Apache::loncommon::lonhttpdurl("/adm/lonIcons/$icon"); - $result .= "$linkopen$alt$linkclose\n"; + $result .= "$linkopen$alt$linkclose"; } else { - $result .= " \n"; + $result .= " "; } } else { # not problem, no icon - $result .= " \n"; + $result .= " "; } - + $result .= "\n"; return $result; } sub render_long_status { my ($resource, $part, $params) = @_; - my $result = "\n"; + my $result = ''; my $firstDisplayed = !$params->{'condensed'} && $params->{'multipart'} && $part eq "0"; @@ -1278,7 +1262,7 @@ sub render { if (!defined($navmap)) { $navmap = Apache::lonnavmaps::navmap->new(); if (!defined($navmap)) { - # no londer in course + # no longer in course return ''.&mt('No course selected').'
'.&mt('Select a course').'
'; } @@ -1346,6 +1330,11 @@ sub render { # Step 1: Check to see if we have a navmap if (!defined($navmap)) { $navmap = Apache::lonnavmaps::navmap->new(); + if (!defined($navmap)) { + # no longer in course + return ''.&mt('No course selected').'
+ '.&mt('Select a course').'
'; + } } # See if we're being passed a specific map @@ -1390,7 +1379,7 @@ sub render { my $printKey = $args->{'printKey'}; my $printCloseAll = $args->{'printCloseAll'}; if (!defined($printCloseAll)) { $printCloseAll = 1; } - + # Print key? if ($printKey) { $result .= ''; @@ -1465,6 +1454,7 @@ END $result.=''; } + if ($args->{'caller'} eq 'navmapsdisplay') { $result .= '
'; @@ -1488,31 +1478,35 @@ END $result.=$args->{'sort_html'}; } - $result .= "
\n"; + #$result .= "
\n"; if ($r) { $r->print($result); $r->rflush(); $result = ""; } # End parameter setting - + + $result .= "\n
'. &Apache::loncommon::help_open_menu('Navigation Screen','Navigation_Screen',undef,'RAT').'
\n\n\n\n\n\n
 
\n"; + $result .= "
\n"; + # Data - $result .= '' ."\n"; + $result .= '
' ."\n"; + my $res = "Apache::lonnavmaps::resource"; my %condenseStatuses = ( $res->NETWORK_FAILURE => 1, $res->NOTHING_SET => 1, $res->CORRECT => 1 ); - my @backgroundColors = ("#FFFFFF", "#F6F6F6"); + my @backgroundColors = ("LC_trEven", "LC_trOdd"); # Shared variables $args->{'counter'} = 0; # counts the rows $args->{'indentLevel'} = 0; $args->{'isNewBranch'} = 0; - $args->{'condensed'} = 0; - my $location= - &Apache::loncommon::lonhttpdurl("/adm/lonIcons/whitespace1.gif"); - $args->{'indentString'} = setDefault($args->{'indentString'}, "  "); + $args->{'condensed'} = 0; + + my $location = &Apache::loncommon::lonhttpdurl("/adm/lonIcons/whitespace_21_21.gif"); + $args->{'indentString'} = setDefault($args->{'indentString'}, ""); $args->{'displayedHereMarker'} = 0; # If we're suppressing empty sequences, look for them here. Use DFS for speed, @@ -1740,7 +1734,7 @@ END $rownum ++; my $backgroundColor = $backgroundColors[$rownum % scalar(@backgroundColors)]; - $result .= " \n"; + $result .= " \n"; # Set up some data about the parts that the cols might want my $filter = $it->{FILTER}; @@ -1837,7 +1831,7 @@ ENDBLOCK $result.='} - '."\n"; foreach my $link (@linkorder) { if (defined($linkitems->{$link})) { if ($linkitems->{$link}{'text'} ne '') { @@ -1848,13 +1842,21 @@ ENDBLOCK } $result .= '  - '."\n"; + '."\n"; return $result; } 1; + + + + + + + + package Apache::lonnavmaps::navmap; =pod @@ -3738,7 +3740,7 @@ sub map_contains_problem { sub is_sequence { my $self=shift; return $self->navHash("is_map_", 1) && - $self->navHash("map_type_" . $self->map_pc()) eq 'sequence'; + $self->navHash("map_type_" . $self->map_pc()) eq 'sequence'; } sub is_survey { my $self = shift();