--- loncom/interface/lonnavmaps.pm 2004/06/29 22:32:11 1.264
+++ loncom/interface/lonnavmaps.pm 2004/07/27 23:35:34 1.273
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Navigate Maps Handler
#
-# $Id: lonnavmaps.pm,v 1.264 2004/06/29 22:32:11 albertel Exp $
+# $Id: lonnavmaps.pm,v 1.273 2004/07/27 23:35:34 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -83,6 +83,56 @@ my %colormap =
# is not yet done and due in less then 24 hours
my $hurryUpColor = "#FF0000";
+sub launch_win {
+ my ($mode,$script)=@_;
+ my $result;
+ if ($script ne 'no') {
+ $result.='';
+ }
+ if ($mode eq 'link') {
+ $result.=''
+ .&mt("Launch navigation in separate window")." ";
+ }
+ return $result;
+}
+
+sub close {
+ if ($ENV{'environment.remotenavmap'} ne 'on') { return ''; }
+ return(<
+window.status='Accessing Nav Control';
+menu=window.open("/adm/rat/empty.html","loncapanav",
+ "height=600,width=400,scrollbars=1");
+window.status='Closing Nav Control';
+menu.close();
+window.status='Done.';
+
+ENDCLOSE
+}
+
+sub update {
+ if ($ENV{'environment.remotenavmap'} ne 'on') { return ''; }
+ if (!$ENV{'request.course.id'}) { return ''; }
+ if ($ENV{'REQUEST_URI'}=~m|^/adm/navmaps|) { return ''; }
+ return(<
+
+ENDUPDATE
+}
+
sub handler {
my $r = shift;
real_handler($r);
@@ -111,6 +161,28 @@ sub real_handler {
&Apache::loncommon::no_cache($r);
$r->send_http_header;
+ if ($ENV{QUERY_STRING} eq 'collapseExternal') {
+ &Apache::lonnet::put('environment',{'remotenavmap' => 'off'});
+ &Apache::lonnet::appenv('environment.remotenavmap' => 'off');
+ $r->print(<<"ENDSUBM");
+
+
+
+
+
+
+ENDSUBM
+ return;
+ }
+ if ($ENV{QUERY_STRING} eq 'launchExternal') {
+ &Apache::lonnet::put('environment',{'remotenavmap' => 'on'});
+ &Apache::lonnet::appenv('environment.remotenavmap' => 'on');
+ }
+
# Create the nav map
my $navmap = Apache::lonnavmaps::navmap->new();
@@ -123,14 +195,27 @@ sub real_handler {
$r->print("\n");
$r->print("".&mt('Navigate Course Contents')."");
# ------------------------------------------------------------ Get query string
- &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['register']);
+ &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['register','sort']);
# ----------------------------------------------------- Force menu registration
my $addentries='';
+ my $more_unload;
+ if ($ENV{'environment.remotenavmap'} eq 'on') {
+ $r->print('');
+# FIXME need to be smarter to only catch window close events
+# $more_unload="collapse()"
+ }
if ($ENV{'form.register'}) {
- $addentries=' onLoad="'.&Apache::lonmenu::loadevents().
- '" onUnload="'.&Apache::lonmenu::unloadevents().'"';
- $r->print(&Apache::lonmenu::registerurl(1));
+ $addentries=' onLoad="'.&Apache::lonmenu::loadevents().
+ '" onUnload="'.&Apache::lonmenu::unloadevents().';'.
+ $more_unload.'"';
+ $r->print(&Apache::lonmenu::registerurl(1));
+ } else {
+ $addentries=' onUnload="'.$more_unload.'"';
}
# Header
@@ -138,9 +223,8 @@ sub real_handler {
&Apache::loncommon::bodytag('Navigate Course Contents','',
$addentries,'','',$ENV{'form.register'}));
$r->print(''.
- &Apache::loncommon::help_open_topic('Navigation_Screen').
- &Apache::loncommon::help_open_bug('RAT'));
-
+ &Apache::loncommon::help_open_menu('','Navigation Screen','Navigation_Screen','',undef,'RAT'));
+
$r->rflush();
# Check that it's defined
@@ -174,6 +258,27 @@ sub real_handler {
}
}
+ if ($ENV{QUERY_STRING} eq 'launchExternal') {
+ $r->print('
+ ');
+ $r->print('
+ ');
+ }
+
+ if ($ENV{'environment.remotenavmap'} ne 'on') {
+ $r->print(&launch_win('link','yes'));
+ }
+ if ($ENV{'environment.remotenavmap'} eq 'on') {
+# $r->print("" .
+ $r->print("" .
+ &mt("Close separate navigation window").
+ " ");
+ }
+
my $jumpToFirstHomework = 0;
# Check to see if the student is jumping to next open, do-able problem
if ($ENV{QUERY_STRING} eq 'jumpToFirstHomework') {
@@ -234,8 +339,20 @@ sub real_handler {
&mt("Show Only Uncompleted Homework")." ");
}
+ $r->print("");
# renderer call
- my $renderArgs = { 'cols' => [0,1,2,3],
+ my $renderArgs = { 'cols' => [0,2,3],
+ 'sort' => $ENV{'form.sort'},
'url' => '/adm/navmaps',
'navmap' => $navmap,
'suppressNavmap' => 1,
@@ -972,8 +1089,12 @@ sub render_resource {
$nonLinkedText .= ' (' . $resource->countParts() . ' parts)';
}
- if (!$params->{'resource_nolink'} && !$resource->is_sequence()) {
- $result .= " $curMarkerBegin$title$partLabel$curMarkerEnd $nonLinkedText";
+ my $target;
+ if ($ENV{'environment.remotenavmap'} eq 'on') {
+ $target=' target="loncapaclient" ';
+ }
+ if (!$params->{'resource_nolink'} && !$resource->is_sequence() && !$resource->is_empty_sequence) {
+ $result .= " $curMarkerBegin$title$partLabel$curMarkerEnd $nonLinkedText";
} else {
$result .= " $curMarkerBegin$title$partLabel$curMarkerEnd $nonLinkedText";
}
@@ -1251,7 +1372,10 @@ sub render {
#$currenturl=~s/^[^\/]+//;
$here = $jump = &Apache::lonnet::symbread($currenturl);
- }
+ } else {
+ &Apache::lonnet::logthis("Hrrm,");
+
+ }
# Step three: Ensure the folders are open
my $mapIterator = $navmap->getIterator(undef, undef, undef, 1);
@@ -1370,9 +1494,43 @@ sub render {
"&here=" . Apache::lonnet::escape($here) .
"\">".&mt('Open All Folders')."";
}
- $result .= "
\n";
- }
+ $result .= "\n";
+ }
+ # Check for any unread discussions in all resources.
+ if (!$args->{'resource_no_folder_link'}) {
+ 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 ++;
+ }
+ }
+ if ($totdisc > 0) {
+ $haveDisc =~ s/:$//;
+ my %lt = &Apache::lonlocal::texthash(
+ 'mapr' => 'Mark all posts read',
+ );
+ $result .= (<$lt{'mapr'}
+
+END
+ } else {
+ $result .= '
';
+ }
+ }
+ $result .= "
\n";
if ($r) {
$r->print($result);
$r->rflush();
@@ -1444,7 +1602,33 @@ sub render {
$args->{'here'} = $here;
$args->{'indentLevel'} = -1; # first BEGIN_MAP takes this to 0
- while ($curRes = $it->next($closeAllPages)) {
+ my @resources;
+ my $code='';# sub { !(shift->is_map();) };
+ if ($args->{'sort'} eq 'title') {
+ @resources=$navmap->retrieveResources(undef,
+ sub { !shift->is_map(); });
+ @resources= sort {lc($a->compTitle) cmp lc($b->compTitle)} @resources;
+ } elsif ($args->{'sort'} eq 'duedate') {
+ @resources=$navmap->retrieveResources(undef,
+ sub { shift->is_problem(); });
+ @resources= sort
+ {
+ if ($a->duedate ne $b->duedate) {
+ return $a->duedate cmp $b->duedate;
+ } else {
+ lc($a->compTitle) cmp lc($b->compTitle)
+ }
+ } @resources;
+ }
+
+ while (1) {
+ if ($args->{'sort'}) {
+ $curRes = shift(@resources);
+ } else {
+ $curRes = $it->next($closeAllPages);
+ }
+ if (!$curRes) { last; }
+
# Maintain indentation level.
if ($curRes == $it->BEGIN_MAP() ||
$curRes == $it->BEGIN_BRANCH() ) {
@@ -1558,10 +1742,15 @@ sub render {
# 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 $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/(\#.*$)//) {
+ if ($src=~s/(\#.*)$//) {
$anchor=$1;
}
my $srcHasQuestion = $src =~ /\?/;
@@ -1569,7 +1758,7 @@ sub render {
($srcHasQuestion?'&':'?') .
'symb=' . &Apache::lonnet::escape($curRes->symb()).
$anchor;
-
+
# Now, display each column.
foreach my $col (@$cols) {
my $colHTML = '';
@@ -1943,7 +2132,7 @@ sub hasDiscussion {
# backward compatibility (bulletin boards used to be 'wrapped')
my $ressymb = $symb;
if ($ressymb =~ m|adm/(\w+)/(\w+)/(\d+)/bulletinboard$|) {
- unless ($ressymb =~ m|bulletin___\d+___adm/wrapper|) {
+ unless ($ressymb =~ m|adm/wrapper/adm|) {
$ressymb = 'bulletin___'.$3.'___adm/wrapper/adm/'.$1.'/'.$2.'/'.$3.'/bulletinboard';
}
}
@@ -1951,7 +2140,8 @@ sub hasDiscussion {
if ( defined ( $self->{LAST_READ}->{$ressymb} ) ) {
return $self->{DISCUSSION_TIME}->{$ressymb} > $self->{LAST_READ}->{$ressymb};
} else {
- return $self->{DISCUSSION_TIME}->{$ressymb} > $self->{LAST_CHECK};
+# return $self->{DISCUSSION_TIME}->{$ressymb} > $self->{LAST_CHECK}; # v.1.1 behavior
+ return $self->{DISCUSSION_TIME}->{$ressymb} > 0; # in 1.2 will display speech bubble icons for all items with posts until marked as read (even if read in v 1.1).
}
}
@@ -3255,6 +3445,12 @@ sub is_survey {
return 0;
}
+sub is_empty_sequence {
+ my $self=shift;
+ my $src = $self->src();
+ return !$self->is_page() && $self->navHash("is_map_", 1) && !$self->navHash("map_type_" . $self->map_pc());
+}
+
# Private method: Shells out to the parmval in the nav map, handler parts.
sub parmval {
my $self = shift;
@@ -4092,7 +4288,7 @@ sub status {
if ($dateStatus == PAST_DUE_ANSWER_LATER ||
$dateStatus == PAST_DUE_NO_ANSWER ) {
- return $dateStatus;
+ return $suppressFeedback ? ANSWER_SUBMITTED : $dateStatus;
}
if ($dateStatus == ANSWER_OPEN) {