--- loncom/interface/lonmodifycourse.pm 2010/03/29 17:32:28 1.52
+++ loncom/interface/lonmodifycourse.pm 2023/09/05 03:50:51 1.79.2.9.2.5
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# handler for DC-only modifiable course settings
#
-# $Id: lonmodifycourse.pm,v 1.52 2010/03/29 17:32:28 raeburn Exp $
+# $Id: lonmodifycourse.pm,v 1.79.2.9.2.5 2023/09/05 03:50:51 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -34,23 +34,36 @@ use Apache::loncommon;
use Apache::lonhtmlcommon;
use Apache::lonlocal;
use Apache::lonuserutils;
+use Apache::loncreateuser;
use Apache::lonpickcourse;
use lib '/home/httpd/lib/perl';
-use LONCAPA;
+use LONCAPA qw(:DEFAULT :match);
+
+my $registered_cleanup;
+my $modified_dom;
sub get_dc_settable {
- my ($type) = @_;
+ my ($type,$cdom) = @_;
if ($type eq 'Community') {
- return ('courseowner');
+ return ('courseowner','selfenrollmgrdc','selfenrollmgrcc');
} else {
- return ('courseowner','coursecode','authtype','autharg');
+ my @items = ('courseowner','coursecode','authtype','autharg','selfenrollmgrdc',
+ 'selfenrollmgrcc','mysqltables');
+ if (&showcredits($cdom)) {
+ push(@items,'defaultcredits');
+ }
+ my %passwdconf = &Apache::lonnet::get_passwdconf($cdom);
+ if (($passwdconf{'crsownerchg'}) && ($type ne 'Placement')) {
+ push(@items,'nopasswdchg');
+ }
+ return @items;
}
}
sub autoenroll_keys {
- my $internals = ['coursecode','courseowner','authtype','autharg','autoadds','autodrops',
- 'autostart','autoend','sectionnums','crosslistings',
- 'co-owners'];
+ my $internals = ['coursecode','courseowner','authtype','autharg','defaultcredits',
+ 'autoadds','autodrops','autostart','autoend','sectionnums',
+ 'crosslistings','co-owners','autodropfailsafe'];
my $accessdates = ['default_enrollment_start_date','default_enrollment_end_date'];
return ($internals,$accessdates);
}
@@ -84,10 +97,11 @@ sub get_enrollment_settings {
my ($cdom,$cnum) = @_;
my ($internals,$accessdates) = &autoenroll_keys();
my @items;
- if ((ref($internals) eq 'ARRAY') && (ref($accessdates) eq 'ARRAY')) {
+ if ((ref($internals) eq 'ARRAY') && (ref($accessdates) eq 'ARRAY')) {
@items = map { 'internal.'.$_; } (@{$internals});
push(@items,@{$accessdates});
}
+ push(@items,'internal.nopasswdchg');
my %settings = &Apache::lonnet::get('environment',\@items,$cdom,$cnum);
my %enrollvar;
$enrollvar{'autharg'} = '';
@@ -112,8 +126,13 @@ sub get_enrollment_settings {
$enrollvar{$type} =~ s/,/, /g;
} elsif ($type eq "authtype"
|| $type eq "autharg" || $type eq "coursecode"
- || $type eq "crosslistings") {
+ || $type eq "crosslistings" || $type eq "selfenrollmgr"
+ || $type eq "autodropfailsafe" || $type eq 'nopasswdchg') {
$enrollvar{$type} = $settings{$item};
+ } elsif ($type eq 'defaultcredits') {
+ if (&showcredits($cdom)) {
+ $enrollvar{$type} = $settings{$item};
+ }
} elsif ($type eq 'courseowner') {
if ($settings{$item} =~ /^[^:]+:[^:]+$/) {
$enrollvar{$type} = $settings{$item};
@@ -145,165 +164,461 @@ sub print_course_search_page {
$type = 'Course';
}
&print_header($r,$type);
- my $filterlist = ['descriptfilter',
- 'instcodefilter','ownerfilter',
- 'coursefilter'];
- my $filter = {};
- my ($numtitles,$cctitle,$dctitle);
+ my ($filterlist,$filter) = &get_filters($dom);
+ my ($numtitles,$cctitle,$dctitle,@codetitles);
my $ccrole = 'cc';
if ($type eq 'Community') {
$ccrole = 'co';
}
$cctitle = &Apache::lonnet::plaintext($ccrole,$type);
$dctitle = &Apache::lonnet::plaintext('dc');
- $r->print(&Apache::lonpickcourse::js_changer());
+ $r->print(&Apache::loncommon::js_changer());
if ($type eq 'Community') {
$r->print('
'.&mt('Search for a community in the [_1] domain',$domdesc).'
');
} else {
$r->print('
'.&mt('Search for a course in the [_1] domain',$domdesc).'
');
- }
- $r->print(&Apache::lonpickcourse::build_filters($filterlist,$type,
- undef,undef,$filter,$action,\$numtitles,'modifycourse'));
+ }
+ $r->print(&Apache::loncommon::build_filters($filterlist,$type,undef,undef,$filter,$action,
+ \$numtitles,'modifycourse',undef,undef,undef,
+ \@codetitles,$dom));
+
+ my ($actiontext,$roleoption,$settingsoption);
if ($type eq 'Community') {
- $r->print(&mt('Actions available after searching for a community:').'
'.
- '
'.&mt('Enter the community with the role of [_1]',$cctitle).'
'."\n".
- '
'.&mt('View or modify community settings which only a [_1] may modify.',$dctitle).
- '
'."\n".'
');
- } else {
- $r->print(&mt('Actions available after searching for a course:').'
'.
- '
'.&mt('Enter the course with the role of [_1]',$cctitle).'
'."\n".
- '
'.&mt('View or modify course settings which only a [_1] may modify.',$dctitle).
- '
'."\n".'
');
+ $actiontext = &mt('Actions available after searching for a community:');
+ } else {
+ $actiontext = &mt('Actions available after searching for a course:');
+ }
+ if (&Apache::lonnet::allowed('ccc',$dom)) {
+ if ($type eq 'Community') {
+ $roleoption = &mt('Enter the community with the role of [_1]',$cctitle);
+ $settingsoption = &mt('View or modify community settings which only a [_1] may modify.',$dctitle);
+ } else {
+ $roleoption = &mt('Enter the course with the role of [_1]',$cctitle);
+ $settingsoption = &mt('View or modify course settings which only a [_1] may modify.',$dctitle);
+ }
+ } elsif (&Apache::lonnet::allowed('rar',$dom)) {
+ my ($roles_by_num,$description,$accessref,$accessinfo) = &Apache::lonnet::get_all_adhocroles($dom);
+ if ((ref($roles_by_num) eq 'ARRAY') && (ref($description) eq 'HASH')) {
+ if (@{$roles_by_num} > 1) {
+ if ($type eq 'Community') {
+ $roleoption = &mt('Enter the community with one of the available ad hoc roles');
+ } else {
+ $roleoption = &mt('Enter the course with one of the available ad hoc roles.');
+ }
+ } else {
+ my $rolename = $description->{$roles_by_num->[0]};
+ if ($type eq 'Community') {
+ $roleoption = &mt('Enter the community with the ad hoc role of: [_1]',$rolename);
+ } else {
+ $roleoption = &mt('Enter the course with the ad hoc role of: [_1]',$rolename);
+ }
+ }
+ }
+ if ($type eq 'Community') {
+ $settingsoption = &mt('View community settings which only a [_1] may modify.',$dctitle);
+ } else {
+ $settingsoption = &mt('View course settings which only a [_1] may modify.',$dctitle);
+ }
}
+ $r->print($actiontext.'
');
+ if ($roleoption) {
+ $r->print('
'.$roleoption.'
'."\n");
+ }
+ $r->print('
'.$settingsoption.'
'."\n".'
');
+ return;
}
sub print_course_selection_page {
- my ($r,$dom,$domdesc) = @_;
+ my ($r,$dom,$domdesc,$permission) = @_;
my $type = $env{'form.type'};
if (!defined($type)) {
$type = 'Course';
}
&print_header($r,$type);
-# Criteria for course search
- my $filterlist = ['descriptfilter',
- 'instcodefilter','ownerfilter',
- 'ownerdomfilter','coursefilter'];
- my %filter;
+ if ($permission->{'adhocrole'} eq 'custom') {
+ my %lt = &Apache::lonlocal::texthash(
+ title => 'Ad hoc role selection',
+ preamble => 'Please choose an ad hoc role in the course.',
+ cancel => 'Click "OK" to enter the course, or "Cancel" to choose a different course.',
+ );
+ my %jslt = &Apache::lonlocal::texthash (
+ none => 'You are not eligible to use an ad hoc role for the selected course',
+ ok => 'OK',
+ exit => 'Cancel',
+ );
+ &js_escape(\%jslt);
+ $r->print(<<"END");
+
+
+
+
$lt{'preamble'}
+
+
$lt{'cancel'}
+
+END
+ } elsif ($permission->{'adhocrole'} eq 'coord') {
+ $r->print(<<"END");
+
+END
+ }
+
+# Criteria for course search
+ my ($filterlist,$filter) = &get_filters();
my $action = '/adm/modifycourse';
my $dctitle = &Apache::lonnet::plaintext('dc');
- my $numtitles;
- $r->print(&Apache::lonpickcourse::js_changer());
+ my ($numtitles,@codetitles);
+ $r->print(&Apache::loncommon::js_changer());
$r->print(&mt('Revise your search criteria for this domain').' ('.$domdesc.'). ');
- $r->print(&Apache::lonpickcourse::build_filters($filterlist,$type,
- undef,undef,\%filter,$action,\$numtitles));
- $filter{'domainfilter'} = $dom;
- my %courses = &Apache::lonpickcourse::search_courses($r,$type,0,
- \%filter,$numtitles);
+ $r->print(&Apache::loncommon::build_filters($filterlist,$type,undef,undef,$filter,$action,
+ \$numtitles,'modifycourse',undef,undef,undef,
+ \@codetitles,$dom,$env{'form.form'}));
+ my %courses = &Apache::loncommon::search_courses($dom,$type,$filter,$numtitles,
+ undef,undef,undef,\@codetitles);
&Apache::lonpickcourse::display_matched_courses($r,$type,0,$action,undef,undef,undef,
- %courses);
+ $dom,undef,%courses);
return;
}
+sub get_filters {
+ my ($dom) = @_;
+ my @filterlist = ('descriptfilter','instcodefilter','ownerfilter',
+ 'ownerdomfilter','coursefilter','sincefilter');
+ # created filter
+ my $loncaparev = &Apache::lonnet::get_server_loncaparev($dom);
+ if ($loncaparev ne 'unknown_cmd') {
+ push(@filterlist,'createdfilter');
+ }
+ my %filter;
+ foreach my $item (@filterlist) {
+ $filter{$item} = $env{'form.'.$item};
+ }
+ return (\@filterlist,\%filter);
+}
+
sub print_modification_menu {
- my ($r,$cdesc,$domdesc,$dom,$type) = @_;
+ my ($r,$cdesc,$domdesc,$dom,$type,$cid,$coursehash,$permission) = @_;
&print_header($r,$type);
- my ($ccrole,$setquota_text,$setparams_text,$cat_text);
+ my ($ccrole,$categorytitle,$setquota_text,$setuploadquota_text,$cdom,$cnum,
+ $extendedtype);
+ if (ref($coursehash) eq 'HASH') {
+ $cdom = $coursehash->{'domain'};
+ $cnum = $coursehash->{'num'};
+ } else {
+ ($cdom,$cnum) = split(/_/,$cid);
+ }
if ($type eq 'Community') {
$ccrole = 'co';
} else {
$ccrole = 'cc';
- }
- my $action = '/adm/modifycourse';
- if ($type eq 'Community') {
- $setquota_text = &mt('Total disk space allocated for storage of portfolio files in all groups in a community.');
- $setparams_text = 'View/Modify community owner';
- $cat_text = 'View/Modify catalog settings for community';
- } else {
- $setquota_text = &mt('Total disk space allocated for storage of portfolio files in all groups in a course.');
- $setparams_text = 'View/Modify course owner, institutional code, and default authentication';
- $cat_text = 'View/Modify catalog settings for course';
}
- my @menu =
- (
- { text => $setparams_text,
- phase => 'setparms',
- },
- { text => 'View/Modify quota for group portfolio files',
- phase => 'setquota',
- }
- );
- my %domconf = &Apache::lonnet::get_dom('configuration',['coursecategories'],$dom);
- my @additional_params = &catalog_settable($domconf{'coursecategories'},$type);
- if (@additional_params > 0) {
- push (@menu, { text => $cat_text,
- phase => 'catsettings',
- });
+ my %linktext;
+ if ($permission->{'setparms'} eq 'edit') {
+ %linktext = (
+ 'setquota' => 'View/Modify quotas for group portfolio files, and for uploaded content',
+ 'setanon' => 'View/Modify responders threshold for anonymous survey submissions display',
+ 'selfenroll' => 'View/Modify Self-Enrollment configuration',
+ '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',
+ );
+ } else {
+ %linktext = (
+ 'setquota' => 'View quotas for group portfolio files, and for uploaded content',
+ 'setanon' => 'View responders threshold for anonymous survey submissions display',
+ 'selfenroll' => 'View Self-Enrollment configuration',
+ 'setpostsubmit' => 'View submit button behavior, post-submission',
+ 'setltiauth' => 'View re-authentication requirement for LTI launch of deep-linked item',
+ 'setexttool' => 'View External Tools permissions',
+ );
}
- unless ($type eq 'Community') {
- push(@menu,
- { text => 'Display current settings for automated enrollment',
- phase => 'viewparms',
- }
- );
- }
- my $menu_html = '
'."\n";
- if ($type eq 'Community') {
- $menu_html .= &mt('Although almost all community settings can be modified by a Coordinator, the following may only be set or modified by a Domain Coordinator:');
- } else {
- $menu_html .= &mt('Although almost all course settings can be modified by a Course Coordinator, the following may only be set or modified by a Domain Coordinator:');
- }
- $menu_html .= '
';
if ($type eq 'Community') {
- $menu_html .= '
'.&mt('Community owner (permitted to assign Coordinator roles in the community).').'
';
+ if ($permission->{'setparms'} eq 'edit') {
+ $categorytitle = 'View/Modify Community Settings';
+ $linktext{'setparms'} = 'View/Modify community owner, self-enrollment and table lifetime';
+ $linktext{'catsettings'} = 'View/Modify catalog settings for community';
+ } else {
+ $categorytitle = 'View Community Settings';
+ $linktext{'setparms'} = 'View community owner, self-enrollment and table lifetime';
+ $linktext{'catsettings'} = 'View catalog settings for community';
+ }
+ $setquota_text = &mt('Total disk space allocated for storage of portfolio files in all groups in a community.');
+ $setuploadquota_text = &mt('Disk space allocated for storage of content uploaded directly to a community via Content Editor.');
} else {
- $menu_html .= '
'.&mt('Course owner (permitted to assign Course Coordinator roles in the course).').'
'.
- '
'.&mt("Institutional code and default authentication (both required for auto-enrollment of students from institutional datafeeds).").'
';
- }
- $menu_html .= '
'.$setquota_text.'
'."\n";
- foreach my $item (@additional_params) {
- if ($type eq 'Community') {
- if ($item eq 'togglecats') {
- $menu_html .= '
'.&mt('Hiding/unhiding a community from the catalog (although can be [_1]configured[_2] to be modifiable by a Coordinator in community context).','','').'
'.&mt('Hiding/unhiding a course from the course catalog (although can be [_1]configured[_2] to be modifiable by a Course Coordinator in course context).','','').'
'.&mt('Manual cataloging of a course (although can be [_1]configured[_2] to be modifiable by a Course Coordinator in course context).','','').'
'."\n";
+ $categorytitle = 'View Course Settings';
+ $linktext{'catsettings'} = 'View catalog settings for course';
+ if (($type ne 'Placement') && (&showcredits($dom))) {
+ $linktext{'setparms'} = 'View course owner, institutional code, default authentication, credits, self-enrollment and table lifetime';
+ } else {
+ $linktext{'setparms'} = 'View course owner, institutional code, default authentication, self-enrollment and table lifetime';
+ }
+ }
+ $setquota_text = &mt('Total disk space allocated for storage of portfolio files in all groups in a course.');
+ $setuploadquota_text = &mt('Disk space allocated for storage of content uploaded directly to a course via Content Editor.');
+ my %settings = &Apache::lonnet::get('environment',['internal.coursecode','internal.textbook'],
+ $cdom,$cnum);
+ $extendedtype = ucfirst(&Apache::lonuserutils::get_extended_type($cdom,$cnum,$type,\%settings));
+ }
+ my $anon_text = &mt('Responder threshold required to display anonymous survey submissions.');
+ my $postsubmit_text = &mt('Override defaults for submit button behavior post-submission for this specific course.');
+ my $mysqltables_text = &mt('Override default for lifetime of "temporary" MySQL tables containing student performance data.');
+ my $ltiauth_text = &mt('Override default for requirement for re-authentication for LTI-limited launch of deep-linked item.');
+ my $exttool_text = &mt('Override default permissions for external tools use for this specific course.');
+ $linktext{'viewparms'} = 'Display current settings for automated enrollment';
+
+ my %domconf = &Apache::lonnet::get_dom('configuration',['coursecategories'],$dom);
+ my @additional_params = &catalog_settable($domconf{'coursecategories'},$type);
+
+ sub manage_selfenrollment {
+ my ($cdom,$cnum,$type,$coursehash,$permission) = @_;
+ if ($permission->{'selfenroll'}) {
+ my ($managed_by_cc,$managed_by_dc) = &Apache::lonuserutils::selfenrollment_administration($cdom,$cnum,$type,$coursehash);
+ if (ref($managed_by_dc) eq 'ARRAY') {
+ if (@{$managed_by_dc}) {
+ return 1;
+ }
}
}
+ return 0;
}
- $menu_html .= '
'.&mt('[_1] still set to: [_2]',$longtype{$attr},$shown).'
';
}
}
if (($type ne 'Community') && ($changed{'code'} || $changed{'owner'})) {
@@ -768,6 +1826,8 @@ sub modify_course {
push(@warnings,&mt('There is no owner associated with this LON-CAPA course.').
' '.&mt('If automated enrollment at your institution requires validation of course owners, automated enrollment will fail.'));
} else {
+ my %crsenv = &Apache::lonnet::get('environment',['internal.co-owners'],$cdom,$cnum);
+ my $coowners = $crsenv{'internal.co-owners'};
if (@sections > 0) {
if ($changed{'code'}) {
foreach my $sec (@sections) {
@@ -776,13 +1836,12 @@ sub modify_course {
my $inst_course_id = $newattr{'coursecode'}.$1;
my $course_check = &Apache::lonnet::auto_validate_courseID($cnum,$cdom,$inst_course_id);
if ($course_check eq 'ok') {
- my $outcome = &Apache::lonnet::auto_new_course($cnum,$cdom,$inst_course_id,$newattr{'courseowner'});
+ my $outcome = &Apache::lonnet::auto_new_course($cnum,$cdom,$inst_course_id,$newattr{'courseowner'},$coowners);
unless ($outcome eq 'ok') {
-
- push(@warnings,&mt('If automatic enrollment is enabled for "[_1]" automated enrollment may fail for "[_2]" - section: [_3], for the following reason: "[_4]"',$description,$newattr{'coursecode'},$instsec,$outcome).' ');
+ push(@warnings,&mt('If automatic enrollment is enabled for "[_1]", automated enrollment may fail for "[_2]" - section: [_3] for the following reason: "[_4]".',$description,$newattr{'coursecode'},$instsec,$outcome).' ');
}
} else {
- push(@warnings,&mt('If automatic enrollment is enabled for "[_1]" automated enrollment may fail for "[_2]" - section: [_3], for the following reason: "[_4]"',$description,$newattr{'coursecode'},$instsec,$course_check));
+ push(@warnings,&mt('If automatic enrollment is enabled for "[_1]", automated enrollment may fail for "[_2]" - section: [_3] for the following reason: "[_4]".',$description,$newattr{'coursecode'},$instsec,$course_check));
}
} else {
push(@warnings,&mt('If automatic enrollment is enabled for "[_1]", automated enrollment may fail for "[_2]" - section: [_3], because this is not a valid section entry.',$description,$newattr{'coursecode'},$sec));
@@ -793,23 +1852,23 @@ sub modify_course {
if ($sec =~ m/^(.+):/) {
my $instsec = $1;
my $inst_course_id = $newattr{'coursecode'}.$instsec;
- my $outcome = &Apache::lonnet::auto_new_course($cnum,$cdom,$inst_course_id,$newattr{'courseowner'});
+ my $outcome = &Apache::lonnet::auto_new_course($cnum,$cdom,$inst_course_id,$newattr{'courseowner'},$coowners);
unless ($outcome eq 'ok') {
- push(@warnings,&mt('If automatic enrollment is enabled for "[_1]", automated enrollment may fail for "[_2]" - section [_3] for the following reason: "[_4]".',$description,$newattr{'coursecode'},$instsec,$outcome));
+ push(@warnings,&mt('If automatic enrollment is enabled for "[_1]", automated enrollment may fail for "[_2]" - section: [_3] for the following reason: "[_4]".',$description,$newattr{'coursecode'},$instsec,$outcome));
}
} else {
- push(@warnings,&mt('If automatic enrollment is enabled for "[_1]", automated enrollment may fail for "[_2]" - section [_3] because this is not a valid section entry.',$description,$newattr{'coursecode'},$sec));
+ push(@warnings,&mt('If automatic enrollment is enabled for "[_1]", automated enrollment may fail for "[_2]" - section: [_3], because this is not a valid section entry.',$description,$newattr{'coursecode'},$sec));
}
}
}
} else {
- push(@warnings,&mt('As no section numbers are currently listed for "[_1]" automated enrollment will not occur for any sections of institutional course code: "[_2]".',$description,$newattr{'coursecode'}));
+ push(@warnings,&mt('As no section numbers are currently listed for "[_1]", automated enrollment will not occur for any sections of institutional course code: "[_2]".',$description,$newattr{'coursecode'}));
}
if ( (@xlists > 0) && ($changed{'owner'}) ) {
foreach my $xlist (@xlists) {
if ($xlist =~ m/^(.+):/) {
my $instxlist = $1;
- my $outcome = &Apache::lonnet::auto_new_course($cnum,$cdom,$instxlist,$newattr{'courseowner'});
+ my $outcome = &Apache::lonnet::auto_new_course($cnum,$cdom,$instxlist,$newattr{'courseowner'},$coowners);
unless ($outcome eq 'ok') {
push(@warnings,&mt('If automatic enrollment is enabled for "[_1]", automated enrollment may fail for crosslisted class "[_2]" for the following reason: "[_3]".',$description,$instxlist,$outcome));
}
@@ -821,7 +1880,17 @@ sub modify_course {
}
} else {
foreach my $attr (@modifiable_params) {
- $nochgresponse .= '
'.$longtype{$attr}.' '.&mt('still set to').' "'.$currattr{$attr}.'".
";
}
my ($warning,$numwarnings);
- my $numwarnings = scalar(@warnings);
+ my $numwarnings = scalar(@warnings);
if ($numwarnings) {
$warning = &mt('The following [quant,_1,warning was,warnings were] generated when applying your changes to automated enrollment:',$numwarnings).'
';
foreach my $warn (@warnings) {
@@ -846,26 +1915,45 @@ sub modify_course {
$reply = $chgresponse.$nochgresponse.$warning;
}
&print_header($r,$type);
- my $mainheader = &modifiable_only_title($type);
- $reply = '