--- loncom/interface/lonmodifycourse.pm 2023/09/05 03:42:31 1.103
+++ loncom/interface/lonmodifycourse.pm 2024/08/21 03:11:41 1.106
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# handler for DC-only modifiable course settings
#
-# $Id: lonmodifycourse.pm,v 1.103 2023/09/05 03:42:31 raeburn Exp $
+# $Id: lonmodifycourse.pm,v 1.106 2024/08/21 03:11:41 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -433,6 +433,8 @@ sub print_modification_menu {
'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',
+ 'setcrsauthor' => 'View/Modify In-course Authoring permissions',
+ 'setcrseditors' => 'View/Modify permitted course resource editors',
);
} else {
%linktext = (
@@ -442,6 +444,8 @@ sub print_modification_menu {
'setpostsubmit' => 'View submit button behavior, post-submission',
'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') {
@@ -582,6 +586,22 @@ sub print_modification_menu {
permission => $permission->{'setexttool'},
linktitle => '',
},
+ {
+ linktext => $linktext{'setcrsauthor'},
+ icon => 'crsauthor.png',
+ #help => '',
+ url => &phaseurl('setcrsauthor'),
+ permission => $permission->{'setcrsauthor'},
+ linktitle => '',
+ },
+ {
+ linktext => $linktext{'setcrseditors'},
+ icon => 'crseditors.png',
+ #help => '',
+ url => &phaseurl('setcrseditors'),
+ permission => $permission->{'setcrseditors'},
+ linktitle => '',
+ },
]
},
);
@@ -1301,171 +1321,102 @@ sub print_selfenrollconfig {
return;
}
-sub print_set_ltiauth {
- my ($r,$cdom,$cnum,$cdesc,$type,$readonly) = @_;
- my %lt = &Apache::lonlocal::texthash(
- 'requ' => 'Requirement for re-authentication for student LTI-limited launch of deep-linked item',
- 'link' => 'Link protection can be set to accept username for an enrolled student (if sent by Consumer)',
- 'logi' => 'Login needed, regardless of user information sent by LTI Consumer in (signed) parameters',
- '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',
- );
- my ($domdef,$checkeddom,$checkedcrs,$domdefdisplay,$divsty,$authok,$authno);
- $domdef = 0;
+sub print_default_overrides {
+ my ($r,$cdom,$cnum,$cdesc,$type,$readonly,$item) = @_;
+ my (%titles,$checkeddom,$checkedcrs,$divsty,$currcrsval,$crsdefault,%crschecked,
+ $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"';
- $domdefdisplay = $lt{'logi'};
$divsty = 'display:none';
- $authno = ' checked="checked"';
- my %domconfig =
- &Apache::lonnet::get_dom('configuration',['coursedefaults'],$cdom);
- if (ref($domconfig{'coursedefaults'}) eq 'HASH') {
- $domdef = $domconfig{'coursedefaults'}{'ltiauth'};
- }
- if ($domdef) {
- $domdefdisplay = $lt{'link'};
- }
- my %settings = &Apache::lonnet::get('environment',['internal.ltiauth'],$cdom,$cnum);
- my $ltiauth = $settings{'internal.ltiauth'};
- if ($ltiauth ne '') {
+ if ($item eq 'ltiauth') {
+ $helpfile = 'Modify_Course_LTI_Authen';
+ $crsdefault = 0;
+ } else {
+ if ($item eq 'exttool') {
+ $helpfile = 'Modify_Course_External_Tool';
+ $crsdefault = 'both';
+ } 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};
+ if ($currcrsval ne '') {
$checkedcrs = $checkeddom;
$checkeddom = '';
$divsty = 'display:inline-block';
- if ($ltiauth) {
- $authok = ' checked="checked"';
+ if ($item eq 'crseditors') {
+ @currcrseditors = split(/,/,$currcrsval);
}
- }
- &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_LTI_Authen');
- my $showtype = &mt($type);
- $r->print(<$showtype: $cdesc
-
-ENDDOCUMENT
- my @actions =
- (''.
- $lt{'back'}.'');
- $r->print('
'.&Apache::lonhtmlcommon::actionbox(\@actions));
- 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};
+ foreach my $option (@{$options}) {
+ 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} = '';
}
}
- }
- 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) {
+ } else {
+ if ($item eq 'crseditors') {
+ my %domdefs = &Apache::lonnet::get_domain_defaults($cdom);
+ @currcrseditors = split(/,/,$domdefs{'crseditors'});
+ }
+ foreach my $option (@{$options}) {
+ 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} = '';
}
}
}
- &print_header($r,$type);
- my $hidden_elements = &hidden_form_elements();
- my ($disabled,$submit);
+ my ($disabled,$submit,$inputtype,$separator);
if ($readonly) {
$disabled = ' disabled="disabled"';
} else {
- $submit = '';
+ $submit = '';
}
- my $helpitem = &Apache::loncommon::help_open_topic('Modify_Course_External_Tool');
+ if ($item eq 'crseditors') {
+ $inputtype = 'checkbox';
+ $separator = ' 'x2;
+ } else {
+ $inputtype = 'radio';
+ $separator = '
';
+ }
+ foreach my $option (@{$options}) {
+ $crselements .= ''.
+ ''.
+ ''.$separator."\n";
+ }
+ &print_header($r,$type);
+ my $hidden_elements = &hidden_form_elements();
+ my $helpitem = &Apache::loncommon::help_open_topic($helpfile);
my $showtype = &mt($type);
$r->print(<$helpitem $title
$showtype: $cdesc
-
$submit
$hidden_elements
@@ -1473,20 +1424,30 @@ $hidden_elements
ENDDOCUMENT
my @actions =
- (''.
+ (''.
$titles{'back'}.'');
$r->print('
'.&Apache::lonhtmlcommon::actionbox(\@actions));
return;
}
-sub exttool_titles {
+sub default_overrides_titles {
my ($type) = @_;
my %titles = &Apache::lonlocal::texthash(
+ 'requ' => 'Requirement for re-authentication for student LTI-limited launch of deep-linked item',
+ 'link' => 'Link protection can be set to accept username for an enrolled student (if sent by Consumer)',
+ 'logi' => 'Login needed, regardless of user information sent by LTI Consumer in (signed) parameters',
'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',
+ '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',
'cour' => 'Use course-specific setting',
'curd' => 'Current domain default is',
@@ -1503,6 +1464,102 @@ sub exttool_titles {
return %titles;
}
+sub default_overrides_common {
+ my ($item,$cdom,$cnum,$type,$titles) = @_;
+ my ($title,$domdef,$domdefdom,$domdefdisplay,%settings,%optiontext,@options);
+ if ($item eq 'ltiauth') {
+ %settings = &Apache::lonnet::get('environment',['internal.'.$item],$cdom,$cnum);
+ $title = $titles->{'requ'};
+ $domdef = 0;
+ @options = ('0','1');
+ %optiontext = (
+ 0 => $titles->{'logi'},
+ 1 => $titles->{'link'},
+ );
+ } else {
+ %settings =
+ &Apache::lonnet::get('environment',['internal.'.$item,'internal.coursecode',
+ 'internal.textbook'],$cdom,$cnum);
+ if ($item eq 'exttool') {
+ $title = $titles->{'extt'};
+ $domdefdom = 1;
+ $domdef = 0;
+ @options = ('both','dom','crs','none');
+ map { $optiontext{$_} = $titles->{$_}; } @options;
+ } elsif ($item eq 'crsauthor') {
+ $title = $titles->{'stan'};
+ $domdef = 1;
+ @options = ('1','0');
+ %optiontext = (
+ 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') || ($item eq 'crseditors')) {
+ $domdef = $domconfig{'coursedefaults'}{$item};
+ } else {
+ my $lctype = &get_lctype($type,\%settings);
+ if (ref($domconfig{'coursedefaults'}{$item}) eq 'HASH') {
+ if (exists($domconfig{'coursedefaults'}{$item}{$lctype})) {
+ $domdef = $domconfig{'coursedefaults'}{$item}{$lctype};
+ }
+ }
+ if ($item eq 'exttool') {
+ if (ref($domconfig{'coursedefaults'}{'domexttool'}) eq 'HASH') {
+ if (exists($domconfig{'coursedefaults'}{'domexttool'}{$lctype})) {
+ $domdefdom = $domconfig{'coursedefaults'}{'domexttool'}{$lctype};
+ }
+ }
+ }
+ }
+ }
+ if ($item eq 'ltiauth') {
+ if ($domdef) {
+ $domdefdisplay = $titles->{'link'};
+ } else {
+ $domdefdisplay = $titles->{'logi'};
+ }
+ } elsif ($item eq 'exttool') {
+ if ($domdef && $domdefdom) {
+ $domdefdisplay = $titles->{'both'};
+ } elsif ($domdef) {
+ $domdefdisplay = $titles->{'crs'};
+ } elsif ($domdefdom) {
+ $domdefdisplay = $titles->{'dom'};
+ } else {
+ $domdefdisplay = $titles->{'none'};
+ }
+ } elsif ($item eq 'crsauthor') {
+ if ($domdef) {
+ $domdefdisplay = $titles->{'on'};
+ } 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);
+}
+
sub modify_selfenrollconfig {
my ($r,$type,$cdesc,$coursehash) = @_;
return unless(ref($coursehash) eq 'HASH');
@@ -2508,182 +2565,87 @@ sub modify_catsettings {
return;
}
-sub modify_ltiauth {
- my ($r,$cdom,$cnum,$cdesc,$domdesc,$type) = @_;
- my %lt = &Apache::lonlocal::texthash(
- 'requ' => 'Requirement for re-authentication for student LTI-limited launch of deep-linked item',
- 'link' => 'Link protection can be set to accept username for an enrolled student (if sent by Consumer)',
- 'logi' => 'Login needed, regardless of user information sent by LTI Consumer in (signed) parameters',
- 'used' => 'Use domain default',
- 'cour' => 'Use course-specific setting',
- 'modi' => 'Save',
- 'back' => 'Pick another action',
- );
+sub modify_default_overrides {
+ my ($r,$cdom,$cnum,$cdesc,$domdesc,$type,$item) = @_;
+ my (%titles,$oldcrsval,$newcrsval,%resulttext,$itemvalue,$nochange,$change,$status,$error);
+ %titles = &default_overrides_titles($type);
+ my ($title,$domdefdisplay,$oldsettings,$optiontext,$options) =
+ &default_overrides_common($item,$cdom,$cnum,$type,\%titles);
+ $oldcrsval = $oldsettings->{'internal.'.$item};
+ if ($item eq 'ltiauth') {
+ %resulttext =
+ &Apache::lonlocal::texthash(
+ chg => 'Re-authentication requirement for LTI launch of deep-linked changed',
+ nochg => 'Re-authentication requirement for LTI launch of deep-linked item is unchanged',
+ );
+ } elsif ($item eq 'exttool') {
+ %resulttext =
+ &Apache::lonlocal::texthash(
+ chg => 'External Tool permissions changed',
+ nochg => 'External Tool permissions unchanged',
+ );
+ } elsif ($item eq 'crsauthor') {
+ %resulttext =
+ &Apache::lonlocal::texthash(
+ 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('