--- loncom/interface/domainprefs.pm 2024/03/03 00:08:37 1.437
+++ loncom/interface/domainprefs.pm 2024/10/11 23:29:34 1.444
@@ -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.444 2024/10/11 23:29:34 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -472,6 +472,8 @@ sub handler {
header => [{col1 => 'Target user has role',
col2 => 'User information updatable in author context'},
{col1 => 'Target user has role',
+ col2 => 'User information updatable by co-author manager'},
+ {col1 => 'Target user has role',
col2 => 'User information updatable in course context'}],
print => \&print_usermodification,
modify => \&modify_usermodification,
@@ -1031,7 +1033,7 @@ sub print_config_box {
($action eq 'usersessions') || ($action eq 'coursecategories') ||
($action eq 'trust') || ($action eq 'contacts') || ($action eq 'defaults') ||
($action eq 'privacy') || ($action eq 'passwords') || ($action eq 'lti') ||
- ($action eq 'ltitools')) {
+ ($action eq 'ltitools') || ($action eq 'usermodification')) {
if ($action eq 'coursecategories') {
$output .= &print_coursecategories('middle',$dom,$item,$settings,\$rowtotal);
$colspan = ' colspan="2"';
@@ -1135,9 +1137,9 @@ sub print_config_box {
}
}
$rowtotal ++;
- } elsif (($action eq 'usermodification') || ($action eq 'coursedefaults') ||
+ } elsif (($action eq 'coursedefaults') || ($action eq 'authordefaults') ||
($action eq 'directorysrch') || ($action eq 'helpsettings') ||
- ($action eq 'wafproxy') || ($action eq 'authordefaults')) {
+ ($action eq 'wafproxy')) {
$output .= $item->{'print'}->('bottom',$dom,$settings,\$rowtotal);
} elsif ($action eq 'scantron') {
$output .= $item->{'print'}->($r,'bottom',$dom,$confname,$settings,\$rowtotal);
@@ -6917,6 +6919,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 +6930,7 @@ sub print_coursedefaults {
domexttool => 1,
exttool => 0,
crsauthor => 1,
+ crseditors => ['edit','xml'],
);
if ($position eq 'top') {
%defaultchecked = (
@@ -7048,6 +7052,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 +7091,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 +7163,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 +7293,9 @@ sub print_coursedefaults {
foreach my $type (@types) {
$datatable .= '
'.
''.
- ''.
- &mt($type).' | '."\n";
+ &mt($type).''."\n";
}
$datatable .= ''."\n";
$itemcount ++;
@@ -7291,9 +7308,9 @@ sub print_coursedefaults {
foreach my $type (@types) {
$datatable .= ''.
''.
- ''.
- &mt($type).' | '."\n";
+ &mt($type).''."\n";
}
$datatable .= ''."\n";
$itemcount ++;
@@ -7306,9 +7323,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 +7350,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);
@@ -7483,6 +7525,15 @@ sub print_authordefaults {
}
$datatable .= '';
$itemcount ++;
+ my %defchecked = (
+ 'archive' => 'off',
+ );
+ my @toggles = ('archive');
+ (my $archive,$itemcount) = &radiobutton_prefs($settings,['archive'],
+ {'archive' => 'off'},
+ \%titles,$itemcount);
+ $datatable .= $archive."\n";
+ $itemcount ++;
}
$$rowtotal += $itemcount;
return $datatable;
@@ -7506,6 +7557,7 @@ sub authordefaults_titles {
none => 'No override set',
overon => 'Override -- webDAV on',
overoff => 'Override -- webDAV off',
+ archive => 'Authors can download tar.gz file of Authoring Space',
);
}
@@ -10674,6 +10726,15 @@ sub print_usermodification {
$$rowtotal ++;
$rowcount ++;
}
+ } elsif ($position eq 'middle') {
+ $rowcount = 0;
+ $context = 'coauthor';
+ foreach my $role ('ca','aa') {
+ $datatable .= &modifiable_userdata_row($context,$role,$settings,
+ $numinrow,$rowcount);
+ $$rowtotal ++;
+ $rowcount ++;
+ }
} elsif ($position eq 'bottom') {
$context = 'course';
$rowcount = 0;
@@ -12179,6 +12240,8 @@ sub modifiable_userdata_row {
} else {
if ($context eq 'lti') {
$prefix = 'lti';
+ } elsif ($context eq 'coauthor') {
+ $prefix = 'cacanmodify';
} elsif ($context eq 'privacy') {
$prefix = 'privacy';
}
@@ -13385,12 +13448,13 @@ sub modify_authordefaults {
'nocodemirror' => 'off',
'daxecollapse' => 'off',
'domcoordacc' => 'on',
- 'editors' => ['edit','xml'].
+ 'editors' => ['edit','xml'],
'authorquota' => 500,
'webdav' => 0,
+ 'archive' => 'off',
);
my %titles = &authordefaults_titles();
- foreach my $item ('nocodemirror','daxecollapse','domcoordacc') {
+ foreach my $item ('nocodemirror','daxecollapse','domcoordacc','archive') {
if ($env{'form.'.$item} =~ /^(0|1)$/) {
$confhash{$item} = $env{'form.'.$item};
}
@@ -13434,7 +13498,7 @@ sub modify_authordefaults {
$save_quotas{'webdav'}{'_LC_adv'} = $env{'form.webdav_LC_adv'};
}
if (ref($domconfig{'authordefaults'}) eq 'HASH') {
- foreach my $item ('nocodemirror','daxecollapse','domcoordacc','copyright','sourceavail') {
+ foreach my $item ('nocodemirror','daxecollapse','domcoordacc','copyright','sourceavail','archive') {
if ($domconfig{'authordefaults'}{$item} ne $confhash{$item}) {
$changes{$item} = 1;
}
@@ -13456,7 +13520,7 @@ sub modify_authordefaults {
}
} else {
my @offon = ('off','on');
- foreach my $item ('nocodemirror','daxecollapse','domcoordacc') {
+ foreach my $item ('nocodemirror','daxecollapse','domcoordacc','archive') {
if ($offon[$confhash{$item}] ne $staticdefaults{$item}) {
$changes{$item} = 1;
}
@@ -13466,6 +13530,12 @@ sub modify_authordefaults {
$changes{$item} = 1;
}
}
+ my @diffs =
+ &Apache::loncommon::compare_arrays($confhash{'editors'},
+ $staticdefaults{'editors'});
+ unless (@diffs == 0) {
+ $changes{'editors'} = 1;
+ }
}
foreach my $key ('authorquota','webdav') {
if (ref($curr_quotas{$key}) eq 'HASH') {
@@ -13547,7 +13617,7 @@ sub modify_authordefaults {
$resulttext .= '';
}
my $domcoordoverride;
- foreach my $key ('editors','authorquota','webdav','webdav_LC_adv') {
+ foreach my $key ('editors','authorquota','webdav','webdav_LC_adv','archive') {
if (exists($changes{$key})) {
my $shown;
unless ($domcoordoverride) {
@@ -13579,6 +13649,9 @@ sub modify_authordefaults {
} else {
$shown = $titles{'none'};
}
+ } elsif ($key eq 'archive') {
+ $domdefaults{$key} = $confhash{$key};
+ $shown = ($confhash{$key} ? &mt('Yes') : &mt('No'));
}
$resulttext .= ''.&mt('[_1] set to: [_2]',$titles{$key},$shown).'';
}
@@ -13586,6 +13659,7 @@ sub modify_authordefaults {
if ($domcoordoverride) {
$resulttext .= '';
}
+ $resulttext .= '';
my $cachetime = 24*60*60;
&Apache::lonnet::do_cache_new('domdefaults',$dom,\%domdefaults,$cachetime);
if (ref($lastactref) eq 'HASH') {
@@ -13658,7 +13732,11 @@ sub modify_colors {
@bgs = ('pgbg','tabbg','sidebg');
}
my %defaults = &role_defaults($role,\@bgs,\@links,\@images,\@logintext);
- unless ($env{'form.'.$role.'_font'} eq $defaults{'font'}) {
+ $env{'form.'.$role.'_font'} = lc($env{'form.'.$role.'_font'});
+ if ($env{'form.'.$role.'_font'} =~ /^\w+/) {
+ $env{'form.'.$role.'_font'} = '#'.$env{'form.'.$role.'_font'};
+ }
+ unless ($env{'form.'.$role.'_font'} eq lc($defaults{'font'})) {
$confhash->{$role}{'font'} = $env{'form.'.$role.'_font'};
}
if ($role eq 'login') {
@@ -14789,6 +14867,7 @@ sub modify_quotas {
$resulttext .= ''.&mt('Validated course requests identified as processed by: [_1]',
''.$changes{'validation'}{'dc'}.'').'';
}
+ $resulttext .= '';
}
}
}
@@ -19819,21 +19898,27 @@ sub modify_usermodification {
}
}
}
- my @contexts = ('author','course');
+ my @contexts = ('author','coauthor','course');
my %context_title = (
author => 'In author context',
+ coauthor => 'As co-author manager',
course => 'In course context',
);
my @fields = ('lastname','firstname','middlename','generation',
'permanentemail','id');
my %roles = (
author => ['ca','aa'],
+ coauthor => ['ca','aa'],
course => ['st','ep','ta','in','cr'],
);
my %fieldtitles = &Apache::loncommon::personal_data_fieldtitles();
foreach my $context (@contexts) {
+ my $prefix = 'canmodify';
+ if ($context eq 'coauthor') {
+ $prefix = 'cacanmodify';
+ }
foreach my $role (@{$roles{$context}}) {
- my @modifiable = &Apache::loncommon::get_env_multiple('form.canmodify_'.$role);
+ my @modifiable = &Apache::loncommon::get_env_multiple('form.'.$prefix.'_'.$role);
foreach my $item (@fields) {
if (grep(/^\Q$item\E$/,@modifiable)) {
$modifyhash{$context}{$role}{$item} = 1;
@@ -21213,12 +21298,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 +21494,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 +21533,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 +21577,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 +21661,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 +21845,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 .= '';