--- loncom/interface/lonnavmaps.pm 2004/09/21 19:28:34 1.267.2.7
+++ loncom/interface/lonnavmaps.pm 2004/08/13 20:12:11 1.275
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Navigate Maps Handler
#
-# $Id: lonnavmaps.pm,v 1.267.2.7 2004/09/21 19:28:34 albertel Exp $
+# $Id: lonnavmaps.pm,v 1.275 2004/08/13 20:12:11 albertel 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,39 @@ 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');
+ my $menu=&Apache::lonmenu::reopenmenu();
+ my $navstatus=&Apache::lonmenu::get_nav_status();
+ if ($menu) {
+ $menu=(<');
+ $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') {
@@ -233,8 +350,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,
@@ -513,7 +642,7 @@ sub timeToHumanString {
}
# Not this year, so show the year
- my $timeStr = strftime("on %A, %b %e %Y at %I:%M %P", localtime($time));
+ my $timeStr = strftime("on %A, %b %e %G at %I:%M %P", localtime($time));
$timeStr =~ s/12:00 am/00:00/;
$timeStr =~ s/12:00 pm/noon/;
return $timeStr;
@@ -959,9 +1088,7 @@ sub render_resource {
if ($resource->is_problem() && $part ne '0' &&
!$params->{'condensed'}) {
- my $displaypart=&Apache::lonnet::EXT('resource.'.$part.'.display',
- $resource->symb());
- unless ($displaypart) { $displaypart=$part; }
+ my $displaypart=$resource->part_display($part);
$partLabel = " (Part: $displaypart)";
$link.='#'.&Apache::lonnet::escape($part);
$title = "";
@@ -971,8 +1098,12 @@ sub render_resource {
$nonLinkedText .= ' (' . $resource->countParts() . ' parts)';
}
+ 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";
+ $result .= " $curMarkerBegin$title$partLabel$curMarkerEnd $nonLinkedText";
} else {
$result .= " $curMarkerBegin$title$partLabel$curMarkerEnd $nonLinkedText";
}
@@ -1250,7 +1381,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);
@@ -1260,7 +1394,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 ($here && ($curRes = $mapIterator->next()) && !$found) {
+ while (($curRes = $mapIterator->next()) && !$found) {
if (ref($curRes) && $curRes->symb() eq $here) {
my $mapStack = $mapIterator->getStack();
@@ -1373,7 +1507,7 @@ sub render {
}
# Check for any unread discussions in all resources.
- if (0 && !$args->{'resource_no_folder_link'}) {
+ if (!$args->{'resource_no_folder_link'}) {
my $totdisc = 0;
my $haveDisc = '';
my @allres=$navmap->retrieveResources();
@@ -1477,7 +1611,33 @@ END
$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() ) {
@@ -1591,10 +1751,15 @@ END
# 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 =~ /\?/;
@@ -1602,7 +1767,7 @@ END
($srcHasQuestion?'&':'?') .
'symb=' . &Apache::lonnet::escape($curRes->symb()).
$anchor;
-
+
# Now, display each column.
foreach my $col (@$cols) {
my $colHTML = '';
@@ -1879,11 +2044,17 @@ sub generate_email_discuss_status {
foreach my $msgid (split(/\&/, $keys)) {
$msgid=&Apache::lonnet::unescape($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);
+ 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 ($what eq 'Error') {
$error{$url}.=','.$msgid;
} else {
@@ -1893,10 +2064,8 @@ sub generate_email_discuss_status {
}
}
- #url's of resources that have feedbacks
$self->{FEEDBACK} = \%feedback;
- #or errors
- $self->{ERROR_MSG} = \%error;
+ $self->{ERROR_MSG} = \%error; # what is this? JB
$self->{DISCUSSION_TIME} = \%discussiontime;
$self->{EMAIL_STATUS} = \%emailstatus;
$self->{LAST_READ} = \%lastreadtime;
@@ -3514,7 +3683,16 @@ sub weight {
$self->symb(), $ENV{'user.domain'},
$ENV{'user.name'},
$ENV{'request.course.sec'});
-
+}
+sub part_display {
+ my $self= shift(); my $partID = shift();
+ if (! defined($partID)) { $partID = '0'; }
+ my $display=&Apache::lonnet::EXT('resource.'.$partID.'.display',
+ $self->symb);
+ if (! defined($display) || $display eq '') {
+ $display = $partID;
+ }
+ return $display;
}
# Multiple things need this
@@ -3978,7 +4156,6 @@ sub getCompletionStatus {
# Left as separate if statements in case we ever do more with this
if ($status eq 'correct_by_student') {return $self->CORRECT;}
- if ($status eq 'correct_by_scantron') {return $self->CORRECT;}
if ($status eq 'correct_by_override') {return $self->CORRECT_BY_OVERRIDE; }
if ($status eq 'incorrect_attempted') {return $self->INCORRECT; }
if ($status eq 'incorrect_by_override') {return $self->INCORRECT_BY_OVERRIDE; }