[LON-CAPA-cvs] cvs: rat / lonsequence.pm loncom/interface lonmenu.pm lonnavmaps.pm
raeburn
raeburn at source.lon-capa.org
Mon Aug 21 17:30:05 EDT 2017
raeburn Mon Aug 21 21:30:05 2017 EDT
Modified files:
/loncom/interface lonmenu.pm lonnavmaps.pm
/rat lonsequence.pm
Log:
- Breadcrumb trail when displaying resource in course context contains
clickable links for folder hierarchy.
- Clicking the folder name causes display of a truncated Course Contents
screen with for just the items in that folder.
-------------- next part --------------
Index: loncom/interface/lonmenu.pm
diff -u loncom/interface/lonmenu.pm:1.474 loncom/interface/lonmenu.pm:1.475
--- loncom/interface/lonmenu.pm:1.474 Mon Aug 21 21:13:09 2017
+++ loncom/interface/lonmenu.pm Mon Aug 21 21:29:56 2017
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Routines to control the menu
#
-# $Id: lonmenu.pm,v 1.474 2017/08/21 21:13:09 raeburn Exp $
+# $Id: lonmenu.pm,v 1.475 2017/08/21 21:29:56 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -646,7 +646,7 @@
undef(@inlineremote);
- my ($mapurl,$resurl,$crstype);
+ my ($mapurl,$resurl,$crstype,$navmap);
if ($env{'request.course.id'}) {
#
@@ -659,7 +659,13 @@
my $maptitle = &Apache::lonnet::gettitle($mapurl);
my $restitle = &Apache::lonnet::gettitle(&Apache::lonnet::symbread());
- my @crumbs;
+ my (@crumbs, at mapcrumbs);
+ if (($env{'request.noversionuri'} ne '/adm/navmaps') && ($mapurl ne '')) {
+ $navmap = Apache::lonnavmaps::navmap->new();
+ if (ref($navmap)) {
+ @mapcrumbs = $navmap->recursed_crumbs($mapurl);
+ }
+ }
unless (($forcereg) &&
($env{'request.noversionuri'} eq '/adm/navmaps') &&
($mapurl eq $env{'course.'.$env{'request.course.id'}.'.url'}) ||
@@ -668,14 +674,18 @@
href => "Javascript:gopost('/adm/navmaps','')"});
}
if ($mapurl ne $env{'course.'.$env{'request.course.id'}.'.url'}) {
- push(@crumbs, {text => '...',
- no_mt => 1});
+ if (@mapcrumbs) {
+ push(@crumbs, at mapcrumbs);
+ } else {
+ push(@crumbs, {text => '...',
+ no_mt => 1});
+ }
}
- unless (($crstype eq 'Placement') && (!$env{'request.role.adv'})) {
- push @crumbs, {text => $maptitle, no_mt => 1} if ($maptitle
- && $maptitle ne 'default.sequence'
- && $maptitle ne $coursetitle);
+ unless ((($crstype eq 'Placement') && (!$env{'request.role.adv'})) || (@mapcrumbs) ||
+ (!$maptitle) || ($maptitle eq 'default.sequence') ||
+ ($mapurl eq $env{'course.'.$env{'request.course.id'}.'.url'})) {
+ push @crumbs, {text => $maptitle, no_mt => 1, href => $mapurl};
}
push @crumbs, {text => $restitle, no_mt => 1} if $restitle;
Index: loncom/interface/lonnavmaps.pm
diff -u loncom/interface/lonnavmaps.pm:1.532 loncom/interface/lonnavmaps.pm:1.533
--- loncom/interface/lonnavmaps.pm:1.532 Mon Jul 10 13:01:39 2017
+++ loncom/interface/lonnavmaps.pm Mon Aug 21 21:29:56 2017
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Navigate Maps Handler
#
-# $Id: lonnavmaps.pm,v 1.532 2017/07/10 13:01:39 raeburn Exp $
+# $Id: lonnavmaps.pm,v 1.533 2017/08/21 21:29:56 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1007,9 +1007,12 @@
# Don't allow users to manipulate folder
$icon = "navmap.$folderType." . ($nowOpen ? 'closed' : 'open') . '.gif';
$icon = "<img class=\"LC_space\" src='$whitespace' alt='' />"."<img class=\"LC_contentImage\" src='$location/$icon' alt=\"".($nowOpen ? &mt('Open Folder') : &mt('Close Folder')).' '.$title."\" />";
-
- $linkopen = "";
- $linkclose = "";
+ if ($params->{'caller'} eq 'sequence') {
+ $linkopen = "<a href=\"$link\">";
+ } else {
+ $linkopen = "";
+ $linkclose = "";
+ }
}
if (((&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) ||
(&Apache::lonnet::allowed('cev',$env{'request.course.id'}))) &&
@@ -1372,10 +1375,11 @@
my $currenturl = $env{'form.postdata'};
#$currenturl=~s/^http\:\/\///;
#$currenturl=~s/^[^\/]+//;
-
- $here = $jump = &Apache::lonnet::symbread($currenturl);
+ unless ($args->{'caller'} eq 'sequence') {
+ $here = $jump = &Apache::lonnet::symbread($currenturl);
+ }
}
- if ($here eq '') {
+ if (($here eq '') && ($args->{'caller'} ne 'sequence')) {
my $last;
if (tie(my %hash,'GDBM_File',$env{'request.course.fn'}.'_symb.db',
&GDBM_READER(),0640)) {
@@ -1866,9 +1870,13 @@
}
}
if (defined($anchor)) { $anchor='#'.$anchor; }
- $args->{"resourceLink"} = $src.
- ($srcHasQuestion?'&':'?') .
- 'symb=' . &escape($symb).$anchor;
+ if (($args->{'caller'} eq 'sequence') && ($curRes->is_map())) {
+ $args->{"resourceLink"} = $src.($srcHasQuestion?'&':'?') .'navmap=1';
+ } else {
+ $args->{"resourceLink"} = $src.
+ ($srcHasQuestion?'&':'?') .
+ 'symb=' . &escape($symb).$anchor;
+ }
}
# Now, we've decided what parts to show. Loop through them and
# show them.
@@ -2873,6 +2881,42 @@
return @recurseup;
}
+sub recursed_crumbs {
+ my ($self,$mapurl) = @_;
+ my (@revmapinfo, at revmapres);
+ my $mapres = $self->getResourceByUrl($mapurl);
+ if (ref($mapres)) {
+ @revmapres = map { $self->getByMapPc($_); } split(/,/,$mapres->map_hierarchy());
+ shift(@revmapres);
+ push(@revmapres,$mapres);
+ }
+ my %toplevel;
+ foreach my $map (@revmapres) {
+ my $pc = $map->map_pc();
+ next if ((!$pc) || ($pc == 1));
+ my $func = sub { return ($_[0]->src() ne $map->src); };
+ my @resources = $self->retrieveResources($map->src,$func,0);
+ my $count = 0;
+ my $notmap = 0;
+ foreach my $res (@resources) {
+ next unless (ref($res));
+ my $symb = $res->symb();
+ unless ($toplevel{$symb}) {
+ $toplevel{$symb} = $res->src;
+ $count ++;
+ unless ($res->is_map()) {
+ $notmap ++;
+ }
+ }
+ }
+ if (($count > 1) || ($count && $notmap)) {
+ push(@revmapinfo,{'href' => $map->link().'?navmap=1','text' => $map->title(),'no_mt' => 1,});
+ }
+ }
+ return @revmapinfo;
+}
+
+
#
# Determines the open/close dates for printing a map that
# encloses a resource.
Index: rat/lonsequence.pm
diff -u rat/lonsequence.pm:1.45 rat/lonsequence.pm:1.46
--- rat/lonsequence.pm:1.45 Mon Dec 15 00:46:52 2014
+++ rat/lonsequence.pm Mon Aug 21 21:30:05 2017
@@ -2,7 +2,7 @@
#
# Sequence Handler
#
-# $Id: lonsequence.pm,v 1.45 2014/12/15 00:46:52 raeburn Exp $
+# $Id: lonsequence.pm,v 1.46 2017/08/21 21:30:05 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -41,6 +41,8 @@
use Apache::loncommon();
use Apache::groupsort();
use Apache::lonlocal;
+use Apache::lonnavmaps();
+use Apache::lonenc();
use HTML::Entities();
my %selhash;
@@ -205,13 +207,105 @@
$r->send_http_header;
return OK;
}
-
+
+ my $requrl=$r->uri;
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
- ['forceselect','launch']);
+ ['forceselect','launch','navmap']);
+
+ if (($env{'request.course.fn'}) && ($env{'form.navmap'}) && ($env{'request.course.id'})) {
+ my $crstype = &Apache::loncommon::course_type();
+ unless (($crstype eq 'Placement') && (!$env{'request.role.adv'})) {
+
+ # Check for critical messages and redirect if present.
+ my ($redirect,$url) = &Apache::loncommon::critical_redirect(300,'contents');
+ if ($redirect) {
+ &Apache::loncommon::content_type($r,'text/html');
+ $r->header_out(Location => $url);
+ return REDIRECT;
+ }
+
+ # Check if course needs to be re-initialized
+ my $loncaparev = $r->dir_config('lonVersion');
+ my ($result, at reinit) = &Apache::loncommon::needs_coursereinit($loncaparev);
+
+ if ($result eq 'switch') {
+ &Apache::loncommon::content_type($r,'text/html');
+ $r->send_http_header;
+ $r->print(&Apache::loncommon::check_release_result(@reinit));
+ return OK;
+ } elsif ($result eq 'update') {
+ my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
+ my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
+ my ($furl,$ferr) = &Apache::lonuserstate::readmap("$cdom/$cnum");
+ if ($ferr) {
+ my $requrl = $r->uri;
+ $env{'user.error.msg'}="$requrl:bre:0:0:Course not initialized";
+ $env{'user.reinit'} = 1;
+ return HTTP_NOT_ACCEPTABLE;
+ }
+ }
+
+ # Create the nav map
+ my $navmap = Apache::lonnavmaps::navmap->new();
+
+ if (ref($navmap)) {
+ # renderer call
+ if (&Apache::lonnet::is_on_map($requrl)) {
+ my $mapurl = &Apache::lonnet::declutter($requrl);
+ my @crumbs = ({text => $crstype.' Contents',
+ href => "javascript:gopost('/adm/navmaps','')"});
+ my $res = $navmap->getResourceByUrl($mapurl);
+ if (ref($res)) {
+ my ($parent) = &Apache::lonnet::decode_symb($res->symb());
+ if ($parent ne $env{'course.'.$env{'request.course.id'}.'.url'}) {
+ my @mapcrumbs = $navmap->recursed_crumbs($parent);
+ if (@mapcrumbs) {
+ push(@crumbs, at mapcrumbs);
+ } else {
+ push(@crumbs,{text => '...',
+ no_mt => 1});
+ }
+ }
+ }
+ my $maptitle = &Apache::lonnet::gettitle($mapurl);
+ push(@crumbs,{text => $maptitle, no_mt => 1});
+ my $args = {'bread_crumbs' => \@crumbs,
+ 'bread_crumbs_nomenu' => 1};
+ &Apache::loncommon::content_type($r,'text/html');
+ $r->send_http_header;
+
+ $r->print(&Apache::loncommon::start_page($maptitle,undef,$args));
+
+ my $renderArgs = { 'cols' => [0,1,2,3],
+ 'url' => $mapurl,
+ 'navmap' => $navmap,
+ 'suppressNavmap' => 1,
+ 'suppressEmptySequences' => 1,
+ 'filterFunc' => undef,
+ 'resource_no_folder_link' => 1,
+ 'r' => $r,
+ 'caller' => 'sequence',
+ 'notools' => 1,
+ 'iterator_map' => $mapurl,
+ };
+
+ my $render = &Apache::lonnavmaps::render($renderArgs);
+
+ # If no resources were found let the user know.
+ if ($renderArgs->{'counter'} == 0) {
+ $r->print("<p><span class=\"LC_info\">".
+ &mt("This folder is empty.")."</span></p>");
+ }
+ $r->print(&Apache::loncommon::end_page());
+ $r->rflush();
+ return OK;
+ }
+ }
+ }
+ }
my %hash;
my %bighash;
- my $requrl=$r->uri;
$successtied=0;
# ------------------------------------------------------------ Tie symb db file
More information about the LON-CAPA-cvs
mailing list