[LON-CAPA-cvs] cvs: loncom /interface domainprefs.pm lonconfigsettings.pm lonexttool.pm

raeburn raeburn at source.lon-capa.org
Sun Dec 31 20:29:39 EST 2017


raeburn		Mon Jan  1 01:29:39 2018 EDT

  Modified files:              
    /loncom/interface	domainprefs.pm lonconfigsettings.pm lonexttool.pm 
  Log:
  - Bug 6754 LON-CAPA as LTI Consumer
    Domain configuration for information sent to Tool Provider on launch
    includes choice of: username, or username:domain in LON-CAPA,
    when "User" is included in the data to be sent (as lis_person_sourcedid).
  
  
-------------- next part --------------
Index: loncom/interface/domainprefs.pm
diff -u loncom/interface/domainprefs.pm:1.323 loncom/interface/domainprefs.pm:1.324
--- loncom/interface/domainprefs.pm:1.323	Sat Dec 30 14:03:53 2017
+++ loncom/interface/domainprefs.pm	Mon Jan  1 01:29:38 2018
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to set domain-wide configuration settings
 #
-# $Id: domainprefs.pm,v 1.323 2017/12/30 14:03:53 raeburn Exp $
+# $Id: domainprefs.pm,v 1.324 2018/01/01 01:29:38 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -2712,6 +2712,19 @@
             }
         }
     }
+    if (setting == 'user') {
+        divid = 'ltitools_'+setting+'_div_'+item;
+        var checkid = 'ltitools_'+setting+'_field_'+item;
+        if (document.getElementById(divid)) {
+            if (document.getElementById(checkid)) {
+                if (document.getElementById(checkid).checked) {
+                    document.getElementById(divid).style.display = 'inline-block';
+                } else {
+                    document.getElementById(divid).style.display = 'none';
+                }
+            }
+        }
+    }
     return;
 }
 // ]]>
@@ -4106,7 +4119,7 @@
     my %lt = &ltitools_names();
     my @courseroles = ('cc','in','ta','ep','st');
     my @ltiroles = qw(Instructor ContentDeveloper TeachingAssistant Learner);
