--- loncom/interface/lonnavmaps.pm 2004/09/15 21:10:11 1.290 +++ loncom/interface/lonnavmaps.pm 2004/09/21 20:44:16 1.297 @@ -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.297 2004/09/21 20:44:16 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -127,7 +127,7 @@ sub nav_control_js { function gonav(url) { if (w_loncapanav_flag != 1) { - go(url); + gopost(url,''); } else { navwindow=window.open(url, "loncapanav","height=600,width=400,scrollbars=1"); @@ -370,7 +370,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 +392,7 @@ ENDSUBM + "); @@ -1343,6 +1344,13 @@ 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}); @@ -1428,7 +1436,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(); @@ -1549,34 +1557,41 @@ 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/:$//; + my $navurl = $ENV{'QUERY_STRING'}; + $result .= (< + END + } } + $result.=''; } if ($args->{'caller'} eq 'navmapsdisplay') { @@ -1685,23 +1700,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'}); @@ -2161,17 +2188,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 +2202,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; @@ -3964,21 +3987,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 {