--- loncom/interface/domainprefs.pm 2024/03/03 00:08:37 1.437
+++ loncom/interface/domainprefs.pm 2024/04/14 17:12:27 1.438
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set domain-wide configuration settings
#
-# $Id: domainprefs.pm,v 1.437 2024/03/03 00:08:37 raeburn Exp $
+# $Id: domainprefs.pm,v 1.438 2024/04/14 17:12:27 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -6917,6 +6917,7 @@ sub print_coursedefaults {
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)',
crsauthor => 'Standard LON-CAPA problems can be created within a course/community (by type)',
+ crseditors => 'Available editors for web pages and/or problems created in a course/community',
);
my %staticdefaults = (
anonsurvey_threshold => 10,
@@ -6927,6 +6928,7 @@ sub print_coursedefaults {
domexttool => 1,
exttool => 0,
crsauthor => 1,
+ crseditors => ['edit','xml'],
);
if ($position eq 'top') {
%defaultchecked = (
@@ -7048,6 +7050,7 @@ sub print_coursedefaults {
my %domexttool;
my %exttool;
my %crsauthor;
+ my %crseditors;
my @types = ('official','unofficial','community','textbook','placement');
if (ref($settings) eq 'HASH') {
if ($settings->{'ltiauth'}) {
@@ -7086,6 +7089,15 @@ sub print_coursedefaults {
}
}
}
+ if (ref($settings->{'crseditors'}) eq 'ARRAY') {
+ foreach my $editor (@{$settings->{'crseditors'}}) {
+ $crseditors{$editor} = ' checked="checked"';
+ }
+ } else {
+ foreach my $editor (@{$staticdefaults{'crseditors'}}) {
+ $crseditors{$editor} = ' checked="checked"';
+ }
+ }
$currdefresponder = $settings->{'anonsurvey_threshold'};
if (ref($settings->{'uploadquota'}) eq 'HASH') {
foreach my $type (keys(%{$settings->{'uploadquota'}})) {
@@ -7149,6 +7161,9 @@ sub print_coursedefaults {
$crsauthor{$type} = ' checked="checked"';
}
}
+ foreach my $editor (@{$staticdefaults{'crseditors'}}) {
+ $crseditors{$editor} = ' checked="checked"';
+ }
}
if (!$currdefresponder) {
$currdefresponder = $staticdefaults{'anonsurvey_threshold'};
@@ -7276,9 +7291,9 @@ sub print_coursedefaults {
foreach my $type (@types) {
$datatable .= '
'.
''.
- ''.
- &mt($type).' | '."\n";
+ &mt($type).''."\n";
}
$datatable .= ''."\n";
$itemcount ++;
@@ -7291,9 +7306,9 @@ sub print_coursedefaults {
foreach my $type (@types) {
$datatable .= ''.
''.
- ''.
- &mt($type).' | '."\n";
+ &mt($type).''."\n";
}
$datatable .= ''."\n";
$itemcount ++;
@@ -7306,9 +7321,26 @@ sub print_coursedefaults {
foreach my $type (@types) {
$datatable .= ''.
''.
- ''.
- &mt($type).' | '."\n";
+ &mt($type).''."\n";
+ }
+ $datatable .= ''."\n";
+ $itemcount ++;
+ $css_class = $itemcount%2 ? ' class="LC_odd_row"' : '';
+ $datatable .= ''.
+ $choices{'crseditors'}.
+ ' | '.
+ ''.
+ ' |
'."\n";
}
@@ -7316,6 +7348,14 @@ sub print_coursedefaults {
return $datatable;
}
+sub crseditor_titles {
+ return &Apache::lonlocal::texthash(
+ edit => 'Standard editor (Edit)',
+ xml => 'Text editor (EditXML)',
+ daxe => 'Daxe editor (Daxe)',
+ );
+}
+
sub print_authordefaults {
my ($position,$dom,$settings,$rowtotal) = @_;
my ($css_class,$datatable,%checkedon,%checkedoff);
@@ -21213,12 +21253,17 @@ sub modify_coursedefaults {
mysqltables => 172800,
domexttool => 1,
crsauthor => 1,
+ crseditors => ['edit','xml'],
);
my %texoptions = (
MathJax => 'MathJax',
mimetex => &mt('Convert to Images'),
tth => &mt('TeX to HTML'),
);
+
+ my @editors = ('edit','xml','daxe');
+ my %editornames = &crseditor_titles();
+
$defaultshash{'coursedefaults'} = {};
if (ref($domconfig{'coursedefaults'}) ne 'HASH') {
@@ -21404,10 +21449,12 @@ sub modify_coursedefaults {
$changes{'postsubmit'} = 1;
}
}
- my (%newdomexttool,%newexttool,%newcrsauthor,%olddomexttool,%oldexttool,%oldcrsauthor);
+ my (%newdomexttool,%newexttool,%newcrsauthor,%olddomexttool,%oldexttool,%oldcrsauthor,
+ %posscrseditors);
map { $newdomexttool{$_} = 1; } &Apache::loncommon::get_env_multiple('form.domexttool');
map { $newexttool{$_} = 1; } &Apache::loncommon::get_env_multiple('form.exttool');
map { $newcrsauthor{$_} = 1; } &Apache::loncommon::get_env_multiple('form.crsauthor');
+ map { $posscrseditors{$_} = 1; } &Apache::loncommon::get_env_multiple('form.crseditors');
if (ref($domconfig{'coursedefaults'}{'domexttool'}) eq 'HASH') {
%olddomexttool = %{$domconfig{'coursedefaults'}{'domexttool'}};
} else {
@@ -21441,6 +21488,27 @@ sub modify_coursedefaults {
}
}
}
+ my @newcrseditors = ();
+ foreach my $editor (@editors) {
+ if ($posscrseditors{$editor}) {
+ push(@newcrseditors,$editor);
+ }
+ }
+ if (ref($domconfig{'coursedefaults'}{'crseditors'}) eq 'ARRAY') {
+ my @diffs =
+ &Apache::loncommon::compare_arrays($domconfig{'coursedefaults'}{'crseditors'},
+ \@newcrseditors);
+ if (@diffs) {
+ $changes{'crseditors'} = 1;
+ }
+ } else {
+ my @diffs =
+ &Apache::loncommon::compare_arrays($staticdefaults{'crseditors'},
+ \@newcrseditors);
+ unless (@diffs == 0) {
+ $changes{'crseditors'} = 1;
+ }
+ }
foreach my $type (@types) {
unless ($newdomexttool{$type}) {
$newdomexttool{$type} = 0;
@@ -21464,6 +21532,7 @@ sub modify_coursedefaults {
$defaultshash{'coursedefaults'}{'domexttool'} = \%newdomexttool;
$defaultshash{'coursedefaults'}{'exttool'} = \%newexttool;
$defaultshash{'coursedefaults'}{'crsauthor'} = \%newcrsauthor;
+ $defaultshash{'coursedefaults'}{'crseditors'} = \@newcrseditors;
}
my $putresult = &Apache::lonnet::put_dom('configuration',\%defaultshash,
$dom);
@@ -21547,6 +21616,11 @@ sub modify_coursedefaults {
}
}
}
+ if ($changes{'crseditors'}) {
+ if (ref($defaultshash{'coursedefaults'}{'crseditors'}) eq 'ARRAY') {
+ $domdefaults{'crseditors'}=join(',',@{$defaultshash{'coursedefaults'}{'crseditors'}});
+ }
+ }
my $cachetime = 24*60*60;
&Apache::lonnet::do_cache_new('domdefaults',$dom,\%domdefaults,$cachetime);
if (ref($lastactref) eq 'HASH') {
@@ -21726,6 +21800,16 @@ sub modify_coursedefaults {
} else {
$resulttext .= ''.$status{$item}{'default'}.'';
}
+ } elsif ($item eq 'crseditors') {
+ if (ref($defaultshash{'coursedefaults'}{$item}) eq 'ARRAY') {
+ my $shown;
+ if (@{$defaultshash{'coursedefaults'}{$item}}) {
+ $shown = join(', ', map { $editornames{$_} } @{$defaultshash{'coursedefaults'}{$item}});
+ } else {
+ $shown = &mt('None');
+ }
+ $resulttext .= ''.&mt('Available editors for course/community resources: [_1]',$shown).'';
+ }
}
}
$resulttext .= '';