-    my @fields = ('fullname','firstname','lastname','email','user','roles');
+    my @fields = ('fullname','firstname','lastname','email','roles','user');
     if (keys(%ordered)) {
         my @items = sort { $a <=> $b } keys(%ordered);
         for (my $i=0; $i<@items; $i++) {
@@ -4253,11 +4266,12 @@
                 $datatable .= '<input type="file" name="ltitools_image_'.$i.'" value="" />';
             }
             $datatable .= '</span></fieldset>';
-            my (%checkedfields,%rolemaps);
+            my (%checkedfields,%rolemaps,$userincdom);
             if (ref($settings->{$item}) eq 'HASH') {
                 if (ref($settings->{$item}->{'fields'}) eq 'HASH') {
                     %checkedfields = %{$settings->{$item}->{'fields'}};
                 }
+                $userincdom = $settings->{$item}->{'incdom'};
                 if (ref($settings->{$item}->{'roles'}) eq 'HASH') {
                     %rolemaps = %{$settings->{$item}->{'roles'}};
                     $checkedfields{'roles'} = 1;
@@ -4265,16 +4279,40 @@
             }
             $datatable .= '<fieldset><legend>'.&mt('User data sent on launch').'</legend>'.
                           '<span class="LC_nobreak">';
+            my $userfieldstyle = 'display:none;';
+            my $seluserdom = '';
+            my $unseluserdom = ' selected="selected"';
             foreach my $field (@fields) {
-                my $checked;
+                my ($checked,$onclick,$id,$spacer);
                 if ($checkedfields{$field}) {
                     $checked = ' checked="checked"';
                 }
+                if ($field eq 'user') {
+                    $id = ' id="ltitools_user_field_'.$i.'"';
+                    $onclick = ' onclick="toggleLTITools(this.form,'."'$field','$i'".')"';
+                    if ($checked) {
+                        $userfieldstyle = 'display:inline-block';
+                        if ($userincdom) {
+                            $seluserdom = $unseluserdom;
+                            $unseluserdom = '';
+                        }
+                    }
+                } else {
+                    $spacer = (' ' x2);
+                }
                 $datatable .= '<label>'.
-                              '<input type="checkbox" name="ltitools_fields_'.$i.'" value="'.$field.'"'.$checked.' />'.
-                              $lt{$field}.'</label>'.(' ' x2);
+                              '<input type="checkbox" name="ltitools_fields_'.$i.'" value="'.$field.'"'.$id.$checked.$onclick.' />'.
+                              $lt{$field}.'</label>'.$spacer;
             }
-            $datatable .= '</span></fieldset>'.
+            $datatable .= '</span>';
+            $datatable .= '<div style="'.$userfieldstyle.'" id="ltitools_user_div_'.$i.'">'.
+                          '<span class="LC_nobreak"> : '.
+                          '<select name="ltitools_userincdom_'.$i.'">'.
+                          '<option value="">'.&mt('Select').'</option>'.
+                          '<option value="0"'.$unseluserdom.'>'.&mt('username').'</option>'.
+                          '<option value="1"'.$seluserdom.'>'.&mt('username:domain').'</option>'.
+                          '</select></span></div>';
+            $datatable .= '</fieldset>'.
                           '<fieldset><legend>'.&mt('Role mapping').'</legend><table><tr>';
             foreach my $role (@courseroles) {
                 my ($selected,$selectnone);
@@ -4426,12 +4464,26 @@
                   '<fieldset><legend>'.&mt('User data sent on launch').'</legend>'.
                   '<span class="LC_nobreak">';
     foreach my $field (@fields) {
+        my ($id,$onclick,$spacer);
+        if ($field eq 'user') {
+            $id = ' id="ltitools_user_field_add"';
+            $onclick = ' onclick="toggleLTITools(this.form,'."'$field','add'".')"';
+        } else {
+            $spacer = (' ' x2);
+        }
         $datatable .= '<label>'.
-                      '<input type="checkbox" name="ltitools_add_fields" value="'.$field.'" />'.
-                      $lt{$field}.'</label>'.(' ' x2);
+                      '<input type="checkbox" name="ltitools_add_fields" value="'.$field.'"'.$id.$onclick.' />'.
+                      $lt{$field}.'</label>'.$spacer;
     }
-    $datatable .= '</span></fieldset>'.
-                  '<fieldset><legend>'.&mt('Role mapping').'</legend><table><tr>';
+    $datatable .= '</span>'.
+                  '<div style="display:none;" id="ltitools_user_div_add">'.
+                  '<span class="LC_nobreak"> : '.
+                  '<select name="ltitools_userincdom_add">'.
+                  '<option value="" selected="selected">'.&mt('Select').'</option>'.
+                  '<option value="0">'.&mt('username').'</option>'.
+                  '<option value="1">'.&mt('username:domain').'</option>'.
+                  '</select></span></div></fieldset>';
+    $datatable .= '<fieldset><legend>'.&mt('Role mapping').'</legend><table><tr>';
     foreach my $role (@courseroles) {
         my ($checked,$checkednone);
         $datatable .= '<td style="text-align: center">'.
@@ -4475,7 +4527,7 @@
                                           'lifetime'       => 'Nonce lifetime (s)',
                                           'secret'         => 'Secret',
                                           'icon'           => 'Icon',   
-                                          'user'           => 'Username:domain',
+                                          'user'           => 'User',
                                           'fullname'       => 'Full Name',
                                           'firstname'      => 'First Name',
                                           'lastname'       => 'Last Name',
@@ -10750,6 +10802,13 @@
                     }
                 }
             }
+            if (ref($confhash{$newid}{'fields'}) eq 'HASH') {
+                if ($confhash{$newid}{'fields'}{'user'}) {
+                    if ($env{'form.ltitools_userincdom_add'}) {
+                        $confhash{$newid}{'incdom'} = 1;
+                    }
+                }
+            }
             my @courseconfig = &Apache::loncommon::get_env_multiple('form.ltitools_courseconfig');
             foreach my $item (@courseconfig) {
                 $confhash{$newid}{'crsconf'}{$item} = 1;
@@ -10939,6 +10998,16 @@
                             }
                         }
                     }
+                    if (ref($confhash{$itemid}{'fields'}) eq 'HASH') {
+                        if ($confhash{$itemid}{'fields'}{'user'}) {
+                            if ($env{'form.ltitools_userincdom_'.$i}) {
+                                $confhash{$itemid}{'incdom'} = 1;
+                            }
+                            if ($domconfig{$action}{$itemid}{'incdom'} ne $confhash{$itemid}{'incdom'}) {
+                                $changes{$itemid} = 1;
+                            }
+                        }
+                    }
                     $allpos[$newpos] = $itemid;
                 }
                 if ($imgdeletions{$itemid}) {
@@ -11149,6 +11218,13 @@
                         }
                         if ($fieldlist) {
                             $fieldlist =~ s/,$//;
+                            if ($confhash{$itemid}{'fields'}{'user'}) {
+                                if ($confhash{$itemid}{'incdom'}) {
+                                    $fieldlist .= ' ('.&mt('username:domain').')';
+                                } else {
+                                    $fieldlist .= ' ('.&mt('username').')';
+                                }
+                            }
                             $resulttext .= '<li>'.&mt('Data sent').':'.$fieldlist.'</li>';
                         }
                     }
