[LON-CAPA-cvs] cvs: loncom /interface loncommon.pm lonmenu.pm mydesk.tab
raeburn
raeburn at source.lon-capa.org
Tue May 8 16:30:13 EDT 2018
raeburn Tue May 8 20:30:13 2018 EDT
Modified files:
/loncom/interface mydesk.tab lonmenu.pm loncommon.pm
Log:
- Bug 6754 LON-CAPA as LTI Provider
- For session launched by LTI Consumer, presence/contents of top line &
second line menus determined by domain and/or course configuration.
-------------- next part --------------
Index: loncom/interface/mydesk.tab
diff -u loncom/interface/mydesk.tab:1.180 loncom/interface/mydesk.tab:1.181
--- loncom/interface/mydesk.tab:1.180 Tue May 1 12:40:06 2018
+++ loncom/interface/mydesk.tab Tue May 8 20:30:12 2018
@@ -1,4 +1,4 @@
-# $Id: mydesk.tab,v 1.180 2018/05/01 12:40:06 raeburn Exp $
+# $Id: mydesk.tab,v 1.181 2018/05/08 20:30:12 raeburn Exp $
# primary menu links
# Apache::lonmenu::primary_menu() generates a menu from these elements
# prim: item belongs to primary menu
@@ -8,13 +8,15 @@
# text: link text
# condition: when to show link, primary_menu will act upon this
# possible conditions:
-# - empty: link is displayed if user is authenticated
-# - public: display link if user is public or authenticated
+# - empty: link is displayed if user is authenticated (unless excluded by LTI)
+# - public: display link if user is public or authenticated (unless excluded by LTI)
# - onlypublic: only show this link to public users
-# - newmsg: only display if there are new messages
-# - nonewmsg: only display if there aren't any new messages
-# - roles: show Roles instead of Courses
-# - courses: show Courses instead of Roles
+# - newmsg: only display if there are new messages (unless excluded by LTI)
+# - nonewmsg: only display if there aren't any new messages (unless excluded by LTI)
+# - roles: show Roles instead of Courses (unless LTI)
+# - courses: show Courses instead of Roles (unless LTI)
+# - notlti: not LTI launch
+# - ltiexc: link shown unless LTI config excludes display
# position: where link is to be displayed
# possible positions:
# - empty (will be displayed on right side -- default location).
@@ -22,7 +24,7 @@
# prim:link:icon:alt:text:condition:position
prim::::Personal::left
prim:/adm/about.html:/adm/lonIcons/minilogo.gif:LON-CAPA Logo:About:public:
-prim:/adm/menu:::Home::
+prim:/adm/menu:::Home:notlti:
prim:/adm/communicate:::Messages:nonewmsg:
prim:/adm/communicate:::New Messages:newmsg:
prim:/adm/roles:::Roles:roles:
@@ -30,7 +32,7 @@
prim:/adm/helpdesk:::Help:onlypublic:
prim:/adm/roles:::Log In:onlypublic:
prim::::Help::
-prim:/adm/logout:::Logout::
+prim:/adm/logout:::Logout:ltiexc:
# primary sub-menu links
# Apache::lonmenu::primary_menu() generates a sub-menus from these elements
@@ -42,7 +44,7 @@
# possible conditions:
# - empty: link displayed if user is authenticated
# - portfolio: link displayed if portfolio access
-# - blogs: link displayed if blog access
+# - blog: link displayed if blog access
# - wishlist: link displayed if user has privileges to use Stored Links
# - reqcrs: link displayed if user can request Course or Community creation
# primsub:parent:link:text:condition
@@ -78,8 +80,11 @@
# - mgr: Manage grades
# - author: authors (au, ca, aa)
# - cca: Grant/revoke role of co-author (author only)
-# - notltimapres: course context and not LTI launch for specific map or resource
-# prim:link:icon:alt:text:condition
+# - lti: LTI launch -- LTI-specific rules apply
+# - notlti: not LTI launch
+# - notltimapres: not LTI launch for specific map or resource
+# scnd:link:icon:alt:text:condition
+scnd::::Personal:lti
scnd:/adm/navmaps?postdata=[url]&postsymb=[symb]:::Contents:notltimapres
scnd:/adm/whatsnew:::What's New:whn
scnd:/adm/quickgrades:::Grades:nvgr
@@ -93,11 +98,15 @@
scnd::::Public:crsedit
scnd:/public/[cdom]/[cnum]/syllabus:::Syllabus:showsyllabus
scnd:/adm/[cdom]/[cnum]/_rss.html:::Feeds:showfeeds
-scnd:/adm/roles:::Roles:
+scnd:/adm/roles:::Roles:notlti
+scnd:/adm/communicate:::Messages:lti
+scnd::::Help:lti
+scnd:/adm/logout:::Logout:lti
scnd:/priv/[udom]/[uname]/:::Authoring Space:author
scnd:/res/[udom]/[uname]/?launch=1:::Browse:author
scnd:/adm/createuser:::People:cca
scnd::::Settings:author
+scnd:[javascript]open_aboutLC();:/adm/lonIcons/minilogo.gif:LON-CAPA Logo:About:lti
# secondary sub-menu links
# Apache::lonmenu::secondary_menu() generates a sub-menus from these elements
@@ -114,7 +123,16 @@
# - mgr: link displayed if user can manage grades
# - viewusers: link displayed if user can either grant/revoke student/member roles or view classlists
# - vcg: link displayed if user can view groups to which he/she does not belong
+# - lti: LTI launch -- LTI-specific rules apply
+# - lti(portfolio,wishlist,blog): LTI launch -- LTI-specific rules apply in
+# addition to access rule for tool itself (portfolio, wishlist or blog)
# scndsub:parent:link:text:condition
+scndsub:Personal:/adm/[domain]/[user]/aboutme:Information:lti
+scndsub:Personal:/adm/preferences:Preferences:lti
+scndsub:Personal:/adm/portfolio:Portfolio:ltiportfolio
+scndsub:Personal:/adm/wishlist:Stored Links:ltiwishlist
+scndsub:Personal:/adm/announcements:Calendar:lti
+scndsub:Personal:/adm/[domain]/[user]/_rss.html:Feeds:ltiblog
scndsub:Grades:/adm/statistics?reportSelected=student_assessment:Assessment Chart:vgr
scndsub:Grades:/adm/statistics:Statistics and Reports:vgr
scndsub:Grades:/adm/classcalc:Spreadsheet:vgr
Index: loncom/interface/lonmenu.pm
diff -u loncom/interface/lonmenu.pm:1.490 loncom/interface/lonmenu.pm:1.491
--- loncom/interface/lonmenu.pm:1.490 Fri Apr 27 23:01:05 2018
+++ loncom/interface/lonmenu.pm Tue May 8 20:30:12 2018
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Routines to control the menu
#
-# $Id: lonmenu.pm,v 1.490 2018/04/27 23:01:05 raeburn Exp $
+# $Id: lonmenu.pm,v 1.491 2018/05/08 20:30:12 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -247,8 +247,8 @@
# @primary_menu is filled within the BEGIN block of this module with
# entries from mydesk.tab
sub primary_menu {
- my ($crstype) = @_;
- my (%menu);
+ my ($crstype,$ltimenu) = @_;
+ my (%menu,%ltiexc);
# each element of @primary contains following array:
# (link url, icon path, alt text, link text, condition, position)
my $public;
@@ -265,9 +265,17 @@
my %roles_in_env;
$rolecount = &Apache::lonroles::roles_from_env(\%roles_in_env,$update);
}
- my $ltitarget;
+ my ($lti,$ltitarget);
if ($env{'request.lti.login'}) {
+ $lti = 1;
$ltitarget = $env{'request.lti.target'};
+ if (ref($ltimenu) eq 'HASH') {
+ foreach my $item ('fullname','logout') {
+ unless ($ltimenu->{$item}) {
+ $ltiexc{$item} = 1;
+ }
+ }
+ }
}
foreach my $menuitem (@primary_menu) {
# evaluate conditions
@@ -283,9 +291,15 @@
&& !$public; # only visible to public
# users
next if $$menuitem[4] eq 'roles' ##show links depending on
- && &Apache::loncommon::show_course(); ##term 'Courses' or
- next if $$menuitem[4] eq 'courses' ##'Roles' wanted
- && !&Apache::loncommon::show_course(); ##
+ && (&Apache::loncommon::show_course() ##term 'Courses' or
+ || $env{'request.lti.login'}); ##'Roles' wanted
+ next if $$menuitem[4] eq 'courses' ##and not LTI access
+ && (!&Apache::loncommon::show_course()
+ || !$env{'request.lti.login'});
+ next if $$menuitem[4] eq 'notlti'
+ && $lti;
+ next if $$menuitem[4] eq 'ltiexc'
+ && exists($ltiexc{lc($menuitem->[3])});
my $title = $menuitem->[3];
if (($crstype eq 'Placement') && (!$env{'request.role.adv'})) {
if ($menuitem->[4] eq 'courses') {
@@ -320,7 +334,9 @@
push(@primsub,$item);
}
if ($title eq 'Personal' && $env{'user.name'} && $env{'user.domain'} ) {
- $title = &Apache::loncommon::plainname($env{'user.name'},$env{'user.domain'});
+ unless ($ltiexc{'fullname'}) {
+ $title = &Apache::loncommon::plainname($env{'user.name'},$env{'user.domain'});
+ }
} else {
$title = &mt($title);
}
@@ -384,7 +400,7 @@
}
sub secondary_menu {
- my ($httphost,$ltiscope) = @_;
+ my ($httphost,$ltiscope,$ltimenu,$noprimary) = @_;
my $menu;
my $crstype = &Apache::loncommon::course_type();
@@ -408,7 +424,7 @@
my $canplc = &Apache::lonnet::allowed('plc', $crs_sec);
my $author = &getauthor();
- my ($cdom,$cnum,$showsyllabus,$showfeeds,$showresv,$grouptools);
+ my ($cdom,$cnum,$showsyllabus,$showfeeds,$showresv,$grouptools,$lti,$ltimapres,%ltiexc);
$grouptools = 0;
if ($env{'request.course.id'}) {
$cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
@@ -443,6 +459,19 @@
}
}
}
+ if ($env{'request.lti.login'}) {
+ $lti = 1;
+ if (ref($ltimenu) eq 'HASH') {
+ foreach my $item ('fullname','coursetitle','role','logout','grades') {
+ unless ($ltimenu->{$item}) {
+ $ltiexc{$item} = 1;
+ }
+ }
+ }
+ if (($ltiscope eq 'map') || ($ltiscope eq 'resource')) {
+ $ltimapres = 1;
+ }
+ }
}
my ($canmodifycoauthor);
@@ -453,6 +482,7 @@
$canmodifycoauthor = 1;
}
}
+
my ($roleswitcher_js,$roleswitcher_form,$ltitarget);
if ($env{'request.lti.login'}) {
$ltitarget = $env{'request.lti.target'};
@@ -468,7 +498,7 @@
next if $$menuitem[4] =~ /^crsedit/
&& (!$canedit && !$canvieweditor);
next if $$menuitem[4] eq 'nvgr'
- && $canvgr;
+ && ($canvgr || $ltiexc{'grades'});
next if $$menuitem[4] eq 'vgr'
&& !$canvgr;
next if $$menuitem[4] eq 'viewusers'
@@ -496,7 +526,13 @@
next if $$menuitem[4] eq 'cca'
&& !$canmodifycoauthor;
next if $$menuitem[4] eq 'notltimapres'
- && (($ltiscope eq 'resource') || ($ltiscope eq 'map'));
+ && $ltimapres;
+ next if $$menuitem[4] eq 'notlti'
+ && $lti;
+ next if $$menuitem[4] eq 'lti'
+ && (!$lti || !$noprimary);
+ next if $$menuitem[3] eq 'Logout'
+ && $ltiexc{'logout'};
my $title = $menuitem->[3];
if (defined($secondary_submenu{$title})) {
@@ -523,9 +559,21 @@
next if ($item->[2] eq 'params' && !$canmodpara && !$canviewpara);
next if ($item->[2] eq 'author' && !$author);
next if ($item->[2] eq 'cca' && !$canmodifycoauthor);
+ next if ($item->[2] eq 'lti' && !$lti);
+ if ($item->[2] =~ /^lti(portfolio|wishlist|blog)$/) {
+ my $tool = $1;
+ next if !$lti;
+ next if (!&Apache::lonnet::usertools_access('','',$tool,
+ undef,'tools'));
+ }
push(@scndsub,$item);
}
}
+ if ($title eq 'Personal' && $env{'user.name'} && $env{'user.domain'} ) {
+ unless ($ltiexc{'fullname'}) {
+ $title = &Apache::loncommon::plainname($env{'user.name'},$env{'user.domain'});
+ }
+ }
if (@scndsub > 0) {
$menu .= &create_submenu($link,$target,$title,\@scndsub,1);
} elsif ($link ne '#') {
@@ -534,15 +582,16 @@
}
} elsif ($$menuitem[3] eq 'Roles' && $env{'request.course.id'}) {
# special treatment for role selector
- unless ($env{'request.lti.login'}) {
- ($roleswitcher_js,$roleswitcher_form,my $switcher) =
- &roles_selector(
- $env{'course.' . $env{'request.course.id'} . '.domain'},
- $env{'course.' . $env{'request.course.id'} . '.num'},
- $httphost,$ltitarget
- );
- $menu .= $switcher;
- }
+ ($roleswitcher_js,$roleswitcher_form,my $switcher) =
+ &roles_selector(
+ $env{'course.' . $env{'request.course.id'} . '.domain'},
+ $env{'course.' . $env{'request.course.id'} . '.num'},
+ $httphost,$ltitarget
+ );
+ $menu .= $switcher;
+ } elsif ($$menuitem[3] eq 'Help') { # special treatment for helplink
+ next if ($crstype eq 'Placement');
+ $menu .= '<li>'.&Apache::loncommon::top_nav_help('Help').'</li>';
} else {
if ($$menuitem[3] eq 'Syllabus' && $env{'request.course.id'}) {
my $url = $$menuitem[0];
@@ -589,7 +638,7 @@
}
$menu =~ s/\[uname\]/$$author{user}/g;
$menu =~ s/\[udom\]/$$author{dom}/g;
- $menu =~ s/\[javascript\]/javascript:/;
+ $menu =~ s/\[javascript\]/javascript:/g;
if ($env{'request.course.id'}) {
$menu =~ s/\[cnum\]/$cnum/g;
$menu =~ s/\[cdom\]/$cdom/g;
@@ -2235,6 +2284,18 @@
'height=500,width=600,resizable=yes,location=no,menubar=no,toolbar=no,scrollbars=yes');
}
+function open_aboutLC() {
+ var isMobile = "$env{'browser.mobile'}";
+ var url = '/adm/about.html';
+ if (isMobile == 1) {
+ openMyModal(url,600,400,'yes');
+ } else {
+ window.open(url,"aboutLONCAPA","height=400,width=600,scrollbars=1,resizable=1,menubar=0,location=1");
+ }
+ return;
+}
+
+
(function (\$) {
\$(document).ready(function () {
\$.single=function(a){return function(b){a[0]=b;return a}}(\$([1]));
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.1317 loncom/interface/loncommon.pm:1.1318
--- loncom/interface/loncommon.pm:1.1317 Tue May 1 13:30:49 2018
+++ loncom/interface/loncommon.pm Tue May 8 20:30:12 2018
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# a pile of common routines
#
-# $Id: loncommon.pm,v 1.1317 2018/05/01 13:30:49 raeburn Exp $
+# $Id: loncommon.pm,v 1.1318 2018/05/08 20:30:12 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -5941,6 +5941,10 @@
context, this will contain the URL for the landing item in
the course, after launch from an LTI Consumer
+=item * $ltimenu, optional argument, if LON-CAPA is in LTI Provider
+ context, this will contain a reference to hash of items
+ to be included in the page header and/or inline menu.
+
=back
Returns: A uniform header for LON-CAPA web pages.
@@ -5952,7 +5956,7 @@
sub bodytag {
my ($title,$function,$addentries,$bodyonly,$domain,$forcereg,
- $no_nav_bar,$bgcolor,$args,$advtoolsref,$ltiscope,$ltiuri)=@_;
+ $no_nav_bar,$bgcolor,$args,$advtoolsref,$ltiscope,$ltiuri,$ltimenu)=@_;
my $public;
if ((($env{'user.name'} eq 'public') && ($env{'user.domain'} eq 'public'))
@@ -6023,7 +6027,18 @@
if ($public) {
undef($role);
}
-
+
+ if (($env{'request.course.id'}) && ($env{'request.lti.login'})) {
+ if (ref($ltimenu) eq 'HASH') {
+ unless ($ltimenu->{'role'}) {
+ undef($role);
+ }
+ unless ($ltimenu->{'coursetitle'}) {
+ $realm=' ';
+ }
+ }
+ }
+
my $titleinfo = '<h1>'.$title.'</h1>';
#
# Extra info if you are the DC
@@ -6057,27 +6072,29 @@
$bodytag .= Apache::lonhtmlcommon::scripttag(
Apache::lonmenu::utilityfunctions($httphost), 'start');
- my ($left,$right) = Apache::lonmenu::primary_menu($crstype);
+ unless ($args->{'no_primary_menu'}) {
+ my ($left,$right) = Apache::lonmenu::primary_menu($crstype,$ltimenu);
- if ($env{'request.noversionuri'} =~ m{^/res/adm/pages/}) {
- if ($dc_info) {
- $dc_info = qq|<span class="LC_cusr_subheading">$dc_info</span>|;
- }
- $bodytag .= qq|<div id="LC_nav_bar">$left $role<br />
- <em>$realm</em> $dc_info</div>|;
- return $bodytag;
- }
+ if ($env{'request.noversionuri'} =~ m{^/res/adm/pages/}) {
+ if ($dc_info) {
+ $dc_info = qq|<span class="LC_cusr_subheading">$dc_info</span>|;
+ }
+ $bodytag .= qq|<div id="LC_nav_bar">$left $role<br />
+ <em>$realm</em> $dc_info</div>|;
+ return $bodytag;
+ }
- unless ($env{'request.symb'} =~ m/\.page___\d+___/) {
- $bodytag .= qq|<div id="LC_nav_bar">$left $role</div>|;
- }
+ unless ($env{'request.symb'} =~ m/\.page___\d+___/) {
+ $bodytag .= qq|<div id="LC_nav_bar">$left $role</div>|;
+ }
- $bodytag .= $right;
+ $bodytag .= $right;
- if ($dc_info) {
- $dc_info = &dc_courseid_toggle($dc_info);
+ if ($dc_info) {
+ $dc_info = &dc_courseid_toggle($dc_info);
+ }
+ $bodytag .= qq|<div id="LC_realm">$realm $dc_info</div>|;
}
- $bodytag .= qq|<div id="LC_realm">$realm $dc_info</div>|;
#if directed to not display the secondary menu, don't.
if ($args->{'no_secondary_menu'}) {
@@ -6085,7 +6102,10 @@
}
#don't show menus for public users
if (!$public){
- $bodytag .= Apache::lonmenu::secondary_menu($httphost,$ltiscope);
+ unless ($args->{'no_inline_menu'}) {
+ $bodytag .= Apache::lonmenu::secondary_menu($httphost,$ltiscope,$ltimenu,
+ $args->{'no_primary_menu'});
+ }
$bodytag .= Apache::lonmenu::serverform();
$bodytag .= Apache::lonhtmlcommon::scripttag('', 'end');
if ($env{'request.state'} eq 'construct') {
@@ -8697,13 +8717,38 @@
#&Apache::lonnet::logthis("start_page ".join(':',caller(0)));
$env{'internal.start_page'}++;
- my ($result, at advtools,$ltiscope,$ltiuri);
+ my ($result, at advtools,$ltiscope,$ltiuri,%ltimenu);
if (! exists($args->{'skip_phases'}{'head'}) ) {
$result .= &xml_begin($args->{'frameset'}) . &headtag($title, $head_extra, $args);
}
if (($env{'request.course.id'}) && ($env{'request.lti.login'})) {
+ if ($env{'course.'.$env{'request.course.id'}.'.lti.override'}) {
+ unless ($env{'course.'.$env{'request.course.id'}.'.lti.topmenu'}) {
+ $args->{'no_primary_menu'} = 1;
+ }
+ unless ($env{'course.'.$env{'request.course.id'}.'.lti.inlinemenu'}) {
+ $args->{'no_inline_menu'} = 1;
+ }
+ if ($env{'course.'.$env{'request.course.id'}.'.lti.lcmenu'}) {
+ map { $ltimenu{$_} = 1; } split(/,/,$env{'course.'.$env{'request.course.id'}.'.lti.lcmenu'});
+ }
+ } else {
+ my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
+ my %lti = &Apache::lonnet::get_domain_lti($cdom,'provider');
+ if (ref($lti{$env{'request.lti.login'}}) eq 'HASH') {
+ unless ($lti{$env{'request.lti.login'}}{'topmenu'}) {
+ $args->{'no_primary_menu'} = 1;
+ }
+ unless ($lti{$env{'request.lti.login'}}{'inlinemenu'}) {
+ $args->{'no_inline_menu'} = 1;
+ }
+ if (ref($lti{$env{'request.lti.login'}}{'lcmenu'}) eq 'ARRAY') {
+ map { $ltimenu{$_} = 1; } @{$lti{$env{'request.lti.login'}}{'lcmenu'}};
+ }
+ }
+ }
($ltiscope,$ltiuri) = &LONCAPA::ltiutils::lti_provider_scope($env{'request.lti.uri'},
$env{'course.'.$env{'request.course.id'}.'.domain'},
$env{'course.'.$env{'request.course.id'}.'.num'});
@@ -8721,7 +8766,7 @@
$args->{'only_body'}, $args->{'domain'},
$args->{'force_register'}, $args->{'no_nav_bar'},
$args->{'bgcolor'}, $args,
- \@advtools,$ltiscope,$ltiuri);
+ \@advtools,$ltiscope,$ltiuri,\%ltimenu);
}
}
More information about the LON-CAPA-cvs
mailing list