--- loncom/interface/lonnavmaps.pm 2004/09/15 21:10:11 1.290 +++ loncom/interface/lonnavmaps.pm 2005/02/05 06:52:50 1.315 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Navigate Maps Handler # -# $Id: lonnavmaps.pm,v 1.290 2004/09/15 21:10:11 matthew Exp $ +# $Id: lonnavmaps.pm,v 1.315 2005/02/05 06:52:50 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -33,9 +33,11 @@ use strict; use Apache::Constants qw(:common :http); use Apache::loncommon(); use Apache::lonmenu(); +use Apache::lonenc(); use Apache::lonlocal; +use Apache::lonnet; use POSIX qw (floor strftime); -use Data::Dumper; # for debugging, not always used +use Data::Dumper; # for debugging, not always # symbolic constants sub SYMB { return 1; } @@ -119,23 +121,6 @@ window.status='Done.'; ENDCLOSE } -sub nav_control_js { - my $nav=($ENV{'environment.remotenavmap'} eq 'on'); - return (<send_http_header; my %toplinkitems=(); - + &add_linkitem(\%toplinkitems,'blank','',"Select Action"); if ($ENV{QUERY_STRING} eq 'collapseExternal') { &Apache::lonnet::put('environment',{'remotenavmap' => 'off'}); &Apache::lonnet::appenv('environment.remotenavmap' => 'off'); @@ -232,7 +217,7 @@ ENDSUBM $r->print("\n"); $r->print("".&mt('Navigate Course Contents').""); # ------------------------------------------------------------ Get query string - &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['register','sort','showOnlyHomework']); + &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['register','sort','showOnlyHomework','postsymb']); # ----------------------------------------------------- Force menu registration my $addentries=''; @@ -370,7 +355,7 @@ ENDSUBM return $res->completable() || $res->is_map(); }; &add_linkitem(\%toplinkitems,'everything', - 'location.href="locatnavmaps?sort='.$ENV{'form.sort'}.'"', + 'location.href="navmaps?sort='.$ENV{'form.sort'}.'"', "Show Everything"); $r->print("

".&mt("Uncompleted Homework")."

