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

raeburn raeburn at source.lon-capa.org
Mon May 7 21:48:18 EDT 2018


raeburn		Tue May  8 01:48:18 2018 EDT

  Modified files:              
    /loncom/interface	domainprefs.pm lonconfigsettings.pm 
                     	courseprefs.pm 
  Log:
  - Bug 6754 LON-CAPA as LTI Provider
    - Domain defaults for each Consumer
      - display standard LON-CAPA menus? (top line and/or second line)
      - menu include: fullname, role, context, logout, and/or grades?
    - Course Coordinator can override in course via "Course Settings".
  
  
-------------- next part --------------
Index: loncom/interface/domainprefs.pm
diff -u loncom/interface/domainprefs.pm:1.325 loncom/interface/domainprefs.pm:1.326
--- loncom/interface/domainprefs.pm:1.325	Fri Mar 23 01:01:20 2018
+++ loncom/interface/domainprefs.pm	Tue May  8 01:48:18 2018
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to set domain-wide configuration settings
 #
-# $Id: domainprefs.pm,v 1.325 2018/03/23 01:01:20 raeburn Exp $
+# $Id: domainprefs.pm,v 1.326 2018/05/08 01:48:18 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -2909,6 +2909,35 @@
                 }
             }
         }
+    } else if (setting == 'lcmenu') {
+        var menus = new Array('lti_topmenu_'+item,'lti_inlinemenu_'+item);
+        var divid = 'lti_menufield_'+item;
+        var setvis = '';
+        for (var i=0; i<menus.length; i++) {
+            var radioname = menus[i];  
+            var num = form.elements[radioname].length;
+            if (num) {
+                for (var j=0; j<num; j++) {
+                    if (form.elements[radioname][j].checked) {
+                        if (form.elements[radioname][j].value == '1') {
+                            if (document.getElementById(divid)) {
+                                document.getElementById(divid).style.display = 'inline-block';
+                            }
+                            setvis = 1;
+                            break;
+                        }
+                    }
+                }
+            }
+            if (setvis == 1) {
+                break;
+            }
+        }
+        if (!setvis) {
+            if (document.getElementById(divid)) {
+                document.getElementById(divid).style.display = 'none';
+            }
+        }
     }
     return;
 }
@@ -4693,6 +4722,8 @@
                                           'other'     => 'Other',
                                           'passback'  => 'Can return grades to Consumer:',
                                           'roster'    => 'Can retrieve roster from Consumer:',
+                                          'topmenu'   => 'Display LON-CAPA page header',
+                                          'inlinemenu'=> 'Display LON-CAPA inline menu', 
                                         );
     return %lt;
 }
@@ -4709,6 +4740,7 @@
     $checked{'crssec'} = {};
     $checked{'crssecsrc'} = {};
     $checked{'lcauth'} = {};
+    $checked{'menuitem'} = {};
     if ($num eq 'add') {
         $checked{'lcauth'}{'lti'} = ' checked="checked"';
     }
@@ -4719,7 +4751,9 @@
     my $lcauthparm;
     my $lcauthparmstyle = 'display:none';
     my $lcauthparmtext;
+    my $menusty;
     my $numinrow = 4;
