[LON-CAPA-cvs] cvs: loncom /interface lonpopulate.pm
raeburn
lon-capa-cvs@mail.lon-capa.org
Mon, 23 Aug 2004 16:53:06 -0000
This is a MIME encoded message
--raeburn1093279986
Content-Type: text/plain
raeburn Mon Aug 23 12:53:06 2004 EDT
Modified files:
/loncom/interface lonpopulate.pm
Log:
Enhancement to guard against setting of start access dates later than end access dates, and also against blank start or end dates. Fix bug 3205.
--raeburn1093279986
Content-Type: text/plain
Content-Disposition: attachment; filename="raeburn-20040823125306.txt"
Index: loncom/interface/lonpopulate.pm
diff -u loncom/interface/lonpopulate.pm:1.18 loncom/interface/lonpopulate.pm:1.19
--- loncom/interface/lonpopulate.pm:1.18 Mon Aug 23 12:32:35 2004
+++ loncom/interface/lonpopulate.pm Mon Aug 23 12:53:06 2004
@@ -1,5 +1,5 @@
# automated enrollment configuration handler
-# $Id: lonpopulate.pm,v 1.18 2004/08/23 16:32:35 raeburn Exp $
+# $Id: lonpopulate.pm,v 1.19 2004/08/23 16:53:06 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -35,7 +35,6 @@
use Apache::Constants qw(:common :http REDIRECT);
use Time::Local;
use LONCAPA::Enrollment;
-use localenroll;
###############################################################
sub header {
@@ -1303,74 +1302,81 @@
my $currstart = $settings{'internal.autostart'};
my $currend = $settings{'internal.autoend'};
my $response = '';
- my ($autostart,$autoend) = &get_dates_from_form();
- my $showstart = &Apache::lonlocal::locallocaltime($autostart);
+ my $showstart = '';
my $showend = '';
my $warning = '';
my $warn_prefix = '';
- if ($autoend) {
- $showend = &Apache::lonlocal::locallocaltime($autoend);
- } else {
- $showend = "'No end date'";
- }
+ 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.<br/>";
+ } 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 <a href="javascript:history.go(-1)">go back</a> 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.<br/>";
- } else {
- if ($currstart == $autostart) {
- $response = "The first date for automated enrollment has been left unchanged as $showstart.<br/>";
- } else {
- $response = "The first date for automated enrollment has been changed to $showstart.<br/>";
- }
- if ($currend == $autoend) {
- $response .= "The last date for automated enrollment has been left unchanged as $showend.<br/>";
- } else {
- $response .= "The last date for automated enrollment has been changed to $showend.<br/>";
- }
+ 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.<br/>";
+ } else {
+ if ($currstart == $autostart) {
+ $response = "The first date for automated enrollment has been left unchanged as $showstart.<br/>";
+ } else {
+ $response = "The first date for automated enrollment has been changed to $showstart.<br/>";
+ }
+ if ($currend == $autoend) {
+ $response .= "The last date for automated enrollment has been left unchanged as $showend.<br/>";
+ } else {
+ $response .= "The last date for automated enrollment has been changed to $showend.<br/>";
+ }
# 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,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";
+ 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 {
- $firstaccess = "a date prior to today";
+ $nextupdate = "tomorrow";
}
- if (($nowstamp >= $autostart) && ($rosterupdated == 0)) {
- $response .= qq|<br>Although you have now set the first enrollment date to $firstaccess, automatic enrollment will <b>not</b> 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 <a href="/adm/populate?action=updatenow">roster update page</a>.<br>|;
+ if ($currstart < $lastupdate) {
+ $rosterupdated = 1;
}
- }
- $warning = &warning_message($dom,$crs,$action);
- $warn_prefix = "<br/><font size ='+1'><b>Warning</b></font>. Although you set a start and end date for auto-enrollment, additional action is required.<br/>";
- unless ($warning eq '') {
- $response .= $warn_prefix.$warning;
- }
+ if ($autostart < $nextmidnt ) {
+ if ( $autostart >= $lastmidnt) {
+ $firstaccess = "today";
+ } else {
+ $firstaccess = "a date prior to today";
+ }
+ if (($nowstamp >= $autostart) && ($rosterupdated == 0)) {
+ $response .= qq|<br>Although you have now set the first enrollment date to $firstaccess, automatic enrollment will <b>not</b> 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 <a href="/adm/populate?action=updatenow">roster update page</a>.<br>|;
+ }
+ }
+ $warning = &warning_message($dom,$crs,$action);
+ $warn_prefix = "<br/><font size ='+1'><b>Warning</b></font>. Although you set a start and end date for auto-enrollment, additional action is required.<br/>";
+ unless ($warning eq '') {
+ $response .= $warn_prefix.$warning;
+ }
+ }
}
&print_reply($r,$response,$$tasktitleref{$action});
return;
@@ -1384,86 +1390,93 @@
my $autostart = $settings{'internal.autostart'};
my $response = '';
my ($startaccess,$endaccess) = &get_dates_from_form();
- my $showstart = &Apache::lonlocal::locallocaltime($startaccess);
- my $showend = '';
- my $warning = '';
- my $warn_prefix = '';
- if ($endaccess) {
- $showend = &Apache::lonlocal::locallocaltime($endaccess);
+ 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.<br/>";
+ } 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 <a href="javascript:history.go(-1)">go back</a> to the previous page to try your changes again.'."\n";
} else {
- $showend = "'No end date'";
- }
+ 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,
+ 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.<br/>";
- } else {
- if ($currstart == $startaccess) {
- $response = "The first access date for students added via automated enrollment has been left unchanged as $showstart.<br/>";
- } else {
- $response = "The first access date for students added via automated enrollment has been changed to
+ 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.<br/>";
+ } else {
+ if ($currstart == $startaccess) {
+ $response = "The first access date for students added via automated enrollment has been left unchanged as $showstart.<br/>";
+ } else {
+ $response = "The first access date for students added via automated enrollment has been changed to
$showstart.<br/>";
- }
- if ($currend == $endaccess) {
- $response .= "The last access date for students added via automated enrollment has been left unchanged as $showend.<br/>";
- } else {
- $response .= "The last access date for students automated enrollment has been changed to
+ }
+ if ($currend == $endaccess) {
+ $response .= "The last access date for students added via automated enrollment has been left unchanged as $showend.<br/>";
+ } else {
+ $response .= "The last access date for students automated enrollment has been changed to
$showend.<br/>";
- }
+ }
# 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";
+ 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 {
- $firstaccess = "a date prior to today";
+ 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|<br>Although you have now set the first access date to $firstaccess, automatic enrollment will <b>not</b> 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 <a href="/adm/populate?action=updatenow">roster update page</a>.<br>|;
+ }
}
- if (($nowstamp >= $startaccess) && ($accessgiven == 0)) {
- $response .= qq|<br>Although you have now set the first access date to $firstaccess, automatic enrollment will <b>not</b> 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 <a href="/adm/populate?action=updatenow">roster update page</a>.<br>|;
+ $warning = &warning_message($dom,$crs,$action);
+ $warn_prefix = "<br/><font size ='+1'><b>Warning</b></font>. Although you have set default first and last access dates for students who are added via automatic enrollment, additional action is required.<br/>";
+ unless ($warning eq '') {
+ $response .= $warn_prefix.$warning;
}
- }
- $warning = &warning_message($dom,$crs,$action);
- $warn_prefix = "<br/><font size ='+1'><b>Warning</b></font>. Although you have set default first and last access dates for students who are added via automatic enrollment, additional action is required.<br/>";
- unless ($warning eq '') {
- $response .= $warn_prefix.$warning;
- }
+ }
}
&print_reply($r,$response,$$tasktitleref{$action});
return;
@@ -2106,14 +2119,17 @@
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'};
+ $updateadds = $ENV{'form.updateadds'};
}
if ( exists($ENV{'form.updatedrops'}) ) {
- $updatedrops = $ENV{'form.updatedrops'};
+ $updatedrops = $ENV{'form.updatedrops'};
}
- if (!$updateadds && !$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.<br />";
+ } 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 <a href="javascript:history.go(-1)">go back</a> 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";
@@ -2161,6 +2177,13 @@
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 {
@@ -2177,7 +2200,7 @@
}
unless ($newusermsg eq '') {
$newusermsg = substr( $newusermsg,0,rindex($newusermsg,'<li>') );
- $newusermsg = "<br/><br/>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.<br/><ul><li>".$newusermsg."</ul><br/>";
+ $newusermsg = "<br/><br/>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.<br/><ul><li>".$newusermsg."</ul><br/>";
}
$response .= $logmsg.$newusermsg;
&print_reply($r,$response,$$tasktitleref{$action});
--raeburn1093279986--