"); $ENV{'form.filter'} = ''; @@ -392,6 +377,7 @@ ENDSUBM + "); @@ -409,7 +395,6 @@ ENDSUBM 'caller' => 'navmapsdisplay', 'linkitems' => \%toplinkitems}; my $render = render($renderArgs); - $navmap->untieHashes(); # If no resources were printed, print a reassuring message so the # user knows there was no error. @@ -450,7 +435,6 @@ sub removeFromFilter { # Convenience function: Given a stack returned from getStack on the iterator, # return the correct src() value. -# Later, this should add an anchor when we start putting anchors in pages. sub getLinkForResource { my $stack = shift; my $res; @@ -458,14 +442,18 @@ sub getLinkForResource { # Check to see if there are any pages in the stack foreach $res (@$stack) { if (defined($res)) { + my $anchor; if ($res->is_page()) { - return $res->src(); + foreach (@$stack) { if (defined($_)) { $anchor = $_; } } + $anchor=&Apache::lonnet::escape($anchor->shown_symb()); + return ($res->link(),$res->shown_symb(),$anchor); } # in case folder was skipped over as "only sequence" my ($map,$id,$src)=&Apache::lonnet::decode_symb($res->symb()); if ($map=~/\.page$/) { - return &Apache::lonnet::clutter($map).'#'. - &Apache::lonnet::escape(&Apache::lonnet::declutter($src)); + my $url=&Apache::lonnet::clutter($map); + $anchor=&Apache::lonnet::escape($src->shown_symb()); + return ($url,$res->shown_symb(),$anchor); } } } @@ -478,7 +466,7 @@ sub getLinkForResource { if (defined($_)) { $res = $_; } } - return $res->src(); + return ($res->link(),$res->shown_symb()); } # Convenience function: This separates the logic of how to create @@ -1026,6 +1014,15 @@ sub render_resource { my $nonLinkedText = ''; # stuff after resource title not in link my $link = $params->{"resourceLink"}; + + # The URL part is not escaped at this point, but the symb is... + # The stuff to the left of the ? must have ' replaced by \' since + # it will be quoted with ' in the href. + + my ($left,$right) = split(/\?/, $link); + $left =~ s/'/\\'/g; + $link = $left.'?'.$right; + my $src = $resource->src(); my $it = $params->{"iterator"}; my $filter = $it->{FILTER}; @@ -1034,28 +1031,31 @@ sub render_resource { my $partLabel = ""; my $newBranchText = ""; - + my $location=&Apache::loncommon::lonhttpdurl("/adm/lonIcons"); # If this is a new branch, label it so if ($params->{'isNewBranch'}) { - $newBranchText = ""; + $newBranchText = ""; } # links to open and close the folder + + my $linkopen = ""; + + my $linkclose = ""; # Default icon: unknown page - my $icon = ""; + my $icon = ""; if ($resource->is_problem()) { if ($part eq '0' || $params->{'condensed'}) { - $icon = ''; + $icon =''; } else { $icon = $params->{'indentString'}; } } else { - $icon = ""; + $icon = ""; } # Display the correct map icon to open or shut map @@ -1070,7 +1070,7 @@ sub render_resource { if (!$params->{'resource_no_folder_link'}) { $icon = "navmap.$folderType." . ($nowOpen ? 'closed' : 'open') . '.gif'; - $icon = ""; + $icon = ""; $linkopen = "{'queryString'} . '&filter='; @@ -1083,11 +1083,12 @@ sub render_resource { '&jump=' . &Apache::lonnet::escape($resource->symb()) . "&folderManip=1'>"; + } else { # Don't allow users to manipulate folder $icon = "navmap.$folderType." . ($nowOpen ? 'closed' : 'open') . '.nomanip.gif'; - $icon = ""; + $icon = ""; $linkopen = ""; $linkclose = ""; @@ -1110,6 +1111,7 @@ sub render_resource { } # Decide what to display + $result .= "$newBranchText$linkopen$icon$linkclose"; my $curMarkerBegin = ''; @@ -1127,7 +1129,7 @@ sub render_resource { !$params->{'condensed'}) { my $displaypart=$resource->part_display($part); $partLabel = " (Part: $displaypart)"; - $link.='#'.&Apache::lonnet::escape($part); + if ($link!~/\#/) { $link.='#'.&Apache::lonnet::escape($part); } $title = ""; } @@ -1155,10 +1157,10 @@ sub render_communication_status { my $link = $params->{"resourceLink"}; my $linkopen = ""; my $linkclose = ""; - + my $location=&Apache::loncommon::lonhttpdurl("/adm/lonMisc"); if ($resource->hasDiscussion()) { $discussionHTML = $linkopen . - '' . + '' . $linkclose; } @@ -1168,7 +1170,7 @@ sub render_communication_status { if ($_) { $feedbackHTML .= ' ' - . ''; } } @@ -1183,7 +1185,7 @@ sub render_communication_status { $errorcount++; $errorHTML .= ' ' - . ''; } } @@ -1212,7 +1214,9 @@ sub render_quick_status { my $icon = $statusIconMap{$resource->simpleStatus($part)}; my $alt = $iconAltTags{$icon}; if ($icon) { - $result .= "$linkopen$alt$linkclose\n"; + my $location= + &Apache::loncommon::lonhttpdurl("/adm/lonIcons/$icon"); + $result .= "$linkopen$alt$linkclose\n"; } else { $result .= " \n"; } @@ -1343,11 +1347,17 @@ sub setDefault { return $val; } +sub cmp_title { + my ($atitle,$btitle) = (lc($_[0]->compTitle),lc($_[1]->compTitle)); + $atitle=~s/^\s*//; + $btitle=~s/^\s*//; + return $atitle cmp $btitle; +} + sub render { my $args = shift; &Apache::loncommon::get_unprocessed_cgi($ENV{QUERY_STRING}); my $result = ''; - # Configure the renderer. my $cols = $args->{'cols'}; if (!defined($cols)) { @@ -1410,7 +1420,7 @@ sub render { # Determine where the "here" marker is and where the screen jumps to. if ($ENV{'form.postsymb'}) { - $here = $jump = $ENV{'form.postsymb'}; + $here = $jump = &Apache::lonnet::symbclean($ENV{'form.postsymb'}); } elsif ($ENV{'form.postdata'}) { # couldn't find a symb, is there a URL? my $currenturl = $ENV{'form.postdata'}; @@ -1428,7 +1438,7 @@ sub render { # We only need to do this if we need to open the maps to show the # current position. This will change the counter so we can't count # for the jump marker with this loop. - while (($curRes = $mapIterator->next()) && !$found) { + while ($here && ($curRes = $mapIterator->next()) && !$found) { if (ref($curRes) && $curRes->symb() eq $here) { my $mapStack = $mapIterator->getStack(); @@ -1504,23 +1514,24 @@ sub render { my $printKey = $args->{'printKey'}; my $printCloseAll = $args->{'printCloseAll'}; if (!defined($printCloseAll)) { $printCloseAll = 1; } - + # Print key? if ($printKey) { $result .= ''; my $date=localtime; $result.=''; + my $location=&Apache::loncommon::lonhttpdurl("/adm/lonMisc"); if ($navmap->{LAST_CHECK}) { $result .= - ' '.&mt('New discussion since').' '. + ' '.&mt('New discussion since').' '. strftime("%A, %b %e at %I:%M %P", localtime($navmap->{LAST_CHECK})). ''; } else { $result .= ''; } @@ -1549,34 +1560,40 @@ sub render { # Check for any unread discussions in all resources. if ($args->{'caller'} eq 'navmapsdisplay') { - my $totdisc = 0; - my $haveDisc = ''; - my @allres=$navmap->retrieveResources(); - foreach my $resource (@allres) { - if ($resource->hasDiscussion()) { - my $ressymb; - if ($resource->symb() =~ m-(___adm/\w+/\w+)/(\d+)/bulletinboard$-) { - $ressymb = 'bulletin___'.$2.$1.'/'.$2.'/bulletinboard'; - } else { - $ressymb = $resource->symb(); + &add_linkitem($args->{'linkitems'},'clearbubbles', + 'document.clearbubbles.submit()', + 'Mark all posts read'); + my $time=time; + $result .= (< + + +END + if ($args->{'sort'} eq 'discussion') { + my $totdisc = 0; + my $haveDisc = ''; + my @allres=$navmap->retrieveResources(); + foreach my $resource (@allres) { + if ($resource->hasDiscussion()) { + my $ressymb; + if ($resource->symb() =~ m-(___adm/\w+/\w+)/(\d+)/bulletinboard$-) { + $ressymb = 'bulletin___'.$2.$1.'/'.$2.'/bulletinboard'; + } else { + $ressymb = $resource->symb(); + } + $haveDisc .= $ressymb.':'; + $totdisc ++; } - $haveDisc .= $ressymb.':'; - $totdisc ++; } - } - if ($totdisc > 0) { - $haveDisc =~ s/:$//; - my $navurl = $ENV{'QUERY_STRING'}; - &add_linkitem($args->{'linkitems'},'clearbubbles', - 'document.clearbubbles.submit()', - 'Mark all posts read'); - $result .= (< - - - + if ($totdisc > 0) { + $haveDisc =~ s/:$//; + $result .= (< + END + } } + $result.=''; } if ($args->{'caller'} eq 'navmapsdisplay') { @@ -1624,7 +1641,9 @@ END $args->{'indentLevel'} = 0; $args->{'isNewBranch'} = 0; $args->{'condensed'} = 0; - $args->{'indentString'} = setDefault($args->{'indentString'}, ""); + my $location= + &Apache::loncommon::lonhttpdurl("/adm/lonIcons/whitespace1.gif"); + $args->{'indentString'} = setDefault($args->{'indentString'}, ""); $args->{'displayedHereMarker'} = 0; # If we're suppressing empty sequences, look for them here. Use DFS for speed, @@ -1685,23 +1704,35 @@ END return &$oldFilterFunc($res); }; @resources=$navmap->retrieveResources(undef,$filterFunc); - @resources= sort { - my ($atitle,$btitle) = (lc($a->compTitle),lc($b->compTitle)); - $atitle=~s/^\s*//; - $btitle=~s/^\s*//; - return $atitle cmp $btitle - } @resources; + @resources= sort { &cmp_title($a,$b) } @resources; } elsif ($args->{'sort'} eq 'duedate') { - @resources=$navmap->retrieveResources(undef, - sub { shift->is_problem(); }); - @resources= sort - { + my $oldFilterFunc = $filterFunc; + my $filterFunc= + sub { + my ($res)=@_; + if (!$res->is_problem()) { return 0;} + return &$oldFilterFunc($res); + }; + @resources=$navmap->retrieveResources(undef,$filterFunc); + @resources= sort { if ($a->duedate ne $b->duedate) { return $a->duedate cmp $b->duedate; - } else { - lc($a->compTitle) cmp lc($b->compTitle) } + my $value=&cmp_title($a,$b); + return $value; } @resources; + } elsif ($args->{'sort'} eq 'discussion') { + my $oldFilterFunc = $filterFunc; + my $filterFunc= + sub { + my ($res)=@_; + if (!$res->hasDiscussion() && + !$res->getFeedback() && + !$res->getErrors()) { return 0;} + return &$oldFilterFunc($res); + }; + @resources=$navmap->retrieveResources(undef,$filterFunc); + @resources= sort { &cmp_title($a,$b) } @resources; } else { #unknow sort mechanism or default undef($args->{'sort'}); @@ -1818,7 +1849,26 @@ END # Add part 0 so we display it correctly. unshift @parts, '0'; } - + + { + my ($src,$symb,$anchor,$stack); + if ($args->{'sort'}) { + my $it = $navmap->getIterator(undef, undef, undef, 1); + while ( my $res=$it->next()) { + if (ref($res) && + $res->symb() eq $curRes->symb()) { last; } + } + $stack=$it->getStack(); + } else { + $stack=$it->getStack(); + } + ($src,$symb,$anchor)=getLinkForResource($stack); + if (defined($anchor)) { $anchor='#'.$anchor; } + my $srcHasQuestion = $src =~ /\?/; + $args->{"resourceLink"} = $src. + ($srcHasQuestion?'&':'?') . + 'symb=' . &Apache::lonnet::escape($symb).$anchor; + } # Now, we've decided what parts to show. Loop through them and # show them. foreach my $part (@parts) { @@ -1829,22 +1879,6 @@ END # Set up some data about the parts that the cols might want my $filter = $it->{FILTER}; - my $src; - if ($args->{'sort'}) { - $src = $curRes->src(); # FIXME this is wrong for .pages - } else { - my $stack = $it->getStack(); - $src=getLinkForResource($stack); - } - my $anchor=''; - if ($src=~s/(\#.*)$//) { - $anchor=$1; - } - my $srcHasQuestion = $src =~ /\?/; - $args->{"resourceLink"} = $src. - ($srcHasQuestion?'&':'?') . - 'symb=' . &Apache::lonnet::escape($curRes->symb()). - $anchor; # Now, display each column. foreach my $col (@$cols) { @@ -1911,8 +1945,6 @@ if (location.href.indexOf('#curloc')==-1 $r->rflush(); } - if ($mustCloseNavMap) { $navmap->untieHashes(); } - return $result; } @@ -1924,8 +1956,8 @@ sub add_linkitem { sub show_linkitems { my ($linkitems)=@_; - my @linkorder = ("launchnav","closenav","firsthomework","everything", - "uncompleted","changefolder","clearbubbles"); + my @linkorder = ("blank","launchnav","closenav","firsthomework", + "everything","uncompleted","changefolder","clearbubbles"); my $result .= (< @@ -1952,6 +1984,7 @@ ENDBLOCK $result .= '  '."\n"; + return $result; } @@ -2012,10 +2045,6 @@ successful, or B if not. =back -When you are done with the $navmap object, you I call -$navmap->untieHashes(), or you'll prevent the current user from using that -course until the web server is restarted. (!) - =head2 Methods =over 4 @@ -2161,17 +2190,11 @@ sub generate_email_discuss_status { foreach my $msgid (split(/\&/, $keys)) { $msgid=&Apache::lonnet::unescape($msgid); - my $plain=&Apache::lonnet::unescape(&Apache::lonnet::unescape($msgid)); - if ($plain=~/(Error|Feedback) \[([^\]]+)\]/) { - my ($what,$url)=($1,$2); - my %status= - &Apache::lonnet::get('email_status',[$msgid]); - if ($status{$msgid}=~/^error\:/) { - $status{$msgid}=''; - } - - if (($status{$msgid} eq 'new') || - (!$status{$msgid})) { + if ((!$emailstatus{$msgid}) || ($emailstatus{$msgid} eq 'new')) { + my $plain= + &Apache::lonnet::unescape(&Apache::lonnet::unescape($msgid)); + if ($plain=~/(Error|Feedback) \[([^\]]+)\]/) { + my ($what,$url)=($1,$2); if ($what eq 'Error') { $error{$url}.=','.$msgid; } else { @@ -2181,8 +2204,10 @@ sub generate_email_discuss_status { } } + #url's of resources that have feedbacks $self->{FEEDBACK} = \%feedback; - $self->{ERROR_MSG} = \%error; # what is this? JB + #or errors + $self->{ERROR_MSG} = \%error; $self->{DISCUSSION_TIME} = \%discussiontime; $self->{EMAIL_STATUS} = \%emailstatus; $self->{LAST_READ} = \%lastreadtime; @@ -2232,17 +2257,11 @@ sub courseMapDefined { sub getIterator { my $self = shift; my $iterator = Apache::lonnavmaps::iterator->new($self, shift, shift, - shift, undef, shift); + shift, undef, shift, + shift, shift); return $iterator; } -# unties the hash when done -sub untieHashes { - my $self = shift; - untie %{$self->{NAV_HASH}}; - untie %{$self->{PARM_HASH}}; -} - # Private method: Does the given resource (as a symb string) have # current discussion? Returns 0 if chat/mail data not extracted. sub hasDiscussion { @@ -2459,8 +2478,6 @@ sub parmval_real { if (defined($courseopt)) { if (defined($$courseopt{$courselevelr})) { return $$courseopt{$courselevelr}; } - if (defined($$courseopt{$courselevelm})) { return $$courseopt{$courselevelm}; } - if (defined($$courseopt{$courselevel})) { return $$courseopt{$courselevel}; } } # ----------------------------------------------------- third, check map parms @@ -2477,7 +2494,13 @@ sub parmval_real { $default=&Apache::lonnet::metadata($fn,'parameter_'.$meta_rwhat); if (defined($default)) { return $default} -# --------------------------------------------------- fifth , cascade up parts +# --------------------------------------------------- fifth, check more course + if (defined($courseopt)) { + if (defined($$courseopt{$courselevelm})) { return $$courseopt{$courselevelm}; } + if (defined($$courseopt{$courselevel})) { return $$courseopt{$courselevel}; } + } + +# --------------------------------------------------- sixth , cascade up parts my ($space,@qualifier)=split(/\./,$rwhat); my $qualifier=join('.',@qualifier); @@ -2506,7 +2529,7 @@ you're not sure if $res is already an ob resource appears multiple times in the course, only the first instance will be returned. As a result, this is probably useful only for maps. -=item * B(map, filterFunc, recursive, bailout): +=item * B(map, filterFunc, recursive, bailout, showall): The map is a specification of a map to retreive the resources from, either as a url or as an object. The filterFunc is a reference to a @@ -2514,13 +2537,14 @@ function that takes a resource object as true if the resource should be included, or false if it should not be. If recursive is true, the map will be recursively examined, otherwise it will not be. If bailout is true, the function will return -as soon as it finds a resource, if false it will finish. By default, -the map is the top-level map of the course, filterFunc is a function -that always returns 1, recursive is true, bailout is false. The -resources will be returned in a list containing the resource objects -for the corresponding resources, with B in -the list; regardless of branching, recursion, etc., it will be a flat -list. +as soon as it finds a resource, if false it will finish. If showall is +true it will not hide maps that contain nothing but one other map. By +default, the map is the top-level map of the course, filterFunc is a +function that always returns 1, recursive is true, bailout is false, +showall is false. The resources will be returned in a list containing +the resource objects for the corresponding resources, with B in the list; regardless of branching, +recursion, etc., it will be a flat list. Thus, this is suitable for cases where you don't want the structure, just a list of all resources. It is also suitable for finding out how @@ -2567,7 +2591,7 @@ sub retrieveResources { if (!defined($recursive)) { $recursive = 1; } my $bailout = shift; if (!defined($bailout)) { $bailout = 0; } - + my $showall = shift; # Create the necessary iterator. if (!ref($map)) { # assume it's a url of a map. $map = $self->getResourceByUrl($map); @@ -2586,7 +2610,7 @@ sub retrieveResources { # Get an iterator. my $it = $self->getIterator($map->map_start(), $map->map_finish(), - undef, $recursive); + undef, $recursive, $showall); my @resources = (); @@ -2623,7 +2647,7 @@ sub hasResource { 1; package Apache::lonnavmaps::iterator; - +use WeakRef; =pod =back @@ -2763,7 +2787,7 @@ sub new { my $class = ref($proto) || $proto; my $self = {}; - $self->{NAV_MAP} = shift; + weaken($self->{NAV_MAP} = shift); return undef unless ($self->{NAV_MAP}); # Handle the parameters @@ -2883,7 +2907,8 @@ sub new { Apache::lonnavmaps::iterator->new($self->{NAV_MAP}, $firstResource, $finishResource, $self->{FILTER}, $self->{ALREADY_SEEN}, - $self->{CONDITION}, 0); + $self->{CONDITION}, + $self->{FORCE_TOP}); } @@ -3046,7 +3071,9 @@ sub next { $self->{RECURSIVE_ITERATOR} = Apache::lonnavmaps::iterator->new($self->{NAV_MAP}, $firstResource, $finishResource, $self->{FILTER}, - $self->{ALREADY_SEEN}, $self->{CONDITION}); + $self->{ALREADY_SEEN}, + $self->{CONDITION}, + $self->{FORCE_TOP}); } # If this is a blank resource, don't actually return it. @@ -3099,7 +3126,7 @@ sub populateStack { 1; package Apache::lonnavmaps::DFSiterator; - +use WeakRef; # Not documented in the perldoc: This is a simple iterator that just walks # through the nav map and presents the resources in a depth-first search # fashion, ignorant of conditionals, randomized resources, etc. It presents @@ -3127,7 +3154,7 @@ sub new { my $class = ref($proto) || $proto; my $self = {}; - $self->{NAV_MAP} = shift; + weaken($self->{NAV_MAP} = shift); return undef unless ($self->{NAV_MAP}); $self->{FIRST_RESOURCE} = shift || $self->{NAV_MAP}->firstResource(); @@ -3281,7 +3308,7 @@ sub populateStack { 1; package Apache::lonnavmaps::resource; - +use WeakRef; use Apache::lonnet; =pod @@ -3363,7 +3390,7 @@ sub new { my $class = ref($proto) || $proto; my $self = {}; - $self->{NAV_MAP} = shift; + weaken($self->{NAV_MAP} = shift); $self->{ID} = shift; # Store this new resource in the parent nav map's cache. @@ -3451,6 +3478,7 @@ Returns the title of the resource. # These info functions can be used directly, as they don't return # resource information. sub comesfrom { my $self=shift; return $self->navHash("comesfrom_", 1); } +sub encrypted { my $self=shift; return $self->navHash("encrypted_", 1); } sub ext { my $self=shift; return $self->navHash("ext_", 1) eq 'true:'; } sub from { my $self=shift; return $self->navHash("from_", 1); } # considered private and undocumented @@ -3462,10 +3490,20 @@ sub randompick { return $self->{NAV_MAP}->{PARM_HASH}->{$self->symb . '.0.parameter_randompick'}; } +sub link { + my $self=shift; + if ($self->encrypted()) { return &Apache::lonenc::encrypted($self->src); } + return $self->src; +} sub src { my $self=shift; return $self->navHash("src_", 1); } +sub shown_symb { + my $self=shift; + if ($self->encrypted()) {return &Apache::lonenc::encrypted($self->symb());} + return $self->symb(); +} sub symb { my $self=shift; (my $first, my $second) = $self->{ID} =~ /(\d+).(\d+)/; @@ -3484,6 +3522,16 @@ sub title { return $self->navHash("title_", 1); } # considered private and undocumented sub to { my $self=shift; return $self->navHash("to_", 1); } +sub condition { + my $self=shift; + my $undercond=$self->navHash("undercond_", 1); + if (!defined($undercond)) { return 1; }; + my $condid=$self->navHash("condid_$undercond"); + if (!defined($condid)) { return 1; }; + my $condition=&Apache::lonnet::directcondval($condid); + return $condition; +} + sub compTitle { my $self = shift; my $title = $self->title(); @@ -3964,21 +4012,21 @@ sub countParts { sub countResponses { my $self = shift; my $count; - foreach my $part ($self->parts()) { - $count+= $self->responseIds($part); + foreach my $part (@{$self->parts()}) { + $count+= scalar($self->responseIds($part)); } return $count; } sub responseTypes { my $self = shift; - my %Responses; + my %responses; foreach my $part ($self->parts()) { foreach my $responsetype ($self->responseType($part)) { - $Responses{$responsetype}++ if (defined($responsetype)); + $responses{$responsetype}++ if (defined($responsetype)); } } - return %Responses; + return %responses; } sub multipart { @@ -4657,6 +4705,7 @@ sub getNext { my $to = $self->to(); foreach my $branch ( split(/,/, $to) ) { my $choice = $self->{NAV_MAP}->getById($branch); + if (!$choice->condition()) { next; } my $next = $choice->goesto(); $next = $self->{NAV_MAP}->getById($next); @@ -4685,7 +4734,8 @@ sub browsePriv { return $self->{BROWSE_PRIV}; } - $self->{BROWSE_PRIV} = &Apache::lonnet::allowed('bre', $self->src()); + $self->{BROWSE_PRIV} = &Apache::lonnet::allowed('bre',$self->src(), + $self->symb()); } =pod
Key:    '. - ' '.&mt('New message (click to open)').'

'. + ' '.&mt('New message (click to open)').'

'. '

  '. - ' '.&mt('Discussions').''. - '   '.&mt('New message (click to open)'). + ' '.&mt('Discussions').''. + '   '.&mt('New message (click to open)'). '