+    my %menutitles = &ltimenu_titles();
 
     if (ref($current) eq 'HASH') {
         if (($current->{'mapuser'} ne '') && ($current->{'mapuser'} ne 'lis_person_sourcedid')) {
@@ -4749,7 +4783,7 @@
         }
         if ($current->{'makecrs'}) { 
             $checked{'makecrs'}{'Y'} = '  checked="checked"';
-        } 
+        }
         if (ref($current->{'makeuser'}) eq 'ARRAY') {
             foreach my $role (@{$current->{'makeuser'}}) {
                 $checked{'makeuser'}{$role} = ' checked="checked"';
@@ -4788,10 +4822,35 @@
         } else {
             $checked{'crssec'}{'N'} = ' checked="checked"';
         }
+        if ($current->{'topmenu'}) {
+            $checked{'topmenu'}{'Y'} = ' checked="checked"';
+        } else {
+            $checked{'topmenu'}{'N'} = ' checked="checked"';
+        }
+        if ($current->{'inlinemenu'}) {
+            $checked{'inlinemenu'}{'Y'} = ' checked="checked"';
+        } else {
+            $checked{'inlinemenu'}{'N'} = ' checked="checked"';
+        }
+        if (($current->{'topmenu'}) || ($current->{'inlinemenu'})) {
+            $menusty = 'inline-block';
+            if (ref($current->{'lcmenu'}) eq 'ARRAY') {
+                foreach my $item (@{$current->{'lcmenu'}}) {
+                    if (exists($menutitles{$item})) {
+                        $checked{'menuitem'}{$item} = ' checked="checked"';
+                    }
+                }
+            }
+        } else {
+            $menusty = 'none';
+        }
     } else {
         $checked{'makecrs'}{'N'} = ' checked="checked"';
         $checked{'crssec'}{'N'} = ' checked="checked"';
-#FIXME        
+        $checked{'topmenu'}{'N'} = ' checked="checked"';
+        $checked{'inlinemenu'}{'Y'} = ' checked="checked"'; 
+        $checked{'menuitem'}{'grades'} = ' checked="checked"';
+        $menusty = 'inline-block'; 
     }
     my @coursetypes = ('official','unofficial','community','textbook','placement','lti');
     my %coursetypetitles = &Apache::lonlocal::texthash (
@@ -4818,6 +4877,7 @@
     my $onclicksec = ' onclick="toggleLTI(this.form,'."'sec','$num'".');"';
     my $onclicksecsrc = ' onclick="toggleLTI(this.form,'."'secsrc','$num'".')"';
     my $onclicklcauth = ' onclick="toggleLTI(this.form,'."'lcauth','$num'".')"';
+    my $onclickmenu = ' onclick="toggleLTI(this.form,'."'lcmenu','$num'".');"';
     my $output = '<fieldset><legend>'.&mt('Mapping users').'</legend>'.
                  '<div class="LC_floatleft"><span class="LC_nobreak">'.&mt('LON-CAPA username').': ';
     foreach my $option ('sourcedid','email','other') {
@@ -4944,6 +5004,27 @@
                    '<label><input type="radio" name="lti_'.$extra.'_'.$num.'" value="1"'.$checkedon.' />'.
                    &mt('Yes').'</label><br />';
     }
+    $output .= '</span></fieldset>'.
+               '<fieldset><legend>'.&mt('Course defaults (Course Coordinator can override)').'</legend>'.
+               '<div class="LC_floatleft"><span class="LC_nobreak">'.$lt{'topmenu'}.': '.
+               '<label><input type="radio" name="lti_topmenu_'.$num.'" value="0"'.
+               $checked{'topmenu'}{'N'}.$onclickmenu.' />'.&mt('No').'</label>'.(' 'x2).
+               '<label><input type="radio" name="lti_topmenu_'.$num.'" value="1"'.
+               $checked{'topmenu'}{'Y'}.$onclickmenu.' />'.&mt('Yes').'</label><span></div>'.
+               '<div style="padding:0;clear:both;margin:0;border:0"></div>'.
+               '<div class="LC_floatleft"><span class="LC_nobreak">'.$lt{'inlinemenu'}.': '.
+               '<label><input type="radio" name="lti_inlinemenu_'.$num.'" value="0"'.
+               $checked{'inlinemenu'}{'N'}.$onclickmenu.' />'.&mt('No').'</label>'.(' 'x2).
+               '<label><input type="radio" name="lti_inlinemenu_'.$num.'" value="1"'.
+               $checked{'inlinemenu'}{'Y'}.$onclickmenu.' />'.&mt('Yes').'</label><span></div>';
+     $output .='<div style="padding:0;clear:both;margin:0;border:0"></div>'. 
+               '<div class="LC_floatleft" style="display:'.$menusty.';" id="lti_menufield_'.$num.'">'.
+               '<span class="LC_nobreak">'.&mt('Menu items').': ';
+    foreach my $type ('fullname','coursetitle','role','logout','grades') {
+        $output .= '<label><input type="checkbox" name="lti_menuitem_'.$num.'" value="'.$type.'"'.
+                   $checked{'menuitem'}{$type}.' />'.$menutitles{$type}.'</label>'.
+                   (' 'x2);
+    }
     $output .= '</span></fieldset>';
 #        '<fieldset><legend>'.&mt('Assigning author roles').'</legend>';
 #
@@ -4952,6 +5033,16 @@
     return $output;
 }
 
