+
+ENDUPDATE
+}
+
sub handler {
my $r = shift;
real_handler($r);
@@ -111,6 +178,46 @@ 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 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') {
@@ -217,29 +362,45 @@ sub real_handler {
# Display only due homework.
my $showOnlyHomework = 0;
- if ($ENV{QUERY_STRING} eq 'showOnlyHomework') {
+ if ($ENV{'form.showOnlyHomework'} eq "1") {
$showOnlyHomework = 1;
$suppressEmptySequences = 1;
$filterFunc = sub { my $res = shift;
return $res->completable() || $res->is_map();
};
+ $r->print("" .
+ &mt("Show Everything")." ");
$r->print("".&mt("Uncompleted Homework")."
");
$ENV{'form.filter'} = '';
$ENV{'form.condition'} = 1;
$resource_no_folder_link = 1;
} else {
- $r->print("" .
+ $r->print("" .
&mt("Show Only Uncompleted Homework")." ");
}
+ my %selected=($ENV{'form.sort'} => 'selected=on');
+ my $sort_html=("");
# 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,
'suppressEmptySequences' => $suppressEmptySequences,
'filterFunc' => $filterFunc,
'resource_no_folder_link' => $resource_no_folder_link,
+ 'sort_html'=> $sort_html,
'r' => $r};
my $render = render($renderArgs);
$navmap->untieHashes();
@@ -512,7 +673,7 @@ sub timeToHumanString {
}
# Not this year, so show the year
- my $timeStr = strftime("on %A, %b %e %G at %I:%M %P", localtime($time));
+ my $timeStr = strftime("on %A, %b %e %Y at %I:%M %P", localtime($time));
$timeStr =~ s/12:00 am/00:00/;
$timeStr =~ s/12:00 pm/noon/;
return $timeStr;
@@ -864,10 +1025,7 @@ sub render_resource {
my $filter = $it->{FILTER};
my $title = $resource->compTitle();
-# if ($src =~ /^\/uploaded\//) {
-# $nonLinkedText=$title;
-# $title = '';
-# }
+
my $partLabel = "";
my $newBranchText = "";
@@ -961,9 +1119,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 = "";
@@ -973,10 +1129,12 @@ sub render_resource {
$nonLinkedText .= ' (' . $resource->countParts() . ' parts)';
}
-# if (!$params->{'resource_nolink'} && $src !~ /^\/uploaded\// &&
-# !$resource->is_sequence()) {
- 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";
}
@@ -1373,9 +1531,46 @@ 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 .= '
';
+ }
+ }
+
+ if ($args->{'sort_html'}) { $result.=$args->{'sort_html'}; }
+ $result .= "
\n";
if ($r) {
$r->print($result);
$r->rflush();
@@ -1447,7 +1642,43 @@ 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') {
+ my $oldFilterFunc = $filterFunc;
+ my $filterFunc=
+ sub {
+ my ($res)=@_;
+ if ($res->is_map()) { return 0;}
+ return &$oldFilterFunc($res);
+ };
+ @resources=$navmap->retrieveResources(undef,$filterFunc);
+ @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;
+ } else {
+ #unknow sort mechanism or default
+ undef($args->{'sort'});
+ }
+
+
+ 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() ) {
@@ -1561,10 +1792,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 =~ /\?/;
@@ -1572,7 +1808,7 @@ sub render {
($srcHasQuestion?'&':'?') .
'symb=' . &Apache::lonnet::escape($curRes->symb()).
$anchor;
-
+
# Now, display each column.
foreach my $col (@$cols) {
my $colHTML = '';
@@ -1818,6 +2054,7 @@ sub generate_course_user_opt {
sub generate_email_discuss_status {
my $self = shift;
+ my $symb = shift;
if ($self->{EMAIL_DISCUSS_GENERATED}) { return; }
my $cid=$ENV{'request.course.id'};
@@ -1830,6 +2067,15 @@ sub generate_email_discuss_status {
$courseLeaveTime : $logoutTime);
my %discussiontime = &Apache::lonnet::dump('discussiontimes',
$cdom, $cnum);
+ my %lastread = &Apache::lonnet::dump('nohist_'.$cid.'_discuss',
+ $ENV{'user.domain'},$ENV{'user.name'},'lastread');
+ my %lastreadtime = ();
+ foreach (keys %lastread) {
+ my $key = $_;
+ $key =~ s/_lastread$//;
+ $lastreadtime{$key} = $lastread{$_};
+ }
+
my %feedback=();
my %error=();
my $keys = &Apache::lonnet::reply('keys:'.
@@ -1863,6 +2109,7 @@ sub generate_email_discuss_status {
$self->{ERROR_MSG} = \%error; # what is this? JB
$self->{DISCUSSION_TIME} = \%discussiontime;
$self->{EMAIL_STATUS} = \%emailstatus;
+ $self->{LAST_READ} = \%lastreadtime;
$self->{EMAIL_DISCUSS_GENERATED} = 1;
}
@@ -1931,8 +2178,21 @@ sub hasDiscussion {
if (!defined($self->{DISCUSSION_TIME})) { return 0; }
#return defined($self->{DISCUSSION_TIME}->{$symb});
- return $self->{DISCUSSION_TIME}->{$symb} >
- $self->{LAST_CHECK};
+
+# backward compatibility (bulletin boards used to be 'wrapped')
+ my $ressymb = $symb;
+ if ($ressymb =~ m|adm/(\w+)/(\w+)/(\d+)/bulletinboard$|) {
+ unless ($ressymb =~ m|adm/wrapper/adm|) {
+ $ressymb = 'bulletin___'.$3.'___adm/wrapper/adm/'.$1.'/'.$2.'/'.$3.'/bulletinboard';
+ }
+ }
+
+ if ( defined ( $self->{LAST_READ}->{$ressymb} ) ) {
+ return $self->{DISCUSSION_TIME}->{$ressymb} > $self->{LAST_READ}->{$ressymb};
+ } else {
+# 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).
+ }
}
# Private method: Does the given resource (as a symb string) have
@@ -2003,9 +2263,14 @@ sub getById {
sub getBySymb {
my $self = shift;
my $symb = shift;
+
my ($mapUrl, $id, $filename) = &Apache::lonnet::decode_symb($symb);
my $map = $self->getResourceByUrl($mapUrl);
- return $self->getById($map->map_pc() . '.' . $id);
+ my $returnvalue = undef;
+ if (ref($map)) {
+ $returnvalue = $self->getById($map->map_pc() .'.'.$id);
+ }
+ return $returnvalue;
}
sub getByMapPc {
@@ -2199,6 +2464,7 @@ in the filter function.
=cut
+
sub getResourceByUrl {
my $self = shift;
my $resUrl = shift;
@@ -3223,6 +3489,23 @@ sub is_sequence {
return $self->navHash("is_map_", 1) &&
$self->navHash("map_type_" . $self->map_pc()) eq 'sequence';
}
+sub is_survey {
+ my $self = shift();
+ my $part = shift();
+ if ($self->parmval('type',$part) eq 'survey') {
+ return 1;
+ }
+ if ($self->src() =~ /\.(survey)$/) {
+ return 1;
+ }
+ 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 {
@@ -3399,6 +3682,11 @@ sub awarded {
}
sub duedate {
(my $self, my $part) = @_;
+ my $interval=$self->parmval("interval", $part);
+ if ($interval) {
+ my $first_access=&Apache::lonnet::get_first_access('map',$self->symb);
+ if ($first_access) { return ($first_access+$interval); }
+ }
return $self->parmval("duedate", $part);
}
sub maxtries {
@@ -3442,7 +3730,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
@@ -3699,6 +3996,20 @@ sub extractParts {
}
}
}
+ my $resorder = &Apache::lonnet::metadata($self->src(),'responseorder');
+ if ($resorder) {
+ my @resorder=split(/,/,$resorder);
+ foreach my $part (keys(%responseIdHash)) {
+ my %resids = map { ($_,1) } @{ $responseIdHash{$part} };
+ my @neworder;
+ foreach my $possibleid (@resorder) {
+ if (exists($resids{$possibleid})) {
+ push(@neworder,$possibleid);
+ }
+ }
+ $responseIdHash{$part}=\@neworder;
+ }
+ }
$self->{RESPONSE_IDS} = \%responseIdHash;
$self->{RESPONSE_TYPES} = \%responseTypeHash;
}
@@ -4042,7 +4353,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) {