[LON-CAPA-cvs] cvs: loncom /interface loncommon.pm lonmenu.pm mydesk.tab

raeburn raeburn at source.lon-capa.org
Fri Apr 27 19:01:06 EDT 2018


raeburn		Fri Apr 27 23:01:06 2018 EDT

  Modified files:              
    /loncom/interface	loncommon.pm lonmenu.pm mydesk.tab 
  Log:
  - Bug 6754 LON-CAPA as LTI Provider
    - No Contents item in inline menu for course if original LTI launch of 
      LON-CAPA was for a resource or map.
    - No Role switcher in inline menu for session launched via LTI (role
      switching should occur in the LTI Consumer). 
  
  
-------------- next part --------------
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.1315 loncom/interface/loncommon.pm:1.1316
--- loncom/interface/loncommon.pm:1.1315	Tue Apr 24 14:05:22 2018
+++ loncom/interface/loncommon.pm	Fri Apr 27 23:01:05 2018
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.1315 2018/04/24 14:05:22 raeburn Exp $
+# $Id: loncommon.pm,v 1.1316 2018/04/27 23:01:05 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -5932,6 +5932,15 @@
             inlineremote items to be added in "Functions" menu below
             breadcrumbs.
 
+=item * $ltiscope, optional argument, will be one of: resource, map or
+            course, if LON-CAPA is in LTI Provider context. Value is
+            the scope of use, i.e., launch was for access to a single, a map
+            or the entire course.
+
+=item * $ltiuri, optional argument, if LON-CAPA is in LTI Provider
+            context, this will contain the URL for the landing item in
+            the course, after launch from an LTI Consumer
+
 =back
 
 Returns: A uniform header for LON-CAPA web pages.  
@@ -5943,7 +5952,7 @@
 
 sub bodytag {
     my ($title,$function,$addentries,$bodyonly,$domain,$forcereg,
-        $no_nav_bar,$bgcolor,$args,$advtoolsref)=@_;
+        $no_nav_bar,$bgcolor,$args,$advtoolsref,$ltiscope,$ltiuri)=@_;
 
     my $public;
     if ((($env{'user.name'} eq 'public') && ($env{'user.domain'} eq 'public'))
@@ -6076,17 +6085,17 @@
         }
         #don't show menus for public users
         if (!$public){
-            $bodytag .= Apache::lonmenu::secondary_menu($httphost);
+            $bodytag .= Apache::lonmenu::secondary_menu($httphost,$ltiscope);
             $bodytag .= Apache::lonmenu::serverform();
             $bodytag .= Apache::lonhtmlcommon::scripttag('', 'end');
             if ($env{'request.state'} eq 'construct') {
                 $bodytag .= &Apache::lonmenu::innerregister($forcereg,
-                                $args->{'bread_crumbs'},'','',$hostname);
+                                $args->{'bread_crumbs'},'','',$hostname,$ltiscope,$ltiuri);
             } elsif ($forcereg) {
                 $bodytag .= &Apache::lonmenu::innerregister($forcereg,undef,
                                                             $args->{'group'},
                                                             $args->{'hide_buttons'},
-                                                            $hostname);
+                                                            $hostname,$ltiscope,$ltiuri);
             } else {
                 $bodytag .= 
                     &Apache::lonmenu::prepare_functions($env{'request.noversionuri'},
@@ -8688,11 +8697,17 @@
     #&Apache::lonnet::logthis("start_page ".join(':',caller(0)));
 
     $env{'internal.start_page'}++;
-    my ($result, at advtools);
+    my ($result, at advtools,$ltiscope,$ltiuri);
 
     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'})) {
+        ($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'});
+    }
     
     if (! exists($args->{'skip_phases'}{'body'}) ) {
 	if ($args->{'frameset'}) {
@@ -8706,7 +8721,7 @@
                          $args->{'only_body'},      $args->{'domain'},
                          $args->{'force_register'}, $args->{'no_nav_bar'},
                          $args->{'bgcolor'},        $args,
-                         \@advtools);
+                         \@advtools,$ltiscope,$ltiuri);
         }
     }
 
@@ -8739,12 +8754,6 @@
                 if (@advtools > 0) {
                     &Apache::lonmenu::advtools_crumbs(@advtools);
                 }