+sub ltimenu_titles {
+    return &Apache::lonlocal::texthash(
+                                        fullname    => 'Full name',
+                                        coursetitle => 'Course title',
+                                        role        => 'Role',
+                                        logout      => 'Logout',
+                                        grades      => 'Grades',
+    );
+}
+
 sub print_coursedefaults {
     my ($position,$dom,$settings,$rowtotal) = @_;
     my ($css_class,$datatable,%checkedon,%checkedoff,%defaultchecked, at toggles);
@@ -11457,8 +11548,8 @@
     map { $posslticrs{$_} = 1; } @lticourseroles;
     map { $posscrstype{$_} = 1; } @coursetypes;
 
-#FIXME
-    
+    my %menutitles = &ltimenu_titles();
+
     my (@items,%deletions,%itemids);
     if ($env{'form.lti_add'}) {
         my $consumer = $env{'form.lti_consumer_add'};
@@ -11610,18 +11701,31 @@
                 }
             }
         }
-        foreach my $field ('passback','roster') {
+        foreach my $field ('passback','roster','topmenu','inlinemenu') {
             if ($env{'form.lti_'.$field.'_'.$idx}) {
                 $confhash{$itemid}{$field} = 1;
             }
         }
+
+        if ($env{'form.lti_topmenu_'.$idx} || $env{'form.lti_inlinemenu_'.$idx}) {
+            $confhash{$itemid}{lcmenu} = [];
+            my @possmenu = &Apache::loncommon::get_env_multiple('form.lti_menuitem_'.$idx);
+            foreach my $field (@possmenu) {
+                if (exists($menutitles{$field})) {
+                    if ($field eq 'grades') {
+                        next unless ($env{'form.lti_inlinemenu_'.$idx});
+                    }
+                    push(@{$confhash{$itemid}{lcmenu}},$field);
+                }
+            }
+        }
         unless (($idx eq 'add') || ($changes{$itemid})) {
-            foreach my $field ('mapuser','mapcrs','makecrs','section','passback','roster','lcauth','lcauthparm') {
+            foreach my $field ('mapuser','mapcrs','makecrs','section','passback','roster','lcauth','lcauthparm','topmenu','inlinemenu') {
                 if ($domconfig{$action}{$itemid}{$field} ne $confhash{$itemid}{$field}) {
                     $changes{$itemid} = 1;
                 }
             }
-            foreach my $field ('makeuser','mapcrstype','selfenroll','instdata') {
+            foreach my $field ('makeuser','mapcrstype','selfenroll','instdata','lcmenu') {
                 unless ($changes{$itemid}) {
                     if (ref($domconfig{$action}{$itemid}{$field}) eq 'ARRAY') {
                         if (ref($confhash{$itemid}{$field}) eq 'ARRAY') {
@@ -11833,8 +11937,8 @@
                     } else {
                         $resulttext .= '<li>'.&mt('No section assignment').'</li>';
                     }
-                    foreach my $item ('passback','roster') {
-                        $resulttext .= '<li>'.$lt{$item}.' ';
+                    foreach my $item ('passback','roster','topmenu','inlinemenu') {
+                        $resulttext .= '<li>'.$lt{$item}.': ';
                         if ($confhash{$itemid}{$item}) {
                             $resulttext .= &mt('Yes');
                         } else {
@@ -11842,6 +11946,14 @@
                         }
                         $resulttext .= '</li>';
                     }
+                    if (ref($confhash{$itemid}{'lcmenu'}) eq 'ARRAY') {
+                        if (@{$confhash{$itemid}{'lcmenu'}} > 0) {
+                            $resulttext .= '<li>'.&mt('Menu items:').' '.
+                                           join(', ', map { $menutitles{$_}; } (@{$confhash{$itemid}{'lcmenu'}})).'</li>'; 
+                        } else {
+                            $resulttext .= '<li>'.&mt('No menu items displayed in header or online menu').'</li>'; 
+                        }
+                    }
                     $resulttext .= '</ul></li>';
                 }
             }
Index: loncom/interface/lonconfigsettings.pm
diff -u loncom/interface/lonconfigsettings.pm:1.42 loncom/interface/lonconfigsettings.pm:1.43
--- loncom/interface/lonconfigsettings.pm:1.42	Fri Mar 23 01:01:21 2018
+++ loncom/interface/lonconfigsettings.pm	Tue May  8 01:48:18 2018
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to set domain-wide configuration settings
 #
-# $Id: lonconfigsettings.pm,v 1.42 2018/03/23 01:01:21 raeburn Exp $
+# $Id: lonconfigsettings.pm,v 1.43 2018/05/08 01:48:18 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -219,7 +219,8 @@
                 $onload .= "toggleLTI(document.display,'user','add');".
                            "toggleLTI(document.display,'crs','add');".
                            "toggleLTI(document.display,'sec','add');".
-                           "toggleLTI(document.display,'lcauth','add');";
+                           "toggleLTI(document.display,'lcauth','add');".
+                           "toggleLTI(document.display,'lcmenu','add');";
                 if (ref($values) eq 'HASH') {
                     if (ref($values->{'lti'}) eq 'HASH') {
                         my $numlti = scalar(keys(%{$values->{'lti'}}));
@@ -227,7 +228,8 @@
                             $onload .= "toggleLTI(document.display,'user','$i');".
                                        "toggleLTI(document.display,'crs','$i');".
                                        "toggleLTI(document.display,'sec','$i');".
-                                       "toggleLTI(document.display,'lcauth','$i');";
+                                       "toggleLTI(document.display,'lcauth','$i');".
+                                       "toggleLTI(document.display,'lcmenu','$i');";
                         }
                     }
                 }
Index: loncom/interface/courseprefs.pm
diff -u loncom/interface/courseprefs.pm:1.86 loncom/interface/courseprefs.pm:1.87
--- loncom/interface/courseprefs.pm:1.86	Wed Jan  3 04:20:54 2018
+++ loncom/interface/courseprefs.pm	Tue May  8 01:48:18 2018
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to set configuration settings for a course
 #
-# $Id: courseprefs.pm,v 1.86 2018/01/03 04:20:54 raeburn Exp $
+# $Id: courseprefs.pm,v 1.87 2018/05/08 01:48:18 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -367,7 +367,7 @@
     my %values=&Apache::lonnet::dump('environment',$cdom,$cnum);
     my @prefs_order = ('courseinfo','localization','feedback','discussion',
                        'classlists','appearance','grading','printouts',
-                       'spreadsheet','bridgetasks','other');
+                       'spreadsheet','bridgetasks','lti','other');
 
     my %prefs = (
         'courseinfo' =>
@@ -530,6 +530,18 @@
                         suppress_embed_prompt => 'Hide upload references prompt if uploading file to portfolio',
                                 },
                   },
+        'lti' =>
+                  {
+                    text => 'LTI provider settings',
+                    help => 'Course_Prefs_LTIProvider',
+                    ordered => ['lti.override','lti.topmenu','lti.inlinemenu','lti.lcmenu'],
+                    itemtext => {
+                         'lti.override'   => 'Override domain defaults',
+                         'lti.topmenu'    => 'Display LON-CAPA page header',
+                         'lti.inlinemenu' => 'Display LON-CAPA inline menu',
+                         'lti.lcmenu'     => 'Menu items',
+                                },
+                  },
         'other' =>
                   { text => 'Other settings',
                     help => 'Course_Prefs_Other',
@@ -725,6 +737,8 @@
         $output .= &print_spreadsheet($cdom,$settings,$ordered,$itemtext,\$rowtotal,$crstype,$noedit);
     } elsif ($action eq 'bridgetasks') {
         $output .= &print_bridgetasks($cdom,$settings,$ordered,$itemtext,\$rowtotal,$crstype,$noedit);
+    } elsif ($action eq 'lti') {
+        $output .= &print_lti($cdom,$settings,$ordered,$itemtext,\$rowtotal,$crstype,$noedit);
     } elsif ($action eq 'other') {
         $output .= &print_other($cdom,$settings,$allitems,\$rowtotal,$crstype,$noedit);
     }
@@ -1257,6 +1271,38 @@
                                 $settings =~ s/,$//;
                             }
                             $newvalues{$entry} = $settings;
+                        } elsif ($action eq 'lti') {
+                            if ($entry eq 'lti.override') {
+                                $newvalues{$entry} = $env{'form.'.$entry};
+                            } elsif (($entry eq 'lti.topmenu') || ($entry eq 'lti.inlinemenu')) {
+                                if ($env{'form.lti.override'}) {
+                                    $newvalues{$entry} = $env{'form.'.$entry};
+                                } else {
+                                    $newvalues{$entry} = '';
+                                }
+                            } elsif ($entry eq 'lti.lcmenu') {
+                                if (($env{'form.lti.override'}) &&
+                                    (($env{'form.lti.topmenu'}) || ($env{'form.lti.inlinemenu'}))) {
+                                    my @lcmenu = &Apache::loncommon::get_env_multiple('form.lti.lcmenu');
+                                    my @newlcmenu;
+                                    if (@lcmenu) {
+                                        my @menuitems = ('fullname','coursetitle','role','logout','grades');
+                                        foreach my $item (@menuitems) {
+                                            next if (($item eq 'grades') && (!$newvalues{'lti.inlinemenu'}));
+                                            if (grep(/^\Q$item\E$/, at lcmenu)) {
+                                                push(@newlcmenu,$item);
+                                            }
+                                        }
+                                    }
+                                    if (@newlcmenu) {
+                                        $newvalues{$entry} = join(',', at newlcmenu);
+                                    } else {
+                                        $newvalues{$entry} = 'none';
+                                    }
+                                } else {
+                                    $newvalues{$entry} = '';
+                                }
+                            }
                         } else {
                             $newvalues{$entry} = $env{'form.'.$entry};
                         }
@@ -1467,6 +1513,22 @@
                                             }
                                         }
                                         $displayname = &mt($text);
