--- loncom/interface/domainprefs.pm 2023/03/19 16:05:48 1.421
+++ loncom/interface/domainprefs.pm 2023/04/11 20:35:19 1.422
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set domain-wide configuration settings
#
-# $Id: domainprefs.pm,v 1.421 2023/03/19 16:05:48 raeburn Exp $
+# $Id: domainprefs.pm,v 1.422 2023/04/11 20:35:19 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -6746,12 +6746,16 @@ sub print_coursedefaults {
canclone => "People who may clone a course (besides course's owner and coordinators)",
mysqltables => 'Lifetime (s) of "Temporary" MySQL tables (student performance data) on homeserver',
ltiauth => 'Student username in LTI launch of deep-linked URL can be accepted without re-authentication',
+ domexttool => 'External Tools defined in the domain may be used in courses/communities (by type)',
+ exttool => 'External Tools can be defined and configured in courses/communities (by type)',
);
my %staticdefaults = (
anonsurvey_threshold => 10,
uploadquota => 500,
postsubmit => 60,
mysqltables => 172800,
+ domexttool => 1,
+ exttool => 0,
);
if ($position eq 'top') {
%defaultchecked = (
@@ -6869,11 +6873,33 @@ sub print_coursedefaults {
my $currusecredits = 0;
my $postsubmitclient = 1;
my $ltiauth = 0;
+ my %domexttool;
+ my %exttool;
my @types = ('official','unofficial','community','textbook','placement');
if (ref($settings) eq 'HASH') {
if ($settings->{'ltiauth'}) {
$ltiauth = 1;
}
+ if (ref($settings->{'domexttool'}) eq 'HASH') {
+ foreach my $type (@types) {
+ if ($settings->{'domexttool'}->{$type}) {
+ $domexttool{$type} = ' checked="checked"';
+ }
+ }
+ } else {
+ foreach my $type (@types) {
+ if ($staticdefaults{'domexttool'}) {
+ $domexttool{$type} = ' checked="checked"';
+ }
+ }
+ }
+ if (ref($settings->{'exttool'}) eq 'HASH') {
+ foreach my $type (@types) {
+ if ($settings->{'exttool'}->{$type}) {
+ $exttool{$type} = ' checked="checked"';
+ }
+ }
+ }
$currdefresponder = $settings->{'anonsurvey_threshold'};
if (ref($settings->{'uploadquota'}) eq 'HASH') {
foreach my $type (keys(%{$settings->{'uploadquota'}})) {
@@ -6925,6 +6951,9 @@ sub print_coursedefaults {
} else {
foreach my $type (@types) {
$deftimeout{$type} = $staticdefaults{'postsubmit'};
+ if ($staticdefaults{'domexttool'}) {
+ $domexttool{$type} = ' checked="checked"';
+ }
}
}
if (!$currdefresponder) {
@@ -7028,7 +7057,35 @@ sub print_coursedefaults {
&radiobutton_prefs($current,\@toggles,\%defaultchecked,
\%choices,$itemcount,undef,undef,'left');
$datatable .= $table;
+ $css_class = $itemcount%2 ? ' class="LC_odd_row"' : '';
+ $datatable .= '
'.
+ $choices{'domexttool'}.
+ ' | '.
+ ''.
+ ' |
'."\n";
$itemcount ++;
+ $css_class = $itemcount%2 ? ' class="LC_odd_row"' : '';
+ $datatable .= ''.
+ $choices{'exttool'}.
+ ' | '.
+ ''.
+ ' |
'."\n";
}
$$rowtotal += $itemcount;
return $datatable;
@@ -20212,6 +20269,7 @@ sub modify_coursedefaults {
uploadquota => 500,
postsubmit => 60,
mysqltables => 172800,
+ domexttool => 1,
);
my %texoptions = (
MathJax => 'MathJax',
@@ -20403,6 +20461,47 @@ sub modify_coursedefaults {
$changes{'postsubmit'} = 1;
}
}
+ my (%newdomexttool,%newexttool,%olddomexttool,%oldexttool);
+ map { $newdomexttool{$_} = 1; } &Apache::loncommon::get_env_multiple('form.domexttool');
+ map { $newexttool{$_} = 1; } &Apache::loncommon::get_env_multiple('form.exttool');
+ if (ref($domconfig{'coursedefaults'}{'domexttool'}) eq 'HASH') {
+ %olddomexttool = %{$domconfig{'coursedefaults'}{'domexttool'}};
+ } else {
+ foreach my $type (@types) {
+ if ($staticdefaults{'domexttool'}) {
+ $olddomexttool{$type} = 1;
+ } else {
+ $olddomexttool{$type} = 0;
+ }
+ }
+ }
+ if (ref($domconfig{'coursedefaults'}{'exttool'}) eq 'HASH') {
+ %oldexttool = %{$domconfig{'coursedefaults'}{'exttool'}};
+ } else {
+ foreach my $type (@types) {
+ if ($staticdefaults{'exttool'}) {
+ $oldexttool{$type} = 1;
+ } else {
+ $oldexttool{$type} = 0;
+ }
+ }
+ }
+ foreach my $type (@types) {
+ unless ($newdomexttool{$type}) {
+ $newdomexttool{$type} = 0;
+ }
+ unless ($newexttool{$type}) {
+ $newexttool{$type} = 0;
+ }
+ if ($newdomexttool{$type} != $olddomexttool{$type}) {
+ $changes{'domexttool'} = 1;
+ }
+ if ($newexttool{$type} != $oldexttool{$type}) {
+ $changes{'exttool'} = 1;
+ }
+ }
+ $defaultshash{'coursedefaults'}{'domexttool'} = \%newdomexttool;
+ $defaultshash{'coursedefaults'}{'exttool'} = \%newexttool;
}
my $putresult = &Apache::lonnet::put_dom('configuration',\%defaultshash,
$dom);
@@ -20412,8 +20511,10 @@ sub modify_coursedefaults {
if (($changes{'canuse_pdfforms'}) || ($changes{'uploadquota'}) || ($changes{'postsubmit'}) ||
($changes{'coursecredits'}) || ($changes{'uselcmath'}) || ($changes{'usejsme'}) ||
($changes{'canclone'}) || ($changes{'mysqltables'}) || ($changes{'texengine'}) ||
- ($changes{'inline_chem'}) || ($changes{'ltiauth'})) {
- foreach my $item ('canuse_pdfforms','uselcmath','usejsme','inline_chem','texengine','ltiauth') {
+ ($changes{'inline_chem'}) || ($changes{'ltiauth'}) || ($changes{'domexttool'}) ||
+ ($changes{'exttool'}) ) {
+ foreach my $item ('canuse_pdfforms','uselcmath','usejsme','inline_chem','texengine',
+ 'ltiauth') {
if ($changes{$item}) {
$domdefaults{$item}=$defaultshash{'coursedefaults'}{$item};
}
@@ -20456,6 +20557,20 @@ sub modify_coursedefaults {
$domdefaults{'canclone'}=$defaultshash{'coursedefaults'}{'canclone'};
}
}
+ if ($changes{'domexttool'}) {
+ if (ref($defaultshash{'coursedefaults'}{'domexttool'}) eq 'HASH') {
+ foreach my $type (@types) {
+ $domdefaults{$type.'domexttool'}=$defaultshash{'coursedefaults'}{'domexttool'}{$type};
+ }
+ }
+ }
+ if ($changes{'exttool'}) {
+ if (ref($defaultshash{'coursedefaults'}{'exttool'}) eq 'HASH') {
+ foreach my $type (@types) {
+ $domdefaults{$type.'exttool'}=$defaultshash{'coursedefaults'}{'exttool'}{$type};
+ }
+ }
+ }
my $cachetime = 24*60*60;
&Apache::lonnet::do_cache_new('domdefaults',$dom,\%domdefaults,$cachetime);
if (ref($lastactref) eq 'HASH') {
@@ -20593,6 +20708,34 @@ sub modify_coursedefaults {
} else {
$resulttext .= ''.&mt('LTI launch of deep-linked URL will require re-authentication').'';
}
+ } elsif ($item eq 'domexttool') {
+ my @noyes = (&mt('no'),&mt('yes'));
+ if (ref($defaultshash{'coursedefaults'}{'domexttool'}) eq 'HASH') {
+ $resulttext .= ''.&mt('External Tools defined in the domain may be used as follows:').''.
+ '- '.&mt('Official courses: [_1]',''.$noyes[$defaultshash{'coursedefaults'}{'domexttool'}{'official'}].'').'
'.
+ '- '.&mt('Unofficial courses: [_1]',''.$noyes[$defaultshash{'coursedefaults'}{'domexttool'}{'unofficial'}].'').'
'.
+ '- '.&mt('Textbook courses: [_1]',''.$noyes[$defaultshash{'coursedefaults'}{'domexttool'}{'textbook'}].'').'
'.
+ '- '.&mt('Placement tests: [_1]',''.$noyes[$defaultshash{'coursedefaults'}{'domexttool'}{'placement'}].'').'
'.
+ '- '.&mt('Communities: [_1]',''.$noyes[$defaultshash{'coursedefaults'}{'domexttool'}{'community'}].'').'
'.
+ '
'.
+ '';
+ } else {
+ $resulttext .= ''.&mt('External Tools defined in the domain may be used in all course types, by default').'';
+ }
+ } elsif ($item eq 'exttool') {
+ my @noyes = (&mt('no'),&mt('yes'));
+ if (ref($defaultshash{'coursedefaults'}{'exttool'}) eq 'HASH') {
+ $resulttext .= ''.&mt('External Tools can be defined and configured in course containers as follows:').''.
+ '- '.&mt('Official courses: [_1]',''.$noyes[$defaultshash{'coursedefaults'}{'exttool'}{'official'}].'').'
'.
+ '- '.&mt('Unofficial courses: [_1]',''.$noyes[$defaultshash{'coursedefaults'}{'exttool'}{'unofficial'}].'').'
'.
+ '- '.&mt('Textbook courses: [_1]',''.$noyes[$defaultshash{'coursedefaults'}{'exttool'}{'textbook'}].'').'
'.
+ '- '.&mt('Placement tests: [_1]',''.$noyes[$defaultshash{'coursedefaults'}{'exttool'}{'placement'}].'').'
'.
+ '- '.&mt('Communities: [_1]',''.$noyes[$defaultshash{'coursedefaults'}{'exttool'}{'community'}].'').'
'.
+ '
'.
+ '';
+ } else {
+ $resulttext .= ''.&mt('External Tools can not be defined in any course types, by default').'';
+ }
}
}
$resulttext .= '';