--- loncom/interface/lonmodifycourse.pm 2023/12/23 02:17:38 1.104
+++ loncom/interface/lonmodifycourse.pm 2024/04/14 17:12:27 1.105
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# handler for DC-only modifiable course settings
#
-# $Id: lonmodifycourse.pm,v 1.104 2023/12/23 02:17:38 raeburn Exp $
+# $Id: lonmodifycourse.pm,v 1.105 2024/04/14 17:12:27 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -434,6 +434,7 @@ sub print_modification_menu {
'setltiauth' => 'View/Modify re-authentication requirement for LTI launch of deep-linked item',
'setexttool' => 'View/Modify External Tools permissions',
'setcrsauthor' => 'View/Modify In-course Authoring permissions',
+ 'setcrseditors' => 'View/Modify permitted course resource editors',
);
} else {
%linktext = (
@@ -444,6 +445,7 @@ sub print_modification_menu {
'setltiauth' => 'View re-authentication requirement for LTI launch of deep-linked item',
'setexttool' => 'View External Tools permissions',
'setcrsauthor' => 'View In-course Authoring permissions',
+ 'setcrseditors' => 'View permitted course resource editors',
);
}
if ($type eq 'Community') {
@@ -592,6 +594,14 @@ sub print_modification_menu {
permission => $permission->{'setcrsauthor'},
linktitle => '',
},
+ {
+ linktext => $linktext{'setcrseditors'},
+ icon => 'crseditors.png',
+ #help => '',
+ url => &phaseurl('setcrseditors'),
+ permission => $permission->{'setcrseditors'},
+ linktitle => '',
+ },
]
},
);
@@ -1314,12 +1324,13 @@ sub print_selfenrollconfig {
sub print_default_overrides {
my ($r,$cdom,$cnum,$cdesc,$type,$readonly,$item) = @_;
my (%titles,$checkeddom,$checkedcrs,$divsty,$currcrsval,$crsdefault,%crschecked,
- $helpfile,$title,$crselements);
+ $helpfile,$title,$crselements,@currcrseditors);
%titles = &default_overrides_titles($type);
my ($title,$domdefdisplay,$settings,$optiontext,$options) =
&default_overrides_common($item,$cdom,$cnum,$type,\%titles);
$checkeddom = ' checked="checked"';
$divsty = 'display:none';
+
if ($item eq 'ltiauth') {
$helpfile = 'Modify_Course_LTI_Authen';
$crsdefault = 0;
@@ -1330,6 +1341,9 @@ sub print_default_overrides {
} elsif ($item eq 'crsauthor') {
$helpfile = 'Modify_Course_Crsauthor';
$crsdefault = 1;
+ } elsif ($item eq 'crseditors') {
+ $helpfile = 'Modify_Course_Resource_Editors';
+ $crsdefault = 'edit,xml';
}
}
$currcrsval = $settings->{'internal.'.$item};
@@ -1337,33 +1351,55 @@ sub print_default_overrides {
$checkedcrs = $checkeddom;
$checkeddom = '';
$divsty = 'display:inline-block';
+ if ($item eq 'crseditors') {
+ @currcrseditors = split(/,/,$currcrsval);
+ }
foreach my $option (@{$options}) {
- if ($currcrsval eq $option) {
+ if ($item eq 'crseditors') {
+ if (grep(/^\Q$option\E$/,@currcrseditors)) {
+ $crschecked{$option} = ' checked="checked"';
+ }
+ } elsif ($currcrsval eq $option) {
$crschecked{$option} = ' checked="checked"';
} else {
$crschecked{$option} = '';
}
}
} else {
+ if ($item eq 'crseditors') {
+ my %domdefs = &Apache::lonnet::get_domain_defaults($cdom);
+ @currcrseditors = split(/,/,$domdefs{'crseditors'});
+ }
foreach my $option (@{$options}) {
- if ($crsdefault eq $option) {
+ if ($item eq 'crseditors') {
+ if (grep(/^\Q$option\E$/,@currcrseditors)) {
+ $crschecked{$option} = ' checked="checked"';
+ }
+ } elsif ($crsdefault eq $option) {
$crschecked{$option} = ' checked="checked"';
} else {
$crschecked{$option} = '';
}
}
}
- my ($disabled,$submit);
+ my ($disabled,$submit,$inputtype,$separator);
if ($readonly) {
$disabled = ' disabled="disabled"';
} else {
$submit = '';
}
+ if ($item eq 'crseditors') {
+ $inputtype = 'checkbox';
+ $separator = ' 'x2;
+ } else {
+ $inputtype = 'radio';
+ $separator = '
';
+ }
foreach my $option (@{$options}) {
$crselements .= ''.
- ''.
- '
'."\n";
+ ''.$separator."\n";
}
&print_header($r,$type);
my $hidden_elements = &hidden_form_elements();
@@ -1406,6 +1442,10 @@ sub default_overrides_titles {
'dom' => 'Only external tools defined in domain may be used',
'both' => 'External tools defined/configured in either domain or course may be used',
'stan' => "'In-course' authoring of standard LON-CAPA problems",
+ 'perc' => 'Permitted course resource editors',
+ 'edit' => 'Standard editor (Edit)',
+ 'xml' => 'Text editor (EditXML)',
+ 'daxe' => 'Daxe editor (Daxe)',
'on' => 'In-course authoring available',
'off' => 'In-course authoring unavailable',
'used' => 'Use domain default',
@@ -1454,12 +1494,17 @@ sub default_overrides_common {
1 => $titles->{'on'},
0 => $titles->{'off'},
);
+ } elsif ($item eq 'crseditors') {
+ $title = $titles->{'perc'};
+ $domdef = 1;
+ @options = ('edit','xml','daxe');
+ map { $optiontext{$_} = $titles->{$_}; } @options;
}
}
my %domconfig =
&Apache::lonnet::get_dom('configuration',['coursedefaults'],$cdom);
if (ref($domconfig{'coursedefaults'}) eq 'HASH') {
- if ($item eq 'ltiauth') {
+ if (($item eq 'ltiauth') || ($item eq 'crseditors')) {
$domdef = $domconfig{'coursedefaults'}{$item};
} else {
my $lctype = &get_lctype($type,\%settings);
@@ -1499,6 +1544,18 @@ sub default_overrides_common {
} else {
$domdefdisplay = $titles->{'off'};
}
+ } elsif ($item eq 'crseditors') {
+ if (ref($domdef) eq 'ARRAY') {
+ if (@{$domdef} == 0) {
+ $domdefdisplay = &mt('No permitted editors');
+ } elsif (@{$domdef} == 1) {
+ $domdefdisplay = $titles->{$domdef->[0]}.' ('.&mt('only').')';
+ } else {
+ $domdefdisplay = join(', ', map { $titles->{$_}; } @{$domdef});
+ }
+ } else {
+ $domdefdisplay = join(', ', map { $titles->{$_}; } ('edit','xml'));
+ }
}
return ($title,$domdefdisplay,\%settings,\%optiontext,\@options);
}
@@ -2533,7 +2590,13 @@ sub modify_default_overrides {
chg => 'In-course authoring permissions changed',
nochg => 'In-course authoring permissions unchanged',
);
- }
+ } elsif ($item eq 'crseditors') {
+ %resulttext =
+ &Apache::lonlocal::texthash(
+ chg => 'Permitted course resource editors changed',
+ nochg => 'Permitted course resource editors unchanged',
+ );
+ }
&print_header($r,$type);
$r->print('