+                                    } elsif ($item eq 'lti') {
+                                        if ($key eq 'lti.lcmenu') {
+                                            if ($changes->{$item}{$key} eq 'none') {
+                                                $displayval = &mt('None of the configurable menu items displayed');
+                                            } else {
+                                                my %ltititles = &ltimenu_titles();
+                                                $displayval = join(', ', map { $ltititles{$_}; } split(/,/,$changes->{$item}{$key}));
+                                            }
+                                        } else {
+                                            if ($changes->{$item}{$key} eq '1') {
+                                                $displayval = &mt('Yes');
+                                            } elsif ($changes->{$item}{$key} eq '') {
+                                                $displayval = &mt('No');
+                                            }
+                                        }
+                                        $displayname = &mt($text);
                                     } else {
                                         $displayname = &mt($text);
                                     }
@@ -1529,8 +1591,23 @@
                                         }
                                     } elsif ($changes->{$item}{$key} eq '') {
                                         push(@delkeys,$key);
-                                        $output .= '<li>'.&Apache::lonhtmlcommon::confirm_success(&mt('Deleted setting for [_1]',
-                                                   '<i>'.$displayname.'</i>')).'</li>';
+                                        if ($item eq 'lti') {
+                                            if (($key eq 'lti.override') || (($key ne 'lti.override') && ($env{'form.lti.override'} ne ''))) {
+                                                if (($key eq 'lti.lcmenu') &&
+                                                    ((!$env{'form.lti.topmenu'}) && (!$env{'form.lti.inlinemenu'}))) {
+                                                    $output .= '<li>'.&mt('LTI settings for menu items only saved if page header and/or inline menu is set to be displayed').'</li>';
+                                                } else {
+                                                    $output .= '<li>'.&Apache::lonhtmlcommon::confirm_success(&mt('[_1] set to [_2]',
+                                                               '<i>'.$displayname.'</i>',
+                                                               "'<b>$displayval</b>'")).'</li>';
+                                                }
+                                            } elsif (!exists($changes->{$item}{'lti.override'})) {
+                                                $output .= '<li>'.&mt('LTI settings only saved if Override is set to "Yes"').'</li>';
+                                            }
+                                        } else {
+                                            $output .= '<li>'.&Apache::lonhtmlcommon::confirm_success(&mt('Deleted setting for [_1]',
+                                                       '<i>'.$displayname.'</i>')).'</li>';
+                                        }
                                     } else {
                                         $output .= '<li>'.&Apache::lonhtmlcommon::confirm_success(&mt('[_1] set to [_2]',
                                                    '<i>'.$displayname.'</i>',
@@ -1569,7 +1646,9 @@
                                 }
                                 if (($key eq 'description') || ($key eq 'cloners') ||
                                     ($key eq 'hidefromcat') || ($key eq 'categories') ||
-                                    ($key eq 'co-owners')) {
+                                    ($key eq 'co-owners') || ($key eq 'lti.override') ||
+                                    ($key eq 'lti.topmenu') || ($key eq 'lti.inlinemenu') ||
+                                    ($key eq 'lti.lcmenu')) {
                                     push(@need_env_update,$key);
                                 }
                             }
@@ -1653,6 +1732,8 @@
                     my @coowners = split(',',$storehash->{'internal.'.$key});
                     $crsinfo{$env{'request.course.id'}}{'co-owners'} = \@coowners;
                     $count ++;
+                } elsif ($key =~ /^lti\./) {
+                    &Apache::lonnet::appenv({'course.'.$env{'request.course.id'}.'.'.$key => $storehash->{$key}});
                 }
             }
             if ($count) {
@@ -4375,6 +4456,144 @@
     return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype,'bridgetasks',$noedit);
 }
 