-                my $ltiscope;
-                if (($env{'request.course.id'}) && ($env{'request.lti.login'})) {
-                    my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
-                    my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
-                    ($ltiscope) = &LONCAPA::ltiutils::lti_provider_scope($env{'request.lti.uri'},$cdom,$cnum);
-                }
                 my $menulink;
                 # if arg: bread_crumbs_nomenu is true pass 0 as $menulink item.
                 if ((exists($args->{'bread_crumbs_nomenu'})) ||
Index: loncom/interface/lonmenu.pm
diff -u loncom/interface/lonmenu.pm:1.489 loncom/interface/lonmenu.pm:1.490
--- loncom/interface/lonmenu.pm:1.489	Fri Apr 27 22:07:11 2018
+++ loncom/interface/lonmenu.pm	Fri Apr 27 23:01:05 2018
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Routines to control the menu
 #
-# $Id: lonmenu.pm,v 1.489 2018/04/27 22:07:11 raeburn Exp $
+# $Id: lonmenu.pm,v 1.490 2018/04/27 23:01:05 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -384,7 +384,7 @@
 }
 
 sub secondary_menu {
-    my ($httphost) = @_;
+    my ($httphost,$ltiscope) = @_;
     my $menu;
 
     my $crstype = &Apache::loncommon::course_type();
@@ -495,6 +495,8 @@
                 && !$author;
         next if    $$menuitem[4]    eq 'cca'
                 && !$canmodifycoauthor;
+        next if    $$menuitem[4]    eq 'notltimapres'
+                && (($ltiscope eq 'resource') || ($ltiscope eq 'map'));
 
         my $title = $menuitem->[3];
         if (defined($secondary_submenu{$title})) {
@@ -532,13 +534,15 @@
             }
         } elsif ($$menuitem[3] eq 'Roles' && $env{'request.course.id'}) {
             # special treatment for role selector
-            ($roleswitcher_js,$roleswitcher_form,my $switcher) =
-                &roles_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;
+                    );
+                $menu .= $switcher;
+            }
         } else {
             if ($$menuitem[3] eq 'Syllabus' && $env{'request.course.id'}) {
                 my $url = $$menuitem[0];
@@ -700,7 +704,7 @@
 }
 
 sub innerregister {
-    my ($forcereg,$bread_crumbs,$group,$pagebuttonshide,$hostname) = @_;
+    my ($forcereg,$bread_crumbs,$group,$pagebuttonshide,$hostname,$ltiscope,$ltiuri) = @_;
     my $const_space = ($env{'request.state'} eq 'construct');
     my $is_const_dir = 0;
 
@@ -710,18 +714,13 @@
 
     undef(@inlineremote);
 
-    my ($mapurl,$resurl,$crstype,$navmap,$ltiscope,$ltiuri);
+    my ($mapurl,$resurl,$crstype,$navmap);
 
     if ($env{'request.course.id'}) {
 #
 #course_type:  Course, Community, or Placement
 #
         $crstype = &Apache::loncommon::course_type();
-        if (($env{'request.lti.login'}) && ($env{'request.lti.uri'})) {
-            my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
-            my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
-            ($ltiscope,$ltiuri) = &LONCAPA::ltiutils::lti_provider_scope($env{'request.lti.uri'},$cdom,$cnum);
-        }
         if ($env{'request.symb'}) {
             my $ignorenull;
             unless ($env{'request.noversionuri'} eq '/adm/navmaps') {
Index: loncom/interface/mydesk.tab
diff -u loncom/interface/mydesk.tab:1.178 loncom/interface/mydesk.tab:1.179
--- loncom/interface/mydesk.tab:1.178	Fri Apr 27 22:07:11 2018
+++ loncom/interface/mydesk.tab	Fri Apr 27 23:01:05 2018
@@ -1,4 +1,4 @@
-# $Id: mydesk.tab,v 1.178 2018/04/27 22:07:11 raeburn Exp $
+# $Id: mydesk.tab,v 1.179 2018/04/27 23:01:05 raeburn Exp $
 # primary menu links
 # Apache::lonmenu::primary_menu() generates a menu from these elements
 # prim: item belongs to primary menu
@@ -78,8 +78,9 @@
 #   - 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
-scnd:/adm/navmaps?postdata=[url]&postsymb=[symb]:::Contents:
+scnd:/adm/navmaps?postdata=[url]&postsymb=[symb]:::Contents:notltimapres
 scnd:/adm/whatsnew:::What's New:whn
 scnd:/adm/quickgrades:::Grades:nvgr
 scnd:[javascript]chat_win();:::Chat:plc


More information about the LON-CAPA-cvs mailing list