Index: loncom/interface/lonconfigsettings.pm
diff -u loncom/interface/lonconfigsettings.pm:1.40 loncom/interface/lonconfigsettings.pm:1.41
--- loncom/interface/lonconfigsettings.pm:1.40	Thu Nov 30 15:15:15 2017
+++ loncom/interface/lonconfigsettings.pm	Mon Jan  1 01:29:38 2018
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to set domain-wide configuration settings
 #
-# $Id: lonconfigsettings.pm,v 1.40 2017/11/30 15:15:15 raeburn Exp $
+# $Id: lonconfigsettings.pm,v 1.41 2018/01/01 01:29:38 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -228,17 +228,19 @@
                                        "toggleLTI(document.display,'sec','$i');";
                         }
                     }
-                } 
+                }
             }
             if (grep(/^ltitools$/, at actions)) {
                 $onload .= "toggleLTITools(document.display,'passback','add');".
-                           "toggleLTITools(document.display,'roster','add');";
+                           "toggleLTITools(document.display,'roster','add');".
+                           "toggleLTITools(document.display,'user','add');";
                 if (ref($values) eq 'HASH') {
                     if (ref($values->{'ltitools'}) eq 'HASH') {
                         my $numltitools = scalar(keys(%{$values->{'ltitools'}}));
                         for (my $i=0; $i<$numltitools; $i++) {
                             $onload .= "toggleLTITools(document.display,'passback','$i');".
-                                       "toggleLTITools(document.display,'roster','$i');";
+                                       "toggleLTITools(document.display,'roster','$i');".
+                                       "toggleLTITools(document.display,'user','$i');";
                         }
                     }
                 }
Index: loncom/interface/lonexttool.pm
diff -u loncom/interface/lonexttool.pm:1.15 loncom/interface/lonexttool.pm:1.16
--- loncom/interface/lonexttool.pm:1.15	Sat Dec 30 19:51:30 2017
+++ loncom/interface/lonexttool.pm	Mon Jan  1 01:29:38 2018
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Launch External Tool Provider (LTI)
 #
-# $Id: lonexttool.pm,v 1.15 2017/12/30 19:51:30 raeburn Exp $
+# $Id: lonexttool.pm,v 1.16 2018/01/01 01:29:38 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -110,10 +110,9 @@
                                            width  => $toolsettings{'width'},
                                            height => $toolsettings{'height'},
                                        };
-                $toolhash{'crslabel'} = $toolsettings{'crslabel'};
-                $toolhash{'crstitle'} = $toolsettings{'crstitle'};
-                $toolhash{'crsappend'} = $toolsettings{'crsappend'};
-                $toolhash{'gradable'} = $toolsettings{'gradable'};
+                foreach my $item (qw(crslabel crstitle crsappend gradable incdom)) {
+                    $toolhash{$item} = $toolsettings{$item};
+                }
                 $is_tool = 1;
             }
         }
@@ -225,7 +224,7 @@
     my ($r,$cnum,$cdom,$idx,$submittext,$toolsref) = @_;
     my ($version,$context_type,$msgtype,$toolname,$passback,$roster,$locale,
         $crslabel,$crstitle,$gradesecret,$rostersecret,%fields,%rolesmap,
-        %display,%custom, at userlangs);
+        %display,%custom, at userlangs,$incdom);
     if (ref($toolsref) eq 'HASH') {
         $version = $toolsref->{'version'};
         $toolname = $toolsref->{'title'};
@@ -234,6 +233,7 @@
         $roster = $toolsref->{'roster'};
         $rostersecret = $toolsref->{'rostersecret'};
         $msgtype = $toolsref->{'messagetype'};
+        $incdom = $toolsref->{'incdom'};
         if (ref($toolsref->{'fields'}) eq 'HASH') {
             %fields = %{$toolsref->{'fields'}};
         }
@@ -403,7 +403,11 @@
         $ltiparams{'lis_person_contact_email_primary'} = $contact_email;
     }
     if ($fields{'user'}) {
-        $ltiparams{'lis_person_sourcedid'} = $uname.':'.$udom;
+        if ($incdom) {
+            $ltiparams{'lis_person_sourcedid'} = $uname.':'.$udom;
+        } else {
+            $ltiparams{'lis_person_sourcedid'} = $uname;
+        }
     }
     if (keys(%custom)) {
         foreach my $key (keys(%custom)) {


More information about the LON-CAPA-cvs mailing list