+sub print_lti {
+    my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$crstype,$noedit) = @_;
+    unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
+        return;
+    }
+    my @menuitems = ('fullname','coursetitle','role','logout','grades');
+    my %menutitles = &ltimenu_titles();
+    my ($domdefs,$displaydefs);
+    if ($env{'request.lti.login'}) {
+        my %lti = &Apache::lonnet::get_domain_lti($cdom,'provider');
+        my @domdefsmenu;
+        if (ref($lti{$env{'request.lti.login'}}) eq 'HASH') {
+            if ($lti{$env{'request.lti.login'}}{'topmenu'}) {
+                $domdefs = &mt('Header shown').', ';
+            }
+            if ($lti{$env{'request.lti.login'}}{'inlinemenu'}) {
+                $domdefs .= &mt('Inline menu shown');
+            }
+            $domdefs =~ s/,\s$//;
+            if (!$domdefs) {
+                $domdefs = &mt('No header or inline menu shown');
+            }
+            $domdefs = ' ('.&mt('Domain default').': '.$domdefs.')';
+            if (ref($lti{$env{'request.lti.login'}}{'lcmenu'}) eq 'ARRAY') {
+                @domdefsmenu = @{$lti{$env{'request.lti.login'}}{'lcmenu'}};
+            }
+        }
+        $displaydefs = &mt('Domain defaults');
+        if (@domdefsmenu) {
+            my @diffs = &Apache::loncommon::compare_arrays(\@menuitems,\@domdefsmenu);
+            if (@diffs) {
+                my $missing;
+                foreach my $item (@menuitems) {
+                    unless (grep(/^\Q$item\E$/, at domdefsmenu)) {
+                        $missing .= ' '.$menutitles{$item}.',';
+                    }
+                }
+                $missing =~ s/,$//;
+                $displaydefs .= ': '.&mt('Not shown').' --'.$missing;
+            } else {
+                $displaydefs .= ': '.&mt('All shown');
+            }
+        } else {
+            $displaydefs .= ': '.&mt('Not shown').' -- '.join(', ', map { $menutitles{$_}; } @menuitems);
+        }
+    } else {
+        $displaydefs = &mt('Domain defaults only available in LTI context');
+    }
+    my %items = (
+        'lti.override' => {
+            text => '<b>'.&mt($itemtext->{'lti.override'}).'</b>'.$domdefs,
+            input => 'radio',
+                   },
+        'lti.topmenu' => {
+            text => '<b>'.&mt($itemtext->{'lti.topmenu'}).'</b>',
+            input => 'radio',
+                   },
+        'lti.inlinemenu' => {
+            text => '<b>'.&mt($itemtext->{'lti.inlinemenu'}).'</b>',
+            input => 'radio',
+                      },
+        'lti.lcmenu' => {
+            text => '<b>'.&mt($itemtext->{'lti.lcmenu'}).'</b><br />'.$displaydefs,
+            input => 'custom',
+                  },
+                );
+    return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype,'lti',$noedit);
+}
+
+sub lcmenu_checkboxes {
+    my ($cdom,$caller,$settings,$crstype,$noedit) = @_;
+    my @menuitems = ('fullname','coursetitle','role','logout','grades');
+    my %menutitles = &ltimenu_titles();
+    my (@current, at domdefs);
+    if ($env{'request.lti.login'}) {
+        my %lti = &Apache::lonnet::get_domain_lti($cdom,'provider');
+        if (ref($lti{$env{'request.lti.login'}}) eq 'HASH') {
+            if (ref($lti{$env{'request.lti.login'}}{'lcmenu'}) eq 'ARRAY') {
+                @domdefs = @{$lti{$env{'request.lti.login'}}{'lcmenu'}};
+            }
+        }
+    }
+    if (ref($settings) eq 'HASH') {
+        if ($settings->{'lti.lcmenu'}) {
+            unless ($settings->{'lti.lcmenu'} eq 'none') {
+                @current = split(',',$settings->{'lti.lcmenu'});
+            }
+        } else {
+            @current = @domdefs;
+        }
+    } else {
+        @current = @domdefs;
+    }
+    my $numinrow = 3;
+    my $count = 0;
+    my $disabled;
+    if ($noedit) {
+        $disabled = ' disabled="disabled"';
+    }
+    my $output = '<table>';
+    foreach my $item (@menuitems) {
+        my $checked = '';
+        if (grep(/^\Q$item\E$/, at current)) {
+            $checked = ' checked="checked" ';
+        }
+        my $rem = $count%($numinrow);
+        if ($rem == 0) {
+            if ($count > 0) {
+                $output .= '</tr>';
+            }
+            $output .= '<tr>';
+        }
+        $output .= '<td align="left"><span class="LC_nobreak"><label><input type="checkbox" '.
+                   'name="lti.lcmenu" value="'.$item.'"'.$checked.$disabled.'/> '.
+                   $menutitles{$item}.'</label></span></td>';
+        $count ++;
+    }
+    my $rem = $count%($numinrow);
+    my $colsleft = $numinrow - $rem;
+    if ($colsleft > 1 ) {
+        $output .= '<td colspan="'.$colsleft.'" class="LC_left_item">'.
+                   ' </td>';
+    } elsif ($colsleft == 1) {
+        $output .= '<td class="LC_left_item"> </td>';
+    }
+    $output .= '</tr></table>';
+}
+
+sub ltimenu_titles {
+    return &Apache::lonlocal::texthash(
+                                        fullname    => 'Full name',
+                                        coursetitle => 'Course title',
+                                        role        => 'Role',
+                                        logout      => 'Logout',
+                                        grades      => 'Grades',
+    );
+}
+
 sub print_other {
     my ($cdom,$settings,$allitems,$rowtotal,$crstype,$noedit) = @_;
     unless ((ref($settings) eq 'HASH') && (ref($allitems) eq 'ARRAY')) {
@@ -4557,6 +4776,8 @@
                 $datatable .= &checkforpriv_row($cdom,$item,$settings,$crstype,$noedit);
             } elsif ($item eq 'print_header_format') {
                 $datatable .= &print_hdrfmt_row($item,$settings,$noedit);
+            } elsif ($item eq 'lti.lcmenu') {
+                $datatable .= &lcmenu_checkboxes($cdom,$item,$settings,$crstype,$noedit);
             } elsif ($items->{$item}{input} eq 'dates') {
                my $disabled;
                if ($noedit) {
@@ -4574,6 +4795,8 @@
                      }
                      $valueyes = "1";
                      $valueno = "0";
+                } elsif (($item eq 'lti.topmenu') || ($item eq 'lti.inlinemenu')) {
+                    $valueyes = '1';
                 }
                 $datatable .= &yesno_radio($item,$settings,$unsetdefault,$valueyes,$valueno,$noedit);
             } elsif ($items->{$item}{input} eq 'selectbox') {


More information about the LON-CAPA-cvs mailing list