[LON-CAPA-cvs] cvs: loncom /interface domainprefs.pm loncommon.pm loncoursequeueadmin.pm lonrequestcourse.pm /lti ltiauth.pm

raeburn raeburn at source.lon-capa.org
Tue Nov 23 23:25:03 EST 2021


raeburn		Wed Nov 24 04:25:03 2021 EDT

  Modified files:              
    /loncom/interface	domainprefs.pm loncommon.pm 
                     	loncoursequeueadmin.pm lonrequestcourse.pm 
    /loncom/lti	ltiauth.pm 
  Log:
  - Bug 6754
    - Storing mapping of Consumer course identifier to LON-CAPA courseID
      honors rules for allowable course types, and also general Y/N option for
      any type.
    - When a course is created due to launch from LTI Consumer, course's
      environment.db contains internal.lti set to 1, and extended course type
      is identified as "lti".
  
  
-------------- next part --------------
Index: loncom/interface/domainprefs.pm
diff -u loncom/interface/domainprefs.pm:1.391 loncom/interface/domainprefs.pm:1.392
--- loncom/interface/domainprefs.pm:1.391	Mon Nov 22 23:40:59 2021
+++ loncom/interface/domainprefs.pm	Wed Nov 24 04:25:01 2021
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to set domain-wide configuration settings
 #
-# $Id: domainprefs.pm,v 1.391 2021/11/22 23:40:59 raeburn Exp $
+# $Id: domainprefs.pm,v 1.392 2021/11/24 04:25:01 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -6129,7 +6129,8 @@
     my (%checked,%rolemaps,$crssecsrc,$userfield,$cidfield,$callback);
     $checked{'mapuser'}{'sourcedid'} = ' checked="checked"';
     $checked{'mapcrs'}{'course_offering_sourcedid'} = ' checked="checked"';
-    $checked{'makecrs'}{'N'} = '  checked="checked"';
+    $checked{'storecrs'}{'Y'} = ' checked="checked"';
+    $checked{'makecrs'}{'N'} = ' checked="checked"';
     $checked{'mapcrstype'} = {};
     $checked{'makeuser'} = {};
     $checked{'selfenroll'} = {};
@@ -6187,6 +6188,10 @@
                 $checked{'mapcrstype'}{$type} = ' checked="checked"';
             }
         }
+        if (!$current->{'storecrs'}) {
+            $checked{'storecrs'}{'N'} = $checked{'storecrs'}{'Y'};
+            $checked{'storecrs'}{'Y'} = '';
+        }
         if ($current->{'makecrs'}) {
             $checked{'makecrs'}{'Y'} = '  checked="checked"';
         }
@@ -6294,7 +6299,7 @@
     my $onclicklcauth = ' onclick="toggleLTI(this.form,'."'lcauth','$num'".')"';
     my $onclickmenu = ' onclick="toggleLTI(this.form,'."'lcmenu','$num'".');"';
     my $output = '<fieldset class="ltioption_usr_'.$num.'" style="display:'.$optionsty.'"><legend>'.&mt('Logout options').'</legend>'.
-                 '<div class="LC_floatleft"><span class="LC_nobreak">'.&mt('Callback on logout').': '.
+                 '<div class="LC_floatleft"><span class="LC_nobreak">'.&mt('Callback to logout LON-CAPA on log out from Consumer').': '.
                  '<label><input type="radio" name="lti_callback_'.$num.'" value="0"'.
                  $checked{'callback'}{'N'}.$onclickcallback.' />'.&mt('No').'</label>'.(' 'x2).
                  '<label><input type="radio" name="lti_callback_'.$num.'" value="1"'.
@@ -6382,7 +6387,13 @@
                    $checked{'mapcrstype'}{$type}.' />'.$coursetypetitles{$type}.'</label>'.
                    (' 'x2);
     }
-    $output .= '</span></fieldset>'.
+    $output .= '</span><br /><br />'.
+               '<span class="LC_nobreak">'.&mt('Store mapping of course identifier to LON-CAPA CourseID').': '.
+               '<label><input type="radio" name="lti_storecrs_'.$num.'" value="0"'.
+               $checked{'storecrs'}{'N'}.' />'.&mt('No').'</label>'.(' 'x2).
+               '<label><input type="radio" name="lti_storecrs_'.$num.'" value="1"'.
+               $checked{'storecrs'}{'Y'}.' />'.&mt('Yes').'</label></span>'.
+               '</fieldset>'.
                '<fieldset class="ltioption_crs_'.$num.'" style="display:'.$crssty.'"><legend>'.&mt('Mapping course roles').'</legend><table><tr>';
     foreach my $ltirole (@lticourseroles) {
         my ($selected,$selectnone);
@@ -14775,13 +14786,14 @@
     my @courseroles = ('cc','in','ta','ep','st');
     my @ltiroles = qw(Learner Instructor ContentDeveloper TeachingAssistant Mentor Member Manager Administrator);
     my @lticourseroles = qw(Instructor TeachingAssistant Mentor Learner);
-    my @coursetypes = ('official','unofficial','community','textbook','placement');
+    my @coursetypes = ('official','unofficial','community','textbook','placement','lti');
     my %coursetypetitles = &Apache::lonlocal::texthash (
                                official   => 'Official',
                                unofficial => 'Unofficial',
                                community  => 'Community',
                                textbook   => 'Textbook',
                                placement  => 'Placement Test',
+                               lti        => 'LTI Provider',
     );
     my %fieldtitles = &Apache::loncommon::personal_data_fieldtitles();
     my %lt = &lti_names();
@@ -14939,6 +14951,9 @@
                     }
                 }
                 $confhash{$itemid}{'mapcrstype'} = \@crstypes;
