--- loncom/interface/lonpopulate.pm 2004/01/15 01:47:21 1.9
+++ loncom/interface/lonpopulate.pm 2004/06/29 04:30:00 1.16
@@ -1,5 +1,5 @@
# automated enrollment configuration handler
-# $Id: lonpopulate.pm,v 1.9 2004/01/15 01:47:21 raeburn Exp $
+# $Id: lonpopulate.pm,v 1.16 2004/06/29 04:30:00 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -31,6 +31,7 @@ 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;
@@ -51,15 +52,19 @@ ENDHEAD
###############################################################
sub choose_header {
+ my $action = shift;
my $bodytag=&Apache::loncommon::bodytag('Classlist Manager');
my $scripttag = qq|
|;
@@ -220,6 +278,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 +291,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 +299,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 +321,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 +396,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 +468,22 @@ Note: Any students added manually by cou
+
+
+
ENDTWO
} elsif ($action eq "notify") {
@@ -579,7 +673,7 @@ ENDTWO
for (my $i=0; $i<@xlists; $i++) {
my $xl = ' ';
my $gp = ' ';
- if ($xlists[$i] =~ /(\w+):(.+)$/) {
+ if ($xlists[$i] =~ /(\w+):?(.*)$/) {
$xl = $1;
$gp = $2;
}
@@ -629,7 +723,8 @@ ENDTWO
");
} 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 = ();
@@ -845,34 +940,256 @@ Note: if you enable automatic import of
Expire students previously added by nightly enrollment process, but no longer listed in institutional classlist(s).
- Yes
- No
-
-
-
-
-
+ Yes
+ No
+
+
+
+
Note: Any students previously added manually by course coordinator(s) using either 'Upload classlist CSV file' or 'Enroll a single user' will be unaffected by the removal process.
-
-
+
+
+
+
");
+ } elsif ($action eq 'viewclass') {
+ $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(<
@@ -884,277 +1201,421 @@ 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 automated enrollment has been changed to $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 ($autostart,$autoend) = &get_dates_from_form();
+ my $showstart = &Apache::lonlocal::locallocaltime($autostart);
+ my $showend = '';
+ my $warning = '';
+ my $warn_prefix = '';
+ 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();
+ 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 = &Apache::lonlocal::locallocaltime($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 = ();
- my $peoplestr = "";
- my $response = "";
- my $noprocess = 0;
-
- if ($notifylist =~ m/,/) {
- @currpeople = split/,/,$notifylist;
- } else {
- $currpeople[0] = $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.notifyshow'}) ) {
- my $notifyshow = $ENV{'form.notifyshow'};
- for (my $i=0; $i<$notifyshow; $i++) {
- if ( exists($ENV{"form.note_$i"}) ) {
- if ( exists($ENV{"form.notifyname_$i"}) ) {
- unless ( $ENV{"form.notifyname_$i"} eq '' ) {
- push @people, $ENV{"form.notifyname_$i"};
- }
- }
- }
- }
- if ($notify) { $peoplestr = join(",",@people); }
- } else {
- if ($notify) {
- if ($currcount) {
- $response = "There was a problem retrieving the updated list of recipients of notification messages. The notification settings for this course have been left unchanged. .";
- $peoplestr = $notifylist;
- @people = @currpeople;
- $noprocess = 1;
- }
- }
- }
- unless ($noprocess == 1) {
- 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.