--- loncom/interface/lonmodifycourse.pm 2022/02/06 21:36:59 1.97
+++ loncom/interface/lonmodifycourse.pm 2023/06/05 02:22:29 1.100
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# handler for DC-only modifiable course settings
#
-# $Id: lonmodifycourse.pm,v 1.97 2022/02/06 21:36:59 raeburn Exp $
+# $Id: lonmodifycourse.pm,v 1.100 2023/06/05 02:22:29 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -431,6 +431,7 @@ sub print_modification_menu {
'selfenroll' => 'View/Modify Self-Enrollment configuration',
'setpostsubmit' => 'View/Modify submit button behavior, post-submission',
'setltiauth' => 'View/Modify re-authentication requirement for LTI launch of deep-linked item',
+ 'setexttool' => 'View/Modify External Tools permissions',
);
} else {
%linktext = (
@@ -439,6 +440,7 @@ sub print_modification_menu {
'selfenroll' => 'View Self-Enrollment configuration',
'setpostsubmit' => 'View submit button behavior, post-submission',
'setltiauth' => 'View re-authentication requirement for LTI launch of deep-linked item',
+ 'setexttool' => 'View External Tools permissions',
);
}
if ($type eq 'Community') {
@@ -477,7 +479,8 @@ sub print_modification_menu {
my $anon_text = &mt('Responder threshold required to display anonymous survey submissions.');
my $postsubmit_text = &mt('Override defaults for submit button behavior post-submission for this specific course.');
my $mysqltables_text = &mt('Override default for lifetime of "temporary" MySQL tables containing student performance data.');
- my $ltiauth_text = &mt('Override default for requirement for re-authentication for LTI-limited launch of deep-linked item');
+ my $ltiauth_text = &mt('Override default for requirement for re-authentication for LTI-limited launch of deep-linked item.');
+ my $exttool_text = &mt('Override default permissions for external tools use for this specific course.');
$linktext{'viewparms'} = 'Display current settings for automated enrollment';
my %domconf = &Apache::lonnet::get_dom('configuration',['coursecategories'],$dom);
@@ -567,6 +570,14 @@ sub print_modification_menu {
permission => $permission->{'setltiauth'},
linktitle => '',
},
+ {
+ linktext => $linktext{'setexttool'},
+ icon => 'exttool.png',
+ #help => '',
+ url => &phaseurl('setexttool'),
+ permission => $permission->{'setexttool'},
+ linktitle => '',
+ },
]
},
);
@@ -598,7 +609,8 @@ sub print_modification_menu {
'
'.$setuploadquota_text.''."\n".
''.$anon_text.''."\n".
''.$postsubmit_text.''."\n".
- ''.$ltiauth_text.''."\n";
+ ''.$ltiauth_text.''."\n".
+ ''.$exttool_text.''."\n";
my ($categories_link_start,$categories_link_end);
if ($permission->{'catsettings'} eq 'edit') {
$categories_link_start = '';
@@ -944,15 +956,7 @@ ENDDOCUMENT
sub domain_postsubtimeout {
my ($cdom,$type,$settings) = @_;
return unless (ref($settings) eq 'HASH');
- my $lctype = lc($type);
- unless (($type eq 'Community') || ($type eq 'Placement')) {
- $lctype = 'unofficial';
- if ($settings->{'internal.coursecode'}) {
- $lctype = 'official';
- } elsif ($settings->{'internal.textbook'}) {
- $lctype = 'textbook';
- }
- }
+ my $lctype = &get_lctype($type,$settings);
my %domconfig =
&Apache::lonnet::get_dom('configuration',['coursedefaults'],$cdom);
my $postsubtimeout = 60;
@@ -968,6 +972,22 @@ sub domain_postsubtimeout {
return $postsubtimeout;
}
+sub get_lctype {
+ my ($type,$settings) = @_;
+ my $lctype = lc($type);
+ unless (($type eq 'Community') || ($type eq 'Placement')) {
+ $lctype = 'unofficial';
+ if (ref($settings) eq 'HASH') {
+ if ($settings->{'internal.coursecode'}) {
+ $lctype = 'official';
+ } elsif ($settings->{'internal.textbook'}) {
+ $lctype = 'textbook';
+ }
+ }
+ }
+ return $lctype;
+}
+
sub print_catsettings {
my ($r,$cdom,$cnum,$cdesc,$type,$readonly) = @_;
&print_header($r,$type);
@@ -1288,10 +1308,10 @@ sub print_set_ltiauth {
);
my ($domdef,$checkeddom,$checkedcrs,$domdefdisplay,$divsty,$authok,$authno);
$domdef = 0;
- $checkeddom = 'checked="checked "';
+ $checkeddom = ' checked="checked"';
$domdefdisplay = $lt{'logi'};
$divsty = 'display:none';
- $authno = 'checked="checked" ';
+ $authno = ' checked="checked"';
my %domconfig =
&Apache::lonnet::get_dom('configuration',['coursedefaults'],$cdom);
if (ref($domconfig{'coursedefaults'}) eq 'HASH') {
@@ -1308,7 +1328,7 @@ sub print_set_ltiauth {
$checkeddom = '';
$divsty = 'display:inline-block';
if ($ltiauth) {
- $authok = 'checked="checked "';
+ $authok = ' checked="checked"';
}
}
&print_header($r,$type);
@@ -1323,18 +1343,18 @@ sub print_set_ltiauth {
$r->print(<
$helpitem $lt{'requ'} $cdesc
-$lt{'curd'}: '.$domdefdisplay
+
$lt{'curd'}: $domdefdisplay
-
+
-
+
$submit
@@ -1346,6 +1366,126 @@ ENDDOCUMENT
return;
}
+sub print_set_exttool {
+ my ($r,$cdom,$cnum,$cdesc,$type,$readonly) = @_;
+ my %titles = &exttool_titles($type);
+ my ($domdef,$domdefdom,$checkeddom,$checkedcrs,$domdefdisplay,$divsty);
+ $domdef = 0;
+ $domdefdom = 1;
+ $checkeddom = ' checked="checked"';
+ $divsty = 'display:none';
+ my %settings = &Apache::lonnet::get('environment',['internal.coursecode',
+ 'internal.textbook'],$cdom,$cnum);
+ my $lctype = &get_lctype($type,\%settings);
+ my %domconfig =
+ &Apache::lonnet::get_dom('configuration',['coursedefaults'],$cdom);
+ if (ref($domconfig{'coursedefaults'}) eq 'HASH') {
+ if (ref($domconfig{'coursedefaults'}{'exttool'}) eq 'HASH') {
+ if (exists($domconfig{'coursedefaults'}{'exttool'}{$lctype})) {
+ $domdef = $domconfig{'coursedefaults'}{'exttool'}{$lctype};
+ }
+ }
+ if (ref($domconfig{'coursedefaults'}{'domexttool'}) eq 'HASH') {
+ if (exists($domconfig{'coursedefaults'}{'domexttool'}{$lctype})) {
+ $domdefdom = $domconfig{'coursedefaults'}{'domexttool'}{$lctype};
+ }
+ }
+ }
+ if ($domdef && $domdefdom) {
+ $domdefdisplay = $titles{'both'};
+ } elsif ($domdef) {
+ $domdefdisplay = $titles{'crs'};
+ } elsif ($domdefdom) {
+ $domdefdisplay = $titles{'dom'};
+ } else {
+ $domdefdisplay = $titles{'none'};
+ }
+ my %settings = &Apache::lonnet::get('environment',['internal.exttool'],$cdom,$cnum);
+ my $crsexttool = $settings{'internal.exttool'};
+ my %crschecked = (
+ both => ' checked="checked"',
+ dom => '',
+ crs => '',
+ none => '',
+ );
+ if ($crsexttool ne '') {
+ $checkedcrs = $checkeddom;
+ $checkeddom = '';
+ $divsty = 'display:inline-block';
+ foreach my $option ('both','dom','crs','none') {
+ if ($crsexttool eq $option) {
+ $crschecked{$option} = ' checked="checked"';
+ } else {
+ $crschecked{$option} = '';
+ }
+ }
+ }
+ &print_header($r,$type);
+ my $hidden_elements = &hidden_form_elements();
+ my ($disabled,$submit);
+ if ($readonly) {
+ $disabled = ' disabled="disabled"';
+ } else {
+ $submit = '';
+ }
+ my $helpitem = &Apache::loncommon::help_open_topic('Modify_Course_External_Tool');
+ $r->print(<
+$helpitem $titles{'extt'}
+$type: $cdesc
+$titles{'curd'}: $domdefdisplay
+
+
+
+
+
+$submit
+
+$hidden_elements
+$titles{'back'}
+
+ENDDOCUMENT
+ return;
+}
+
+sub exttool_titles {
+ my ($type) = @_;
+ my %titles = &Apache::lonlocal::texthash(
+ 'extt' => 'External Tool permissions',
+ 'none' => 'Use of external tools not permitted',
+ 'crs' => 'Only external tools defined in course may be used',
+ 'dom' => 'Only external tools defined in domain may be used',
+ 'both' => 'External tools defined/configured in either domain or course may be used',
+ 'used' => 'Use domain default',
+ 'cour' => 'Use course-specific setting',
+ 'curd' => 'Current domain default is',
+ 'valu' => 'Value for this course',
+ 'modi' => 'Save',
+ 'back' => 'Pick another action',
+ );
+ if ($type eq 'Community') {
+ $titles{'crs'} = &mt('Only external tools defined in community may be used');
+ $titles{'both'} = &mt('External tools defined/configured in either domain or community may be used');
+ $titles{'cour'} = &mt('Use community-specific setting');
+ $titles{'valu'} = &mt('Value for this community');
+ }
+ return %titles;
+}
+
sub modify_selfenrollconfig {
my ($r,$type,$cdesc,$coursehash) = @_;
return unless(ref($coursehash) eq 'HASH');
@@ -2441,7 +2581,115 @@ sub modify_ltiauth {
$r->print('
'.$status);
$r->print(''.
''.
- &mt('Pick another action').'
');
+ $lt{'back'}.'');
+ $r->print(&hidden_form_elements().'');
+ return;
+}
+
+sub modify_exttool {
+ my ($r,$cdom,$cnum,$cdesc,$domdesc,$type) = @_;
+ my %titles = &exttool_titles($type);
+ &print_header($r,$type);
+ $r->print('');
return;
}
@@ -2630,6 +2878,35 @@ function toggleLTIOptions(form) {
}
ENDJS
+ } elsif ($phase eq 'setexttool') {
+ $js .= <<"ENDJS";
+function toggleExtToolOptions(form) {
+ var radioname = 'exttoolset';
+ var divid = 'crsexttool';
+ var num = form.elements[radioname].length;
+ if (num) {
+ var setvis = '';
+ for (var i=0; i {'onload' => "toggleLTIOptions(document.setltiauth);"},
};
+ } elsif ($env{'form.phase'} eq 'setexttool') {
+ $starthash = {
+ add_entries => {'onload' => "toggleExtToolOptions(document.setexttool);"},
+ };
}
$r->print(&Apache::loncommon::start_page('View/Modify Course/Community Settings',
&Apache::lonhtmlcommon::scripttag($js),
@@ -2743,8 +3024,8 @@ sub hidden_form_elements {
'locarg','krbarg','krbver','counter','hidefromcat','usecategory',
'threshold','postsubmit','postsubtimeout','defaultcredits','uploadquota',
'selfenrollmgrdc','selfenrollmgrcc','action','state','currsec_st',
- 'sections','newsec','mysqltables','nopasswdchg','ltiauth','ltiauthset'],
- ['^selfenrollmgr_','^selfenroll_'])."\n".
+ 'sections','newsec','mysqltables','nopasswdchg','ltiauth','ltiauthset',
+ 'exttoolset','exttool'],['^selfenrollmgr_','^selfenroll_'])."\n".
'';
return $hidden_elements;
}
@@ -2779,6 +3060,8 @@ sub get_permission {
adhocrole => 'coord',
setltiauth => 'edit',
processltiauth => 'edit',
+ setexttool => 'edit',
+ processexttool => 'edit',
);
if ($passwdconf{'crsownerchg'}) {
$permission{passwdchg} = 'edit';
@@ -2795,6 +3078,7 @@ sub get_permission {
selfenroll => 'view',
adhocrole => 'custom',
setltiauth => 'view',
+ setexttool => 'view',
);
if ($passwdconf{'crsownerchg'}) {
$permission{passwdchg} = 'view';
@@ -3006,11 +3290,22 @@ sub handler {
} elsif (($phase eq 'processltiauth') && ($permission->{'processltiauth'})) {
&Apache::lonhtmlcommon::add_breadcrumb
({href=>"javascript:changePage(document.$phase,'setltiauth')",
- text=>"Requirement for re-authentication for LTI launch of deep-linked item"});
+ text=>"Requirement for re-authentication for LTI launch of deep-linked item"},
+ {href=>"javascript:changePage(document.$phase,'$phase')",
+ text=>"Result"});
+ &modify_ltiauth($r,$cdom,$cnum,$cdesc,$domdesc,$type);
+ } elsif (($phase eq 'setexttool') && ($permission->{'setexttool'})) {
&Apache::lonhtmlcommon::add_breadcrumb
({href=>"javascript:changePage(document.$phase,'$phase')",
+ text=>"External Tool permission"});
+ &print_set_exttool($r,$cdom,$cnum,$cdesc,$type,$readonly);
+ } elsif (($phase eq 'processexttool') && ($permission->{'processexttool'})) {
+ &Apache::lonhtmlcommon::add_breadcrumb
+ ({href=>"javascript:changePage(document.$phase,'setexttool')",
+ text=>"External Tool permission"},
+ {href=>"javascript:changePage(document.$phase,'$phase')",
text=>"Result"});
- &modify_ltiauth($r,$cdom,$cnum,$cdesc,$domdesc,$type);
+ &modify_exttool($r,$cdom,$cnum,$cdesc,$domdesc,$type);
}
}
} else {