[LON-CAPA-cvs] cvs: loncom /interface lonpopulate.pm
raeburn
lon-capa-cvs@mail.lon-capa.org
Mon, 15 Dec 2003 07:55:59 -0000
This is a MIME encoded message
--raeburn1071474959
Content-Type: text/plain
raeburn Mon Dec 15 02:55:59 2003 EDT
Modified files:
/loncom/interface lonpopulate.pm
Log:
Modified notification interface for consistency with other interfaces. Changed method for determining course coordinators (now uses LONCAPA::Enrollment::check_user_status to avoid problem of stale dates in nohist_userroles.db, and can also provide options when nohist_userroles.db does not exist). Small changes to interface for 'Section settings'.
--raeburn1071474959
Content-Type: text/plain
Content-Disposition: attachment; filename="raeburn-20031215025559.txt"
Index: loncom/interface/lonpopulate.pm
diff -u loncom/interface/lonpopulate.pm:1.6 loncom/interface/lonpopulate.pm:1.7
--- loncom/interface/lonpopulate.pm:1.6 Thu Dec 11 19:45:49 2003
+++ loncom/interface/lonpopulate.pm Mon Dec 15 02:55:59 2003
@@ -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.7 2003/12/15 07:55:59 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -27,13 +27,13 @@
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::Constants qw(:common :http REDIRECT);
use Time::Local;
-use LONCAPA::Enrollment ();
+use LONCAPA::Enrollment;
use localenroll;
###############################################################
@@ -439,76 +439,111 @@
</td>
</tr>
");
- my $option_str = '';
- my $lastpname = '';
- my $option_count = 0;
-
- my %coursepersonnel=&Apache::lonnet::get_course_adv_roles($dom.'/'.$crs);
- foreach (sort keys %coursepersonnel) {
- if ($_ eq &mt("Course Coordinator") )
- {
- my @ccs = ();
- if ($coursepersonnel{$_} =~ m/,/) {
- @ccs = split(/,/,$coursepersonnel{$_});
- } else {
- @ccs = $coursepersonnel{$_};
- }
- foreach (@ccs) {
- my ($puname,$pudom)=split(/\:/,$_);
- my $pname = &Apache::loncommon::plainname($puname,$pudom);
- if (grep/^$puname\@$pudom$/,@notified) {
- $option_str .="<option value=\"$puname\@$pudom\" selected>$pname</option>\n";
+ my @coursepersonnel = &Apache::lonnet::getkeys('nohist_userroles',$dom,$crs);
+ my @ccs = ();
+ my @oldccs = ();
+ my %pname = ();
+ my %notifystate = ();
+ foreach (@coursepersonnel) {
+ my @roleinfo = split/:/,$_;
+ if ($roleinfo[0] eq 'cc') {
+ unless (grep/^$roleinfo[1]\@$roleinfo[2]/,@ccs) {
+ my $active_cc = &LONCAPA::Enrollment::check_user_status($roleinfo[2],$roleinfo[1],$dom,$crs,'cc');
+ if ($active_cc eq 'ok') {
+ push @ccs, "$roleinfo[1]\@$roleinfo[2]";
+ $pname{"$roleinfo[1]\@$roleinfo[2]"} = &Apache::loncommon::plainname($roleinfo[1],$roleinfo[2]);
+ if (grep/^$roleinfo[1]\@$roleinfo[2]$/,@notified) {
+ $notifystate{"$roleinfo[1]\@$roleinfo[2]"} = 1;
+ } else {
+ $notifystate{"$roleinfo[1]\@$roleinfo[2]"} = 0;
+ }
} else {
- $option_str .="<option value=\"$puname\@$pudom\">$pname</option>\n";
+ push @oldccs, "$roleinfo[1]\@$roleinfo[2]";
}
- $option_count ++;
- $lastpname = $pname.'@'.$pudom;
}
}
}
- if ($option_count > 1) {
- my $optionsize = $option_count;
- if ($optionsize > 6) {
- $optionsize = 6;
- }
+ if ($notifycount > 0) {
+ foreach my $person (@notified) {
+ unless ( (grep/^$person$/,@ccs) || ($person eq '') || (grep/^$person$/,@oldccs) ) {
+ push @ccs, $person;
+ my ($puname,$pdom) = split/\@/,$person;
+ $pname{$person} = &Apache::loncommon::plainname($puname,$pdom);
+ $notifystate{$person} = 1;
+ }
+ }
+ }
+ my $viewer = $ENV{'user.name'}.'@'.$ENV{'user.domain'};
+ unless ( (grep/^$viewer$/,@ccs) || ($viewer eq '') ) {
+ push @ccs,$viewer;
+ $pname{$viewer} = &Apache::loncommon::plainname($ENV{'user.name'},$ENV{'user.domain'});
+ $notifystate{$viewer} = 0;
+ }
+
+ my $notifyshow = @ccs;
+
+ if (@ccs > 0) {
+ @ccs = sort @ccs;
$r->print("
<tr>
- <td>
-Select which course coordinators should receive information about roster changes whenever any adds or drops occur during the nightly enrollment check.<br/><br/>
- <select name=\"notifylist\" multiple size=\"$optionsize\">$option_str</select>
+ <td>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.
</td>
</tr>
<tr>
<td>
- Select more than one recipient by using the following keyboard and mouse combinations:<br/>
- <ul>
- <li>Apple-click: MacOS</li>
- <li>Ctrl-click: Windows</li>
- <li>Left click: Linux</li>
- </ul>
- </td>
- </tr>
+ <table border=\"0\" cellpadding=\"3\" cellspacing=\"3\">
+ <tr bgcolor=\"#CCCCFF\">
+ <td><b>Name</b></td>
+ <td><b>username</b></td>
+ <td><b>Current status</b></td>
+ <td><b>Notification?</b></td>
+ </tr>
");
- } else {
+ for (my $i=0; $i<@ccs; $i++) {
+ my $colflag = $i%2;
+ $r->print("<tr bgcolor=\"$bgcolors[$colflag]\" align=\"left\">
+ <td>$pname{$ccs[$i]}</td>
+ <td><input type=\"hidden\" name=\"notifyname_$i\" value=\"$ccs[$i]\" />$ccs[$i]</td>
+ <td>
+ ");
+ if ($notifystate{$ccs[$i]} == 1) {
+ $r->print("Notification active");
+ } else {
+ $r->print("Notification inactive");
+ }
+ if ($notifystate{$ccs[$i]} == 1) {
+ $r->print("</td><td><input type=\"checkbox\" name=\"note_$i\" checked=\"true\" /></td></tr>");
+ } else {
+ $r->print("</td><td><input type=\"checkbox\" name=\"note_$i\" /></td></tr>");
+ }
+ }
$r->print("
- <tr>
- <td>
-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.
- <input type=\"hidden\" name=\"notifylist\" value=\"$lastpname\" />
- </td>
- </tr>
+ </table>
+ <br/>
+ <table width=\"100%\" border=\"0\" cellspadding=\"2\" cellspacing=\"2\">
+ <tr>
+ <td align=\"right\">
+ <input type=\"button\" name=\"notifyset\" value=\"Go\" onClick=\"process('notify')\" />
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
");
+ } else {
+ $r->print("
+ <tr>
+ <td>
+ No course coordinators found.
+ </td>
+ </tr>");
}
$r->print("
- <tr>
- <td align=\"right\">
- <input type=\"button\" name=\"notifyset\" value=\"Go\" onClick=\"process('notify')\" />
- </td>
- </tr>
- </table>
- <input type=\"hidden\" name=\"action\" value=\"$action\">
- <input type=\"hidden\" name=\"state\" value=\"process\">
- </form>
+ </table>
+ <input type=\"hidden\" name=\"notifyshow\" value=\"$notifyshow\">
+ <input type=\"hidden\" name=\"action\" value=\"$action\">
+ <input type=\"hidden\" name=\"state\" value=\"process\">
+ </form>
");
} elsif ($action eq "crosslist") {
my @xlists = ();
@@ -526,7 +561,7 @@
");
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: <b>$realm ($enrollvar{coursecode})</b>; 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: <b>$realm ($enrollvar{coursecode})</b>; 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.
</td>
</tr>
</table>
@@ -627,16 +662,13 @@
</tr>
</table>
<br/>
- <table border=\"0\" width=\"100%\" cellspacing=\"3\" cellpadding=\"3\">
- <tr>
- <td>
- <table width=\"100%\" border=\"0\" cellpadding=\"3\" cellspacing=\"3\">
- <tr bgcolor=\"#CCCCFF\">
- <td><b>Section</b></td>
- <td><b>Current status</b></td>
- <td><b>LON-CAPA section/group ID</b></td>
- <td><b>Enrollment in this course?</b></td>
- </tr>
+ <table border=\"0\" cellpadding=\"3\" cellspacing=\"3\">
+ <tr bgcolor=\"#CCCCFF\">
+ <td><b>Section</b></td>
+ <td><b>Current status</b></td>
+ <td><b>LON-CAPA section/group ID</b></td>
+ <td><b>Enrollment in this course?</b></td>
+ </tr>
");
for (my $i=0; $i<@sections; $i++) {
my $colflag = $i%2;
@@ -652,29 +684,25 @@
$r->print("Enrollment inactive");
}
if ($shrflag) {
- $r->print("</td><td><input type=\"text\" name=\"loncapasec_$i\" value=\"$sec_id{$sections[$i]}\"></td><td><input type=\"checkbox\" name=\"sec_$i\" checked=\"true\" /></td></tr>");
+ $r->print("</td><td><input type=\"text\" size=\"10\" name=\"loncapasec_$i\" value=\"$sec_id{$sections[$i]}\"></td><td><input type=\"checkbox\" name=\"sec_$i\" checked=\"true\" /></td></tr>");
} else {
- $r->print("</td><td><input type=\"text\" name=\"loncapasec_$i\" value=\"\"><td><input type=\"checkbox\" name=\"sec_$i\" /></td></tr>");
+ $r->print("</td><td><input type=\"text\" size=\"10\" name=\"loncapasec_$i\" value=\"\"><td><input type=\"checkbox\" name=\"sec_$i\" /></td></tr>");
}
}
$r->print("
- </tr>
- </table>
- </td>
- </tr>
- </table>
- <br/>
- <table width=\"100%\" border=\"0\" cellspacing=\"3\" cellpadding=\"3\">
- <tr>
- <td align=\"right\">
- <input type=\"hidden\" name=\"secshow\" value=\"$secshow\" />
- <input type=\"button\" name=\"sections\" value=\"Go\" onClick=\"process('sections')\" />
- </td>
- </tr>
- </table>
- <input type=\"hidden\" name=\"action\" value=\"$action\">
- <input type=\"hidden\" name=\"state\" value=\"process\">
- </form>
+ </table>
+ <br/>
+ <table width=\"100%\" border=\"0\" cellspacing=\"3\" cellpadding=\"3\">
+ <tr>
+ <td align=\"right\">
+ <input type=\"hidden\" name=\"secshow\" value=\"$secshow\" />
+ <input type=\"button\" name=\"sections\" value=\"Go\" onClick=\"process('sections')\" />
+ </td>
+ </tr>
+ </table>
+ <input type=\"hidden\" name=\"action\" value=\"$action\">
+ <input type=\"hidden\" name=\"state\" value=\"process\">
+ </form>
");
} else {
$r->print("<br/>
@@ -689,7 +717,7 @@
<tr>
<td>As your institution's course catalog only includes a single section for this course, there are no additional sections that can be set for inclusion in the LON-CAPA roster for the course.</td>
</tr>
- </table>
+ </table>
");
}
} else {
@@ -702,7 +730,7 @@
if (@currsections) {
my $secshow = @currsections;
$r->print("
- Currently, LON-CAPA course: $realm ($enrollvar{coursecode}) incorporates enrollment from $secshow sections. Students enrolling in any of 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 section, uncheck the checkbox if you want registered students in that section to cease being included in the student roster for LON-CAPA course: <b>$realm ($enrollvar{coursecode})</b>; otherwise leave it checked. If you want to change the section/group designation used for this section in LON-CAPA, delete the current value in the LON-CAPA section/groupID textbox and enter the new value. If you wish to add new course section, enter the number of new sections to add in the textbox at the bottom of the page. You will provide information about each of the new sections on a subsequent page. Click 'Go' to store your changes.
+ Currently, this LON-CAPA course incorporates enrollment from $secshow sections. Students enrolling in any of 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 section, uncheck the checkbox if you want registered students in that section to cease being included in the student roster for LON-CAPA course: <b>$realm ($enrollvar{coursecode})</b>; otherwise leave it checked. If you want to change the section/group designation used for this section in LON-CAPA, delete the current value in the LON-CAPA section/groupID textbox and enter the new value. If you wish to add new course section, enter the number of new sections to add in the textbox at the bottom of the page. You will provide information about each of the new sections on a subsequent page. Click 'Go' to store your changes.
</td>
</tr>
</table>
@@ -1007,11 +1035,14 @@
my @currpeople = ();
my $notify = 0;
my @people = ();
+ my $peoplestr = "";
+ my $response = "";
+ my $noprocess = 0;
if ($notifylist =~ m/,/) {
@currpeople = split/,/,$notifylist;
} else {
- @currpeople = $notifylist;
+ $currpeople[0] = $notifylist;
}
my $currcount = 0;
foreach (@currpeople) {
@@ -1020,43 +1051,56 @@
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.<br/>";
+ 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 (@people) {
- if ($currcount) {
- $response = "Notification of enrollment changes still <b>enabled</b><br/>";
- } else {
- $response = "Notification of enrollment changes now <b>enabled</b><br/>";
- }
- $response .= "<br/>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: <br/><ul>\n";
- foreach my $person (@people) {
- $response .= "<li>$person</li>\n";
- }
- $response .= "</ul>\n";
- } else {
- $response = "Notification of enrollment changes was <b> not enabled</b> as no course coordinators were selected as recipients.<br/>";
+ 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.<br/>.";
+ $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.<br/>";
} else {
- if ($currcount) {
- $response = "Notification of enrollment changes now <b>disabled</b><br/>";
+ if ($notify) {
+ if (@people) {
+ if ($currcount) {
+ $response .= "Notification of enrollment changes still <b>enabled</b><br/>";
+ } else {
+ $response .= "Notification of enrollment changes now <b>enabled</b><br/>";
+ }
+ $response .= "<br/>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: <br/><ul>\n";
+ foreach my $person (@people) {
+ $response .= "<li>$person</li>\n";
+ }
+ $response .= "</ul>\n";
+ } else {
+ $response = "Notification of enrollment changes was <b> not enabled</b> as no course coordinators were selected as recipients.<br/>";
+ }
} else {
- $response = "Notification of enrollment changes still <b>disabled</b><br/>";
+ if ($currcount) {
+ $response = "Notification of enrollment changes now <b>disabled</b><br/>";
+ } else {
+ $response = "Notification of enrollment changes still <b>disabled</b><br/>";
+ }
}
}
}
--raeburn1071474959--