--- loncom/interface/lonpopulate.pm 2003/12/12 00:45:49 1.6
+++ loncom/interface/lonpopulate.pm 2004/08/23 16:53:06 1.19
@@ -1,5 +1,5 @@
# automated enrollment configuration handler
-# $Id: lonpopulate.pm,v 1.6 2003/12/12 00:45:49 raeburn Exp $
+# $Id: lonpopulate.pm,v 1.19 2004/08/23 16:53:06 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -27,14 +27,14 @@ package Apache::lonpopulate;
use strict;
use lib qw(/home/httpd/lib/perl);
-use Apache::lonnet ();
-use Apache::loncommon ();
-use Apache::lonhtmlcommon ();
+use Apache::lonnet;
+use Apache::loncommon;
+use Apache::lonhtmlcommon;
use Apache::lonlocal;
+use Apache::loncoursedata;
use Apache::Constants qw(:common :http REDIRECT);
use Time::Local;
-use LONCAPA::Enrollment ();
-use localenroll;
+use LONCAPA::Enrollment;
###############################################################
sub header {
@@ -51,15 +51,19 @@ ENDHEAD
###############################################################
sub choose_header {
+ my $action = shift;
my $bodytag=&Apache::loncommon::bodytag('Classlist Manager');
my $scripttag = qq|
|;
@@ -220,6 +277,8 @@ sub print_main_frame {
foreach my $item (keys %settings) {
if ($item =~ m/^internal\.(.+)$/) {
$enrollvar{$1} = $settings{$item};
+ } elsif ($item =~ /^default_enrollment_(start|end)_date$/) {
+ $enrollvar{$item} = $settings{$item};
}
}
@@ -231,7 +290,7 @@ sub print_main_frame {
Use the menu on the left to choose an enrollment management task.
-
Use "Automated adds/drops" to enable or disable automatic nightly adds or drops in your LON-CAPA course based on instututional enrollment information.
+
Use "Automated adds/drops" to enable or disable automatic nightly adds or drops in your LON-CAPA course based on institutional enrollment information.
@@ -239,6 +298,10 @@ sub print_main_frame {
+
Use "Change access dates" to change the default start and/or end dates for student roles created by automated enrollment.
+
+
+
Use "Notification of changes" to enable or disable notification of enrollment changes and to add or remove course coordinators from the recipient list.
@@ -257,6 +320,10 @@ sub print_main_frame {
Use "Update roster now" to add and/or drop students from your course based on the most current institutional classlist information.
+
+
Use "View students and change type" to display the current course roster, and (optionally) change enrollment type for selected students from 'auto' to 'manual' and vice versa.
+
+
@@ -328,18 +395,30 @@ Note: Any students added manually by cou
");
} elsif ($action eq "setdates") {
- my ($start_table,$end_table) = &date_setting_table($enrollvar{autostart},$enrollvar{autoend});
- my $oldstartshow = localtime($enrollvar{autostart});
- my $oldendshow = localtime($enrollvar{autoend});
- if ($enrollvar{autoend} == 0) {
- $oldendshow = "No ending date";
+ my ($start_table,$end_table) = &date_setting_table($enrollvar{autostart},$enrollvar{autoend},$action);
+ my $oldstartshow = '';
+ my $oldendshow = '';
+ if ( defined($enrollvar{autostart}) ) {
+ $oldstartshow = &Apache::lonlocal::locallocaltime($enrollvar{autostart});
+ }
+ if ( defined($enrollvar{autoend}) ) {
+ $oldendshow = &Apache::lonlocal::locallocaltime($enrollvar{autoend});
+ if ($enrollvar{autoend} == 0) {
+ $oldendshow = "No ending date";
+ }
+ }
+ my $dateshow;
+ if ( ($oldendshow eq '') && ($oldstartshow eq '') ) {
+ $dateshow = " Warning. Currently NO first enrollment or last enrollment dates are set. You must use this menu to set a start date and an end date if you plan to utilise automated adds and/or drops in this course.\n";
+ } else {
+ $dateshow = "Currently: First enrollment: $oldstartshow, Last enrollment: $oldendshow\n";
}
$r->print(<
-
$$tasktitleref{$action}
- Currently: First enrollment: $oldstartshow, Last enrollment: $oldendshow
+
$$tasktitleref{$action}
+ $dateshow
@@ -388,8 +467,22 @@ Note: Any students added manually by cou
-Select which course coordinators should receive information about roster changes whenever any adds or drops occur during the nightly enrollment check.
-
+
The table below contains a list of course coordinators in this course. Uncheck the 'Notification?' checkbox for each person who is to be removed from the list of recipients who are currently informed of roster changes whenever any adds or drops occur during the nightly enrollment check. To include individuals who are not currently recipients, simply check the 'Notification?' checkbox. Click 'Go' to store your changes.
- Select more than one recipient by using the following keyboard and mouse combinations:
-
-
Apple-click: MacOS
-
Ctrl-click: Windows
-
Left click: Linux
-
-
-
+
+
+
Name
+
username
+
Current status
+
Notification?
+
+ ");
+ for (my $i=0; $i<@ccs; $i++) {
+ my $colflag = $i%2;
+ $r->print("
-As you are the only user with the role of course coordinator in this course, if you choose to enable notification of roster changes, you will be the sole recipient of LON-CAPA messages generated whenever any adds or drops occur during the nightly enrollment check.
-
+
+
+ No course coordinators found.
-
- ");
+ ");
}
$r->print("
-
-
-
-
-
-
-
-
-
+
+
+
+
+
");
} elsif ($action eq "crosslist") {
my @xlists = ();
@@ -526,7 +654,7 @@ As you are the only user with the role o
");
if ($cross_str > 0) {
$r->print("
- Currently, LON-CAPA course: $realm ($enrollvar{coursecode}) is crosslisted with $cross_str course section(s). Students enrolling in these course sections will be automatically added to the class roster for the course, if you have chosen to enable a nightly automated enrollment update. For each crosslisting, leave the checkbox checked if you want registered students in that course to be included in the student roster for LON-CAPA course: $realm ($enrollvar{coursecode}); otherwise uncheck it. If you wish to change the section/group ID assigned in your LON-CAPA course for a crosslisted course, enter the new section/group ID in the appropriate textbox. The LON-CAPA section/group ID can be left (or set to) empty, if you do not wish to tie a section/group ID to this crosslisting. If you wish to add new crosslisted courses, enter the number of new courses to add in the textbox at the bottom of the page. You will provide information about each of the new crosslistings on a subsequent page. Click 'Go' to store your changes.
+ Currently, this LON-CAPA course is crosslisted with $cross_str course section(s). Students enrolling in these course sections will be automatically added to the class roster for the course, if you have chosen to enable a nightly automated enrollment update. For each crosslisting, leave the checkbox checked if you want registered students in that course to be included in the student roster for LON-CAPA course: $realm ($enrollvar{coursecode}); otherwise uncheck it. If you wish to change the section/group ID assigned in your LON-CAPA course for a crosslisted course, enter the new section/group ID in the appropriate textbox. The LON-CAPA section/group ID can be left (or set to) empty, if you do not wish to tie a section/group ID to this crosslisting. If you wish to add new crosslisted courses, enter the number of new courses to add in the textbox at the bottom of the page. You will provide information about each of the new crosslistings on a subsequent page. Click 'Go' to store your changes.
@@ -544,7 +672,7 @@ As you are the only user with the role o
for (my $i=0; $i<@xlists; $i++) {
my $xl = ' ';
my $gp = ' ';
- if ($xlists[$i] =~ /(\w+):(.+)$/) {
+ if ($xlists[$i] =~ /(\w+):?(.*)$/) {
$xl = $1;
$gp = $2;
}
@@ -594,7 +722,8 @@ As you are the only user with the role o
");
} elsif ($action eq "sections") {
- my @sections = &localenroll::get_sections($enrollvar{coursecode});
+ my @sections = ();
+ @sections = &Apache::lonnet::auto_get_sections($crs,$dom,$enrollvar{coursecode});
my @storedsections = ();
my @currsections = ();
my %sec_id = ();
@@ -610,9 +739,8 @@ As you are the only user with the role o
}
}
if (@sections > 0) {
- if (@sections > 1) {
- my $secshow = @sections;
- $r->print("
+ my $secshow = @sections;
+ $r->print("
+
+
+
+
Section changes, name changes, and class drops that can be set to occur either automatically or when using the 'Update roster now' feature, will affect only those students with an enroll type of 'auto'. Students with an enroll type of 'manual', will be converted automatically to the 'auto' type, when they first appear in the institutional classlist for the course - as long as nightly adds are enabled and active, or the update roster utility is used. Use the 'Lock' checkbox for any manually enrolled students for whom you wish to prevent type conversion. Use the 'Change' checkbox to switch the enroll type from auto to manual, and vice versa. Use the 'Unlock' checkbox for any maually enrolled students for whom you no longer wish to lock the enroll type. Click the 'Go' button at the end of the page to process your desired changes.
+
+
+
+
+
+
");
+ if (! exists($ENV{'form.sortby'})) {
+ $ENV{'form.sortby'} = 'username';
+ }
+ if ($ENV{'form.Status'} !~ /^(Any|Expired|Active)$/) {
+ $ENV{'form.Status'} = 'Active';
+ }
+ my $status_select = &Apache::lonhtmlcommon::StatusOptions($ENV{'form.Status'});
+# Get current classlist
+ my ($classlist,$keylist)=&Apache::loncoursedata::get_classlist();
+ if (! defined($classlist)) {
+ $r->print(&mt('There are no students either currently or previously enrolled.').
+ "\n");
+ } else {
+ $r->print(&mt('Student Status: [_1]',$status_select)."\n");
+ $r->print(''.
+ "\n\n");
+
+ my ($studentcount,$autocount,$manualcount,$lockcount,$unlockcount) = &Apache::londropadd::show_class_list($r,'autoenroll','nothing',$ENV{'form.Status'},$classlist,$keylist);
+ $r->print("
+
+
+ ");
+ if ($studentcount > 0) {
+ $r->print("
+
+ ");
+ my $cellcount = 0;
+ if ($autocount > 0) {
+ $cellcount ++;
+ $r->print(<
+END
+ }
+ if ($manualcount > 0) {
+ $cellcount ++;
+ $r->print(<
+END
+ }
+ if ($lockcount > 0) {
+ if ($cellcount == 2) {
+ $r->print("
+ ");
+ }
}
}
+sub print_accessdate_table {
+ my ($r,$enrollvar,$tasktitleref,$action) = @_;
+ my ($start_table,$end_table) = &date_setting_table($$enrollvar{'default_enrollment_start_date'},$$enrollvar{'default_enrollment_end_date'},$action);
+ my $oldstartshow = '';
+ my $oldendshow = '';
+ if ( defined($$enrollvar{'default_enrollment_start_date'}) ) {
+ $oldstartshow = &Apache::lonlocal::locallocaltime($$enrollvar{'default_enrollment_start_date'});
+ }
+ if ( defined($$enrollvar{'default_enrollment_end_date'}) ) {
+ $oldendshow = &Apache::lonlocal::locallocaltime($$enrollvar{default_enrollment_end_date});
+ if ($$enrollvar{'default_enrollment_end_date'} eq '0') {
+ $oldendshow = "No ending date";
+ }
+ }
+ my %lt =&Apache::lonlocal::texthash(
+ 'cuno' => 'Currently NO default first access or last access dates are set.',
+ 'ifyo' => 'If you do not set a start date and an end date, then student roles for students added by the automated enrollment process will start immediately when the student is added and will never become inactive.',
+ 'ifyd' => 'If you do not set an access start date and an end date, then student roles for new students added when you click "Go" will become active immediately and will never become inactive.',
+ 'setf' => 'Set date of first access',
+ 'setl' => 'Set date of last access',
+ 'freg' => 'for registered students added via automated enrollment',
+ 'fnew' => 'for new students added when you update the class roster',
+ 'ifad' => 'If automated adds are enabled, then when students are added their student roles will become active on the date set here for first access, and their roles will become inactive on the date set here for last access. These default access dates will be overridden for specific students if the institutional classlist data supplied to the automatic enrollment process includes entries for the startdate and enddate fields for those students.',
+ 'ncds' => 'changing default start and end access dates will affect future enrollments and ALSO currently inactive students (i.e., those for whom access will begin in the future). To change access dates for currently active students, you should change the access dates via this screen, then use Enrollment manager -> Drop Students to drop the students, and then use Automated Enrollment Manager -> Update roster now to re-enroll them with the new access dates.'
+
+ );
+ my $dateshow;
+ if ( ($oldendshow eq '') && ($oldstartshow eq '') ) {
+ $dateshow = " ".&mt('Warning').". ".$lt{'cuno'}." ";
+ if ($action eq 'setaccess') {
+ $dateshow .= $lt{'ifyo'}."\n";
+ } elsif ($action eq 'updatenow') {
+ $dateshow .= $lt{'ifyd'}."\n";
+ }
+ } else {
+ $dateshow = &mt('Currently: default first access').": $oldstartshow, ".&mt('default last access').": $oldendshow\n";
+ }
+ if ($action eq 'setaccess') {
+ $r->print(<
+
+ENDFOUR
+ if ($action eq 'setaccess') {
+ $r->print("
+
+
$lt{'ifad'}
+
+
+
+
+
+
".&mt('Note').": ".$lt{'ncds'}."
+
+
+ ");
+ } elsif ($action eq 'updatenow') {
+ $r->print("
+
+
+ ");
+ }
+}
+
###############################################################
sub print_doc_base {
- my $r = shift;
- $r->print(<print(<
@@ -873,261 +1199,435 @@ ENDBASE
###################################################################
sub print_chgsettings_response {
- my ($r,$realm,$dom,$crs,$action,$tasktitleref) = @_;
- my %settings = &Apache::lonnet::get('environment',['internal.autoadds','internal.autodrops'],$dom,$crs);
- my $curradds = $settings{'internal.autoadds'};
- my $currdrops = $settings{'internal.autodrops'};
- my $autoadds = '';
- my $autodrops = '';
+ my ($r,$realm,$dom,$crs,$action,$tasktitleref) = @_;
+ my %settings = &Apache::lonnet::get('environment',['internal.sectionnums','internal.crosslistings','internal.autostart','internal.autoend','internal.autoadds','internal.autodrops'],$dom,$crs);
+ my $currend = '';
+ my $currstart = '';
+ my $currsecs = '';
+ my $currxlists = '';
+ my $curradds = '';
+ my $currdrops = '';
+ if ( defined($settings{'internal.autoadds'}) ) {
+ $curradds = $settings{'internal.autoadds'};
+ }
+ if ( defined($settings{'internal.autodrops'}) ) {
+ $currdrops = $settings{'internal.autodrops'};
+ }
+ if ( defined($settings{'internal.autostart'}) ) {
+ $currstart = $settings{'internal.autostart'};
+ }
+ if ( defined($settings{'internal.autoend'}) ) {
+ $currend = $settings{'internal.autoend'};
+ }
+ if ( defined($settings{'internal.sectionnums'}) ) {
+ $currsecs = $settings{'internal.sectionnums'};
+ }
+ if ( defined($settings{'internal.crosslistings'}) ) {
+ $currxlists = $settings{'internal.crosslistings'}
+ }
+ my $autoadds = '';
+ my $autodrops = '';
- if ( exists($ENV{'form.autoadds'}) ) {
- $autoadds=$ENV{'form.autoadds'};
- }
- if ( exists($ENV{'form.autodrops'}) ) {
- $autodrops=$ENV{'form.autodrops'};
- }
+ if ( exists($ENV{'form.autoadds'}) ) {
+ $autoadds=$ENV{'form.autoadds'};
+ }
+ if ( exists($ENV{'form.autodrops'}) ) {
+ $autodrops=$ENV{'form.autodrops'};
+ }
- my $response = "";
- my %cenv = ('internal.autoadds' => $autoadds,
- 'internal.autodrops' => $autodrops);
- my $reply = &Apache::lonnet::put('environment',\%cenv,$dom,$crs);
- if ($reply !~ /^ok$/) {
- $response = "There was a problem processing your requested changes. The automated enrollment settings for this course have been left unchanged. ";
- } else {
- if ($autoadds) {
- if ($curradds) {
- $response = "Nightly additions based on classlist changes still enabled ";
- } else {
- $response = "Nightly additions based on classlist changes now enabled ";
- }
- } else {
- if ($curradds) {
- $response = "Nightly additions based on classlist changes now disabled ";
- } else {
- $response = "Nightly additions based on classlist changes still disabled ";
- }
- }
- if ($autodrops) {
- if ($currdrops) {
- $response .= "Nightly removals based on classlist changes still enabled ";
- } else {
- $response .= "Nightly removals based on classlist changes now enabled ";
- }
- } else {
- if ($currdrops) {
- $response .= "Nightly removals based on classlist changes now disabled ";
- } else {
- $response .= "Nightly removals based on classlist changes still disabled";
- }
- }
- }
- &print_reply($r,$response,$$tasktitleref{$action});
- return;
+ my $response = "";
+ my $warning = "";
+ my $warn_prefix = "";
+ my $warn_suffix = "";
+ my $warnfiller = "";
+ my %cenv = ('internal.autoadds' => $autoadds,
+ 'internal.autodrops' => $autodrops);
+ my $reply = &Apache::lonnet::put('environment',\%cenv,$dom,$crs);
+ if ($reply !~ /^ok$/) {
+ $response = "There was a problem processing your requested changes. The automated enrollment settings for this course have been left unchanged. ";
+ } else {
+ if ($autoadds) {
+ if ($curradds) {
+ $response = "Nightly additions based on classlist changes still enabled ";
+ } else {
+ $response = "Nightly additions based on classlist changes now enabled ";
+ }
+ } else {
+ if ($curradds) {
+ $response = "Nightly additions based on classlist changes now disabled ";
+ } else {
+ $response = "Nightly additions based on classlist changes still disabled ";
+ }
+ }
+ if ($autodrops) {
+ if ($currdrops) {
+ $response .= "Nightly removals based on classlist changes still enabled ";
+ } else {
+ $response .= "Nightly removals based on classlist changes now enabled ";
+ }
+ } else {
+ if ($currdrops) {
+ $response .= "Nightly removals based on classlist changes now disabled ";
+ } else {
+ $response .= "Nightly removals based on classlist changes still disabled";
+ }
+ }
+ if ($autoadds || $autodrops) {
+ $warning = &warning_message($dom,$crs,$action);
+ $warn_prefix = " Warning. Although you indicated that nightly ";
+ $warn_suffix = " should be enabled, additional action is required. ";
+ }
+ if ($autoadds) {
+ if ($autodrops) {
+ $warnfiller = "adds and drops";
+ } else {
+ $warnfiller = "adds";
+ }
+ } else {
+ if ($autodrops) {
+ $warnfiller = "drops";
+ }
+ }
+ unless ($warning eq '') {
+ $response = $warn_prefix.$warnfiller.$warn_suffix.$warning;
+ }
+ }
+ &print_reply($r,$response,$$tasktitleref{$action});
+ return;
}
sub print_setdates_response {
- my ($r,$realm,$dom,$crs,$action,$tasktitleref) = @_;
- my %settings = &Apache::lonnet::get('environment',['internal.autostart','internal.autoend'],$dom,$crs);
- my $currstart = $settings{'internal.autostart'};
- my $currend = $settings{'internal.autoend'};
- my $response = '';
- my ($autostart,$autoend) = &get_dates_from_form();
- my $showstart = localtime($autostart);
- my $showend = '';
- if ($autoend) {
- $showend = localtime($autoend);
- } else {
- $showend = "'No end date'";
- }
-
- my %cenv = ('internal.autostart' => $autostart,
- 'internal.autoend' => $autoend);
- my $reply = &Apache::lonnet::put('environment',\%cenv,$dom,$crs);
- if ($reply !~ /^ok$/) {
- $response = "There was a problem processing your requested changes. The automated enrollment settings for this course have been left unchanged. ";
- } else {
- if ($currstart == $autostart) {
- $response = "The first date for automated enrollment has been left unchanged as $showstart. ";
- } else {
- $response = "The first date for automated enrollment has been changed to $showstart. ";
- }
- if ($currend == $autoend) {
- $response .= "The last date for automated enrollment has been left unchanged as $showend. ";
- } else {
- $response .= "The last date for enrollment has been left unchanged as $showend. ";
- }
+ my ($r,$realm,$dom,$crs,$action,$tasktitleref) = @_;
+ my %settings = &Apache::lonnet::get('environment',['internal.autostart','internal.autoend'],$dom,$crs);
+ my $currstart = $settings{'internal.autostart'};
+ my $currend = $settings{'internal.autoend'};
+ my $response = '';
+ my $showstart = '';
+ my $showend = '';
+ my $warning = '';
+ my $warn_prefix = '';
+ my ($autostart,$autoend) = &get_dates_from_form();
+ if ( ($autostart eq '') || ($autoend eq '') ) {
+ $response = "There was a problem processing your requested changes. The automated enrollment settings for this course have been left unchanged. ";
+ } elsif (($autoend > 0) && ($autoend <= $autostart)) {
+ $response = 'The date/time selected for starting auto-enrollment was the same or later than the date/time selected for ending auto-enrollment. As this means auto-enrollment will never be active, your requested changes have not been processed, and the existing values remain in effect. Please go back to the previous page to try your changes again.'."\n";
+ } else {
+ $showstart = &Apache::lonlocal::locallocaltime($autostart);
+ if ($autoend) {
+ $showend = &Apache::lonlocal::locallocaltime($autoend);
+ } else {
+ $showend = "'No end date'";
+ }
+
+ my %cenv = ('internal.autostart' => $autostart,
+ 'internal.autoend' => $autoend);
+ my $reply = &Apache::lonnet::put('environment',\%cenv,$dom,$crs);
+ if ($reply !~ /^ok$/) {
+ $response = "There was a problem processing your requested changes. The automated enrollment settings for this course have been left unchanged. ";
+ } else {
+ if ($currstart == $autostart) {
+ $response = "The first date for automated enrollment has been left unchanged as $showstart. ";
+ } else {
+ $response = "The first date for automated enrollment has been changed to $showstart. ";
+ }
+ if ($currend == $autoend) {
+ $response .= "The last date for automated enrollment has been left unchanged as $showend. ";
+ } else {
+ $response .= "The last date for automated enrollment has been changed to $showend. ";
+ }
-# Generate message in case where old first access date was later than today, but new first access date is now today or earlier.
+# Generate message in case where old first enrollment date was later than today, but new first enrollment date is now today or earlier.
- my $rosterupdated = 0;
- my $firstaccess = "";
- my $nextupdate = "";
- my $lastupdate = "";
-
- my $nowstamp = time;
- my @date_list=localtime(time);
- my $cur_year = $date_list[5];
- my $curday = $date_list[3];
- my $curmonth = $date_list[4];
- my $lastmidnt = timelocal(0,0,0,$date_list[3],$date_list[4],$date_list[5]);
- my $nextmidnt = 86400 + $lastmidnt;
-
- my $todayupdate = timelocal(0,40,4,$date_list[3],$date_list[4],$date_list[5]);
- my $lastupdate = $todayupdate - 86400;
- if ($nowstamp < $todayupdate) {
- $nextupdate = "today";
- } else {
- $nextupdate = "tomorrow";
- }
- if ($currstart < $lastupdate) {
- $rosterupdated = 1;
- }
- if ($autostart < $nextmidnt ) {
- if ( $autostart >= $lastmidnt) {
- $firstaccess = "today";
- } else {
- $firstaccess = "a date prior to today";
- }
- if (($nowstamp >= $autostart) && ($rosterupdated == 0)) {
- $response .= qq| Although you have now set the first enrollment date to $firstaccess, automatic enrollment will not occur until the next automatic enrollment update occurs for all LON-CAPA courses at 4.40 am $nextupdate. If you wish to grant immediate course access for registered students included in the institutional classlist for this class, please visit the roster update page. |;
- }
- }
- }
- &print_reply($r,$response,$$tasktitleref{$action});
- return;
+ my $rosterupdated = 0;
+ my $firstaccess = "";
+ my $nextupdate = "";
+ my $lastupdate = "";
+
+ my $nowstamp = time;
+ my @date_list=localtime(time);
+ my $cur_year = $date_list[5];
+ my $curday = $date_list[3];
+ my $curmonth = $date_list[4];
+ my $lastmidnt = timelocal(0,0,0,$date_list[3],$date_list[4],$date_list[5]);
+ my $nextmidnt = 86400 + $lastmidnt;
+
+ my $todayupdate = timelocal(0,30,1,$date_list[3],$date_list[4],$date_list[5]);
+ my $lastupdate = $todayupdate - 86400;
+ if ($nowstamp < $todayupdate) {
+ $nextupdate = "today";
+ } else {
+ $nextupdate = "tomorrow";
+ }
+ if ($currstart < $lastupdate) {
+ $rosterupdated = 1;
+ }
+ if ($autostart < $nextmidnt ) {
+ if ( $autostart >= $lastmidnt) {
+ $firstaccess = "today";
+ } else {
+ $firstaccess = "a date prior to today";
+ }
+ if (($nowstamp >= $autostart) && ($rosterupdated == 0)) {
+ $response .= qq| Although you have now set the first enrollment date to $firstaccess, automatic enrollment will not occur until the next automatic enrollment update occurs for all LON-CAPA courses at 1.30 am $nextupdate. If you wish to immediately enroll registered students included in the institutional classlist for this class, please visit the roster update page. |;
+ }
+ }
+ $warning = &warning_message($dom,$crs,$action);
+ $warn_prefix = " Warning. Although you set a start and end date for auto-enrollment, additional action is required. ";
+ unless ($warning eq '') {
+ $response .= $warn_prefix.$warning;
+ }
+ }
+ }
+ &print_reply($r,$response,$$tasktitleref{$action});
+ return;
+}
+
+sub print_setaccess_response {
+ my ($r,$realm,$dom,$crs,$action,$tasktitleref) = @_;
+ my %settings = &Apache::lonnet::get('environment',['default_enrollment_start_date','default_enrollment_end_date','internal.autostart'],$dom,$crs);
+ my $currstart = $settings{'default_enrollment_start_date'};
+ my $currend = $settings{'default_enrollment_end_date'};
+ my $autostart = $settings{'internal.autostart'};
+ my $response = '';
+ my ($startaccess,$endaccess) = &get_dates_from_form();
+ if (($startaccess eq '') || ($endaccess eq '')) {
+ $response = "There was a problem processing your requested changes. The default
+start and end access dates for this course have been left unchanged. ";
+ } elsif (($endaccess > 0) && ($endaccess <= $startaccess)) {
+ $response = 'The default start access date/time you chose was the same or later than the default end access date/time. As this means that roles will never be active, your requested changes have not been processed, and the existing values remain in effect. Please go back to the previous page to try your changes again.'."\n";
+ } else {
+ my $showstart = &Apache::lonlocal::locallocaltime($startaccess);
+ my $showend = '';
+ my $warning = '';
+ my $warn_prefix = '';
+ if ($endaccess) {
+ $showend = &Apache::lonlocal::locallocaltime($endaccess);
+ } else {
+ $showend = "'No end date'";
+ }
+
+ my %cenv = ('default_enrollment_start_date' => $startaccess,
+ 'default_enrollment_end_date' => $endaccess);
+ my $reply = &Apache::lonnet::put('environment',\%cenv,$dom,$crs);
+ if ($reply !~ /^ok$/) {
+ $response = "There was a problem processing your requested changes. The automated enrollment settings for this course have been left unchanged. ";
+ } else {
+ if ($currstart == $startaccess) {
+ $response = "The first access date for students added via automated enrollment has been left unchanged as $showstart. ";
+ } else {
+ $response = "The first access date for students added via automated enrollment has been changed to
+$showstart. ";
+ }
+ if ($currend == $endaccess) {
+ $response .= "The last access date for students added via automated enrollment has been left unchanged as $showend. ";
+ } else {
+ $response .= "The last access date for students automated enrollment has been changed to
+$showend. ";
+ }
+
+# Generate message in case where old first access date was later than today, but new first access date is now today or earlier.
+
+ my $accessgiven= 0;
+ my $firstaccess = "";
+ my $nextupdate = "";
+ my $lastupdate = "";
+
+ my $nowstamp = time;
+ my @date_list=localtime(time);
+ my $cur_year = $date_list[5];
+ my $curday = $date_list[3];
+ my $curmonth = $date_list[4];
+ my $lastmidnt = timelocal(0,0,0,$date_list[3],$date_list[4],$date_list[5]);
+ my $nextmidnt = 86400 + $lastmidnt;
+
+ my $todayupdate = timelocal(0,30,1,$date_list[3],$date_list[4],$date_list[5]);
+ my $tomorrowupdate = $todayupdate + 86400;
+ my $lastupdate = $todayupdate - 86400;
+
+ if ($autostart < $nextmidnt) {
+ if ($nowstamp < $todayupdate) {
+ $nextupdate = "at 1.30 am today";
+ } else {
+ $nextupdate = "at 1.30 am tomorrow";
+ }
+ } else {
+ my @enrollstart = localtime($autostart);
+ $nextupdate = timelocal(0,30,1,$enrollstart[3],$enrollstart[4],$enrollstart[5]);
+ unless (($enrollstart[2] < 1) || ($enrollstart[2] == 1 && $enrollstart[1] <=30)) {
+ $nextupdate += 86400;
+ }
+ $nextupdate = &Apache::lonlocal::locallocaltime($nextupdate);
+ }
+ if (($currstart < $lastupdate) && ($autostart < $lastupdate)) {
+ $accessgiven = 1;
+ }
+ if ($startaccess < $nextmidnt ) {
+ if ( $startaccess >= $lastmidnt) {
+ $firstaccess = "today";
+ } else {
+ $firstaccess = "a date prior to today";
+ }
+ if (($nowstamp >= $startaccess) && ($accessgiven == 0)) {
+ $response .= qq| Although you have now set the first access date to $firstaccess, automatic enrollment will not occur until the next automatic enrollment update occurs for all LON-CAPA courses $nextupdate. If you wish to grant immediate course access for registered students included in the institutional classlist for this class, please visit the roster update page. |;
+ }
+ }
+ $warning = &warning_message($dom,$crs,$action);
+ $warn_prefix = " Warning. Although you have set default first and last access dates for students who are added via automatic enrollment, additional action is required. ";
+ unless ($warning eq '') {
+ $response .= $warn_prefix.$warning;
+ }
+ }
+ }
+ &print_reply($r,$response,$$tasktitleref{$action});
+ return;
}
sub print_notify_response {
- my ($r,$realm,$dom,$crs,$action,$tasktitleref) = @_;
+ my ($r,$realm,$dom,$crs,$action,$tasktitleref) = @_;
# Get current settings
- my %settings = &Apache::lonnet::get('environment',['internal.notifylist','internal.coursecode'],$dom,$crs);
- my $notifylist = $settings{'internal.notifylist'};
- my $coursecode = $settings{'internal.coursecode'};
- my @currpeople = ();
- my $notify = 0;
- my @people = ();
-
- if ($notifylist =~ m/,/) {
- @currpeople = split/,/,$notifylist;
- } else {
- @currpeople = $notifylist;
- }
- my $currcount = 0;
- foreach (@currpeople) {
- unless ($_ eq '') { $currcount ++; }
- }
+ my %settings = &Apache::lonnet::get('environment',['internal.notifylist','internal.coursecode'],$dom,$crs);
+ my $notifylist = $settings{'internal.notifylist'};
+ my $coursecode = $settings{'internal.coursecode'};
+ my @currpeople = ();
+ my $notify = 0;
+ my @people = ();
+ my $peoplestr = "";
+ my $response = "";
+ my $noprocess = 0;
- if ( exists($ENV{'form.notify'}) ) {
- $notify=$ENV{'form.notify'};
- }
- if ( exists($ENV{'form.notifylist'}) ) {
- if (ref($ENV{'form.notifylist'})) {
- @people=@{ $ENV{'form.notifylist'} };
- } else {
- $people[0]=$ENV{'form.notifylist'};
- }
- }
- my $response = "";
- my $peoplestr = "";
- if ($notify) { $peoplestr = join(",",@people); }
- my %cenv = ('internal.notifylist' => $peoplestr);
- my $reply = &Apache::lonnet::put('environment',\%cenv,$dom,$crs);
- if ($reply !~ /^ok$/) {
- $response = "There was a problem processing your requested changes. The notification settings for this course have been left unchanged. ";
- } else {
- if ($notify) {
- if (@people) {
- if ($currcount) {
- $response = "Notification of enrollment changes still enabled ";
- } else {
- $response = "Notification of enrollment changes now enabled ";
- }
- $response .= " The following will receive notification if there are any changes in enrollment in LON-CAPA course: $realm ($coursecode) as a result of
-the nightly enrollment check:
\n";
+ } else {
+ $response = "Notification of enrollment changes was not enabled as no course coordinators were selected as recipients. ";
+ }
+ } else {
+ if ($currcount) {
+ $response = "Notification of enrollment changes now disabled ";
+ } else {
+ $response = "Notification of enrollment changes still disabled ";
+ }
+ }
+ }
+ }
+ &print_reply($r,$response,$$tasktitleref{$action});
+ return;
}
sub print_crosslistings_menu () {
- my ($r,$realm,$dom,$crs,$action,$tasktitleref) = @_;
- my %settings = &Apache::lonnet::get('environment',['internal.crosslistings','internal.coursecode'],$dom,$crs);
- my @currxlists = ();
- my @xlists = ();
- my $crosscount = 0;
- my $removecount = 0;
- my $xliststr = '';
- my $response = '';
- my $coursecode = $settings{'internal.coursecode'};
- if ($settings{'internal.crosslistings'} =~ m/,/) {
- @currxlists = split/,/,$settings{'internal.crosslistings'};
- } elsif ($settings{'internal.crosslistings'} ne '') {
- $currxlists[0] = $settings{'internal.crosslistings'};
- }
+ my ($r,$realm,$dom,$crs,$action,$tasktitleref) = @_;
+ my %settings = &Apache::lonnet::get('environment',['internal.crosslistings','internal.coursecode'],$dom,$crs);
+ my @currxlists = ();
+ my @xlists = ();
+ my $crosscount = 0;
+ my $removecount = 0;
+ my $xliststr = '';
+ my $response = '';
+ my $coursecode = $settings{'internal.coursecode'};
+ if ($settings{'internal.crosslistings'} =~ m/,/) {
+ @currxlists = split/,/,$settings{'internal.crosslistings'};
+ } elsif ($settings{'internal.crosslistings'} ne '') {
+ $currxlists[0] = $settings{'internal.crosslistings'};
+ }
- if (@currxlists > 0) {
- for (my $i=0; $i<@currxlists; $i++) {
- my $xlist = "cross_".$i;
- my $gp = "gp_".$i;
- if ( exists($ENV{"form.$xlist"}) ) {
- my $xlistentry = '';
- if ($currxlists[$i] =~ m/^(\w+:)/) {
- $xlistentry = $1;
- }
- if ( exists($ENV{"form.$gp"}) ) {
- $xlistentry .= $ENV{"form.$gp"};
- }
- push @xlists,$xlistentry;
- $crosscount ++;
- } else {
- $removecount ++;
- }
- }
- }
+ if (@currxlists > 0) {
+ for (my $i=0; $i<@currxlists; $i++) {
+ my $xlist = "cross_".$i;
+ my $gp = "gp_".$i;
+ if ( exists($ENV{"form.$xlist"}) ) {
+ my $xlistentry = '';
+ if ($currxlists[$i] =~ m/^([^:]+)/) {
+ $xlistentry = $1.':';
+ }
+ if ( exists($ENV{"form.$gp"}) ) {
+ $xlistentry .= $ENV{"form.$gp"};
+ }
+ push @xlists,$xlistentry;
+ $crosscount ++;
+ } else {
+ $removecount ++;
+ }
+ }
+ }
- if ($crosscount > 1) {
- $xliststr = join(",",@xlists);
- } else {
- $xliststr = $xlists[0];
- }
- my %cenv = ('internal.crosslistings' => $xliststr);
- my $reply = &Apache::lonnet::put('environment',\%cenv,$dom,$crs);
- if ($reply !~ /^ok$/) {
- $response = "There was a problem processing your requested changes. The automated enrollment settings for this course have been left unchanged. ";
- } else {
- if ($removecount > 0) {
- $response = "A total of $removecount courses are no longer crosslisted with LON-CAPA course: $realm ($coursecode).
";
- }
- if ($crosscount > 0) {
- $response .= "The $crosscount courses listed below remain crosslisted with this LON-CAPA course, and students enrolling in these course sections will be automatically added to the class roster for the course, if you have chosen to enable a nightly automated enrollment update.
\n";
- }
- }
- if ( exists($ENV{'form.numcross'}) ) {
- my $numcross = $ENV{'form.numcross'};
- if ($numcross > 0) {
- my @bgcolors=("#eeeeee","#cccccc");
- $response .= qq(
- You indicated that you wish to add an additional $numcross crosslisting(s). For each new crosslisting enter the insititutional course section code (e.g., fs03zol101001, for section 001 of zol101 for fs03 semester), and the LON-CAPA section/group ID you wish to assign to students who will be enrolled in your LON-CAPA class as a result of their registration in the crosslisted course section. The LON-CAPA section/group ID can be left blank, if you do not wish to tie a section/group ID to this crosslisting. The institutional course section code should only contain letters and/or numbers, and must be consistent with the scheme adopted by your Domain Coordinator to map course codes (and section numbers) to your institution's student information system.
+ if ($crosscount > 1) {
+ $xliststr = join(",",@xlists);
+ } else {
+ $xliststr = $xlists[0];
+ }
+ my %cenv = ('internal.crosslistings' => $xliststr);
+ my $reply = &Apache::lonnet::put('environment',\%cenv,$dom,$crs);
+ if ($reply !~ /^ok$/) {
+ $response = "There was a problem processing your requested changes. The automated enrollment settings for this course have been left unchanged. ";
+ } else {
+ if ($removecount > 0) {
+ $response = "A total of $removecount courses are no longer crosslisted with LON-CAPA course: $realm ($coursecode).
";
+ }
+ if ($crosscount > 0) {
+ $response .= "The $crosscount courses listed below remain crosslisted with this LON-CAPA course, and students enrolling in these course sections will be automatically added to the class roster for the course, if you have chosen to enable a nightly automated enrollment update.
\n";
+ }
+ }
+ if ( exists($ENV{'form.numcross'}) ) {
+ my $numcross = $ENV{'form.numcross'};
+ if ($numcross > 0) {
+ my @bgcolors=("#eeeeee","#cccccc");
+ $response .= qq(You indicated that you wish to add an additional $numcross crosslisting(s). For each new crosslisting enter the insititutional course section code (e.g., fs03zol101001, for section 001 of zol101 for fs03 semester), and the LON-CAPA section/group ID you wish to assign to students who will be enrolled in your LON-CAPA class as a result of their registration in the crosslisted course section. The LON-CAPA section/group ID can be left blank, if you do not wish to tie a section/group ID to this crosslisting. The institutional course section code should only contain letters and/or numbers, and must be consistent with the scheme adopted by your Domain Coordinator to map course codes (and section numbers) to your institution\'s student information system.
@@ -1137,17 +1637,17 @@ sub print_crosslistings_menu () {
Crosslisting
LON-CAPA section/groupID
- );
- for (my $i=0; $i<$numcross; $i++) {
- my $colflag = $i%2;
- $response .= qq(
+ );
+ for (my $i=0; $i<$numcross; $i++) {
+ my $colflag = $i%2;
+ $response .= qq(
- );
- }
- $response .= qq(
+ );
+ }
+ $response .= qq(
@@ -1160,215 +1660,272 @@ sub print_crosslistings_menu () {
- );
- }
- }
- &print_reply($r,$response,$$tasktitleref{$action});
- return;
+ );
+ }
+ }
+ &print_reply($r,$response,$$tasktitleref{$action});
+ return;
}
sub print_crosslistings_response () {
- my ($r,$realm,$dom,$crs,$action,$tasktitleref) = @_;
- my %settings = &Apache::lonnet::get('environment',['internal.crosslistings','internal.coursecode','internal.courseowner'],$dom,$crs);
- my @currxlists = ();
- my @xlists = ();
- my @allxlists = ();
- my @badxlists = ();
- my @badowner = ();
- my $numcross = 0;
- my $xliststr = $settings{'internal.crosslistings'};
- my $coursecode = $settings{'internal.coursecode'};
- my $owner = $settings{'internal.courseowner'};
- my $response = '';
-
- if ($xliststr =~ m/,/) {
- @allxlists = split/,/,$xliststr;
- } else {
- unless ($xliststr eq '') { $allxlists[0] = $xliststr; }
- }
+ my ($r,$realm,$dom,$crs,$action,$tasktitleref) = @_;
+ my %settings = &Apache::lonnet::get('environment',['internal.crosslistings','internal.coursecode','internal.courseowner'],$dom,$crs);
+ my @currxlists = ();
+ my @xlists = ();
+ my @allxlists = ();
+ my @badxlists = ();
+ my @badowner = ();
+ my $numcross = 0;
+ my $xliststr = $settings{'internal.crosslistings'};
+ my $coursecode = $settings{'internal.coursecode'};
+ my $owner = $settings{'internal.courseowner'};
+ my $response = '';
+ my $warning = '';
+ my $warn_prefix = '';
- if ( exists($ENV{'form.numcross'}) ) {
- $numcross = $ENV{'form.numcross'};
- }
+ if ($xliststr =~ m/,/) {
+ @allxlists = split/,/,$xliststr;
+ } else {
+ unless ($xliststr eq '') { $allxlists[0] = $xliststr; }
+ }
- if ($numcross > 0) {
- for (my $i=0; $i<$numcross; $i++) {
- my $xl = "newcross_".$i;
- my $gp = "newgroupid_".$i;
- if ( exists($ENV{"form.$xl"}) ) {
- my $coursecheck = &localenroll::validate_courseID($ENV{"form.$xl"});
- if ($coursecheck eq 'ok') {
- my $addcheck = &localenroll::new_course($ENV{"form.$xl"},$owner);
- if ($addcheck eq 'ok') {
- push @xlists,$ENV{"form.$xl"}.":".$ENV{"form.$gp"};
- } else {
- push @badowner,$ENV{"form.$xl"}.":".$ENV{"form.$gp"};
- }
- } else {
- push @badxlists, $ENV{"form.$xl"}.":".$ENV{"form.$gp"}.":".$coursecheck;
- }
- }
- }
- push @allxlists, @xlists;
- }
+ if ( exists($ENV{'form.numcross'}) ) {
+ $numcross = $ENV{'form.numcross'};
+ }
- if (@xlists > 0 ) {
- unless ($xliststr eq '') { $xliststr .= ","; }
- if (@xlists > 1) {
- $xliststr .= join(",",@xlists);
- } else {
- $xliststr .= $xlists[0];
- }
- my %cenv = ('internal.crosslistings' => $xliststr);
- my $reply = &Apache::lonnet::put('environment',\%cenv,$dom,$crs);
- if ($reply !~ /^ok$/) {
- $response = "There was a problem processing your requested changes. The automated enrollment settings for this course have been left unchanged.
";
- } else {
- $response = "The courses listed below are now crosslisted with this LON-CAPA course, and students enrolling in these course sections will be automatically added to the class roster for the course, if you have chosen to enable a nightly automated enrollment update.
\n";
- }
- }
- if (@badxlists > 0) {
- $response .= "The courses listed below could not be included in the crosslistings for this LON-CAPA course, because they are not valid courses according to your institution's official schedule of classes and sections.
\n";
- }
+ if ($numcross > 0) {
+ for (my $i=0; $i<$numcross; $i++) {
+ my $xl = "newcross_".$i;
+ my $gp = "newgroupid_".$i;
+ if ( exists($ENV{"form.$xl"}) ) {
+ my $coursecheck = '';
+ $coursecheck = &Apache::lonnet::auto_validate_courseID($crs,$dom,$ENV{"form.$xl"});
+ if ($coursecheck eq 'ok') {
+ my $addcheck = '';
+ $addcheck = &Apache::lonnet::auto_new_course($crs,$dom,$ENV{"form.$xl"},$owner);
+ if ($addcheck eq 'ok') {
+ push @xlists,$ENV{"form.$xl"}.":".$ENV{"form.$gp"};
+ } else {
+ push @badowner,$ENV{"form.$xl"}.":".$ENV{"form.$gp"};
+ }
+ } else {
+ push @badxlists, $ENV{"form.$xl"}.":".$ENV{"form.$gp"}.":".$coursecheck;
+ }
+ }
+ }
+ push @allxlists, @xlists;
+ }
+
+ if (@xlists > 0 ) {
+ unless ($xliststr eq '') { $xliststr .= ","; }
+ if (@xlists > 1) {
+ $xliststr .= join(",",@xlists);
+ } else {
+ $xliststr .= $xlists[0];
+ }
+ my %cenv = ('internal.crosslistings' => $xliststr);
+ my $reply = &Apache::lonnet::put('environment',\%cenv,$dom,$crs);
+ if ($reply !~ /^ok$/) {
+ $response = "There was a problem processing your requested changes. The automated enrollment settings for this course have been left unchanged.
";
+ } else {
+ $response = "The courses listed below are now crosslisted with this LON-CAPA course, and students enrolling in these course sections will be automatically added to the class roster for the course, if you have chosen to enable a nightly automated enrollment update.
\n";
+ }
+ }
+ if (@badxlists > 0) {
+ $response .= "The courses listed below could not be included in the crosslistings for this LON-CAPA course, because they are not valid courses according to your institution's official schedule of classes and sections.
\n";
+ }
+
+ if (@badowner > 0) {
+ $response .= "The courses listed below could not be included in the crosslistings for this LON-CAPA course, because the owner of this course - $owner - does not have rights to view enrollment in those classes as determined by your instititution's policies on access to official classlists.
\n";
+ }
- if (@badowner > 0) {
- $response .= "The courses listed below could not be included in the crosslistings for this LON-CAPA course, because the owner of this course - $owner - does not have rights to view enrollment in those classes as determined by your instititution's policies on access to official classlists.
\n";
- }
+ if (@allxlists > 0) {
+ $warning = &warning_message($dom,$crs,$action);
+ $warn_prefix = " Warning. Although you have selected crosslisted courses to contribute enrollment to this course, additional action is required. ";
+ unless ($warning eq '') {
+ $response .= $warn_prefix.$warning;
+ }
+ }
- &print_reply($r,$response,$$tasktitleref{$action});
- return;
+ &print_reply($r,$response,$$tasktitleref{$action});
+ return;
}
sub print_sections_menu () {
- my ($r,$realm,$dom,$crs,$action,$tasktitleref) = @_;
- my %settings = &Apache::lonnet::get('environment',['internal.sectionnums','internal.coursecode'],$dom,$crs);
- my @currsections = ();
- my @sections = ();
- my $seccount = 0;
- my $removecount = 0;
- my $addcount = 0;
- my $secstr = '';
- my $response = '';
- my $coursecode = $settings{'internal.coursecode'};
- if ($settings{'internal.sectionnums'} =~ m/,/) {
- @currsections = split/,/,$settings{'internal.sectionnums'};
- } elsif ($settings{'internal.sectionnums'} ne '') {
- $currsections[0] = $settings{'internal.sectionnums'};
- }
-
- if ( exists($ENV{'form.secshow'}) ) {
- for (my $i=0; $i<$ENV{'form.secshow'}; $i++) {
- my $gp = "loncapasec_".$i;
- my $secnum = "secnum_".$i;
- my $sec = "sec_".$i;
- if ( exists( $ENV{"form.$sec"} ) ) {
- my $secentry;
- if ( exists( $ENV{"form.$secnum"} ) ) {
- $secentry = $ENV{"form.$secnum"}.':';
- }
- if ( exists( $ENV{"form.$gp"} ) ) {
- $secentry .= $ENV{"form.$gp"};
- }
- push @sections, $secentry;
- $seccount ++;
- unless (grep/^$ENV{"form.$secnum"}:/,@currsections) {
- $addcount ++;
- }
- }
- }
- if (@currsections > 0) {
- for (my $i=0; $i<@currsections; $i++) {
- if ($currsections[$i] =~ m/^(\w+:)/ ) {
- my $oldsec = $1;
- unless (grep/^$oldsec/,@sections) {
- $removecount ++;
- }
- }
- }
- }
- } elsif (@currsections > 0) {
- for (my $i=0; $i<@currsections; $i++) {
- my $sec = "sec_".$i;
- my $gp = "secgp_".$i;
- if ( exists($ENV{"form.$sec"}) ) {
- my $secentry = '';
- if ($currsections[$i] =~ m/^(\w+:)/ ) {
- $secentry = $1;
- }
- if ( exists($ENV{"form.$gp"}) ) {
- $secentry .= $ENV{"form.$gp"};
- }
- push @sections,$secentry;
- $seccount ++;
- } else {
- $removecount ++;
- }
- }
- }
-
- if ($seccount > 1) {
- $secstr = join(",",@sections);
- } else {
- $secstr = $sections[0];
- }
- my %cenv = ('internal.sectionnums' => $secstr);
- my $reply = &Apache::lonnet::put('environment',\%cenv,$dom,$crs);
- if ($reply !~ /^ok$/) {
- $response = "There was a problem processing your requested changes. The automated enrollment settings for this course have been left unchanged. ";
- } else {
- if ($removecount > 0) {
- $response = "A total of $removecount sections have been removed from the list of sections which contribute to enrollment in LON-CAPA course: $realm ($coursecode).
";
- }
- if ($addcount > 0) {
- $response .= "A total of $addcount sections have been added to the list of
+ my ($r,$realm,$dom,$crs,$action,$tasktitleref) = @_;
+ my %settings = &Apache::lonnet::get('environment',['internal.sectionnums','internal.coursecode','internal.courseowner'],$dom,$crs);
+ my @currsections = ();
+ my @sections = ();
+ my @badowner = ();
+ my @badsections = ();
+ my $seccount = 0;
+ my $removecount = 0;
+ my $addcount = 0;
+ my $secstr = '';
+ my $response = '';
+ my $warning = "";
+ my $warn_prefix = "";
+ my $coursecode = $settings{'internal.coursecode'};
+ my $owner = $settings{'internal.courseowner'};
+ if ($settings{'internal.sectionnums'} =~ m/,/) {
+ @currsections = split/,/,$settings{'internal.sectionnums'};
+ } elsif ($settings{'internal.sectionnums'} ne '') {
+ $currsections[0] = $settings{'internal.sectionnums'};
+ }
+
+ if ( exists($ENV{'form.secshow'}) ) {
+ for (my $i=0; $i<$ENV{'form.secshow'}; $i++) {
+ my $gp = "loncapasec_".$i;
+ my $secnum = "secnum_".$i;
+ my $sec = "sec_".$i;
+ if ( exists( $ENV{"form.$sec"} ) ) {
+ my $secentry;
+ if ( exists( $ENV{"form.$secnum"} ) ) {
+ $secentry = $ENV{"form.$secnum"}.':';
+ }
+ if ( exists( $ENV{"form.$gp"} ) ) {
+ $secentry .= $ENV{"form.$gp"};
+ }
+ if ( grep/^$ENV{"form.$secnum"}:/,@currsections) {
+ push @sections, $secentry;
+ $seccount ++;
+ } else {
+ my $newsec = $coursecode.$ENV{"form.$secnum"};
+ my $coursecheck = &Apache::lonnet::auto_validate_courseID($crs,$dom,$newsec);
+ if ($coursecheck eq 'ok') {
+ my $addcheck = &Apache::lonnet::auto_new_course($crs,$dom,$newsec,$owner);
+ if ($addcheck eq 'ok') {
+ push @sections,$ENV{"form.$secnum"}.":".$ENV{"form.$gp"};
+ $seccount ++;
+ $addcount ++;
+ } else {
+ push @badowner,$ENV{"form.$secnum"}.":".$ENV{"form.$gp"};
+ }
+ } else {
+ push @badsections, $ENV{"form.$secnum"}.":".$ENV{"form.$gp"}.":".$coursecheck;
+ }
+ }
+ }
+ }
+ if (@currsections > 0) {
+ for (my $i=0; $i<@currsections; $i++) {
+ if ($currsections[$i] =~ m/^(\w+:)/ ) {
+ my $oldsec = $1;
+ unless (grep/^$oldsec/,@sections) {
+ $removecount ++;
+ }
+ }
+ }
+ }
+ } elsif (@currsections > 0) {
+ for (my $i=0; $i<@currsections; $i++) {
+ my $sec = "sec_".$i;
+ my $gp = "secgp_".$i;
+ if ( exists($ENV{"form.$sec"}) ) {
+ my $secentry = '';
+ if ($currsections[$i] =~ m/^(\w+:)/ ) {
+ $secentry = $1;
+ }
+ if ( exists($ENV{"form.$gp"}) ) {
+ $secentry .= $ENV{"form.$gp"};
+ }
+ push @sections,$secentry;
+ $seccount ++;
+ } else {
+ $removecount ++;
+ }
+ }
+ }
+
+ if ($seccount > 1) {
+ $secstr = join(",",@sections);
+ } else {
+ $secstr = $sections[0];
+ }
+ my %cenv = ('internal.sectionnums' => $secstr);
+ my $reply = &Apache::lonnet::put('environment',\%cenv,$dom,$crs);
+ if ($reply !~ /^ok$/) {
+ $response = "There was a problem processing your requested changes. The automated enrollment settings for this course have been left unchanged. ";
+ } else {
+ if ($removecount > 0) {
+ $response = "A total of $removecount sections have been removed from the list of sections which contribute to enrollment in LON-CAPA course: $realm ($coursecode).
";
+ }
+ if ($addcount > 0) {
+ $response .= "A total of $addcount sections have been added to the list of
sections which contribute to enrollment in LON-CAPA course: $realm ($coursecode).
";
- }
- if ($seccount > 0) {
- $response .= "Students enrolling in the $seccount section(s) listed below will be automatically added to the class roster for the course, if you have chosen to enable a nightly automated enrollment update.
\n";
- }
- }
-
- if ( exists($ENV{'form.numsec'}) ) {
- my $numsec = $ENV{'form.numsec'};
- if ($numsec > 0) {
- my @bgcolors=("#eeeeee","#cccccc");
- $response .= qq(
- You indicated that you wish to incorporate student enrollment in your LON-CAPA course from an additional $numsec section(s). For each new section enter the insititutional section code (e.g., 004), and the LON-CAPA section/group ID you wish to assign to students who will be enrolled in your LON-CAPA class as a result of their registration in this particular section. The LON-CAPA section/group ID can be left blank, if you do not wish to designate a section/group ID for this course section. The institutional section code should only contain letters and/or numbers, and must be consistent with the scheme adopted by your Domain Coordinator to map course section numbers to your institution's student information system.
+ }
+ if ($seccount > 0) {
+ $response .= "Students enrolling in the $seccount section(s) listed below will be automatically added to the class roster for the course, if you have chosen to enable a nightly automated enrollment update.
\n";
+ }
+ }
+
+ if (@badsections > 0) {
+ $response .= "The sections listed below could not be included in the sections for this LON-CAPA course, because they are not valid section numbers according to your institution's official schedule of classes and sections.
\n";
+ }
+
+ if (@badowner > 0) {
+ $response .= "The sections listed below could not be included in the sections for this LON-CAPA course, because the owner of this course - $owner - does not have rights to view enrollment in those classes as determined by your instititution's policies on access to official classlists.
\n";
+ }
+
+ if ($seccount > 0) {
+ $warning = &warning_message($dom,$crs,$action);
+ $warn_prefix = " Warning. Although you have selected sections to contribute enrollment to this course, additional action is required. ";
+ unless ($warning eq '') {
+ $response .= $warn_prefix.$warning;
+ }
+ }
+
+ if ( exists($ENV{'form.numsec'}) ) {
+ my $numsec = $ENV{'form.numsec'};
+ if ($numsec > 0) {
+ my @bgcolors=("#eeeeee","#cccccc");
+ $response .= qq(
+ You indicated that you wish to incorporate student enrollment in your LON-CAPA course from an additional $numsec section(s). For each new section enter the insititutional section code (e.g., 004), and the LON-CAPA section/group ID you wish to assign to students who will be enrolled in your LON-CAPA class as a result of their registration in this particular section. The LON-CAPA section/group ID can be left blank, if you do not wish to designate a section/group ID for this course section. The institutional section code should only contain letters and/or numbers, and must be consistent with the scheme adopted by your Domain Coordinator to map course section numbers to your institution\'s student information system.
@@ -1378,17 +1935,17 @@ sections which contribute to enrollment
Section number
LON-CAPA section/groupID
- );
- for (my $i=0; $i<$numsec; $i++) {
- my $colflag = $i%2;
- $response .= qq(
+ );
+ for (my $i=0; $i<$numsec; $i++) {
+ my $colflag = $i%2;
+ $response .= qq(
- );
- }
- $response .= qq(
+ );
+ }
+ $response .= qq(
@@ -1401,199 +1958,507 @@ sections which contribute to enrollment
- );
- }
- }
- &print_reply($r,$response,$$tasktitleref{$action});
- return;
+ );
+ }
+ }
+ &print_reply($r,$response,$$tasktitleref{$action});
+ return;
}
sub print_sections_response () {
- my ($r,$realm,$dom,$crs,$action,$tasktitleref) = @_;
- my %settings = &Apache::lonnet::get('environment',['internal.sectionnums','internal.coursecode'],$dom,$crs);
- my @currsections = ();
- my @sections = ();
- my @allsections = ();
- my $numsec = 0;
- my $secstr = $settings{'internal.sectionnums'};
- my $coursecode = $settings{'internal.coursecode'};
- my $response = '';
-
- if ($secstr =~ m/,/) {
- @allsections = split/,/,$secstr;
- } else {
- unless ($secstr eq '') { $allsections[0] = $secstr; }
- }
+ my ($r,$realm,$dom,$crs,$action,$tasktitleref) = @_;
+ my %settings = &Apache::lonnet::get('environment',['internal.sectionnums','internal.coursecode','internal.courseowner'],$dom,$crs);
+ my @currsections = ();
+ my @sections = ();
+ my @allsections = ();
+ my @badowner = ();
+ my @badsections = ();
+ my $numsec = 0;
+ my $secstr = $settings{'internal.sectionnums'};
+ my $coursecode = $settings{'internal.coursecode'};
+ my $owner = $settings{'internal.courseowner'};
+ my $response = '';
+ my $putreply = '';
+ my $warning = '';
+ my $warn_prefix = '';
+ if ($secstr =~ m/,/) {
+ @allsections = split/,/,$secstr;
+ } else {
+ unless ($secstr eq '') { $allsections[0] = $secstr; }
+ }
+
+ if ( exists($ENV{'form.numsec'}) ) {
+ $numsec = $ENV{'form.numsec'};
+ }
+
+ if ($numsec > 0) {
+ for (my $i=0; $i<$numsec; $i++) {
+ my $sec = "newsec_".$i;
+ my $gp = "newsecgp_".$i;
+ if ( exists($ENV{"form.$sec"}) ) {
+ unless ( (grep/^$ENV{"form.$sec"}:/,@allsections) || (grep/^$ENV{"form.$sec"}:/,@sections) ) {
+ my $newsec = $coursecode.$ENV{"form.$sec"};
+ my $coursecheck = &Apache::lonnet::auto_validate_courseID($crs,$dom,$newsec);
+ if ($coursecheck eq 'ok') {
+ my $addcheck = &Apache::lonnet::auto_new_course($crs,$dom,$newsec,$owner);
+ if ($addcheck eq 'ok') {
+ push @sections,$ENV{"form.$sec"}.":".$ENV{"form.$gp"};
+ } else {
+ push @badowner,$ENV{"form.$sec"}.":".$ENV{"form.$gp"};
+ }
+ } else {
+ push @badsections, $ENV{"form.$sec"}.":".$ENV{"form.$gp"}.":".$coursecheck;
+ }
+ }
+ }
+ }
+ push @allsections, @sections;
+ }
+
+ if (@sections > 0 ) {
+ unless ($secstr eq '') { $secstr .= ","; }
+ if (@sections > 1) {
+ $secstr .= join(",",@sections);
+ } else {
+ $secstr .= $sections[0];
+ }
+ my %cenv = ('internal.sectionnums' => $secstr);
+ $putreply = &Apache::lonnet::put('environment',\%cenv,$dom,$crs);
+ if ($putreply !~ /^ok$/) {
+ $response = "There was a problem processing your requested changes. The automated enrollment settings for this course have been left unchanged.
";
+ }
+ }
- if ( exists($ENV{'form.numsec'}) ) {
- $numsec = $ENV{'form.numsec'};
- }
-
- if ($numsec > 0) {
- for (my $i=0; $i<$numsec; $i++) {
- my $sec = "newsec_".$i;
- my $gp = "newsecgp_".$i;
- if ( exists($ENV{"form.$sec"}) ) {
- push @sections,$ENV{"form.$sec"}.":".$ENV{"form.$gp"};
- }
- }
- push @allsections, @sections;
- }
-
- if (@sections > 0 ) {
- unless ($secstr eq '') { $secstr .= ","; }
- if (@sections > 1) {
- $secstr .= join(",",@sections);
- } else {
- $secstr .= $sections[0];
- }
- my %cenv = ('internal.sectionnums' => $secstr);
- my $reply = &Apache::lonnet::put('environment',\%cenv,$dom,$crs);
- if ($reply !~ /^ok$/) {
- $response = "There was a problem processing your requested changes. The automated enrollment settings for this course have been left unchanged. ";
- } else {
- $response = "Students enrolling in the sections listed below will be automatically added to the class roster for LON-CAPA course $realm ($coursecode), if you have chosen to enable a nightly automated enrollment update.
\n";
-
- &print_reply($r,$response,$$tasktitleref{$action});
- return;
+ if ($putreply =~ /^ok/) {
+ $response = "Students enrolling in the sections listed below will be automatically added to the class roster for LON-CAPA course $realm ($coursecode), if you have chosen to enable a nightly automated enrollment update.
\n";
+ }
+
+ if (@badsections > 0) {
+ $response .= "The sections listed below could not be included in the sections for this LON-CAPA course, because they are not valid section numbers according to your institution's official schedule of classes and sections.
\n";
+ }
+
+ if (@badowner > 0) {
+ $response .= "The sections listed below could not be included in the sections for this LON-CAPA course, because the owner of this course - $owner - does not have rights to view enrollment in those classes as determined by your instititution's policies on access to official classlists.
\n";
+ }
+
+ if (@allsections > 0) {
+ $warning = &warning_message($dom,$crs,$action);
+ $warn_prefix = " Warning. Although you have selected sections to contribute enrollment to this course, additional action is required. ";
+ unless ($warning eq '') {
+ $response .= $warn_prefix.$warning;
+ }
+ }
+
+ &print_reply($r,$response,$$tasktitleref{$action});
+ return;
}
sub print_photos_response () {
- my ($r,$realm,$dom,$crs,$action,$tasktitleref) = @_;
- my %settings = &Apache::lonnet::get('environment',['internal.showphotos'],$dom,$crs);
- my $currphotos = $settings{'internal.showphotos'};
- my $showphotos = '';
- if ( exists($ENV{'form.showphotos'}) ) {
- $showphotos=$ENV{'form.showphotos'};
- }
-
- my $response = "";
- my %cenv = ('internal.showphotos' => $showphotos);
- my $reply = &Apache::lonnet::put('environment',\%cenv,$dom,$crs);
- if ($reply !~ /^ok$/) {
- $response = "There was a problem processing your requested change. The student photo import setting for this course has been left unchanged. ";
- } else {
- if ($showphotos) {
- if ($currphotos) {
- $response = "Retrieval of student photos is still enabled ";
- } else {
- $response = "Retrieval of student photos in now enabled ";
- }
- } else {
- if ($currphotos) {
- $response = "Retrieval of student photos is now disabled ";
- } else {
- $response = "Retrieval of student photos is still disabled ";
- }
- }
- }
- &print_reply($r,$response,$$tasktitleref{$action});
- return;
+ my ($r,$realm,$dom,$crs,$action,$tasktitleref) = @_;
+ my %settings = &Apache::lonnet::get('environment',['internal.showphotos'],$dom,$crs);
+ my $currphotos = $settings{'internal.showphotos'};
+ my $showphotos = '';
+ if ( exists($ENV{'form.showphotos'}) ) {
+ $showphotos=$ENV{'form.showphotos'};
+ }
+
+ my $response = "";
+ my %cenv = ('internal.showphotos' => $showphotos);
+ my $reply = &Apache::lonnet::put('environment',\%cenv,$dom,$crs);
+ if ($reply !~ /^ok$/) {
+ $response = "There was a problem processing your requested change. The student photo import setting for this course has been left unchanged. ";
+ } else {
+ if ($showphotos) {
+ if ($currphotos) {
+ $response = "Retrieval of student photos is still enabled ";
+ } else {
+ $response = "Retrieval of student photos in now enabled ";
+ }
+ } else {
+ if ($currphotos) {
+ $response = "Retrieval of student photos is now disabled ";
+ } else {
+ $response = "Retrieval of student photos is still disabled ";
+ }
+ }
+ }
+ &print_reply($r,$response,$$tasktitleref{$action});
+ return;
}
sub print_update_result () {
- my ($r,$realm,$dom,$crs,$action,$tasktitleref) = @_;
- my $response = '';
- my $updateadds = 0;
- my $updatedrops = 0;
- my $changecount = 0;
- my %affiliates = ();
- my %reply = ();
- my @allcourses = ();
- my %LC_code = ();
- my $logmsg = '';
- my $newusermsg = '';
-
- my %settings = &Apache::lonnet::get('environment',['internal.coursecode','internal.sectionnums','internal.crosslistings','internal.authtype','internal.autharg','internal.autostart','internal.autoend'],$dom,$crs);
- my $coursecode = $settings{'internal.coursecode'};
- my $authtype = $settings{'internal.authtype'};
- my $autharg = $settings{'internal.autharg'};
- my $autostart = $settings{'internal.autostart'};
- my $autoend = $settings{'internal.autoend'};
-
- if ( exists($ENV{'form.updateadds'}) ) {
- $updateadds = $ENV{'form.updateadds'};
- }
- if ( exists($ENV{'form.updatedrops'}) ) {
- $updatedrops = $ENV{'form.updatedrops'};
- }
- if (!$updateadds && !$updatedrops) {
- $response = "An update of the class roster has not been carried out because you indicated that you wanted to neither add new students, nor expire dropped students based on a comparison between the institutional class lists for the course sections and crosslisted courses that contribure enrollment to this LON-CAPA course.";
- } elsif ($coursecode eq '') {
- $response = "There was a problem retrieving the course code for this LON-CAPA course. An update of the class roster has not been carried out, and enrollment remains unchanged";
- } else {
+ my ($r,$realm,$dom,$crs,$action,$tasktitleref) = @_;
+ my $response = '';
+ my $updateadds = 0;
+ my $updatedrops = 0;
+ my $changecount = 0;
+ my %affiliates = ();
+ my %reply = ();
+ my @allcourses = ();
+ my %LC_code = ();
+ my $logmsg = '';
+ my $newusermsg = '';
+
+ my %settings = &Apache::lonnet::get('environment',['internal.coursecode','internal.sectionnums','internal.crosslistings','internal.authtype','internal.autharg'],$dom,$crs);
+ my $coursecode = $settings{'internal.coursecode'};
+ my $authtype = $settings{'internal.authtype'};
+ my $autharg = $settings{'internal.autharg'};
+ my ($startaccess,$endaccess) = &get_dates_from_form();
+ if ( exists($ENV{'form.updateadds'}) ) {
+ $updateadds = $ENV{'form.updateadds'};
+ }
+ if ( exists($ENV{'form.updatedrops'}) ) {
+ $updatedrops = $ENV{'form.updatedrops'};
+ }
+ if (($startaccess eq '') || ($endaccess eq '')) {
+ $response = "There was a problem processing your requested roster update because start and and access dates could not be determined. No changes have been made to the class roster. ";
+ } elsif ($updateadds && (($endaccess > 0) && ($endaccess <= $startaccess))) {
+ $response = 'The start access date/time is the same or later than the end access date/time. As this means that new roles will never be active, your requested roster update has not been carried out, and the roster remains unchanged. Please go back to the previous page to try your changes again.'."\n";
+ } elsif (!$updateadds && !$updatedrops) {
+ $response = "An update of the class roster has not been carried out because you indicated that you wanted to neither add new students, nor expire dropped students based on a comparison between the institutional class lists for the course sections and crosslisted courses that contribure enrollment to this LON-CAPA course.";
+ } elsif ($coursecode eq '') {
+ $response = "There was a problem retrieving the course code for this LON-CAPA course. An update of the class roster has not been carried out, and enrollment remains unchanged";
+ } else {
# Get complete list of course sections to update
- my @currsections = ();
- my @currxlists = ();
+ my @currsections = ();
+ my @currxlists = ();
+
+ if ($settings{'internal.sectionnums'} =~ m/,/) {
+ @currsections = split/,/,$settings{'internal.sectionnums'};
+ } elsif ($settings{'internal.sectionnums'} ne '') {
+ $currsections[0] = $settings{'internal.sectionnums'};
+ }
+
+ if ($settings{'internal.crosslistings'} =~ m/,/) {
+ @currxlists = split/,/,$settings{'internal.crosslistings'};
+ } elsif ($settings{'internal.crosslistings'} ne '') {
+ $currxlists[0] = $settings{'internal.crosslistings'};
+ }
+
+ if (@currxlists > 0) {
+ foreach (@currxlists) {
+ if (m/^(\w+):(\w*)$/) {
+ unless (grep/^$1$/,@allcourses) {
+ push @allcourses,$1;
+ $LC_code{$1} = $2;
+ }
+ }
+ }
+ }
+
+ if (@currsections > 0) {
+ foreach (@currsections) {
+ if (m/^(\w+):(\w*)$/) {
+ my $sec = $coursecode.$1;
+ my $gp = $2;
+ unless (grep/^$sec$/,@allcourses) {
+ push @allcourses,$sec;
+ $LC_code{$sec} = $gp;
+ }
+ }
+ }
+ }
+
+ if (@allcourses > 0) {
+ @{$affiliates{$crs}} = @allcourses;
+ my $outcome = &Apache::lonnet::fetch_enrollment_query('updatenow',\%affiliates,\%reply,$dom,$crs);
+ unless ($outcome eq 'ok') {
+ &Apache::lonnet::logthis("lonpopulate:update roster".
+ "failed to retrieve classlist".
+ " data for ".$crs."\@".$dom." by ".
+ $ENV{'user.name'}." \@ ".$ENV{'user.domain'}.
+ ": ".$outcome);
+ }
+ if ($reply{$crs} > 0) {
+ ($changecount,$response) = &LONCAPA::Enrollment::update_LC($dom,$crs,$updateadds,$updatedrops,$startaccess,$endaccess,$authtype,$autharg,\@allcourses,\%LC_code,\$logmsg,\$newusermsg,"updatenow");
+ } else {
+ $response = "There was a problem retrieving institutional class list data for the course sections and crosslisted courses which contribute enrollment to this course. No updates have been carried out, and the roster remains unchanged.";
+ }
+ } else {
+ $response = "There are currently no course sections or crosslisted courses designated as contributors to enrollment in this LON-CAPA course. As a result a student roster update has not been carried out for $realm ($coursecode)";
+ }
+ }
+ unless ($logmsg eq '') {
+ my $loglength = length($logmsg);
+ $logmsg = substr($logmsg,0,$loglength-4);
+ $logmsg = "
The following messages were generated by the roster update process:
The following new system user(s) who was/were created will be using local or internal authentication with an initial randomly generated password. A valid e-mail address was not available for this/these user(s) so LON-CAPA account credentials could not be sent via e-mail.
".$newusermsg."
";
+ }
+ $response .= $logmsg.$newusermsg;
+ &print_reply($r,$response,$$tasktitleref{$action});
+ return;
+}
- if ($settings{'internal.sectionnums'} =~ m/,/) {
- @currsections = split/,/,$settings{'internal.sectionnums'};
- } elsif ($settings{'internal.sectionnums'} ne '') {
- $currsections[0] = $settings{'internal.sectionnums'};
- }
-
- if ($settings{'internal.crosslistings'} =~ m/,/) {
- @currxlists = split/,/,$settings{'internal.crosslistings'};
- } elsif ($settings{'internal.crosslistings'} ne '') {
- $currxlists[0] = $settings{'internal.crosslistings'};
- }
-
- if (@currxlists > 0) {
- foreach (@currxlists) {
- if (m/^(\w+):(\w*)$/) {
- unless (grep/^$1$/,@allcourses) {
- push @allcourses,$1;
- $LC_code{$1} = $2;
- }
- }
- }
- }
+sub print_viewclass_response {
+ my ($r,$realm,$dom,$crs,$action,$tasktitleref) = @_;
+ my $response;
+ my $chgtotal = 0;
+ my $chgok = 0;
+ my $chgfail = 0;
+ my $othdom = 0;
+ my $locktotal = 0;
+ my $lockok = 0;
+ my $lockfail = 0;
+ my $cid = $dom."_".$crs;
+ my %chg = ();
+ my %nochg = ();
+ my %otherdom = ();
+ my %lockchg = ();
+ my %nolockchg = ();
+ my $classlist = &Apache::loncoursedata::get_classlist($cid,$dom,$crs);
+ my $endidx = &Apache::loncoursedata::CL_END;
+ my $startidx = &Apache::loncoursedata::CL_START;
+ my $ididx=&Apache::loncoursedata::CL_ID;
+ my $secidx=&Apache::loncoursedata::CL_SECTION;
+ my $typeidx=&Apache::loncoursedata::CL_TYPE;
+ my $lockedidx=&Apache::loncoursedata::CL_LOCKEDTYPE;
+ my @typechglist = ();
+ my @lockchglist = ();
+ &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['chgauto','chgmanual','lockchg','unlockchg']);
+ if ($ENV{'form.chgauto'}) {
+ if (ref($ENV{'form.chgauto'}) eq 'ARRAY') {
+ push @typechglist, @{$ENV{'form.chgauto'}};
+ } else {
+ push @typechglist, $ENV{'form.chgauto'};
+ }
+ }
+ if ($ENV{'form.chgmanual'}) {
+ if (ref($ENV{'form.chgmanual'}) eq 'ARRAY') {
+ push @typechglist, @{$ENV{'form.chgmanual'}};
+ } else {
+ push @typechglist, $ENV{'form.chgmanual'};
+ }
+ }
+ if ($ENV{'form.lockchg'}) {
+ if (ref($ENV{'form.lockchg'}) eq 'ARRAY') {
+ push @lockchglist, @{$ENV{'form.lockchg'}};
+ } else {
+ push @lockchglist, $ENV{'form.lockchg'};
+ }
+ }
+ if ($ENV{'form.unlockchg'}) {
+ if (ref($ENV{'form.unlockchg'}) eq 'ARRAY') {
+ push @lockchglist, @{$ENV{'form.unlockchg'}};
+ } else {
+ push @lockchglist, $ENV{'form.unlockchg'};
+ }
+ }
+ foreach my $student (sort @typechglist) {
+ my ($uname,$udom) = split/:/,$student;
+ my $sdata = $classlist->{$student};
+ my $section = $sdata->[$secidx];
+ my $uid = $sdata->[$ididx];
+ my $start = $sdata->[$startidx];
+ my $end = $sdata->[$endidx];
+ my $type = $sdata->[$typeidx];
+ my $lock = $sdata->[$lockedidx];
+ my $newlock = $lock;
+ $chgtotal ++;
+ my $newtype = 'auto';
+ my $change = 'auto';
+ my $oldtype = 'manual';
+ if ($type eq 'auto') {
+ $oldtype = 'auto';
+ $newtype = '';
+ $change = 'manual';
+ }
+ if ($udom eq $dom) {
+ if ($newtype eq 'auto') {
+ $newlock = '';
+ } elsif ($newtype eq '') {
+ $newlock = '1';
+ }
+ my $modreply = &Apache::lonnet::modify_student_enrollment($udom,$uname,$uid,'','','','',$section,$end,$start,$newtype,$newlock,$cid);
+ if ($modreply eq 'ok') {
+ $chgok ++;
+ $chg{$student} = "Changed to $change";
+ } else {
+ $chgfail ++;
+ $nochg{$student} = "Still set to $oldtype";
+ }
+ } else {
+ $othdom ++;
+ $otherdom{$student} = "Still set to $oldtype";
+ }
+ }
+ foreach my $student (@lockchglist) {
+ my ($uname,$udom) = split/:/,$student;
+ my $sdata = $classlist->{$student};
+ my $section = $sdata->[$secidx];
+ my $uid = $sdata->[$ididx];
+ my $start = $sdata->[$startidx];
+ my $end = $sdata->[$endidx];
+ my $type = $sdata->[$typeidx];
+ my $lock = $sdata->[$lockedidx];
+ my $newlock = 1;
+ my $oldlockname = &mt('unlocked');
+ my $newlockname = &mt('locked');
+ $locktotal++;
+ unless ($type eq 'auto') {
+ if ($lock) {
+ $newlock = '';
+ $newlockname = &mt('unlocked');
+ $oldlockname = &mt('locked');
+ }
+ my $lockreply = &Apache::lonnet::modify_student_enrollment($udom,$uname,$uid,'','','','',$section,$end,$start,$type,$newlock,$cid);
+ if ($lockreply eq 'ok') {
+ $lockok ++;
+ $lockchg{$student} = 'Changed to '.$newlockname;
+ } else {
+ $lockfail ++;
+ $nolockchg{$student} = 'Still set to '.$oldlockname;
+ }
+ }
+ }
+ if ($chgtotal > 0) {
+ $response = "You requested a change in enrollment type for $chgtotal students.
\n";
+ $classlist = &Apache::loncoursedata::get_classlist($cid,$dom,$crs);
+ if ($chgok > 0) {
+ $response .= "The following $chgok changes were successful: ";
+ $response .= &enrolltype_result(\%chg,$classlist,$endidx,$startidx,$ididx,$secidx,$typeidx);
+ }
+ if ($chgfail > 0) {
+ $response .= "The following $chgfail students were not modified successfully: ";
+ $response .= &enrolltype_result(\%nochg,$classlist,$endidx,$startidx,$ididx,$secidx,$typeidx);
+ }
+ if ($othdom > 0) {
+ $response .= "The following $othdom students were not modified because students must be in the same LON-CAPA domain as the course, in order to be set to an enrollment type of 'auto': ";
+ $response .= &enrolltype_result(\%otherdom,$classlist,$endidx,$startidx,$ididx,$secidx,$typeidx);
+ }
+ $response .= "
";
+ }
+ if ($locktotal > 0) {
+ $response .= "You requested locking/unlocking for $locktotal manually enrolled students.
\n";
+ $classlist = &Apache::loncoursedata::get_classlist($cid,$dom,$crs);
+ if ($lockok > 0) {
+ $response .= "The following $lockok changes were successful: ";
+ $response .= &enrolltype_result(\%lockchg,$classlist,$endidx,$startidx,$ididx,$secidx,$typeidx,$lockedidx);
+ }
+ if ($lockfail > 0) {
+ $response .= "The following $lockfail students were not modified successfully: ";
+ $response .= &enrolltype_result(\%nolockchg,$classlist,$endidx,$startidx,$ididx,$secidx,$typeidx,$lockedidx);
+ }
+ }
+ &print_reply($r,$response,$$tasktitleref{$action});
+ return;
+}
- if (@currsections > 0) {
- foreach (@currsections) {
- if (m/^(\w+):(\w*)$/) {
- my $sec = $coursecode.$1;
- my $gp = $2;
- unless (grep/^$sec$/,@allcourses) {
- push @allcourses,$sec;
- $LC_code{$sec} = $gp;
- }
- }
- }
- }
+sub enrolltype_result {
+ my ($changes,$classlist,$endidx,$startidx,$ididx,$secidx,$typeidx,$lockedidx) = @_;
+ my $reply = "
+
";
+ return $reply;
+}
- if (@allcourses > 0) {
- @{$affiliates{$crs}} = @allcourses;
- &localenroll::fetch_enrollment($dom,\%affiliates,\%reply);
- if ($reply{$crs} > 0) {
- ($changecount,$response) = &LONCAPA::Enrollment::update_LC($dom,$crs,$updateadds,$updatedrops,$autostart,$autoend,$authtype,$autharg,\@allcourses,\%LC_code,\$logmsg,\$newusermsg,"updatenow");
- } else {
- $response = "There was a problem retrieving institutional class list data for the course sections and crosslisted courses which contribute enrollment to this course. No updates have been carried out, and the roster remains unchanged.";
- }
- } else {
- $response = "There are currently no course sections or crosslisted courses designated as contributors to enrollment in this LON-CAPA course. As a result a student roster update has not been carried out for $realm ($coursecode)";
- }
- }
- unless ($logmsg eq '') {
- my $loglength = length($logmsg);
- $logmsg = substr($logmsg,0,$loglength-4);
- $logmsg = "
The following messages were generated by the roster update process:
The following new system user(s) who was/were created will be using internal authentication with an initial randomly generated password. A valid e-mail address was not available for this/these user(s) so LON-CAPA account credentials could not be sent via e-mail.
".$newusermsg."
";
- }
- $response .= $logmsg.$newusermsg;
- &print_reply($r,$response,$$tasktitleref{$action});
- return;
+sub warning_message {
+ my ($dom,$crs,$caller) = @_;
+ my %settings = &Apache::lonnet::get('environment',['internal.autoadds','internal.autodrops','internal.sectionnums','internal.crosslistings','internal.autostart','internal.autoend'],$dom,$crs);
+ my $currend = '';
+ my $currstart = '';
+ my $currsecs = '';
+ my $currxlists = '';
+ my $warning = '';
+ my $curradds = '';
+ my $currdrops = '';
+ if ( defined($settings{'internal.autoadds'}) ) {
+ $curradds = $settings{'internal.autoadds'};
+ }
+ if (defined($settings{'internal.autodrops'}) ) {
+ $currdrops = $settings{'internal.autodrops'};
+ }
+ if ( defined($settings{'internal.autostart'}) ) {
+ $currstart = $settings{'internal.autostart'};
+ }
+ if ( defined($settings{'internal.autoend'}) ) {
+ $currend = $settings{'internal.autoend'};
+ }
+ if ( defined($settings{'internal.sectionnums'}) ) {
+ $currsecs = $settings{'internal.sectionnums'};
+ }
+ if ( defined($settings{'internal.crosslistings'}) ) {
+ $currxlists = $settings{'internal.crosslistings'}
+ }
+ unless ($caller eq 'setdates') {
+ if ( ($currstart eq '') && ($currend eq '') ) {
+ $warning = "You must now use Change enrollment dates to set a start date and an end date for the enrollment (or check the 'No end date' checkbox) for the nightly adds process to actually occur.";
+ }
+ }
+ unless ( ($caller eq 'sections') || ($caller eq 'crosslist') ) {
+ if ( ($currsecs eq '') && ($currxlists eq '') ) {
+ $warning .= "You must now use Section settings and/or Change crosslistings to choose at least one section of the course, or at least one crosslisted course which will contribute enrollment to this LON-CAPA course. At present there are NO sections or crosslisted courses that are affiliated with this course that are set to contribute to the automated enrollment process.
";
+ }
+ }
+ unless ( $caller eq 'chgsettings') {
+ if ( (!$curradds) && (!$currdrops) ) {
+ $warning .= "You must now use Automated adds/drops to enable automated adds and/or drops if you want automatic enrollment updates to occur in this course.