Annotation of loncom/interface/lonpopulate.pm, revision 1.13
1.4 albertel 1: # automated enrollment configuration handler
1.13 ! raeburn 2: # $Id: lonpopulate.pm,v 1.12 2004/06/08 22:09:44 raeburn Exp $
1.4 albertel 3: #
4: # Copyright Michigan State University Board of Trustees
5: #
6: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
7: #
8: # LON-CAPA is free software; you can redistribute it and/or modify
9: # it under the terms of the GNU General Public License as published by
10: # the Free Software Foundation; either version 2 of the License, or
11: # (at your option) any later version.
12: #
13: # LON-CAPA is distributed in the hope that it will be useful,
14: # but WITHOUT ANY WARRANTY; without even the implied warranty of
15: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16: # GNU General Public License for more details.
17: #
18: # You should have received a copy of the GNU General Public License
19: # along with LON-CAPA; if not, write to the Free Software
20: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21: #
22: # /home/httpd/html/adm/gpl.txt
23: #
24: # http://www.lon-capa.org/
25: #
1.1 raeburn 26: package Apache::lonpopulate;
27:
28: use strict;
29: use lib qw(/home/httpd/lib/perl);
1.7 raeburn 30: use Apache::lonnet;
31: use Apache::loncommon;
32: use Apache::lonhtmlcommon;
1.3 albertel 33: use Apache::lonlocal;
1.1 raeburn 34: use Apache::Constants qw(:common :http REDIRECT);
35: use Time::Local;
1.7 raeburn 36: use LONCAPA::Enrollment;
1.1 raeburn 37: use localenroll;
38:
39: ###############################################################
40: sub header {
41: my $bodytag=&Apache::loncommon::bodytag('Classlist Manager');
42: return(<<ENDHEAD);
43: <html>
44: <head>
45: <title>LON-CAPA Classlist Manager</title>
46: </head>
47: $bodytag
48: ENDHEAD
49: }
50:
51: ###############################################################
52:
53: sub choose_header {
54: my $bodytag=&Apache::loncommon::bodytag('Classlist Manager');
55: my $scripttag = qq|
56: <script language='javascript' type='text/javascript'>
57: <!--
58: function process(calling) {
59: var checker = 1
60: var rad1 = 0
61: var rad2 = 0
62: var formName = document.forms.enter
63: formName.action.value = calling
64: if (calling == "chgsettings") {
65: for (var j=0; j<formName.autoadds.length; j++) {
66: if (formName.autoadds[j].checked) {
67: rad1 = 1
68: }
69: }
70: for (var k=0; k<formName.autodrops.length; k++) {
71: if (formName.autodrops[k].checked) {
72: rad2 = 1
73: }
74: }
75: if (rad1 == 0) {
76: alert("You must check either 'Enable' or 'Disable' for nightly additions based on classlist changes")
77: checker = 0
78: }
79: if (rad2 == 0) {
80: alert("You must check either 'Enable' or 'Disable' for nightly removals based on classlist changes")
81: checker = 0
82: }
83: }
84: if (calling == "updatenow") {
85: var enrolldis
86: var unenrolldis
87: for (var j=0; j<formName.updateadds.length; j++) {
88: if (formName.updateadds[j].value == 0) {
89: enrolldis = j
90: }
91: if (formName.updateadds[j].checked) {
92: rad1 = 1
93: }
94: }
95: for (var k=0; k<formName.updatedrops.length; k++) {
96: if (formName.updatedrops[k].value == 0) {
97: unenrolldis = k
98: }
99: if (formName.updatedrops[k].checked) {
100: rad2 = 1
101: }
102: }
103: if (rad1 == 0) {
104: alert("You must check either 'Enable' or 'Disable' for nightly additions based on classlist changes")
105: checker = 0
106: }
107: if (rad2 == 0) {
108: alert("You must check either 'Enable' or 'Disable' for nightly removals based on classlist changes")
109: checker = 0
110: }
111: if (formName.updatedrops[unenrolldis].checked && formName.updateadds[enrolldis].checked ) {
112: alert("You have checked 'Disable' for both addition and removal of students\\n in the Registrar's classlist but not in your LON-CAPA course. \\nHence there is no update to carry out")
113: checker = 0
114: }
115: }
116: if (checker == 1) {
117: formName.submit();
118: }
119: }
120: // End hiding -->
121: </script>
122: |;
123: return(<<ENDHEAD);
124: <html>
125: <head>
126: <title>LON-CAPA Classlist Manager</title>
127: $scripttag
128: $bodytag
129: ENDHEAD
130: }
131:
132: sub print_mainbox {
133: my ($r,$tasklongref,$realm,$reply) = @_;
134: my $action = "information";
135: if ( exists($ENV{'form.action'}) ) {
136: $action = $ENV{'form.action'};
137: }
138: my $page = '';
139: if ($action eq "information") {
140: $page = "<b>Automated Enrollment</b>";
141: } else {
142: $page = '<a href="/adm/populate">Automated Enrollment</a>';
143: if ($reply) {
144: if ($action eq "newcross") {
145: $action = "crosslist";
146: } elsif ($action eq "newsections") {
147: $action = "sections";
148: }
149: $page .= "-> <a href=\"/adm/populate?action=$action\">".$$tasklongref{$action}."</a> -> <b>result</b>";
150: } else {
151: $page .= " -> <b>".$$tasklongref{$action}."</b>";
152: }
153: }
154: $r->print(<<ENDTHIS);
155: <table width="100%" border="0" cellpadding="0" cellspacing="0">
156: <tr>
157: <td bgcolor="#CCCCFF">
158: <font size="2"><a href="/adm/menu">$realm</a> -> <a href="/adm/dropadd">Enrollment Manager</a> -> $page</font><br/>
159: </td>
160: <td align="right" bgcolor="#CCCCFF" valign="top">
161: <font size="+1">Automated Enrollment Manager </font>
162: </td>
163: </tr>
164: </table>
165: <table width="100%" border="0" cellpadding="0" cellspacing="0">
166: <tr>
167: ENDTHIS
168: }
169:
170: sub print_navmenu {
171: my ($r,$tasksref,$tasklongref) = @_;
172: my $action = "information";
173: if (exists($ENV{'form.action'}) ) {
174: $action = $ENV{'form.action'};
175: }
176: $r->print(<<ENDONE);
177: <td width="10" valign="top" bgcolor="#DDFFFF"> </td>
178: <td width="20%" valign="top" bgcolor="#DDFFFF">
179: <br/>
180: ENDONE
181: foreach my $task (@{$tasksref}) {
182: if ($task eq $action) {
183: $r->print("
184: <p>
185: <font color=\"#999999\">
186: <b>$$tasklongref{$task}</b><br/>
187: </font>
188: </p>");
189: } else {
190: $r->print("
191: <p>
192: <font color=\"#004263\">
193: <b><a href=\"/adm/populate?action=$task\">$$tasklongref{$task}</a></b><br/>
194: </font>
195: </p>");
196:
197: }
198: }
199: $r->print("
200: <p> </p>
201: </td>
202: <td width=\"10\" valign=\"top\" bgcolor=\"#CCCCFF\"> </td>
203: <td width=\"10\" valign=\"top\" bgcolor=\"#FFFFFF\"> </td>
204: <td bgcolor=\"#ffffff\" valign=\"top\">");
205: }
206:
207: ###############################################################
208:
209: sub print_main_frame {
1.13 ! raeburn 210: my ($r,$realm,$dom,$crs,$tasktitleref) = @_;
1.1 raeburn 211: my $action = "information";
212: if (exists($ENV{'form.action'}) ) {
213: $action = $ENV{'form.action'};
214: }
215:
216: # Get course settings
217: my %enrollvar;
218: my @bgcolors=("#eeeeee","#cccccc");
219: my %settings = &Apache::lonnet::dump('environment',$dom,$crs);
220: foreach my $item (keys %settings) {
221: if ($item =~ m/^internal\.(.+)$/) {
222: $enrollvar{$1} = $settings{$item};
223: }
224: }
225:
226: if ($action eq "information") {
227: $r->print(<<ENDONE);
1.2 raeburn 228: <br/><table border='0' width='100%'>
1.1 raeburn 229: <tr>
230: <td> </td>
231: <td><b>Use the menu on the left to choose an enrollment management task.</b><br/><br/></td>
232: <tr>
233: <td> </td>
234: <td>Use <i>"Automated adds/drops"</i> to enable or disable automatic nightly adds or drops in your LON-CAPA course based on instututional enrollment information.</td>
235: </tr>
236: <tr>
237: <td> </td>
238: <td>Use <i>"Change enrollment dates"</i> to change the date of first automated enrollment and/or the date of last automated enrollment for registered students.</td>
239: </tr>
240: <tr>
241: <td> </td>
242: <td>Use <i>"Notification of changes"</i> to enable or disable notification of enrollment changes and to add or remove course coordinators from the recipient list.</td>
243: </tr>
244: <tr>
245: <td> </td>
246: <td>Use <i>"Change crosslisting"</i> to include or exclude enrollment from crosslisted classes.</td>
247: </tr>
248: <tr>
249: <td> </td>
250: <td>Use <i>"Section settings"</i> to make changes to the choice of sections included for enrollment in your LON-CAPA course.</td>
251: </tr>
252: <td> </td>
1.2 raeburn 253: <td>Use <i>"Student photos"</i> to enable or disable automatic upload of student photos to your course.</td>
1.1 raeburn 254: </tr>
255: <tr>
256: <td> </td>
257: <td>Use <i>"Update roster now"</i> to add and/or drop students from your course based on the <b>most current</b> institutional classlist information.</td>
258: </tr>
259: <tr>
260: <td colspan='2'> </td>
261: </tr>
262: <tr>
263: <td> </td>
264: <td><b>Note: if automated adds and/or drops are enabled, the nightly enrollment update will ONLY occur once the first enrollment date has been reached.</b></td>
265: </tr>
266: </table>
267: ENDONE
268: } elsif ($action eq "chgsettings") {
269: my @autosets = ("OFF","ON");
270: $r->print(<<ENDTWO);
271: <form name="enter" method="post"><br/>
272: <table width="100%" border="0" cellpadding="2" cellspacing="2">
273: <tr>
274: <td align="left"><b>$$tasktitleref{$action}</b><br/>
275: Currently: Nightly adds: <i>$autosets[$enrollvar{autoadds}]</i>, Nightly drops: <i>$autosets[$enrollvar{autodrops}]</i>
276: </td>
277: </tr>
278: </table>
279: <table width="100%" border="0" cellpadding="3" cellspacing="3">
280: <tr>
281: <td>
282: Additions based on classlist changes:
283: ENDTWO
284: if ($enrollvar{autoadds}) {
285: $r->print("
286: <input type=\"radio\" name=\"autoadds\" value=\"1\" checked=\"true\" /> Enable
287: <input type=\"radio\" name=\"autoadds\" value=\"0\" /> Disable
288: ");
289: } else {
290: $r->print("
291: <input type=\"radio\" name=\"autoadds\" value=\"1\" /> Enable
292: <input type=\"radio\" name=\"autoadds\" value=\"0\" checked=\"true\" /> Disable
293: ");
294: }
295: $r->print("
296: </td>
297: </tr>
298: <tr>
299: <td>
300: Removals based on classlist changes: ");
301: if ($enrollvar{autodrops}) {
302: $r->print("
303: <input type=\"radio\" name=\"autodrops\" value=\"1\" checked=\"true\" /> Enable
304: <input type=\"radio\" name=\"autodrops\" value=\"0\" /> Disable");
305: } else {
306: $r->print("
307: <input type=\"radio\" name=\"autodrops\" value=\"1\" /> Enable
308: <input type=\"radio\" name=\"autodrops\" value=\"0\" checked=\"true\" /> Disable");
309: }
310: $r->print("
311: </td>
312: </tr>
313: <tr>
314: <td>
315: <font color=\"#888888\">
316: Note: Any students added manually by course coordinators using the Enrollment Manager will be unaffected by the nightly removal process if you choose to enable it.
317: </font>
318: </td>
319: </tr>
320: <tr>
321: <td align=\"right\">
322: <input type=\"button\" name=\"chgsettings\" value=\"Go\" onClick=\"process('chgsettings')\" />
323: </td>
324: </tr>
325: </table>
326: <input type=\"hidden\" name=\"action\" value=\"$action\">
327: <input type=\"hidden\" name=\"state\" value=\"process\">
328: </form>
329: ");
330: } elsif ($action eq "setdates") {
331: my ($start_table,$end_table) = &date_setting_table($enrollvar{autostart},$enrollvar{autoend});
1.10 raeburn 332: my $oldstartshow = '';
333: my $oldendshow = '';
334: if ( defined($enrollvar{autostart}) ) {
335: $oldstartshow = localtime($enrollvar{autostart});
336: }
337: if ( defined($enrollvar{autoend}) ) {
338: $oldendshow = localtime($enrollvar{autoend});
339: if ($enrollvar{autoend} == 0) {
340: $oldendshow = "No ending date";
341: }
342: }
343: my $dateshow;
344: if ( ($oldendshow eq '') && ($oldstartshow eq '') ) {
345: $dateshow = "<br/><font size='+1'>Warning</font>. Currently <b>NO</b> first enrollment or last enrollment dates are set. You <b>must</b> use this menu to set a start date and an end date (or check the 'no ending date' checkbox) if you plan to utilise automated adds and/or drops in this course.\n";
346: } else {
347: $dateshow = "Currently: First enrollment: <b><i>$oldstartshow</i></b>, Last enrollment: <b><i>$oldendshow</i></b>\n";
1.1 raeburn 348: }
349: $r->print(<<ENDTWO);
350: <form name="enter" method="post"><br/>
351: <table width="100%" border="0" cellpadding="2" cellspacing="2">
352: <tr>
1.10 raeburn 353: <td align="left"><b>$$tasktitleref{$action}</b><br/><br/>
354: $dateshow
1.1 raeburn 355: </td>
356: </tr>
357: </table>
358: <table width="100%" border="0" cellpadding="3" cellspacing="3">
359: <tr>
360: <td align="left" colspan="2">
361: <table border="0" cellspacing="0" cellpadding="2">
362: <tr>
363: <td colspan="3">
364: <i>Set date of first automated enrollment for registered students</i>
365: </td>
366: </tr>
367: <tr>
368: <td>$start_table
369: </td>
370: </tr>
371: </table>
372: </td>
373: </tr>
374: <tr>
375: <td colspan="2"><font color="#888888">If automated adds and/or drops are enabled, then your class roster will be automatically updated nightly, once the first enrollment date has been reached. Prior to this date, the class roster will only contain students you have added directly using the standard LON-CAPA enrollment tools</font></td>
376: </tr>
377: <tr>
378: <td align="left" colspan="2">
379: <table border="0' cellspacing="0" cellpadding="2">
380: <tr>
381: <td colspan="3">
382: <i>Set date of last automated enrollment for registered students</i>
383: </td>
384: </tr>
385: <tr>
386: <td>$end_table
387: </td>
388: </tr>
389: </table>
390: </td>
391: </tr>
392: <tr>
393: <td colspan="2"><font color="#888888">If automated adds and/or drops are enabled, then your class roster will be automatically updated nightly, until the last enrollment date has been reached.</font></td>
394: </tr>
395: </table>
396: <table width="100%">
397: <tr>
398: <td align="right">
399: <input type="button" name="setdates" value="Go" onClick="process('setdates')" />
400: </td>
401: </tr>
402: </table>
403: <input type=\"hidden\" name=\"action\" value=\"$action\">
404: <input type=\"hidden\" name=\"state\" value=\"process\">
405: </form>
406: ENDTWO
407: } elsif ($action eq "notify") {
408: my @notified = ();
409: if ($enrollvar{notifylist} =~ m/,/) {
410: @notified = split/,/,$enrollvar{notifylist};
411: } else {
412: @notified = $enrollvar{notifylist};
413: }
414: my $notifycount = 0;
415: foreach (@notified) {
416: unless ($_ eq '') { $notifycount ++; }
417: }
418: my $noteset = '';
419: if ($notifycount) {
420: $noteset = "ON";
421: } else {
422: $noteset = "OFF";
423: }
424:
425: $r->print("
426: <form name=\"enter\" method=\"post\"><br/>
427: <table width=\"100%\" border=\"0\" cellpadding=\"6\" cellspacing=\"0\">
428: <tr>
429: <td align=\"left\"><b>$$tasktitleref{$action}</b><br/>
430: Currently: Notification: $noteset
431: </td>
432: </tr>
433: </table>
434: <table width=\"100%\" border=\"0\" cellpadding=\"3\" cellspacing=\"3\">
435: <tr>
436: <td>
437: Notification of LON-CAPA course roster changes resulting from nightly automated enrollment process?
438: ");
439: if ($notifycount) {
440: $r->print("
441: <input type=\"radio\" name=\"notify\" value=\"1\" checked=\"true\" /> Yes
442: <input type=\"radio\" name=\"notify\" value=\"0\" /> No
443: ");
444: } else {
445: $r->print("
446: <input type=\"radio\" name=\"notify\" value=\"1\" /> Yes
447: <input type=\"radio\" name=\"notify\" value=\"0\" checked=\"true\" /> No
448: ");
449: }
450: $r->print("
451: </td>
452: </tr>
453: ");
1.7 raeburn 454: my @coursepersonnel = &Apache::lonnet::getkeys('nohist_userroles',$dom,$crs);
455: my @ccs = ();
456: my @oldccs = ();
457: my %pname = ();
458: my %notifystate = ();
459: foreach (@coursepersonnel) {
460: my @roleinfo = split/:/,$_;
461: if ($roleinfo[0] eq 'cc') {
462: unless (grep/^$roleinfo[1]\@$roleinfo[2]/,@ccs) {
463: my $active_cc = &LONCAPA::Enrollment::check_user_status($roleinfo[2],$roleinfo[1],$dom,$crs,'cc');
464: if ($active_cc eq 'ok') {
465: push @ccs, "$roleinfo[1]\@$roleinfo[2]";
466: $pname{"$roleinfo[1]\@$roleinfo[2]"} = &Apache::loncommon::plainname($roleinfo[1],$roleinfo[2]);
467: if (grep/^$roleinfo[1]\@$roleinfo[2]$/,@notified) {
468: $notifystate{"$roleinfo[1]\@$roleinfo[2]"} = 1;
469: } else {
470: $notifystate{"$roleinfo[1]\@$roleinfo[2]"} = 0;
471: }
1.1 raeburn 472: } else {
1.7 raeburn 473: push @oldccs, "$roleinfo[1]\@$roleinfo[2]";
1.1 raeburn 474: }
475: }
476: }
477: }
1.7 raeburn 478: if ($notifycount > 0) {
479: foreach my $person (@notified) {
480: unless ( (grep/^$person$/,@ccs) || ($person eq '') || (grep/^$person$/,@oldccs) ) {
481: push @ccs, $person;
482: my ($puname,$pdom) = split/\@/,$person;
483: $pname{$person} = &Apache::loncommon::plainname($puname,$pdom);
484: $notifystate{$person} = 1;
485: }
486: }
487: }
488: my $viewer = $ENV{'user.name'}.'@'.$ENV{'user.domain'};
489: unless ( (grep/^$viewer$/,@ccs) || ($viewer eq '') ) {
490: push @ccs,$viewer;
491: $pname{$viewer} = &Apache::loncommon::plainname($ENV{'user.name'},$ENV{'user.domain'});
492: $notifystate{$viewer} = 0;
493: }
494:
495: my $notifyshow = @ccs;
496:
497: if (@ccs > 0) {
498: @ccs = sort @ccs;
1.1 raeburn 499: $r->print("
500: <tr>
1.7 raeburn 501: <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.
1.1 raeburn 502: </td>
503: </tr>
504: <tr>
505: <td>
1.7 raeburn 506: <table border=\"0\" cellpadding=\"3\" cellspacing=\"3\">
507: <tr bgcolor=\"#CCCCFF\">
508: <td><b>Name</b></td>
509: <td><b>username</b></td>
510: <td><b>Current status</b></td>
511: <td><b>Notification?</b></td>
512: </tr>
513: ");
514: for (my $i=0; $i<@ccs; $i++) {
515: my $colflag = $i%2;
516: $r->print("<tr bgcolor=\"$bgcolors[$colflag]\" align=\"left\">
517: <td>$pname{$ccs[$i]}</td>
518: <td><input type=\"hidden\" name=\"notifyname_$i\" value=\"$ccs[$i]\" />$ccs[$i]</td>
519: <td>
520: ");
521: if ($notifystate{$ccs[$i]} == 1) {
522: $r->print("Notification active");
523: } else {
524: $r->print("Notification inactive");
525: }
526: if ($notifystate{$ccs[$i]} == 1) {
527: $r->print("</td><td><input type=\"checkbox\" name=\"note_$i\" checked=\"true\" /></td></tr>");
528: } else {
529: $r->print("</td><td><input type=\"checkbox\" name=\"note_$i\" /></td></tr>");
530: }
531: }
532: $r->print("
533: </table>
534: <br/>
535: <table width=\"100%\" border=\"0\" cellspadding=\"2\" cellspacing=\"2\">
536: <tr>
537: <td align=\"right\">
538: <input type=\"button\" name=\"notifyset\" value=\"Go\" onClick=\"process('notify')\" />
539: </td>
540: </tr>
541: </table>
542: </td>
543: </tr>
1.1 raeburn 544: ");
1.7 raeburn 545: } else {
1.1 raeburn 546: $r->print("
1.7 raeburn 547: <tr>
548: <td>
549: No course coordinators found.
1.1 raeburn 550: </td>
1.7 raeburn 551: </tr>");
1.1 raeburn 552: }
553: $r->print("
1.7 raeburn 554: </table>
555: <input type=\"hidden\" name=\"notifyshow\" value=\"$notifyshow\">
556: <input type=\"hidden\" name=\"action\" value=\"$action\">
557: <input type=\"hidden\" name=\"state\" value=\"process\">
558: </form>
1.1 raeburn 559: ");
560: } elsif ($action eq "crosslist") {
561: my @xlists = ();
562: if ($enrollvar{crosslistings} =~ m/,/) {
563: @xlists = split/,/,$enrollvar{crosslistings};
564: } elsif ($enrollvar{crosslistings} ne '') {
565: $xlists[0] = $enrollvar{crosslistings};
566: }
567: my $cross_str = @xlists;
568: $r->print("
569: <form name=\"enter\" method=\"post\"><br/>
570: <table width=\"100%\" border=\"0\" cellpadding=\"2\" cellspacing=\"2\">
571: <tr>
572: <td align=\"left\"><b>$$tasktitleref{$action}</b><br/>
573: ");
574: if ($cross_str > 0) {
575: $r->print("
1.7 raeburn 576: 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.
1.1 raeburn 577: </td>
578: </tr>
579: </table>
580: <br/>
581: <table border=\"0\" cellpadding=\"3\" cellspacing=\"3\">
582: <tr>
583: <td>
584: <table border=\"0\" width=\"100%\" cellspacing=\"3\" cellpadding=\"3\">
585: <tr bgcolor=\"#CCCCFF\" align=\"left\">
586: <td><b>Enrollment?</b></td>
587: <td><b>Crosslisted course</b></td>
588: <td><b>LON-CAPA section/groupID</b></td>
589: </tr>
590: ");
591: for (my $i=0; $i<@xlists; $i++) {
592: my $xl = ' ';
593: my $gp = ' ';
594: if ($xlists[$i] =~ /(\w+):(.+)$/) {
595: $xl = $1;
596: $gp = $2;
597: }
598: my $colflag = $i%2;
599: $r->print("
600: <tr bgcolor=\"$bgcolors[$colflag]\" align=\"left\">
601: <td><input type=\"checkbox\" name=\"cross_$i\" checked=\"true\"/></td>
602: <td>$xl</td>
603: <td><input type =\"text\" size=\"10\" name=\"gp_$i\" value=\"$gp\"></td>
604: </tr>
605: ");
606: }
607: $r->print(" </table>
608: </td>
609: </tr>
610: </table>
611: ");
612: }
613: else {
614: $r->print("
615: Currently no crosslisted courses are recorded for $enrollvar{coursecode}.
616: </td>
617: </tr>
618: </table>
619: ");
620: }
621: $r->print("
622: <br/>
623: <table width=\"100%\" border=\"0\" cellpadding=\"3\" cellspacing=\"3\">
624: <tr>
625: <td align=\"left\">
626: <b>Add new crosslistings.</b><br/>
627: Number of new crosslistings to add: <input type=\"text\" size=\"2\" name=\"numcross\" value=\"0\" />
628: </td>
629: </tr>
630: </table>
631: <br/>
632: <table width=\"100%\" border=\"0\" cellspadding=\"2\" cellspacing=\"2\">
633: <tr>
634: <td align=\"right\">
635: <input type=\"button\" name=\"crosslist\" value=\"Go\" onClick=\"process('crosslist')\" />
636: </td>
637: </tr>
638: </table>
639: <input type=\"hidden\" name=\"action\" value=\"$action\">
640: <input type=\"hidden\" name=\"state\" value=\"process\">
641: </form>
642: ");
643: } elsif ($action eq "sections") {
1.12 raeburn 644: my @sections = ();
1.13 ! raeburn 645: @sections = &Apache::lonnet::auto_get_sections($crs,$dom,$enrollvar{coursecode});
1.1 raeburn 646: my @storedsections = ();
647: my @currsections = ();
648: my %sec_id = ();
649: if ($enrollvar{sectionnums} =~ m/,/) {
650: @storedsections = split/,/,$enrollvar{sectionnums};
651: } else {
652: $storedsections[0] = $enrollvar{sectionnums};
653: }
654: foreach (@storedsections) {
655: if ($_ =~ m/^(\w+):(\w*)$/) {
656: push @currsections, $1;
657: $sec_id{$1} = $2;
658: }
659: }
660: if (@sections > 0) {
1.8 raeburn 661: my $secshow = @sections;
662: $r->print("
1.1 raeburn 663: <form name=\"enter\" method=\"post\"><br/>
664: <table width=\"100%\" border=\"0\" cellpadding=\"3\" cellspacing=\"3\">
665: <tr>
666: <td align=\"left\">
667: <b>$$tasktitleref{$action}</b><br/>
668: Your institution's course catalog includes $secshow sections for course code: $enrollvar{coursecode}.
669: </td>
670: </tr>
671: <tr>
1.5 raeburn 672: <td>For each section, check the checkbox if you want registered students in that section to be included in the student roster for LON-CAPA course: <b>$realm ($enrollvar{coursecode})</b>; otherwise uncheck it. 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/group textbox and enter the new value. 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 section. To add a new section, check the 'Enrollment in this course?' checkbox, and enter the desired LON-CAPA section/groupID in the appropriate textbox. Click 'Go' to store
673: your changes.</td>
1.1 raeburn 674: </tr>
675: </table>
676: <br/>
1.7 raeburn 677: <table border=\"0\" cellpadding=\"3\" cellspacing=\"3\">
678: <tr bgcolor=\"#CCCCFF\">
679: <td><b>Section</b></td>
680: <td><b>Current status</b></td>
681: <td><b>LON-CAPA section/group ID</b></td>
682: <td><b>Enrollment in this course?</b></td>
683: </tr>
1.8 raeburn 684: ");
685: for (my $i=0; $i<@sections; $i++) {
686: my $colflag = $i%2;
687: my $shrflag = 0;
688: $r->print("<tr bgcolor=\"$bgcolors[$colflag]\" align=\"left\">
1.5 raeburn 689: <td>$sections[$i]<input type=\"hidden\" name=\"secnum_$i\" value=\"$sections[$i]\" /></td>
1.1 raeburn 690: <td>
1.8 raeburn 691: ");
692: if (grep/^$sections[$i]$/,@currsections) {
693: $r->print("Enrollment active");
694: $shrflag = 1;
695: } else {
696: $r->print("Enrollment inactive");
697: }
698: if ($shrflag) {
699: $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>");
700: } else {
701: $r->print("</td><td><input type=\"text\" size=\"10\" name=\"loncapasec_$i\" value=\"\"><td><input type=\"checkbox\" name=\"sec_$i\" /></td></tr>");
1.1 raeburn 702: }
1.8 raeburn 703: }
704: $r->print("
1.7 raeburn 705: </table>
706: <br/>
707: <table width=\"100%\" border=\"0\" cellspacing=\"3\" cellpadding=\"3\">
708: <tr>
709: <td align=\"right\">
710: <input type=\"hidden\" name=\"secshow\" value=\"$secshow\" />
711: <input type=\"button\" name=\"sections\" value=\"Go\" onClick=\"process('sections')\" />
712: </td>
713: </tr>
714: </table>
715: <input type=\"hidden\" name=\"action\" value=\"$action\">
716: <input type=\"hidden\" name=\"state\" value=\"process\">
717: </form>
1.8 raeburn 718: ");
1.1 raeburn 719: } else {
720: $r->print("
721: <form name=\"enter\" method=\"post\"><br/>
722: <table width=\"100%\" border=\"0\" cellpadding=\"2\" cellspacing=\"2\">
723: <tr>
724: <td align=\"left\"><b>$$tasktitleref{$action}</b><br/>
725: ");
726: if (@currsections) {
727: my $secshow = @currsections;
728: $r->print("
1.7 raeburn 729: 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.
1.1 raeburn 730: </td>
731: </tr>
732: </table>
733: <br/>
734: <table border=\"0\" cellpadding=\"3\" cellspacing=\"3\">
735: <tr>
736: <td>
737: <table border=\"0\" width=\"100%\" cellspacing=\"3\" cellpadding=\"3\">
738: <tr bgcolor=\"#CCCCFF\">
739: <td><b>Enrollment?</b></td>
740: <td><b>Section</b></td>
741: <td><b>LON-CAPA section/groupID</b></td>
742: </tr>
743: ");
744: for (my $j=0; $j<@currsections; $j++) {
745: my $colflag = $j%2;
746: $r->print("
747: <tr bgcolor=\"$bgcolors[$colflag]\" align=\"left\">
748: <td><input type=\"checkbox\" name=\"sec_$j\" checked=\"true\"/></td>
749: <td>$currsections[$j]</td>
750: <td><input type=\"text\" name=\"secgp_$j\" size=\"10\" value=\"$sec_id{$currsections[$j]}\"></td>
751: </tr>
752: ");
753: }
754: $r->print(" </table>
755: </td>
756: </tr>
757: </table>
758: ");
759: } else {
760: $r->print("
761: Currently no sections of $realm ($enrollvar{coursecode}) are contributing enrollment to the LON-CAPA class roster.
762: </td>
763: </tr>
764: </table>
765: ");
766: }
767: $r->print("
768: <br/>
769: <table width=\"100%\" border=\"0\" cellpadding=\"3\" cellspacing=\"3\">
770: <tr>
771: <td align=\"left\">
772: <b>Add enrollment from additional sections.</b><br/>
773: Number of new sections to add: <input type=\"text\" size=\"2\" name=\"numsec\" value=\"0\" />
774: </td>
775: </tr>
776: </table>
777: <br/>
778: <table width=\"100%\" border=\"0\" cellspadding=\"2\" cellspacing=\"2\">
779: <tr>
780: <td align=\"right\">
781: <input type=\"button\" name=\"sections\" value=\"Go\" onClick=\"process('sections')\" />
782: </td>
783: </tr>
784: </table>
785: <input type=\"hidden\" name=\"action\" value=\"$action\">
786: <input type=\"hidden\" name=\"state\" value=\"process\">
787: </form>
788: ");
789: }
790: } elsif ($action eq "photos") {
791: my @photosets = ("OFF","ON");
792: $r->print("
793: <form name=\"enter\" method=\"post\"><br/>
794: <table width=\"100%\" border=\"0\" cellpadding=\"2\" cellspacing=\"2\">
795: <tr>
796: <td align=\"left\"><b>$$tasktitleref{$action}</b><br/>
797: Currently: Student photo import: <i>$photosets[$enrollvar{showphotos}]</i>
798: </td>
799: </tr>
800: </table>
801: <table width=\"100%\" border=\"0\" cellpadding=\"3\" cellspacing=\"3\">
802: <tr>
803: <td>
804: Automatic import of student photos from institutional data repository:
805:
806: ");
807: if ($enrollvar{showphotos}) {
808: $r->print("
809: <input type=\"radio\" name=\"showphotos\" value=\"1\" checked=\"true\" /> Yes
810: <input type=\"radio\" name=\"showphotos\" value=\"0\" /> No
811: ");
812: } else {
813: $r->print("
814: <input type=\"radio\" name=\"showphotos\" value=\"1\" /> Yes
815: <input type=\"radio\" name=\"showphotos\" value=\"0\" checked=\"true\" /> No
816: ");
817: }
818: $r->print("
819: </td>
820: </tr>
821: <tr>
822: <td>
823: <font color=\"#888888\">
824: Note: if you enable automatic import of student photos, your course will automatically have access to photos stored by your institution for all officially registered students, via a conduit established by your LON-CAPA domain coordinator.
825: </font>
826: </td>
827: </tr>
828: <tr>
829: </td> </td>
830: </tr>
831: <tr>
832: <td align=\"right\">
833: <input type=\"button\" name=\"showphotos\" value=\"Go\" onClick=\"process('photos')\">
834: </td>
835: </tr>
836: </table>
837: <input type=\"hidden\" name=\"action\" value=\"$action\">
838: <input type=\"hidden\" name=\"state\" value=\"process\">
839: </form>
840: ");
841: } elsif ($action eq "updatenow") {
842: $r->print("
843: <form name=\"enter\" method=\"post\"><br/>
844: <table width=\"100%\" border=\"0\" cellpadding=\"2\" cellspacing=\"2\">
845: <tr>
846: <td align=\"left\"><b>$$tasktitleref{$action}</b>
847: </td>
848: </tr>
849: </table>
850: <table width=\"100%\" border=\"0\" cellpadding=\"3\" cellspacing=\"3\">
851: <tr>
852: <td>
853: Add any students currently included in institutional classlist(s) but not enrolled in your LON-CAPA course.
854: <input type=\"radio\" name=\"updateadds\" value=\"1\"> Yes
855: <input type=\"radio\" name=\"updateadds\" value=\"0\"> No
856: </td>
857: </tr>
858: <tr>
859: <td>
860: Expire students previously added by nightly enrollment process, but no longer listed in institutional classlist(s).
861: <input type=\"radio\" name=\"updatedrops\" value=\"1\"> Yes
862: <input type=\"radio\" name=\"updatedrops\" value=\"0\"> No <br/>
863: </td>
864: </tr>
865: <tr>
866: <td>
867: <font color=\"#888888\">
868: 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.
869: </font>
870: </td>
871: </tr>
872: <tr>
873: <td align=\"right\">
874: <input type=\"button\" name=\"updatenow\" value=\"Go\" onClick=\"process('updatenow')\">
875: </td>
876: </tr>
877: </table>
878: <input type=\"hidden\" name=\"action\" value=\"$action\">
879: <input type=\"hidden\" name=\"state\" value=\"process\">
880: </form>
881: ");
882: }
883: }
884:
885: ###############################################################
886: sub print_doc_base {
887: my $r = shift;
888: $r->print(<<ENDBASE);
889: </td>
890: </tr>
891: </table>
892: <br/>
893: </body>
894: </html>
895: ENDBASE
896: }
897:
898: ###################################################################
899: sub print_chgsettings_response {
900: my ($r,$realm,$dom,$crs,$action,$tasktitleref) = @_;
1.10 raeburn 901: my %settings = &Apache::lonnet::get('environment',['internal.sectionnums','internal.crosslistings','internal.autostart','internal.autoend','internal.autoadds','internal.autodrops'],$dom,$crs);
902: my $currend = '';
903: my $currstart = '';
904: my $currsecs = '';
905: my $currxlists = '';
906: my $curradds = '';
907: my $currdrops = '';
908: if ( defined($settings{'internal.autoadds'}) ) {
909: $curradds = $settings{'internal.autoadds'};
910: }
911: if ( defined($settings{'internal.autodrops'}) ) {
912: $currdrops = $settings{'internal.autodrops'};
913: }
914: if ( defined($settings{'internal.autostart'}) ) {
915: $currstart = $settings{'internal.autostart'};
916: }
917: if ( defined($settings{'internal.autoend'}) ) {
918: $currend = $settings{'internal.autoend'};
919: }
920: if ( defined($settings{'internal.sectionnums'}) ) {
921: $currsecs = $settings{'internal.sectionnums'};
922: }
923: if ( defined($settings{'internal.crosslistings'}) ) {
924: $currxlists = $settings{'internal.crosslistings'}
925: }
1.1 raeburn 926: my $autoadds = '';
927: my $autodrops = '';
928:
929: if ( exists($ENV{'form.autoadds'}) ) {
930: $autoadds=$ENV{'form.autoadds'};
931: }
932: if ( exists($ENV{'form.autodrops'}) ) {
933: $autodrops=$ENV{'form.autodrops'};
934: }
935:
936: my $response = "";
1.10 raeburn 937: my $warning = "";
938: my $warn_prefix = "";
939: my $warn_suffix = "";
940: my $warnfiller = "";
1.1 raeburn 941: my %cenv = ('internal.autoadds' => $autoadds,
942: 'internal.autodrops' => $autodrops);
943: my $reply = &Apache::lonnet::put('environment',\%cenv,$dom,$crs);
944: if ($reply !~ /^ok$/) {
945: $response = "There was a problem processing your requested changes. The automated enrollment settings for this course have been left unchanged.<br/>";
946: } else {
947: if ($autoadds) {
948: if ($curradds) {
949: $response = "Nightly additions based on classlist changes still <b>enabled</b><br/>";
950: } else {
951: $response = "Nightly additions based on classlist changes now <b>enabled</b><br/>";
1.10 raeburn 952: }
1.1 raeburn 953: } else {
954: if ($curradds) {
955: $response = "Nightly additions based on classlist changes now <b>disabled</b><br/>";
956: } else {
957: $response = "Nightly additions based on classlist changes still <b>disabled</b><br/>";
958: }
959: }
960: if ($autodrops) {
961: if ($currdrops) {
962: $response .= "Nightly removals based on classlist changes still <b>enabled</b><br>";
963: } else {
964: $response .= "Nightly removals based on classlist changes now <b>enabled</b><br/>";
965: }
966: } else {
967: if ($currdrops) {
968: $response .= "Nightly removals based on classlist changes now <b>disabled</b><br>";
969: } else {
970: $response .= "Nightly removals based on classlist changes still <b>disabled</b>";
971: }
972: }
1.10 raeburn 973: if ($autoadds || $autodrops) {
974: $warning = &warning_message($dom,$crs,$action);
975: $warn_prefix = "<br/><font size ='+1'><b>Warning</b></font>. Although you indicated that nightly ";
976: $warn_suffix = " should be enabled, additional action is required.<br/>";
977: }
978: if ($autoadds) {
979: if ($autodrops) {
980: $warnfiller = "adds and drops";
981: } else {
982: $warnfiller = "adds";
983: }
984: } else {
985: if ($autodrops) {
986: $warnfiller = "drops";
987: }
988: }
989: unless ($warning eq '') {
990: $response = $warn_prefix.$warnfiller.$warn_suffix.$warning;
991: }
1.1 raeburn 992: }
993: &print_reply($r,$response,$$tasktitleref{$action});
994: return;
995: }
996:
997: sub print_setdates_response {
998: my ($r,$realm,$dom,$crs,$action,$tasktitleref) = @_;
999: my %settings = &Apache::lonnet::get('environment',['internal.autostart','internal.autoend'],$dom,$crs);
1000: my $currstart = $settings{'internal.autostart'};
1001: my $currend = $settings{'internal.autoend'};
1002: my $response = '';
1003: my ($autostart,$autoend) = &get_dates_from_form();
1004: my $showstart = localtime($autostart);
1005: my $showend = '';
1.10 raeburn 1006: my $warning = '';
1007: my $warn_prefix = '';
1.1 raeburn 1008: if ($autoend) {
1009: $showend = localtime($autoend);
1010: } else {
1011: $showend = "'No end date'";
1012: }
1013:
1014: my %cenv = ('internal.autostart' => $autostart,
1015: 'internal.autoend' => $autoend);
1016: my $reply = &Apache::lonnet::put('environment',\%cenv,$dom,$crs);
1017: if ($reply !~ /^ok$/) {
1018: $response = "There was a problem processing your requested changes. The automated enrollment settings for this course have been left unchanged.<br/>";
1019: } else {
1020: if ($currstart == $autostart) {
1021: $response = "The first date for automated enrollment has been left unchanged as $showstart.<br/>";
1022: } else {
1023: $response = "The first date for automated enrollment has been changed to $showstart.<br/>";
1024: }
1025: if ($currend == $autoend) {
1026: $response .= "The last date for automated enrollment has been left unchanged as $showend.<br/>";
1027: } else {
1.9 raeburn 1028: $response .= "The last date for automated enrollment has been changed to $showend.<br/>";
1.1 raeburn 1029: }
1030:
1031: # Generate message in case where old first access date was later than today, but new first access date is now today or earlier.
1032:
1033: my $rosterupdated = 0;
1034: my $firstaccess = "";
1035: my $nextupdate = "";
1036: my $lastupdate = "";
1037:
1038: my $nowstamp = time;
1039: my @date_list=localtime(time);
1040: my $cur_year = $date_list[5];
1041: my $curday = $date_list[3];
1042: my $curmonth = $date_list[4];
1043: my $lastmidnt = timelocal(0,0,0,$date_list[3],$date_list[4],$date_list[5]);
1044: my $nextmidnt = 86400 + $lastmidnt;
1045:
1.10 raeburn 1046: my $todayupdate = timelocal(0,30,1,$date_list[3],$date_list[4],$date_list[5]);
1.1 raeburn 1047: my $lastupdate = $todayupdate - 86400;
1048: if ($nowstamp < $todayupdate) {
1049: $nextupdate = "today";
1050: } else {
1051: $nextupdate = "tomorrow";
1052: }
1053: if ($currstart < $lastupdate) {
1054: $rosterupdated = 1;
1055: }
1056: if ($autostart < $nextmidnt ) {
1057: if ( $autostart >= $lastmidnt) {
1058: $firstaccess = "today";
1059: } else {
1060: $firstaccess = "a date prior to today";
1061: }
1062: if (($nowstamp >= $autostart) && ($rosterupdated == 0)) {
1.10 raeburn 1063: $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 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>|;
1.1 raeburn 1064: }
1065: }
1.10 raeburn 1066: $warning = &warning_message($dom,$crs,$action);
1067: $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/>";
1068: unless ($warning eq '') {
1069: $response .= $warn_prefix.$warning;
1070: }
1.1 raeburn 1071: }
1072: &print_reply($r,$response,$$tasktitleref{$action});
1073: return;
1074: }
1075:
1076: sub print_notify_response {
1077: my ($r,$realm,$dom,$crs,$action,$tasktitleref) = @_;
1078:
1079: # Get current settings
1080: my %settings = &Apache::lonnet::get('environment',['internal.notifylist','internal.coursecode'],$dom,$crs);
1081: my $notifylist = $settings{'internal.notifylist'};
1082: my $coursecode = $settings{'internal.coursecode'};
1083: my @currpeople = ();
1084: my $notify = 0;
1085: my @people = ();
1.7 raeburn 1086: my $peoplestr = "";
1087: my $response = "";
1088: my $noprocess = 0;
1.1 raeburn 1089:
1090: if ($notifylist =~ m/,/) {
1091: @currpeople = split/,/,$notifylist;
1092: } else {
1.7 raeburn 1093: $currpeople[0] = $notifylist;
1.1 raeburn 1094: }
1095: my $currcount = 0;
1096: foreach (@currpeople) {
1097: unless ($_ eq '') { $currcount ++; }
1098: }
1099:
1100: if ( exists($ENV{'form.notify'}) ) {
1101: $notify=$ENV{'form.notify'};
1102: }
1.7 raeburn 1103: if ( exists($ENV{'form.notifyshow'}) ) {
1104: my $notifyshow = $ENV{'form.notifyshow'};
1105: for (my $i=0; $i<$notifyshow; $i++) {
1106: if ( exists($ENV{"form.note_$i"}) ) {
1107: if ( exists($ENV{"form.notifyname_$i"}) ) {
1108: unless ( $ENV{"form.notifyname_$i"} eq '' ) {
1109: push @people, $ENV{"form.notifyname_$i"};
1110: }
1111: }
1112: }
1113: }
1114: if ($notify) { $peoplestr = join(",",@people); }
1.1 raeburn 1115: } else {
1116: if ($notify) {
1.7 raeburn 1117: if ($currcount) {
1118: $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/>.";
1119: $peoplestr = $notifylist;
1120: @people = @currpeople;
1121: $noprocess = 1;
1122: }
1123: }
1124: }
1125: unless ($noprocess == 1) {
1126: my %cenv = ('internal.notifylist' => $peoplestr);
1127: my $reply = &Apache::lonnet::put('environment',\%cenv,$dom,$crs);
1128: if ($reply !~ /^ok$/) {
1129: $response = "There was a problem processing your requested changes. The notification settings for this course have been left unchanged.<br/>";
1130: } else {
1131: if ($notify) {
1132: if (@people) {
1133: if ($currcount) {
1134: $response .= "Notification of enrollment changes still <b>enabled</b><br/>";
1135: } else {
1136: $response .= "Notification of enrollment changes now <b>enabled</b><br/>";
1137: }
1138: $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";
1139: foreach my $person (@people) {
1140: $response .= "<li>$person</li>\n";
1141: }
1142: $response .= "</ul>\n";
1143: } else {
1144: $response = "Notification of enrollment changes was <b> not enabled</b> as no course coordinators were selected as recipients.<br/>";
1145: }
1146: } else {
1.1 raeburn 1147: if ($currcount) {
1.7 raeburn 1148: $response = "Notification of enrollment changes now <b>disabled</b><br/>";
1.1 raeburn 1149: } else {
1.7 raeburn 1150: $response = "Notification of enrollment changes still <b>disabled</b><br/>";
1.1 raeburn 1151: }
1152: }
1153: }
1154: }
1155: &print_reply($r,$response,$$tasktitleref{$action});
1156: return;
1157: }
1158:
1159: sub print_crosslistings_menu () {
1.13 ! raeburn 1160: my ($r,$realm,$dom,$crs,$action,$tasktitleref) = @_;
1.1 raeburn 1161: my %settings = &Apache::lonnet::get('environment',['internal.crosslistings','internal.coursecode'],$dom,$crs);
1162: my @currxlists = ();
1163: my @xlists = ();
1164: my $crosscount = 0;
1165: my $removecount = 0;
1166: my $xliststr = '';
1167: my $response = '';
1168: my $coursecode = $settings{'internal.coursecode'};
1169: if ($settings{'internal.crosslistings'} =~ m/,/) {
1170: @currxlists = split/,/,$settings{'internal.crosslistings'};
1171: } elsif ($settings{'internal.crosslistings'} ne '') {
1172: $currxlists[0] = $settings{'internal.crosslistings'};
1173: }
1174:
1175: if (@currxlists > 0) {
1176: for (my $i=0; $i<@currxlists; $i++) {
1177: my $xlist = "cross_".$i;
1178: my $gp = "gp_".$i;
1179: if ( exists($ENV{"form.$xlist"}) ) {
1180: my $xlistentry = '';
1181: if ($currxlists[$i] =~ m/^(\w+:)/) {
1182: $xlistentry = $1;
1183: }
1184: if ( exists($ENV{"form.$gp"}) ) {
1185: $xlistentry .= $ENV{"form.$gp"};
1186: }
1187: push @xlists,$xlistentry;
1188: $crosscount ++;
1189: } else {
1190: $removecount ++;
1191: }
1192: }
1193: }
1194:
1195: if ($crosscount > 1) {
1196: $xliststr = join(",",@xlists);
1197: } else {
1198: $xliststr = $xlists[0];
1199: }
1200: my %cenv = ('internal.crosslistings' => $xliststr);
1201: my $reply = &Apache::lonnet::put('environment',\%cenv,$dom,$crs);
1202: if ($reply !~ /^ok$/) {
1203: $response = "There was a problem processing your requested changes. The automated enrollment settings for this course have been left unchanged.<br/>";
1204: } else {
1205: if ($removecount > 0) {
1.5 raeburn 1206: $response = "A total of $removecount courses are no longer crosslisted with LON-CAPA course: $realm ($coursecode).<br/><br/>";
1.1 raeburn 1207: }
1208: if ($crosscount > 0) {
1209: $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.<br/><ul>\n";
1210: foreach (@xlists) {
1211: my ($xlist,$gp) = split/:/,$_;
1212: $response .= "<li>$xlist - ID: $gp</li>\n";
1213: }
1214: $response .= "</ul><br/>\n";
1215: }
1216: }
1217: if ( exists($ENV{'form.numcross'}) ) {
1218: my $numcross = $ENV{'form.numcross'};
1219: if ($numcross > 0) {
1220: my @bgcolors=("#eeeeee","#cccccc");
1221: $response .= qq(
1222: 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.<br/><br/>
1223: <form name="enter" method="post">
1224: <table border="0" cellpadding="2" cellspacing="2" width="100%">
1225: <tr>
1226: <td>
1227: <table border="0" cellspacing="3" cellpadding="3">
1228: <tr bgcolor="#CCCCFF" align="left">
1229: <td><b>Crosslisting</b></td>
1230: <td><b>LON-CAPA section/groupID</b></td>
1231: </tr>
1232: );
1233: for (my $i=0; $i<$numcross; $i++) {
1234: my $colflag = $i%2;
1235: $response .= qq(
1236: <tr bgcolor="$bgcolors[$colflag]" align="left">
1237: <td><input type="text" size="15" name="newcross_$i" /></td>
1238: <td><input type="text" size="10" name="newgroupid_$i" /></td>
1239: </tr>
1240: );
1241: }
1242: $response .= qq( </table>
1243: </td>
1244: </tr>
1245: <tr>
1246: <td align="right">
1247: <input type="button" name="newcross" value="Go" onClick="process('newcross')" />
1248: </td>
1249: </tr>
1250: </table>
1251: <input type=\"hidden\" name=\"numcross\" value=\"$numcross\">
1252: <input type=\"hidden\" name=\"action\" value=\"newcross\">
1253: <input type=\"hidden\" name=\"state\" value=\"process\">
1254: </form>
1255: );
1256: }
1257: }
1258: &print_reply($r,$response,$$tasktitleref{$action});
1259: return;
1260: }
1261:
1262: sub print_crosslistings_response () {
1.13 ! raeburn 1263: my ($r,$realm,$dom,$crs,$action,$tasktitleref) = @_;
1.5 raeburn 1264: my %settings = &Apache::lonnet::get('environment',['internal.crosslistings','internal.coursecode','internal.courseowner'],$dom,$crs);
1.1 raeburn 1265: my @currxlists = ();
1266: my @xlists = ();
1267: my @allxlists = ();
1.5 raeburn 1268: my @badxlists = ();
1269: my @badowner = ();
1.1 raeburn 1270: my $numcross = 0;
1271: my $xliststr = $settings{'internal.crosslistings'};
1272: my $coursecode = $settings{'internal.coursecode'};
1.5 raeburn 1273: my $owner = $settings{'internal.courseowner'};
1.1 raeburn 1274: my $response = '';
1.10 raeburn 1275: my $warning = '';
1276: my $warn_prefix = '';
1.1 raeburn 1277:
1278: if ($xliststr =~ m/,/) {
1279: @allxlists = split/,/,$xliststr;
1280: } else {
1281: unless ($xliststr eq '') { $allxlists[0] = $xliststr; }
1282: }
1283:
1284: if ( exists($ENV{'form.numcross'}) ) {
1285: $numcross = $ENV{'form.numcross'};
1286: }
1287:
1288: if ($numcross > 0) {
1289: for (my $i=0; $i<$numcross; $i++) {
1290: my $xl = "newcross_".$i;
1291: my $gp = "newgroupid_".$i;
1292: if ( exists($ENV{"form.$xl"}) ) {
1.12 raeburn 1293: my $coursecheck = '';
1.13 ! raeburn 1294: $coursecheck = &Apache::lonnet::auto_validate_courseID($crs,$dom,$ENV{"form.$xl"});
1.5 raeburn 1295: if ($coursecheck eq 'ok') {
1.12 raeburn 1296: my $addcheck = '';
1.13 ! raeburn 1297: $addcheck = &Apache::lonnet::auto_new_course($crs,$dom,$ENV{"form.$xl"},$owner);
1.5 raeburn 1298: if ($addcheck eq 'ok') {
1299: push @xlists,$ENV{"form.$xl"}.":".$ENV{"form.$gp"};
1300: } else {
1301: push @badowner,$ENV{"form.$xl"}.":".$ENV{"form.$gp"};
1.12 raeburn 1302: }
1.5 raeburn 1303: } else {
1.6 raeburn 1304: push @badxlists, $ENV{"form.$xl"}.":".$ENV{"form.$gp"}.":".$coursecheck;
1.5 raeburn 1305: }
1.1 raeburn 1306: }
1307: }
1308: push @allxlists, @xlists;
1309: }
1310:
1311: if (@xlists > 0 ) {
1312: unless ($xliststr eq '') { $xliststr .= ","; }
1313: if (@xlists > 1) {
1314: $xliststr .= join(",",@xlists);
1315: } else {
1316: $xliststr .= $xlists[0];
1317: }
1318: my %cenv = ('internal.crosslistings' => $xliststr);
1319: my $reply = &Apache::lonnet::put('environment',\%cenv,$dom,$crs);
1320: if ($reply !~ /^ok$/) {
1.6 raeburn 1321: $response = "There was a problem processing your requested changes. The automated enrollment settings for this course have been left unchanged.<br/><br/>";
1.1 raeburn 1322: } else {
1323: $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.<br/><ul>\n";
1.6 raeburn 1324: foreach (@allxlists) {
1325: my ($xlist,$gp) = split/:/,$_;
1326: $response .= "<li>$xlist - ID: $gp</li>\n";
1327: }
1328: $response .= "</ul><br/><br/>\n";
1329: }
1330: } else {
1331: if ($xliststr =~ m/:/) {
1332: my @oldxlists = ();
1333: if ($xliststr =~ m/,/) {
1334: @oldxlists = split/,/,$xliststr;
1335: } else {
1336: $oldxlists[0] = $xliststr;
1337: }
1338: $response .= "Although no new crosslistings were added, the courses listed below continue to be crosslisted with your LON-CAPA course.<br/><ul>\n";
1339: foreach (@oldxlists) {
1340: my ($xlist,$gp) = split/:/,$_;
1341: $response .= "<li>$xlist - ID: $gp</li>\n";
1342: }
1343: $response .= "</ul><br/><br/>\n";
1.1 raeburn 1344: }
1345: }
1.5 raeburn 1346: if (@badxlists > 0) {
1347: $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.<br/><ul>\n";
1348: foreach (@badxlists) {
1.6 raeburn 1349: my ($xlist,$gp,$prob) = split/:/,$_;
1350: $response .= "<li>$xlist - ID: $gp - Error: $prob</li>\n";
1.5 raeburn 1351: }
1352: $response .= "</ul><br/><br/>\n";
1353: }
1354:
1355: if (@badowner > 0) {
1356: $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.<br/><ul>\n";
1357: foreach (@badowner) {
1358: my ($xlist,$gp) = split/:/,$_;
1359: $response .= "<li>$xlist - ID: $gp</li>\n";
1360: }
1361: $response .= "</ul><br/><br/>\n";
1362: }
1.1 raeburn 1363:
1.10 raeburn 1364: if (@allxlists > 0) {
1365: $warning = &warning_message($dom,$crs,$action);
1366: $warn_prefix = "<br/><font size ='+1'><b>Warning</b></font>. Although you have selected crosslisted courses to contribute enrollment to this course, additional action is required.<br/>";
1367: unless ($warning eq '') {
1368: $response .= $warn_prefix.$warning;
1369: }
1370: }
1371:
1.1 raeburn 1372: &print_reply($r,$response,$$tasktitleref{$action});
1373: return;
1374: }
1375:
1376: sub print_sections_menu () {
1.13 ! raeburn 1377: my ($r,$realm,$dom,$crs,$action,$tasktitleref) = @_;
1.8 raeburn 1378: my %settings = &Apache::lonnet::get('environment',['internal.sectionnums','internal.coursecode','internal.courseowner'],$dom,$crs);
1.1 raeburn 1379: my @currsections = ();
1380: my @sections = ();
1.8 raeburn 1381: my @badowner = ();
1382: my @badsections = ();
1.1 raeburn 1383: my $seccount = 0;
1384: my $removecount = 0;
1.6 raeburn 1385: my $addcount = 0;
1.1 raeburn 1386: my $secstr = '';
1387: my $response = '';
1.10 raeburn 1388: my $warning = "";
1389: my $warn_prefix = "";
1.1 raeburn 1390: my $coursecode = $settings{'internal.coursecode'};
1.8 raeburn 1391: my $owner = $settings{'internal.courseowner'};
1.1 raeburn 1392: if ($settings{'internal.sectionnums'} =~ m/,/) {
1393: @currsections = split/,/,$settings{'internal.sectionnums'};
1394: } elsif ($settings{'internal.sectionnums'} ne '') {
1395: $currsections[0] = $settings{'internal.sectionnums'};
1396: }
1.6 raeburn 1397:
1398: if ( exists($ENV{'form.secshow'}) ) {
1.8 raeburn 1399: for (my $i=0; $i<$ENV{'form.secshow'}; $i++) {
1400: my $gp = "loncapasec_".$i;
1401: my $secnum = "secnum_".$i;
1402: my $sec = "sec_".$i;
1403: if ( exists( $ENV{"form.$sec"} ) ) {
1404: my $secentry;
1405: if ( exists( $ENV{"form.$secnum"} ) ) {
1406: $secentry = $ENV{"form.$secnum"}.':';
1407: }
1408: if ( exists( $ENV{"form.$gp"} ) ) {
1409: $secentry .= $ENV{"form.$gp"};
1410: }
1411: if ( grep/^$ENV{"form.$secnum"}:/,@currsections) {
1412: push @sections, $secentry;
1413: $seccount ++;
1414: } else {
1415: my $newsec = $coursecode.$ENV{"form.$secnum"};
1.13 ! raeburn 1416: my $coursecheck = &Apache::lonnet::auto_validate_courseID($crs,$dom,$newsec);
1.8 raeburn 1417: if ($coursecheck eq 'ok') {
1.13 ! raeburn 1418: my $addcheck = &Apache::lonnet::auto_new_course($crs,$dom,$newsec,$owner);
1.8 raeburn 1419: if ($addcheck eq 'ok') {
1420: push @sections,$ENV{"form.$secnum"}.":".$ENV{"form.$gp"};
1421: $seccount ++;
1422: $addcount ++;
1423: } else {
1424: push @badowner,$ENV{"form.$secnum"}.":".$ENV{"form.$gp"};
1425: }
1426: } else {
1427: push @badsections, $ENV{"form.$secnum"}.":".$ENV{"form.$gp"}.":".$coursecheck;
1428: }
1429: }
1430: }
1431: }
1432: if (@currsections > 0) {
1433: for (my $i=0; $i<@currsections; $i++) {
1434: if ($currsections[$i] =~ m/^(\w+:)/ ) {
1435: my $oldsec = $1;
1436: unless (grep/^$oldsec/,@sections) {
1437: $removecount ++;
1438: }
1439: }
1440: }
1441: }
1.6 raeburn 1442: } elsif (@currsections > 0) {
1.1 raeburn 1443: for (my $i=0; $i<@currsections; $i++) {
1444: my $sec = "sec_".$i;
1445: my $gp = "secgp_".$i;
1446: if ( exists($ENV{"form.$sec"}) ) {
1447: my $secentry = '';
1.6 raeburn 1448: if ($currsections[$i] =~ m/^(\w+:)/ ) {
1.1 raeburn 1449: $secentry = $1;
1450: }
1451: if ( exists($ENV{"form.$gp"}) ) {
1452: $secentry .= $ENV{"form.$gp"};
1453: }
1454: push @sections,$secentry;
1455: $seccount ++;
1456: } else {
1457: $removecount ++;
1458: }
1459: }
1460: }
1461:
1462: if ($seccount > 1) {
1463: $secstr = join(",",@sections);
1464: } else {
1465: $secstr = $sections[0];
1466: }
1467: my %cenv = ('internal.sectionnums' => $secstr);
1468: my $reply = &Apache::lonnet::put('environment',\%cenv,$dom,$crs);
1469: if ($reply !~ /^ok$/) {
1470: $response = "There was a problem processing your requested changes. The automated enrollment settings for this course have been left unchanged.<br/>";
1471: } else {
1472: if ($removecount > 0) {
1473: $response = "A total of $removecount sections have been removed from the list of sections which contribute to enrollment in LON-CAPA course: $realm ($coursecode).<br/><br/>";
1474: }
1.6 raeburn 1475: if ($addcount > 0) {
1476: $response .= "A total of $addcount sections have been added to the list of
1477: sections which contribute to enrollment in LON-CAPA course: $realm ($coursecode).<br/><br/>";
1478: }
1.1 raeburn 1479: if ($seccount > 0) {
1.6 raeburn 1480: $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.<br/><ul>\n";
1.1 raeburn 1481: foreach (@sections) {
1482: my ($sec,$gp) = split/:/,$_;
1483: $response .= "<li>$sec - ID: $gp</li>\n";
1484: }
1485: $response .= "</ul><br/>\n";
1486: }
1487: }
1488:
1.8 raeburn 1489: if (@badsections > 0) {
1490: $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.<br/><ul>\n";
1491: foreach (@badsections) {
1492: my ($secnum,$gp,$prob) = split/:/,$_;
1493: $response .= "<li>$secnum - ID: $gp - Error: $prob</li>\n";
1494: }
1495: $response .= "</ul><br/><br/>\n";
1496: }
1497:
1498: if (@badowner > 0) {
1499: $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.<br/><ul>\n";
1500: foreach (@badowner) {
1501: my ($secnum,$gp) = split/:/,$_;
1502: $response .= "<li>$secnum - ID: $gp</li>\n";
1503: }
1504: $response .= "</ul><br/><br/>\n";
1505: }
1506:
1.10 raeburn 1507: if ($seccount > 0) {
1508: $warning = &warning_message($dom,$crs,$action);
1509: $warn_prefix = "<br/><font size ='+1'><b>Warning</b></font>. Although you have selected sections to contribute enrollment to this course, additional action is required.<br/>";
1510: unless ($warning eq '') {
1511: $response .= $warn_prefix.$warning;
1512: }
1513: }
1514:
1.1 raeburn 1515: if ( exists($ENV{'form.numsec'}) ) {
1516: my $numsec = $ENV{'form.numsec'};
1517: if ($numsec > 0) {
1518: my @bgcolors=("#eeeeee","#cccccc");
1519: $response .= qq(
1520: 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.<br/><br/>
1521: <form name="enter" method="post">
1522: <table border="0" cellpadding="2" cellspacing="2" width="100%">
1523: <tr>
1524: <td>
1525: <table border="0" cellspacing="3" cellpadding="3">
1526: <tr bgcolor="#CCCCFF" align="left">
1527: <td><b>Section number</b></td>
1528: <td><b>LON-CAPA section/groupID</b></td>
1529: </tr>
1530: );
1531: for (my $i=0; $i<$numsec; $i++) {
1532: my $colflag = $i%2;
1533: $response .= qq(
1534: <tr bgcolor="$bgcolors[$colflag]" align="left">
1535: <td><input type="text" size="15" name="newsec_$i" /></td>
1536: <td><input type="text" size="10" name="newsecgp_$i" /></td>
1537: </tr>
1538: );
1539: }
1540: $response .= qq( </table>
1541: </td>
1542: </tr>
1543: <tr>
1544: <td align="right">
1545: <input type="button" name="newsections" value="Go" onClick="process('newsections')" />
1546: </td>
1547: </tr>
1548: </table>
1549: <input type=\"hidden\" name=\"numsec\" value=\"$numsec\">
1550: <input type=\"hidden\" name=\"action\" value=\"newsections\">
1551: <input type=\"hidden\" name=\"state\" value=\"process\">
1552: </form>
1553: );
1554: }
1555: }
1556: &print_reply($r,$response,$$tasktitleref{$action});
1557: return;
1558: }
1559:
1560: sub print_sections_response () {
1.13 ! raeburn 1561: my ($r,$realm,$dom,$crs,$action,$tasktitleref) = @_;
1.8 raeburn 1562: my %settings = &Apache::lonnet::get('environment',['internal.sectionnums','internal.coursecode','internal.courseowner'],$dom,$crs);
1.1 raeburn 1563: my @currsections = ();
1564: my @sections = ();
1565: my @allsections = ();
1.8 raeburn 1566: my @badowner = ();
1567: my @badsections = ();
1.1 raeburn 1568: my $numsec = 0;
1569: my $secstr = $settings{'internal.sectionnums'};
1570: my $coursecode = $settings{'internal.coursecode'};
1.8 raeburn 1571: my $owner = $settings{'internal.courseowner'};
1.1 raeburn 1572: my $response = '';
1.8 raeburn 1573: my $putreply = '';
1.10 raeburn 1574: my $warning = '';
1575: my $warn_prefix = '';
1.1 raeburn 1576: if ($secstr =~ m/,/) {
1577: @allsections = split/,/,$secstr;
1578: } else {
1579: unless ($secstr eq '') { $allsections[0] = $secstr; }
1580: }
1581:
1582: if ( exists($ENV{'form.numsec'}) ) {
1583: $numsec = $ENV{'form.numsec'};
1584: }
1.8 raeburn 1585:
1.1 raeburn 1586: if ($numsec > 0) {
1587: for (my $i=0; $i<$numsec; $i++) {
1588: my $sec = "newsec_".$i;
1589: my $gp = "newsecgp_".$i;
1590: if ( exists($ENV{"form.$sec"}) ) {
1.8 raeburn 1591: unless ( (grep/^$ENV{"form.$sec"}:/,@allsections) || (grep/^$ENV{"form.$sec"}:/,@sections) ) {
1592: my $newsec = $coursecode.$ENV{"form.$sec"};
1.13 ! raeburn 1593: my $coursecheck = &Apache::lonnet::auto_validate_courseID($crs,$dom,$newsec);
1.8 raeburn 1594: if ($coursecheck eq 'ok') {
1.13 ! raeburn 1595: my $addcheck = &Apache::lonnet::auto_new_course($crs,$dom,$newsec,$owner);
1.8 raeburn 1596: if ($addcheck eq 'ok') {
1597: push @sections,$ENV{"form.$sec"}.":".$ENV{"form.$gp"};
1598: } else {
1599: push @badowner,$ENV{"form.$sec"}.":".$ENV{"form.$gp"};
1600: }
1601: } else {
1602: push @badsections, $ENV{"form.$sec"}.":".$ENV{"form.$gp"}.":".$coursecheck;
1603: }
1604: }
1.1 raeburn 1605: }
1606: }
1607: push @allsections, @sections;
1608: }
1.8 raeburn 1609:
1.1 raeburn 1610: if (@sections > 0 ) {
1611: unless ($secstr eq '') { $secstr .= ","; }
1612: if (@sections > 1) {
1613: $secstr .= join(",",@sections);
1614: } else {
1615: $secstr .= $sections[0];
1616: }
1617: my %cenv = ('internal.sectionnums' => $secstr);
1.8 raeburn 1618: $putreply = &Apache::lonnet::put('environment',\%cenv,$dom,$crs);
1619: if ($putreply !~ /^ok$/) {
1620: $response = "There was a problem processing your requested changes. The automated enrollment settings for this course have been left unchanged.<br/><br/>";
1621: }
1622: }
1623:
1624: if ($putreply =~ /^ok/) {
1625: $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.<br/><ul>\n";
1626: foreach (@allsections) {
1627: my ($sec,$gp) = split/:/,$_;
1628: $response .= "<li>$sec - ID: $gp</li>\n";
1629: }
1630: $response .= "</ul><br/><br/>\n";
1631: }
1632:
1633: if (@badsections > 0) {
1634: $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.<br/><ul>\n";
1635: foreach (@badsections) {
1636: my ($secnum,$gp,$prob) = split/:/,$_;
1637: $response .= "<li>$secnum - ID: $gp - Error: $prob</li>\n";
1.1 raeburn 1638: }
1.8 raeburn 1639: $response .= "</ul><br/><br/>\n";
1.1 raeburn 1640: }
1.8 raeburn 1641:
1642: if (@badowner > 0) {
1643: $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.<br/><ul>\n";
1644: foreach (@badowner) {
1645: my ($secnum,$gp) = split/:/,$_;
1646: $response .= "<li>$secnum - ID: $gp</li>\n";
1647: }
1648: $response .= "</ul><br/><br/>\n";
1.1 raeburn 1649: }
1.8 raeburn 1650:
1.10 raeburn 1651: if (@allsections > 0) {
1652: $warning = &warning_message($dom,$crs,$action);
1653: $warn_prefix = "<br/><font size ='+1'><b>Warning</b></font>. Although you have selected sections to contribute enrollment to this course, additional action is required.<br/>";
1654: unless ($warning eq '') {
1655: $response .= $warn_prefix.$warning;
1656: }
1657: }
1658:
1.1 raeburn 1659: &print_reply($r,$response,$$tasktitleref{$action});
1660: return;
1661: }
1662:
1663: sub print_photos_response () {
1664: my ($r,$realm,$dom,$crs,$action,$tasktitleref) = @_;
1665: my %settings = &Apache::lonnet::get('environment',['internal.showphotos'],$dom,$crs);
1666: my $currphotos = $settings{'internal.showphotos'};
1667: my $showphotos = '';
1668: if ( exists($ENV{'form.showphotos'}) ) {
1669: $showphotos=$ENV{'form.showphotos'};
1670: }
1.8 raeburn 1671:
1.1 raeburn 1672: my $response = "";
1673: my %cenv = ('internal.showphotos' => $showphotos);
1674: my $reply = &Apache::lonnet::put('environment',\%cenv,$dom,$crs);
1675: if ($reply !~ /^ok$/) {
1676: $response = "There was a problem processing your requested change. The student photo import setting for this course has been left unchanged.<br/>";
1677: } else {
1678: if ($showphotos) {
1679: if ($currphotos) {
1680: $response = "Retrieval of student photos is still <b>enabled</b><br/>";
1681: } else {
1682: $response = "Retrieval of student photos in now <b>enabled</b><br/>";
1683: }
1684: } else {
1685: if ($currphotos) {
1686: $response = "Retrieval of student photos is now <b>disabled</b><br/>";
1687: } else {
1688: $response = "Retrieval of student photos is still <b>disabled</b><br/>";
1689: }
1690: }
1691: }
1692: &print_reply($r,$response,$$tasktitleref{$action});
1693: return;
1694: }
1695:
1696: sub print_update_result () {
1.13 ! raeburn 1697: my ($r,$realm,$dom,$crs,$action,$tasktitleref) = @_;
1.1 raeburn 1698: my $response = '';
1699: my $updateadds = 0;
1700: my $updatedrops = 0;
1701: my $changecount = 0;
1702: my %affiliates = ();
1703: my %reply = ();
1704: my @allcourses = ();
1705: my %LC_code = ();
1706: my $logmsg = '';
1.5 raeburn 1707: my $newusermsg = '';
1.1 raeburn 1708:
1709: my %settings = &Apache::lonnet::get('environment',['internal.coursecode','internal.sectionnums','internal.crosslistings','internal.authtype','internal.autharg','internal.autostart','internal.autoend'],$dom,$crs);
1710: my $coursecode = $settings{'internal.coursecode'};
1711: my $authtype = $settings{'internal.authtype'};
1712: my $autharg = $settings{'internal.autharg'};
1713: my $autostart = $settings{'internal.autostart'};
1714: my $autoend = $settings{'internal.autoend'};
1715:
1716: if ( exists($ENV{'form.updateadds'}) ) {
1717: $updateadds = $ENV{'form.updateadds'};
1718: }
1719: if ( exists($ENV{'form.updatedrops'}) ) {
1720: $updatedrops = $ENV{'form.updatedrops'};
1721: }
1722: if (!$updateadds && !$updatedrops) {
1723: $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.";
1724: } elsif ($coursecode eq '') {
1725: $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";
1726: } else {
1727: # Get complete list of course sections to update
1728: my @currsections = ();
1729: my @currxlists = ();
1730:
1731: if ($settings{'internal.sectionnums'} =~ m/,/) {
1732: @currsections = split/,/,$settings{'internal.sectionnums'};
1733: } elsif ($settings{'internal.sectionnums'} ne '') {
1734: $currsections[0] = $settings{'internal.sectionnums'};
1735: }
1736:
1737: if ($settings{'internal.crosslistings'} =~ m/,/) {
1738: @currxlists = split/,/,$settings{'internal.crosslistings'};
1739: } elsif ($settings{'internal.crosslistings'} ne '') {
1740: $currxlists[0] = $settings{'internal.crosslistings'};
1741: }
1742:
1743: if (@currxlists > 0) {
1744: foreach (@currxlists) {
1745: if (m/^(\w+):(\w*)$/) {
1746: unless (grep/^$1$/,@allcourses) {
1747: push @allcourses,$1;
1748: $LC_code{$1} = $2;
1749: }
1750: }
1751: }
1752: }
1753:
1754: if (@currsections > 0) {
1755: foreach (@currsections) {
1756: if (m/^(\w+):(\w*)$/) {
1757: my $sec = $coursecode.$1;
1758: my $gp = $2;
1759: unless (grep/^$sec$/,@allcourses) {
1760: push @allcourses,$sec;
1761: $LC_code{$sec} = $gp;
1762: }
1763: }
1764: }
1765: }
1766:
1767: if (@allcourses > 0) {
1768: @{$affiliates{$crs}} = @allcourses;
1.13 ! raeburn 1769: my $outcome = &Apache::lonnet::fetch_enrollment_query('updatenow',\%affiliates,\%reply,$crs,$dom);
1.1 raeburn 1770: if ($reply{$crs} > 0) {
1.5 raeburn 1771: ($changecount,$response) = &LONCAPA::Enrollment::update_LC($dom,$crs,$updateadds,$updatedrops,$autostart,$autoend,$authtype,$autharg,\@allcourses,\%LC_code,\$logmsg,\$newusermsg,"updatenow");
1.1 raeburn 1772: } else {
1773: $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.";
1774: }
1775: } else {
1776: $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)";
1777: }
1778: }
1779: unless ($logmsg eq '') {
1780: my $loglength = length($logmsg);
1781: $logmsg = substr($logmsg,0,$loglength-4);
1782: $logmsg = "<br/><br/>The following messages were generated by the roster update process: <br/><ul><li>".$logmsg."</ul><br/>";
1783: }
1.5 raeburn 1784: unless ($newusermsg eq '') {
1785: $newusermsg = substr( $newusermsg,0,rindex($newusermsg,'<li>') );
1786: $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/>";
1787: }
1788: $response .= $logmsg.$newusermsg;
1.1 raeburn 1789: &print_reply($r,$response,$$tasktitleref{$action});
1790: return;
1.10 raeburn 1791: }
1792:
1793: sub warning_message {
1794: my ($dom,$crs,$caller) = @_;
1795: my %settings = &Apache::lonnet::get('environment',['internal.autoadds','internal.autodrops','internal.sectionnums','internal.crosslistings','internal.autostart','internal.autoend'],$dom,$crs);
1796: my $currend = '';
1797: my $currstart = '';
1798: my $currsecs = '';
1799: my $currxlists = '';
1800: my $warning = '';
1801: my $curradds = '';
1802: my $currdrops = '';
1803: if ( defined($settings{'internal.autoadds'}) ) {
1804: $curradds = $settings{'internal.autoadds'};
1805: }
1806: if (defined($settings{'internal.autodrops'}) ) {
1807: $currdrops = $settings{'internal.autodrops'};
1808: }
1809: if ( defined($settings{'internal.autostart'}) ) {
1810: $currstart = $settings{'internal.autostart'};
1811: }
1812: if ( defined($settings{'internal.autoend'}) ) {
1813: $currend = $settings{'internal.autoend'};
1814: }
1815: if ( defined($settings{'internal.sectionnums'}) ) {
1816: $currsecs = $settings{'internal.sectionnums'};
1817: }
1818: if ( defined($settings{'internal.crosslistings'}) ) {
1819: $currxlists = $settings{'internal.crosslistings'}
1820: }
1821: unless ($caller eq 'setdates') {
1822: if ( ($currstart eq '') && ($currend eq '') ) {
1823: $warning = "You <b>must</b> now use <a href='/adm/populate?action=setdates'>Change enrollment dates</a> to set a start date <i>and</i> an end date for the enrollment (or check the 'No end date' checkbox) for the nightly adds process to actually occur.</br></br>";
1824: }
1825: }
1826: unless ( ($caller eq 'sections') || ($caller eq 'crosslist') ) {
1827: if ( ($currsecs eq '') && ($currxlists eq '') ) {
1828: $warning .= "You <b>must</b> now use <a href='/adm/populate?action=sections'>Section settings</a> and/or <a href='/adm/populate?action=crosslist'>Change crosslistings</a> 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 <b>NO</b> sections or crosslisted courses that are affiliated with this course that are set to contribute to the automated enrollment process.<br/><br/>";
1829: }
1830: }
1831: unless ( $caller eq 'chgsettings') {
1832: if ( (!$curradds) && (!$currdrops) ) {
1833: $warning .= "You <b>must</b> now use <a href='/adm/populate?action=chgsettings'>Automated adds/drops</a> to enable automated adds and/or drops if you want automatic enrollment updates to occur in this course.<br/><br/>.";
1834: }
1835: }
1836: return $warning;
1.1 raeburn 1837: }
1838:
1839: sub print_reply () {
1840: my ($r,$response,$caller) = @_;
1841: $r->print("
1842: <br/><table width=\"100%\" border=\"0\" cellpadding=\"2\" cellspacing=\"2\">
1843: <tr>
1844: <tr align=\"left\"><b>$caller</b> - result<br/><br/>$response</td>
1845: </td>
1846: </tr>
1847: </table>
1848: ");
1849: return;
1850: }
1851:
1852: sub setup_date_selectors {
1853: my ($starttime,$endtime) = @_;
1854: if (! defined($starttime)) {
1855: $starttime = time;
1856: if (exists($ENV{'course.'.$ENV{'request.course.id'}.
1857: '.default_enrollment_start_date'})) {
1858: $starttime = $ENV{'course.'.$ENV{'request.course.id'}.
1859: '.default_enrollment_start_date'};
1860: }
1861: }
1862: if (! defined($endtime)) {
1863: $endtime = time+(6*30*24*60*60); # 6 months from now, approx
1864: if (exists($ENV{'course.'.$ENV{'request.course.id'}.
1865: '.default_enrollment_end_date'})) {
1866: $endtime = $ENV{'course.'.$ENV{'request.course.id'}.
1867: '.default_enrollment_end_date'};
1868: }
1869: }
1870: my $startdateform = &Apache::lonhtmlcommon::date_setter('enter',
1871: 'startdate',
1872: $starttime);
1873: my $enddateform = &Apache::lonhtmlcommon::date_setter('enter',
1874: 'enddate',
1875: $endtime);
1876: return ($startdateform,$enddateform);
1877: }
1878:
1879: sub get_dates_from_form {
1880: my $startdate = &Apache::lonhtmlcommon::get_date_from_form('startdate');
1881: my $enddate = &Apache::lonhtmlcommon::get_date_from_form('enddate');
1882: if ( exists ($ENV{'form.no_end_date'}) ) {
1883: $enddate = 0;
1884: }
1885: return ($startdate,$enddate);
1886: }
1887:
1888: sub date_setting_table {
1889: my ($starttime,$endtime) = @_;
1890: my ($startform,$endform) = &setup_date_selectors($starttime,$endtime);
1891: my $perpetual = '<nobr><input type="checkbox" name="no_end_date"';
1892: if (defined($endtime) && $endtime == 0) {
1893: $perpetual .= ' checked';
1894: }
1895: $perpetual.= ' />'.' no ending date</nobr>';
1896: my $start_table = '';
1897: $start_table .= "<table>\n";
1898: $start_table .= '<tr><td align="right">Starting Date</td>'.
1899: '<td>'.$startform.'</td>'.
1900: '<td> </td>'."</tr>\n";
1901: $start_table .= "</table>";
1902: my $end_table = '';
1903: $end_table .= "<table>\n";
1904: $end_table .= '<tr><td align="right">Ending Date</td>'.
1905: '<td>'.$endform.'</td>'.
1906: '<td>'.$perpetual.'</td>'."</tr>\n";
1907: $end_table .= "</table>\n";
1908: return ($start_table, $end_table);
1909: }
1910:
1911: ###################################################################
1912: sub handler {
1913: my $r = shift;
1914: if ($r->header_only) {
1915: $r->content_type('text/html');
1916: $r->send_http_header;
1917: return OK;
1918: }
1919: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['action','state']);
1920: # Needs to be in a course
1921: if (! (($ENV{'request.course.fn'}) && (&Apache::lonnet::allowed('cst',$ENV{'request.course.id'})))) {
1922: # Not in a course, or not allowed to modify parms
1923: $ENV{'user.error.msg'}="/adm/populate:cst:0:0:Cannot drop or add students";
1924: return HTTP_NOT_ACCEPTABLE;
1925: }
1926: # Start page
1927: $r->content_type('text/html');
1928: $r->send_http_header;
1929:
1930: my @tasks = ("information","chgsettings","setdates","notify","crosslist","sections","photos","updatenow");
1931:
1932: my %tasklong = (
1933: information => "Task information",
1934: chgsettings => "Automated adds/drops",
1935: setdates => "Change enrollment dates",
1936: notify => "Notification of changes",
1937: crosslist => "Change crosslistings",
1938: sections => "Section settings",
1939: photos => "Student photos",
1940: updatenow => "Update roster now",
1941: newcross => "Add crosslistings",
1942: newsections => "Add sections"
1943: );
1944:
1945: my %tasktitle = (
1946: chgsettings => "Changes to nightly automated enrollments",
1947: setdates => "Changes to first and/or last automated enrollment dates",
1948: notify => "Notification of enrollment changes",
1949: crosslist => "Changes to crosslistings",
1950: sections => "Changes to section settings",
1951: photos => "Automatic import of student photos",
1952: updatenow => "Immediate course roster update",
1953: newcross => "Adding new crosslisted courses",
1954: newsections => "Adding new course sections"
1955: );
1956:
1957: my $realm = '';
1958: if ( exists($ENV{'request.course.id'}) ) {
1959: $realm= $ENV{'course.'.$ENV{'request.course.id'}.'.description'};
1960: }
1961: unless ($realm) { $realm=' '; }
1962: my $dom = $ENV{'course.'.$ENV{'request.course.id'}.'.domain'};
1963: my $crs = $ENV{'course.'.$ENV{'request.course.id'}.'.num'};
1964:
1965: #
1966: # Main switch on form.action and form.state, as appropriate
1967: #
1968:
1969: my $action = "information";
1970: if ( exists($ENV{'form.action'}) ) {
1971: $action = $ENV{'form.action'};
1972: }
1973: my $state = "choose";
1974:
1975: if ( exists($ENV{'form.state'}) ) {
1976: $state = $ENV{'form.state'};
1977: }
1978:
1979: if ($action eq "information") {
1980: $r->print(&header());
1981: } else {
1982: if ($state eq "choose") {
1983: $r->print(&choose_header());
1984: } else {
1985: if ($action eq "crosslist") {
1986: if ( exists($ENV{'form.numcross'}) ) {
1987: if ( $ENV{'form.numcross'} > 0 ) {
1988: $r->print(&choose_header());
1989: } else {
1990: $r->print(&header());
1991: }
1992: } else {
1993: $r->print(&header());
1994: }
1995: } elsif ($action eq "sections") {
1996: if ( exists($ENV{'form.numsec'}) ) {
1997: if ( $ENV{'form.numsec'} > 0 ) {
1998: $r->print(&choose_header());
1999: } else {
2000: $r->print(&header());
2001: }
2002: } else {
2003: $r->print(&header());
2004: }
2005: } else {
2006: $r->print(&header());
2007: }
2008: }
2009: }
1.12 raeburn 2010:
1.1 raeburn 2011: my $reply = 0;
2012: unless ($state eq "choose") { $reply = 1; }
2013:
2014: &print_mainbox($r,\%tasklong,$realm,$reply);
2015: &print_navmenu($r,\@tasks,\%tasklong);
2016:
2017: if (($state eq "choose") || ($action eq "information")) {
1.13 ! raeburn 2018: &print_main_frame($r,$realm,$dom,$crs,\%tasktitle);
1.1 raeburn 2019: } elsif ($action eq "chgsettings") {
2020: &print_chgsettings_response($r,$realm,$dom,$crs,$action,\%tasktitle);
2021: } elsif ($action eq "setdates") {
2022: &print_setdates_response($r,$realm,$dom,$crs,$action,\%tasktitle);
2023: } elsif ($action eq "notify") {
2024: &print_notify_response($r,$realm,$dom,$crs,$action,\%tasktitle);
2025: } elsif ($action eq "sections") {
1.13 ! raeburn 2026: &print_sections_menu($r,$realm,$dom,$crs,$action,\%tasktitle);
1.1 raeburn 2027: } elsif ($action eq "crosslist") {
1.13 ! raeburn 2028: &print_crosslistings_menu($r,$realm,$dom,$crs,$action,\%tasktitle);
1.1 raeburn 2029: } elsif ($action eq "updatenow") {
1.13 ! raeburn 2030: &print_update_result($r,$realm,$dom,$crs,$action,\%tasktitle);
1.1 raeburn 2031: } elsif ($action eq "photos") {
2032: &print_photos_response($r,$realm,$dom,$crs,$action,\%tasktitle);
2033: } elsif ($action eq "newcross") {
1.13 ! raeburn 2034: &print_crosslistings_response($r,$realm,$dom,$crs,$action,\%tasktitle);
1.1 raeburn 2035: } elsif ($action eq "newsections") {
1.13 ! raeburn 2036: &print_sections_response($r,$realm,$dom,$crs,$action,\%tasktitle);
1.1 raeburn 2037: }
2038: &print_doc_base($r);
2039: return OK;
2040: }
2041: ###################################################################
2042: 1;
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>