'.
+ &Apache::loncommon::start_data_table().
+ &build_tools_display($ccuname,$ccdomain,'requestcourses').
+ &Apache::loncommon::end_data_table());
+ }
$r->print('');
my $user_auth_text = &user_authentication($ccuname,$ccdomain,$formname);
- my ($user_quota_text,$user_tools_text);
+ my ($user_quota_text,$user_tools_text,$user_reqcrs_text);
if ((&Apache::lonnet::allowed('mpq',$ccdomain)) ||
(&Apache::lonnet::allowed('mut',$ccdomain))) {
# Current user has quota modification privileges
@@ -1680,8 +1713,8 @@ sub update_user_data {
}
if ( $env{'form.ccuname'} ne
&LONCAPA::clean_username($env{'form.ccuname'}) ) {
- $r->print($error.&mt('Invalid login name').'. '.
- &mt('Only letters, numbers, periods, dashes, @, and underscores are valid').'.'.
+ $r->print($error.&mt('Invalid login name.').' '.
+ &mt('Only letters, numbers, periods, dashes, @, and underscores are valid.').
$end.$rtnlink);
return;
}
@@ -1691,8 +1724,8 @@ sub update_user_data {
}
if ( $env{'form.ccdomain'} ne
&LONCAPA::clean_domain($env{'form.ccdomain'}) ) {
- $r->print($error.&mt ('Invalid domain name').'. '.
- &mt('Only letters, numbers, periods, dashes, and underscores are valid').'.'.
+ $r->print($error.&mt('Invalid domain name.').' '.
+ &mt('Only letters, numbers, periods, dashes, and underscores are valid.').
$end.$rtnlink);
return;
}
@@ -1740,6 +1773,7 @@ sub update_user_data {
$env{'form.ccuname'}, $env{'form.ccdomain'}).'');
my (%alerts,%rulematch,%inst_results,%curr_rules);
my @usertools = ('aboutme','blog','portfolio');
+ my @requestcourses = ('official','unofficial');
if ($env{'form.makeuser'}) {
$r->print('
'.&mt('Creating new account.').'
');
# Check for the authentication mode and password
@@ -1813,9 +1847,15 @@ sub update_user_data {
foreach my $item (@usertools) {
if ($env{'form.custom'.$item} == 1) {
$newcustom{$item} = $env{'form.tools_'.$item};
- $changed{$item} = &tool_admin($item,$newcustom{$item},\%changeHash);
+ $changed{$item} = &tool_admin($item,$newcustom{$item},
+ \%changeHash,'tools');
}
}
+ foreach my $item (@requestcourses) {
+ $newcustom{$item} = $env{'form.requestcourses_'.$item};
+ $changed{$item} = &tool_admin($item,$newcustom{$item},
+ \%changeHash,'requestcourses');
+ }
if (keys(%changed)) {
$changeHash{'firstname'} = $env{'form.cfirstname'};
$changeHash{'middlename'} = $env{'form.cmiddlename'};
@@ -1860,7 +1900,8 @@ sub update_user_data {
my %userenv = &Apache::lonnet::get
('environment',['firstname','middlename','lastname','generation',
'id','permanentemail','portfolioquota','inststatus','tools.aboutme',
- 'tools.blog','tools.portfolio'],
+ 'tools.blog','tools.portfolio','requestcourses.official',
+ 'requestcourses.unofficial'],
$env{'form.ccdomain'},$env{'form.ccuname'});
my ($tmp) = keys(%userenv);
if ($tmp =~ /^(con_lost|error)/i) {
@@ -1988,13 +2029,16 @@ sub update_user_data {
$newdefquotatext,%oldaccess,%oldaccesstext,%newaccess,%newaccesstext);
my ($defquota,$settingstatus) =
&Apache::loncommon::default_quota($env{'form.ccdomain'},$inststatus);
- my ($showquota,$showtools);
+ my ($showquota,$showtools,$showrequestcourses);
if (&Apache::lonnet::allowed('mpq',$env{'form.ccdomain'})) {
$showquota = 1;
}
if (&Apache::lonnet::allowed('mut',$env{'form.ccdomain'})) {
$showtools = 1;
}
+ if (&Apache::lonnet::allowed('ccc',$env{'form.ccdomain'})) {
+ $showrequestcourses = 1;
+ }
my (%changeHash,%changed);
$changeHash{'portfolioquota'} = $userenv{'portfolioquota'};
if ($userenv{'portfolioquota'} ne '') {
@@ -2036,74 +2080,10 @@ sub update_user_data {
if ($newisdefault) {
$newdefquotatext = &get_defaultquota_text($settingstatus);
}
-
- foreach my $tool (@usertools) {
- if ($userenv{'tools.'.$tool} ne '') {
- $oldaccess{$tool} = &mt('custom');
- if ($userenv{'tools_'.$tool}) {
- $oldaccesstext{$tool} = &mt("availability set to 'on'");
- } else {
- $oldaccesstext{$tool} = &mt("availability set to 'off'");
- }
- $changeHash{'tools.'.$tool} = $userenv{'tools.'.$tool};
- if ($env{'form.custom'.$tool} == 1) {
- if ($env{'form.tools_'.$tool} ne $userenv{'tools.'.$tool}) {
- $changed{$tool} = &tool_admin($tool,$env{'form.tools_'.$tool},
- \%changeHash);
- if ($changed{$tool}) {
- $newaccess{$tool} = &mt('custom');
- if ($env{'form.tools_'.$tool}) {
- $newaccesstext{$tool} = &mt("availability set to 'on'");
- } else {
- $newaccesstext{$tool} = &mt("availability set to 'off'");
- }
- } else {
- $newaccess{$tool} = $oldaccess{$tool};
- if ($userenv{'tools.'.$tool}) {
- $newaccesstext{$tool} = &mt("availability set to 'on'");
- } else {
- $newaccesstext{$tool} = &mt("availability set to 'off'");
- }
- }
- } else {
- $newaccess{$tool} = $oldaccess{$tool};
- $newaccesstext{$tool} = $oldaccesstext{$tool};
- }
- } else {
- $changed{$tool} = &tool_admin($tool,'',\%changeHash);
- print STDERR "for $tool - changed is $changed{$tool}\n";
- if ($changed{$tool}) {
- $newaccess{$tool} = &mt('default');
- } else {
- $newaccess{$tool} = $oldaccess{$tool};
- if ($userenv{'tools.'.$tool}) {
- $newaccesstext{$tool} = &mt("availability set to 'on'");
- } else {
- $newaccesstext{$tool} = &mt("availability set to 'off'");
- }
- }
- }
- } else {
- $oldaccess{$tool} = &mt('default');
- if ($env{'form.custom'.$tool} == 1) {
- $changed{$tool} = &tool_admin($tool,$env{'form.tools_'.$tool},
- \%changeHash);
- if ($changed{$tool}) {
- $newaccess{$tool} = &mt('custom');
- if ($env{'form.tools_'.$tool}) {
- $newaccesstext{$tool} = &mt("availability set to 'on'");
- } else {
- $newaccesstext{$tool} = &mt("availability set to 'off'");
- }
- } else {
- $newaccess{$tool} = $oldaccess{$tool};
- }
- } else {
- $newaccess{$tool} = $oldaccess{$tool};
- }
- }
- }
-
+ &tool_changes('tools',\@usertools,\%oldaccess,\%oldaccesstext,\%userenv,
+ \%changeHash,\%changed,\%newaccess,\%newaccesstext);
+ &tool_changes('requestcourses',\@requestcourses,\%oldaccess,\%oldaccesstext,
+ \%userenv, \%changeHash,\%changed,\%newaccess,\%newaccesstext);
if ($env{'form.cfirstname'} ne $userenv{'firstname'} ||
$env{'form.cmiddlename'} ne $userenv{'middlename'} ||
$env{'form.clastname'} ne $userenv{'lastname'} ||
@@ -2129,11 +2109,27 @@ sub update_user_data {
($env{'user.domain'} eq $env{'form.ccdomain'})) {
my %newenvhash;
foreach my $key (keys(%changed)) {
- if ($key ne 'quota') {
+ if (($key eq 'official') || ($key eq 'unofficial')) {
+ $newenvhash{'environment.requestcourses.'.$key} =
+ $changeHash{'requestcourses.'.$key};
+ if ($changeHash{'requestcourses.'.$key} ne '') {
+ $newenvhash{'environment.canrequest.'.$key} =
+ $changeHash{'requestcourses.'.$key};
+ } else {
+ $newenvhash{'environment.canrequest.'.$key} =
+ &Apache::lonnet::usertools_access($env{'user.name'},$env{'user.domain'},
+ $key,'reload','requestcourses');
+ }
+ } elsif ($key ne 'quota') {
$newenvhash{'environment.tools.'.$key} =
$changeHash{'tools.'.$key};
- $newenvhash{'environment.availabletools.'.$key} =
- $changeHash{'tools.'.$key};
+ if ($changeHash{'tools.'.$key} ne '') {
+ $newenvhash{'environment.availabletools.'.$key} =
+ $changeHash{'tools.'.$key};
+ } else {
+ $newenvhash{'environment.availabletools.'.$key} =
+ &Apache::lonnet::usertools_access($env{'user.name'},$env{'user.domain'}, $key,'reload','tools');
+ }
}
}
if (keys(%newenvhash)) {
@@ -2162,19 +2158,21 @@ sub update_user_data {
((keys(%changed) > 0) && $chgresult eq 'ok')) {
# Tell the user we changed the name
my %lt=&Apache::lonlocal::texthash(
- 'uic' => "User Information Changed",
- 'frst' => "First",
- 'mddl' => "Middle",
- 'lst' => "Last",
- 'gen' => "Generation",
- 'id' => "Student/Employee ID",
- 'mail' => "Permanent E-mail",
- 'disk' => "Disk space allocated to portfolio files",
- 'blog' => "Blog Availability",
- 'aboutme' => "Home Page Availability",
- 'portfolio' => "Portfolio Availability",
- 'prvs' => "Previous",
- 'chto' => "Changed To"
+ 'uic' => "User Information Changed",
+ 'frst' => "First",
+ 'mddl' => "Middle",
+ 'lst' => "Last",
+ 'gen' => "Generation",
+ 'id' => "Student/Employee ID",
+ 'mail' => "Permanent E-mail",
+ 'disk' => "Disk space allocated to portfolio files",
+ 'blog' => "Blog Availability",
+ 'aboutme' => "Home Page Availability",
+ 'portfolio' => "Portfolio Availability",
+ 'official' => "Can Request Official Courses",
+ 'unofficial' => "Can Request Unofficial Courses",
+ 'prvs' => "Previous",
+ 'chto' => "Changed To"
);
$r->print('
'.$lt{'uic'}.'
'.
&Apache::loncommon::start_data_table().
@@ -2188,6 +2186,12 @@ sub update_user_data {
$lt{'id'}
$lt{'mail'}
END
+ if ($showrequestcourses) {
+ foreach my $item (@requestcourses) {
+ $r->print("
+
$lt{$item}
\n");
+ }
+ }
if ($showquota) {
$r->print("
$lt{'disk'}
\n");
@@ -2209,6 +2213,12 @@ END
$userenv{'id'}
$userenv{'permanentemail'}
END
+ if ($showrequestcourses) {
+ foreach my $item (@requestcourses) {
+ $r->print("
+
$oldaccess{$item} $oldaccesstext{$item}
\n");
+ }
+ }
if ($showquota) {
$r->print("
$oldportfolioquota Mb $olddefquotatext
\n");
@@ -2230,6 +2240,12 @@ END
$env{'form.cid'}
$env{'form.cpermanentemail'}
END
+ if ($showrequestcourses) {
+ foreach my $item (@requestcourses) {
+ $r->print("
+
$newaccess{$item} $newaccesstext{$item}
\n");
+ }
+ }
if ($showquota) {
$r->print("
$newportfolioquota Mb $newdefquotatext
\n");
@@ -2268,15 +2284,18 @@ END
$env{'form.ccdomain'}.' ');
}
} else { # End of if ($env ... ) logic
- # They did not want to change the users name, quota or tool availability,
+ # They did not want to change the users name, quota, tool availability,
+ # or ability to request creation of courses,
# but we can still tell them what the name and quota and availabilities are
my %lt=&Apache::lonlocal::texthash(
- 'id' => "Student/Employee ID",
- 'mail' => "Permanent e-mail",
- 'disk' => "Disk space allocated to user's portfolio files",
- 'blog' => "Blog Availability",
- 'aboutme' => "Home Page Availability",
- 'portfolio' => "Portfolio Availability",
+ 'id' => "Student/Employee ID",
+ 'mail' => "Permanent e-mail",
+ 'disk' => "Disk space allocated to user's portfolio files",
+ 'blog' => "Blog Availability",
+ 'aboutme' => "Home Page Availability",
+ 'portfolio' => "Portfolio Availability",
+ 'official' => "Can Request Official Courses",
+ 'unofficial' => "Can Request Unofficial Course",
);
$r->print(<<"END");
$userenv{'firstname'} $userenv{'middlename'} $userenv{'lastname'} $userenv{'generation'}
@@ -2285,6 +2304,12 @@ END
$r->print(' ['.$lt{'mail'}.': '.
$userenv{'permanentemail'}.']');
}
+ if ($showrequestcourses) {
+ foreach my $item (@requestcourses) {
+ $r->print(' ['.$lt{$item}.': '.$newaccess{$item}.' '.
+ $newaccesstext{$item}.']'."\n");
+ }
+ }
if ($showtools) {
foreach my $item (@usertools) {
$r->print(' ['.$lt{$item}.': '.$newaccess{$item}.' '.
@@ -2363,6 +2388,83 @@ END
$r->print(&Apache::loncommon::end_page());
}
+sub tool_changes {
+ my ($context,$usertools,$oldaccess,$oldaccesstext,$userenv,$changeHash,
+ $changed,$newaccess,$newaccesstext) = @_;
+ if (!((ref($usertools) eq 'ARRAY') && (ref($oldaccess) eq 'HASH') &&
+ (ref($oldaccesstext) eq 'HASH') && (ref($userenv) eq 'HASH') &&
+ (ref($changeHash) eq 'HASH') && (ref($changed) eq 'HASH') &&
+ (ref($newaccess) eq 'HASH') && (ref($newaccesstext) eq 'HASH'))) {
+ return;
+ }
+ foreach my $tool (@{$usertools}) {
+ if ($userenv->{$context.'.'.$tool} ne '') {
+ $oldaccess->{$tool} = &mt('custom');
+ if ($userenv->{$context.'.'.$tool}) {
+ $oldaccesstext->{$tool} = &mt("availability set to 'on'");
+ } else {
+ $oldaccesstext->{$tool} = &mt("availability set to 'off'");
+ }
+ $changeHash->{$context.'.'.$tool} = $userenv->{$context.'.'.$tool};
+ if ($env{'form.custom'.$tool} == 1) {
+ if ($env{'form.'.$context.'_'.$tool} ne $userenv->{$context.'.'.$tool}) {
+ $changed->{$tool} = &tool_admin($tool,$env{'form.'.$context.'_'.$tool},
+ $changeHash,$context);
+ if ($changed->{$tool}) {
+ $newaccess->{$tool} = &mt('custom');
+ if ($env{'form.'.$context.'_'.$tool}) {
+ $newaccesstext->{$tool} = &mt("availability set to 'on'");
+ } else {
+ $newaccesstext->{$tool} = &mt("availability set to 'off'");
+ }
+ } else {
+ $newaccess->{$tool} = $oldaccess->{$tool};
+ if ($userenv->{$context.'.'.$tool}) {
+ $newaccesstext->{$tool} = &mt("availability set to 'on'");
+ } else {
+ $newaccesstext->{$tool} = &mt("availability set to 'off'");
+ }
+ }
+ } else {
+ $newaccess->{$tool} = $oldaccess->{$tool};
+ $newaccesstext->{$tool} = $oldaccesstext->{$tool};
+ }
+ } else {
+ $changed->{$tool} = &tool_admin($tool,'',$changeHash,$context);
+ if ($changed->{$tool}) {
+ $newaccess->{$tool} = &mt('default');
+ } else {
+ $newaccess->{$tool} = $oldaccess->{$tool};
+ if ($userenv->{$context.'.'.$tool}) {
+ $newaccesstext->{$tool} = &mt("availability set to 'on'");
+ } else {
+ $newaccesstext->{$tool} = &mt("availability set to 'off'");
+ }
+ }
+ }
+ } else {
+ $oldaccess->{$tool} = &mt('default');
+ if ($env{'form.custom'.$tool} == 1) {
+ $changed->{$tool} = &tool_admin($tool,$env{'form.'.$context.'_'.$tool},
+ $changeHash,$context);
+ if ($changed->{$tool}) {
+ $newaccess->{$tool} = &mt('custom');
+ if ($env{'form.'.$context.'_'.$tool}) {
+ $newaccesstext->{$tool} = &mt("availability set to 'on'");
+ } else {
+ $newaccesstext->{$tool} = &mt("availability set to 'off'");
+ }
+ } else {
+ $newaccess->{$tool} = $oldaccess->{$tool};
+ }
+ } else {
+ $newaccess->{$tool} = $oldaccess->{$tool};
+ }
+ }
+ }
+ return;
+}
+
sub update_roles {
my ($r,$context) = @_;
my $now=time;
@@ -2605,12 +2707,18 @@ sub update_roles {
$r->print('
'.&mt('[_1] may not be used as the name for a section, as it is a reserved word.',$key));
+ $r->print(&mt('[_1] may not be used as the name for a section, as it is a reserved word.',''.$key.''));
} else {
- $r->print('
'.&mt('[_1] may not be used as the name for a section, as it is the name of a course group.',$key));
+ $r->print(&mt('[_1] may not be used as the name for a section, as it is the name of a course group.',''.$key.''));
}
- $r->print(' '.&mt('Please go back and choose a different section name.').'
');
+ $r->print('
'
+ .&mt('Please [_1]go back[_2] and choose a different section name.'
+ ,''."\n".''."\n".
''."\n".
- ''.
+ ''.
&Apache::loncommon::end_page());
}
# --------------------------------------------------------
@@ -3302,6 +3418,29 @@ sub handler {
&update_selfenroll_config($r,$context,$permission);
}
$r->print(&Apache::loncommon::end_page());
+ } elsif ($env{'form.action'} eq 'selfenrollqueue') {
+ $r->print(&header());
+ &Apache::lonhtmlcommon::add_breadcrumb
+ ({href=>'/adm/createuser?action=selfenrollqueue',
+ text=>"Enrollment requests"});
+ my $cid = $env{'request.course.id'};
+ my $cdom = $env{'course.'.$cid.'.domain'};
+ my $cnum = $env{'course.'.$cid.'.num'};
+ if (!exists($env{'form.state'})) {
+ $r->print(&Apache::lonhtmlcommon::breadcrumbs('Enrollment requests',
+ 'Course_SelfEnrollment_Approval'));
+ $r->print('
'.&mt('The following enrollment requests were deleted because the user is already enrolled in the course:').'
');
+ foreach my $user (@existing) {
+ $r->print('
'.$user.'
');
+ }
+ $r->print('
');
+ }
+ if (@missingreq) {
+ $r->print('
'.&mt('The following enrollment requests were ignored because the request is no longer in the enrollment queue:').'
');
+ foreach my $user (@missingreq) {
+ $r->print('
'.$user.'
');
+ }
+ $r->print('
');
+ }
+ if (@invalidusers) {
+ $r->print('
'.&mt('The following enrollment requests were deleted because the requestor does not have a LON-CAPA account:').'
');
+ foreach my $user (@invalidusers) {
+ $r->print('
'.$user.'
');
+ }
+ $r->print('
');
+ }
+ if (@limitexceeded) {
+ $r->print('
'.&mt('The following enrollment requests were skipped because the enrollment limit has been reached for the course:').'
');
+ foreach my $user (@limitexceeded) {
+ $r->print('
'.$user.'
');
+ }
+ $r->print('
');
+ }
+ if (@enrollerrors) {
+ $r->print('
'.&mt('The following enrollment requests could not be processed because an error occurred:').'
');
+ foreach my $user (@enrollerrors) {
+ $r->print('
'.$user.'
');
+ }
+ $r->print('
');
+ }
+ if (@warn_approves) {
+ $r->print('
'.&mt("For the following users, an error occurred when updating the user's own self-enroll requests record:").'
');
+ foreach my $user (@warn_approves) {
+ $r->print('
'.$user.'
');
+ }
+ $r->print('
');
+ }
+ if (@warn_rejects) {
+ $r->print('
'.&mt("For the following users, an error occurred when updating the user's own self-enroll requests record:").'
');
+ foreach my $user (@warn_rejects) {
+ $r->print('
'.$user.'
');
+ }
+ $r->print('
');
+ }
+ return;
+}
+
+sub get_student_counts {
+ my ($cdom,$cnum) = @_;
+ my (%idx,%stucounts);
+ my $classlist = &Apache::loncoursedata::get_classlist($cdom,$cnum);
+ $idx{'type'} = &Apache::loncoursedata::CL_TYPE();
+ $idx{'status'} = &Apache::loncoursedata::CL_STATUS();
+ while (my ($student,$data) = each(%$classlist)) {
+ if (($data->[$idx{'status'}] eq 'Active') ||
+ ($data->[$idx{'status'}] eq 'Future')) {
+ if ($data->[$idx{'type'}] eq 'selfenroll') {
+ $stucounts{'selfenroll'} ++;
+ }
+ $stucounts{'allstudents'} ++;
+ }
+ }
+ return (\%stucounts,\%idx,$classlist);
+}
+
sub visible_in_cat {
my ($cdom,$cnum) = @_;
my %domconf = &Apache::lonnet::get_dom('configuration',['coursecategories'],$cdom);
@@ -3841,7 +4378,7 @@ sub visible_in_cat {
miss => 'Your course does not currently appear in the Course Catalog for this domain.',
yous => 'You should remedy this if you plan to allow self-enrollment, otherwise students will have difficulty finding your course.',
coca => 'Courses can be absent from the Catalog, because they do not have an institutional code, have no assigned category, or have been specifically excluded.',
- make => 'Make any changes to self-enrollment settings below, click "Save changes", then take action to include the course in the Catalog:',
+ make => 'Make any changes to self-enrollment settings below, click "Save", then take action to include the course in the Catalog:',
take => 'Take the following action to ensure the course appears in the Catalog:',
dc_unhide => 'Ask a domain coordinator to change the "Exclude from course catalog" setting.',
dc_addinst => 'Ask a domain coordinator to enable display the catalog of "Official courses (with institutional codes)".',
@@ -5026,6 +5563,74 @@ sub update_selfenroll_config {
$changes{'internal.selfenroll_types'} = $selfenroll_types;
}
}
+ } elsif ($item eq 'limit') {
+ my $newlimit = $env{'form.selfenroll_limit'};
+ my $newcap = $env{'form.selfenroll_cap'};
+ $newcap =~s/\s+//g;
+ my $currlimit = $env{'course.'.$env{'request.course.id'}.'.internal.selfenroll_limit'};
+ $currlimit = 'none' if ($currlimit eq '');
+ my $currcap = $env{'course.'.$env{'request.course.id'}.'.internal.selfenroll_cap'};
+ if ($newlimit ne $currlimit) {
+ if ($newlimit ne 'none') {
+ if ($newcap =~ /^\d+$/) {
+ if ($newcap ne $currcap) {
+ $changes{'internal.selfenroll_cap'} = $newcap;
+ }
+ $changes{'internal.selfenroll_limit'} = $newlimit;
+ } else {
+ $warning{$item} = &mt('Maximum enrollment setting unchanged.').' '.&mt('The value provided was invalid - it must be a positive integer if enrollment is being limited.');
+ }
+ } elsif ($currcap ne '') {
+ $changes{'internal.selfenroll_cap'} = '';
+ $changes{'internal.selfenroll_limit'} = $newlimit;
+ }
+ } elsif ($currlimit ne 'none') {
+ if ($newcap =~ /^\d+$/) {
+ if ($newcap ne $currcap) {
+ $changes{'internal.selfenroll_cap'} = $newcap;
+ }
+ } else {
+ $warning{$item} = &mt('Maximum enrollment setting unchanged.').' '.&mt('The value provided was invalid - it must be a positive integer if enrollment is being limited.');
+ }
+ }
+ } elsif ($item eq 'approval') {
+ my (@currnotified,@newnotified);
+ my $currapproval = $env{'course.'.$env{'request.course.id'}.'.internal.selfenroll_approval'};
+ my $currnotifylist = $env{'course.'.$env{'request.course.id'}.'.internal.selfenroll_notifylist'};
+ if ($currnotifylist ne '') {
+ @currnotified = split(/,/,$currnotifylist);
+ @currnotified = sort(@currnotified);
+ }
+ my $newapproval = $env{'form.selfenroll_approval'};
+ @newnotified = &Apache::loncommon::get_env_multiple('form.selfenroll_notify');
+ @newnotified = sort(@newnotified);
+ if ($newapproval ne $currapproval) {
+ $changes{'internal.selfenroll_approval'} = $newapproval;
+ if (!$newapproval) {
+ if ($currnotifylist ne '') {
+ $changes{'internal.selfenroll_notifylist'} = '';
+ }
+ } else {
+ my @differences =
+ &compare_arrays(\@currnotified,\@newnotified);
+ if (@differences > 0) {
+ if (@newnotified > 0) {
+ $changes{'internal.selfenroll_notifylist'} = join(',',@newnotified);
+ } else {
+ $changes{'internal.selfenroll_notifylist'} = join(',',@newnotified);
+ }
+ }
+ }
+ } else {
+ my @differences = &compare_arrays(\@currnotified,\@newnotified);
+ if (@differences > 0) {
+ if (@newnotified > 0) {
+ $changes{'internal.selfenroll_notifylist'} = join(',',@newnotified);
+ } else {
+ $changes{'internal.selfenroll_notifylist'} = '';
+ }
+ }
+ }
} else {
my $curr_val =
$env{'course.'.$env{'request.course.id'}.'.internal.selfenroll_'.$item};
@@ -5037,7 +5642,7 @@ sub update_selfenroll_config {
$warning{$item} = &mt('Section for self-enrolled users unchanged as the proposed section is a group').' '.&mt('Group names and section names must be distinct');
} elsif ($newval eq 'all') {
$newval = $curr_val;
- $warning{$item} = &mt("Section for self-enrolled users unchanged, as 'all' is a reserved section name.");
+ $warning{$item} = &mt('Section for self-enrolled users unchanged, as "all" is a reserved section name.');
}
if ($newval eq '') {
$newval = 'none';
@@ -5098,6 +5703,62 @@ sub update_selfenroll_config {
$title,$type,$newdate).'');
}
}
+ } elsif ($item eq 'limit') {
+ if ((exists($changes{'internal.selfenroll_limit'})) ||
+ (exists($changes{'internal.selfenroll_cap'}))) {
+ my ($newval,$newcap);
+ if ($changes{'internal.selfenroll_cap'} ne '') {
+ $newcap = $changes{'internal.selfenroll_cap'}
+ } else {
+ $newcap = $env{'course.'.$env{'request.course.id'}.'.internal.selfenroll_cap'};
+ }
+ if ($changes{'internal.selfenroll_limit'} eq 'none') {
+ $newval = &mt('No limit');
+ } elsif ($changes{'internal.selfenroll_limit'} eq
+ 'allstudents') {
+ $newval = &mt('New self-enrollment no longer allowed when total (all students) reaches [_1].',$newcap);
+ } elsif ($changes{'internal.selfenroll_limit'} eq 'selfenrolled') {
+ $newval = &mt('New self-enrollment no longer allowed when total number of self-enrolled students reaches [_1].',$newcap);
+ } else {
+ my $currlimit = $env{'course.'.$env{'request.course.id'}.'.internal.selfenroll_limit'};
+ if ($currlimit eq 'allstudents') {
+ $newval = &mt('New self-enrollment no longer allowed when total (all students) reaches [_1].',$newcap);
+ } elsif ($changes{'internal.selfenroll_limit'} eq 'selfenrolled') {
+ $newval = &mt('New self-enrollment no longer allowed when total umber of self-enrolled students reaches [_1].',$newcap);
+ }
+ }
+ $r->print('
'.&mt('"[_1]" set to "[_2]".',$title,$newval));
+ if ($newnotify) {
+ $r->print(' '.&mt('The following will be notified when an enrollment request needs approval, or has been approved: [_1].',$newnotify));
+ } else {
+ $r->print(' '.&mt('No notifications sent when an enrollment request needs approval, or has been approved.'));
+ }
+ $r->print('
'."\n");
+ }
} else {
if (exists($changes{'internal.selfenroll_'.$item})) {
my $newval = $changes{'internal.selfenroll_'.$item};
@@ -5151,14 +5812,33 @@ sub update_selfenroll_config {
return;
}
+sub compare_arrays {
+ my ($arrayref1,$arrayref2) = @_;
+ my (@difference,%count);
+ @difference = ();
+ %count = ();
+ if ((ref($arrayref1) eq 'ARRAY') && (ref($arrayref2) eq 'ARRAY')) {
+ foreach my $element (@{$arrayref1}, @{$arrayref2}) { $count{$element}++; }
+ foreach my $element (keys(%count)) {
+ if ($count{$element} == 1) {
+ push(@difference,$element);
+ }
+ }
+ }
+ return @difference;
+}
+
sub get_selfenroll_titles {
- my @row = ('types','registered','enroll_dates','access_dates','section');
+ my @row = ('types','registered','enroll_dates','access_dates','section',
+ 'approval','limit');
my %lt = &Apache::lonlocal::texthash (
types => 'Users allowed to self-enroll in this course',
registered => 'Restrict self-enrollment to students officially registered for the course',
enroll_dates => 'Dates self-enrollment available',
access_dates => 'Course access dates assigned to self-enrolling users',
section => 'Section assigned to self-enrolling users',
+ approval => 'Self-enrollment requests need approval?',
+ limit => 'Enrollment limit',
);
return (\@row,\%lt);
}