+                if ($env{'form.lti_storecrs_'.$idx}) {
+                    $confhash{$itemid}{'storecrs'} = 1;
+                }       
                 if ($env{'form.lti_makecrs_'.$idx}) {
                     $confhash{$itemid}{'makecrs'} = 1;
                 }
@@ -14983,7 +14998,7 @@
             }
             unless (($idx eq 'add') || ($changes{$itemid})) {
                 if ($confhash{$itemid}{'crsinc'}) {
-                    foreach my $field ('mapcrs','makecrs','section','passback','roster') {
+                    foreach my $field ('mapcrs','storecrs','makecrs','section','passback','roster') {
                         if ($domconfig{$action}{$itemid}{$field} ne $confhash{$itemid}{$field}) {
                             $changes{$itemid} = 1;
                         }
@@ -15145,7 +15160,7 @@
                         if ($confhash{$itemid}{'callback'}) {
                             $resulttext .= '<li>'.&mt('Callback setting').': '.$confhash{$itemid}{'callback'}.'</li>';
                         } else {
-                            $resulttext .= '<li>'.&mt('No callback to logout LON-CAPA session when user logs out of Comsumer').'</li>';
+                            $resulttext .= '<li>'.&mt('Callback to logout LON-CAPA on log out from Consumer').'</li>';
                         }
                         if ($confhash{$itemid}{'mapuser'}) {
                             my $shownmapuser;
@@ -15234,6 +15249,9 @@
                                     $resulttext .= '<li>'.&mt('No mapping to LON-CAPA courses').'</li>';
                                 }
                             }
+                            if ($confhash{$itemid}{'storecrs'}) {
+                                $resulttext .= '<li>'.&mt('Store mapping of course identifier to LON-CAPA CourseID').': '.$confhash{$itemid}{'storecrs'}.'</li>';
+                            }
                             if ($confhash{$itemid}{'makecrs'}) {
                                 $resulttext .= '<li>'.&mt('Instructor may create course (if absent).').'</li>';
                             } else {
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.1370 loncom/interface/loncommon.pm:1.1371
--- loncom/interface/loncommon.pm:1.1370	Wed Nov 17 19:55:15 2021
+++ loncom/interface/loncommon.pm	Wed Nov 24 04:25:01 2021
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.1370 2021/11/17 19:55:15 raeburn Exp $
+# $Id: loncommon.pm,v 1.1371 2021/11/24 04:25:01 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -16452,6 +16452,9 @@
     if ($args->{'crstype'}) {
         $cenv{'type'}=$args->{'crstype'};
     }
+    if ($args->{'lti'}) {
+        $cenv{'internal.lti'}=$args->{'lti'};
+    }
     if ($args->{'crsid'}) {
         $cenv{'courseid'}=$args->{'crsid'};
     }
Index: loncom/interface/loncoursequeueadmin.pm
diff -u loncom/interface/loncoursequeueadmin.pm:1.61 loncom/interface/loncoursequeueadmin.pm:1.62
--- loncom/interface/loncoursequeueadmin.pm:1.61	Tue Jun 15 20:52:26 2021
+++ loncom/interface/loncoursequeueadmin.pm	Wed Nov 24 04:25:02 2021
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Utilities to administer domain course requests and course self-enroll requests
 #
-# $Id: loncoursequeueadmin.pm,v 1.61 2021/06/15 20:52:26 raeburn Exp $
+# $Id: loncoursequeueadmin.pm,v 1.62 2021/11/24 04:25:02 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1713,6 +1713,8 @@
                     my %clonedfrom = &Apache::lonnet::coursedescription($details->{'clonedom'}.'_'.$details->{'clonecrs'});
                     $batchhash{'textbook'} = $clonedfrom{'description'};
                 }
+            } elsif ($details->{'crstype'} eq 'lti') {
+                $batchhash{'lti'} = 1;
             }
             $batchhash{'crstype'} = 'Course';
         }
Index: loncom/interface/lonrequestcourse.pm
diff -u loncom/interface/lonrequestcourse.pm:1.112 loncom/interface/lonrequestcourse.pm:1.113
--- loncom/interface/lonrequestcourse.pm:1.112	Tue Aug 31 17:21:24 2021
+++ loncom/interface/lonrequestcourse.pm	Wed Nov 24 04:25:02 2021
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Request a course
 #
-# $Id: lonrequestcourse.pm,v 1.112 2021/08/31 17:21:24 raeburn Exp $
+# $Id: lonrequestcourse.pm,v 1.113 2021/11/24 04:25:02 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -5226,9 +5226,18 @@
                                                         '',$req_notifylist,[],$domconfig);
     $r->print($output);
     if ($crstype eq 'lti') {
-        my %consumers = &Apache::lonnet::get_dom('lticonsumers',[$env{'form.sourcecrs'}],$dom);
-        if (($env{'form.lti.sourcecrs'} ne '')  && ($consumers{$env{'form.lti.sourcecrs'}} eq '') && ($cnum ne '')) {
-            &Apache::lonnet::put_dom('lticonsumers',{ $env{'form.lti.sourcecrs'} => $cnum },$dom);
+        my $storecrs;
+        if ($env{'request.lti.login'}) {
+            my %lti = &Apache::lonnet::get_domain_lti($dom,'provider');
+            if (ref($lti{$env{'request.lti.login'}}) eq 'HASH') {
+                $storecrs = $lti{$env{'request.lti.login'}}{'storecrs'};
+            }
+        }
+        if ($storecrs) {
+            my %consumers = &Apache::lonnet::get_dom('lticonsumers',[$env{'form.sourcecrs'}],$dom);
+            if (($env{'form.lti.sourcecrs'} ne '')  && ($consumers{$env{'form.lti.sourcecrs'}} eq '') && ($cnum ne '')) {
+                &Apache::lonnet::put_dom('lticonsumers',{ $env{'form.lti.sourcecrs'} => $cnum },$dom);
+            }
         }
     } elsif (&Apache::loncoursequeueadmin::author_prompt()) {
         unless ($customized) {
Index: loncom/lti/ltiauth.pm
diff -u loncom/lti/ltiauth.pm:1.26 loncom/lti/ltiauth.pm:1.27
--- loncom/lti/ltiauth.pm:1.26	Mon Nov 22 23:41:00 2021
+++ loncom/lti/ltiauth.pm	Wed Nov 24 04:25:03 2021
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Basic LTI Authentication Module
 #
-# $Id: ltiauth.pm,v 1.26 2021/11/22 23:41:00 raeburn Exp $
+# $Id: ltiauth.pm,v 1.27 2021/11/24 04:25:03 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -640,7 +640,7 @@
 #
 # If LON-CAPA course is a Community, and LON-CAPA role
 # indicated is cc, change role indicated to co.
-# 
+#
 
     my %crsenv;
     if ($lcroles[0] eq 'cc') {
@@ -745,11 +745,41 @@
     }
 
 #
-# Store consumer-to-LON-CAPA course mapping
+# Retrieve course type of LON-CAPA course to check if mapping from a Consumer
+# course identifier permitted for this type of course (one of: official,
+# unofficial, community, textbook, placement or lti.
+#
+
+    unless (%crsenv) {
+        %crsenv = &Apache::lonnet::coursedescription($cdom.'_'.$cnum);
+    }
+    my $crstype = lc($crsenv{'type'});
+    if ($crstype eq '') {
+        $crstype = 'course';
+    }
+    if ($crstype eq 'course') {
+        if ($crsenv{'internal.coursecode'}) {
+            $crstype = 'official';
+        } elsif ($crsenv{'internal.textbook'}) {
+            $crstype = 'textbook';
+        } elsif ($crsenv{'internal.lti'}) {
+            $crstype = 'lti';
+        } else {
+            $crstype = 'unofficial';
+        }
+    }
+
+#
+# Store consumer-to-LON-CAPA course mapping if permitted
 #
 
-    if (($sourcecrs ne '')  && ($consumers{$sourcecrs} eq '') && ($cnum ne '')) {
-        &Apache::lonnet::put_dom('lticonsumers',{ $sourcecrs => $cnum },$cdom);
+    if (($lti{$itemid}{'storecrs'}) && ($sourcecrs ne '') && 
+        ($consumers{$sourcecrs} eq '') && ($cnum ne '')) {
+        if (ref($lti{$itemid}{'mapcrstype'}) eq 'ARRAY') {
+            if (grep(/^$crstype$/,@{$lti{$itemid}{'mapcrstype'}})) {
+                &Apache::lonnet::put_dom('lticonsumers',{ $sourcecrs => $cnum },$cdom);
+            }
+        }
     }
 
 #


More information about the LON-CAPA-cvs mailing list