Annotation of loncom/interface/lonpopulate.pm, revision 1.7
1.4 albertel 1: # automated enrollment configuration handler
1.7 ! raeburn 2: # $Id: lonpopulate.pm,v 1.6 2003/12/12 00:45:49 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 {
210: my ($r,$realm,$dom,$crs,$tasktitleref) = @_;
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});
332: my $oldstartshow = localtime($enrollvar{autostart});
333: my $oldendshow = localtime($enrollvar{autoend});
334: if ($enrollvar{autoend} == 0) {
335: $oldendshow = "No ending date";
336: }
337: $r->print(<<ENDTWO);
338: <form name="enter" method="post"><br/>
339: <table width="100%" border="0" cellpadding="2" cellspacing="2">
340: <tr>
341: <td align="left"><b>$$tasktitleref{$action}</b><br/>
342: Currently: First enrollment: <i>$oldstartshow</i>, Last enrollment: <i>$oldendshow</i>
343: </td>
344: </tr>
345: </table>
346: <table width="100%" border="0" cellpadding="3" cellspacing="3">
347: <tr>
348: <td align="left" colspan="2">
349: <table border="0" cellspacing="0" cellpadding="2">
350: <tr>
351: <td colspan="3">
352: <i>Set date of first automated enrollment for registered students</i>
353: </td>
354: </tr>
355: <tr>
356: <td>$start_table
357: </td>
358: </tr>
359: </table>
360: </td>
361: </tr>
362: <tr>
363: <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>
364: </tr>
365: <tr>
366: <td align="left" colspan="2">
367: <table border="0' cellspacing="0" cellpadding="2">
368: <tr>
369: <td colspan="3">
370: <i>Set date of last automated enrollment for registered students</i>
371: </td>
372: </tr>
373: <tr>
374: <td>$end_table
375: </td>
376: </tr>
377: </table>
378: </td>
379: </tr>
380: <tr>
381: <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>
382: </tr>
383: </table>
384: <table width="100%">
385: <tr>
386: <td align="right">
387: <input type="button" name="setdates" value="Go" onClick="process('setdates')" />
388: </td>
389: </tr>
390: </table>
391: <input type=\"hidden\" name=\"action\" value=\"$action\">
392: <input type=\"hidden\" name=\"state\" value=\"process\">
393: </form>
394: ENDTWO
395: } elsif ($action eq "notify") {
396: my @notified = ();
397: if ($enrollvar{notifylist} =~ m/,/) {
398: @notified = split/,/,$enrollvar{notifylist};
399: } else {
400: @notified = $enrollvar{notifylist};
401: }
402: my $notifycount = 0;
403: foreach (@notified) {
404: unless ($_ eq '') { $notifycount ++; }
405: }
406: my $noteset = '';
407: if ($notifycount) {
408: $noteset = "ON";
409: } else {
410: $noteset = "OFF";
411: }
412:
413: $r->print("
414: <form name=\"enter\" method=\"post\"><br/>
415: <table width=\"100%\" border=\"0\" cellpadding=\"6\" cellspacing=\"0\">
416: <tr>
417: <td align=\"left\"><b>$$tasktitleref{$action}</b><br/>
418: Currently: Notification: $noteset
419: </td>
420: </tr>
421: </table>
422: <table width=\"100%\" border=\"0\" cellpadding=\"3\" cellspacing=\"3\">
423: <tr>
424: <td>
425: Notification of LON-CAPA course roster changes resulting from nightly automated enrollment process?
426: ");
427: if ($notifycount) {
428: $r->print("
429: <input type=\"radio\" name=\"notify\" value=\"1\" checked=\"true\" /> Yes
430: <input type=\"radio\" name=\"notify\" value=\"0\" /> No
431: ");
432: } else {
433: $r->print("
434: <input type=\"radio\" name=\"notify\" value=\"1\" /> Yes
435: <input type=\"radio\" name=\"notify\" value=\"0\" checked=\"true\" /> No
436: ");
437: }
438: $r->print("
439: </td>
440: </tr>
441: ");
1.7 ! raeburn 442: my @coursepersonnel = &Apache::lonnet::getkeys('nohist_userroles',$dom,$crs);
! 443: my @ccs = ();
! 444: my @oldccs = ();
! 445: my %pname = ();
! 446: my %notifystate = ();
! 447: foreach (@coursepersonnel) {
! 448: my @roleinfo = split/:/,$_;
! 449: if ($roleinfo[0] eq 'cc') {
! 450: unless (grep/^$roleinfo[1]\@$roleinfo[2]/,@ccs) {
! 451: my $active_cc = &LONCAPA::Enrollment::check_user_status($roleinfo[2],$roleinfo[1],$dom,$crs,'cc');
! 452: if ($active_cc eq 'ok') {
! 453: push @ccs, "$roleinfo[1]\@$roleinfo[2]";
! 454: $pname{"$roleinfo[1]\@$roleinfo[2]"} = &Apache::loncommon::plainname($roleinfo[1],$roleinfo[2]);
! 455: if (grep/^$roleinfo[1]\@$roleinfo[2]$/,@notified) {
! 456: $notifystate{"$roleinfo[1]\@$roleinfo[2]"} = 1;
! 457: } else {
! 458: $notifystate{"$roleinfo[1]\@$roleinfo[2]"} = 0;
! 459: }
1.1 raeburn 460: } else {
1.7 ! raeburn 461: push @oldccs, "$roleinfo[1]\@$roleinfo[2]";
1.1 raeburn 462: }
463: }
464: }
465: }
1.7 ! raeburn 466: if ($notifycount > 0) {
! 467: foreach my $person (@notified) {
! 468: unless ( (grep/^$person$/,@ccs) || ($person eq '') || (grep/^$person$/,@oldccs) ) {
! 469: push @ccs, $person;
! 470: my ($puname,$pdom) = split/\@/,$person;
! 471: $pname{$person} = &Apache::loncommon::plainname($puname,$pdom);
! 472: $notifystate{$person} = 1;
! 473: }
! 474: }
! 475: }
! 476: my $viewer = $ENV{'user.name'}.'@'.$ENV{'user.domain'};
! 477: unless ( (grep/^$viewer$/,@ccs) || ($viewer eq '') ) {
! 478: push @ccs,$viewer;
! 479: $pname{$viewer} = &Apache::loncommon::plainname($ENV{'user.name'},$ENV{'user.domain'});
! 480: $notifystate{$viewer} = 0;
! 481: }
! 482:
! 483: my $notifyshow = @ccs;
! 484:
! 485: if (@ccs > 0) {
! 486: @ccs = sort @ccs;
1.1 raeburn 487: $r->print("
488: <tr>
1.7 ! raeburn 489: <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 490: </td>
491: </tr>
492: <tr>
493: <td>
1.7 ! raeburn 494: <table border=\"0\" cellpadding=\"3\" cellspacing=\"3\">
! 495: <tr bgcolor=\"#CCCCFF\">
! 496: <td><b>Name</b></td>
! 497: <td><b>username</b></td>
! 498: <td><b>Current status</b></td>
! 499: <td><b>Notification?</b></td>
! 500: </tr>
! 501: ");
! 502: for (my $i=0; $i<@ccs; $i++) {
! 503: my $colflag = $i%2;
! 504: $r->print("<tr bgcolor=\"$bgcolors[$colflag]\" align=\"left\">
! 505: <td>$pname{$ccs[$i]}</td>
! 506: <td><input type=\"hidden\" name=\"notifyname_$i\" value=\"$ccs[$i]\" />$ccs[$i]</td>
! 507: <td>
! 508: ");
! 509: if ($notifystate{$ccs[$i]} == 1) {
! 510: $r->print("Notification active");
! 511: } else {
! 512: $r->print("Notification inactive");
! 513: }
! 514: if ($notifystate{$ccs[$i]} == 1) {
! 515: $r->print("</td><td><input type=\"checkbox\" name=\"note_$i\" checked=\"true\" /></td></tr>");
! 516: } else {
! 517: $r->print("</td><td><input type=\"checkbox\" name=\"note_$i\" /></td></tr>");
! 518: }
! 519: }
! 520: $r->print("
! 521: </table>
! 522: <br/>
! 523: <table width=\"100%\" border=\"0\" cellspadding=\"2\" cellspacing=\"2\">
! 524: <tr>
! 525: <td align=\"right\">
! 526: <input type=\"button\" name=\"notifyset\" value=\"Go\" onClick=\"process('notify')\" />
! 527: </td>
! 528: </tr>
! 529: </table>
! 530: </td>
! 531: </tr>
1.1 raeburn 532: ");
1.7 ! raeburn 533: } else {
1.1 raeburn 534: $r->print("
1.7 ! raeburn 535: <tr>
! 536: <td>
! 537: No course coordinators found.
1.1 raeburn 538: </td>
1.7 ! raeburn 539: </tr>");
1.1 raeburn 540: }
541: $r->print("
1.7 ! raeburn 542: </table>
! 543: <input type=\"hidden\" name=\"notifyshow\" value=\"$notifyshow\">
! 544: <input type=\"hidden\" name=\"action\" value=\"$action\">
! 545: <input type=\"hidden\" name=\"state\" value=\"process\">
! 546: </form>
1.1 raeburn 547: ");
548: } elsif ($action eq "crosslist") {
549: my @xlists = ();
550: if ($enrollvar{crosslistings} =~ m/,/) {
551: @xlists = split/,/,$enrollvar{crosslistings};
552: } elsif ($enrollvar{crosslistings} ne '') {
553: $xlists[0] = $enrollvar{crosslistings};
554: }
555: my $cross_str = @xlists;
556: $r->print("
557: <form name=\"enter\" method=\"post\"><br/>
558: <table width=\"100%\" border=\"0\" cellpadding=\"2\" cellspacing=\"2\">
559: <tr>
560: <td align=\"left\"><b>$$tasktitleref{$action}</b><br/>
561: ");
562: if ($cross_str > 0) {
563: $r->print("
1.7 ! raeburn 564: 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 565: </td>
566: </tr>
567: </table>
568: <br/>
569: <table border=\"0\" cellpadding=\"3\" cellspacing=\"3\">
570: <tr>
571: <td>
572: <table border=\"0\" width=\"100%\" cellspacing=\"3\" cellpadding=\"3\">
573: <tr bgcolor=\"#CCCCFF\" align=\"left\">
574: <td><b>Enrollment?</b></td>
575: <td><b>Crosslisted course</b></td>
576: <td><b>LON-CAPA section/groupID</b></td>
577: </tr>
578: ");
579: for (my $i=0; $i<@xlists; $i++) {
580: my $xl = ' ';
581: my $gp = ' ';
582: if ($xlists[$i] =~ /(\w+):(.+)$/) {
583: $xl = $1;
584: $gp = $2;
585: }
586: my $colflag = $i%2;
587: $r->print("
588: <tr bgcolor=\"$bgcolors[$colflag]\" align=\"left\">
589: <td><input type=\"checkbox\" name=\"cross_$i\" checked=\"true\"/></td>
590: <td>$xl</td>
591: <td><input type =\"text\" size=\"10\" name=\"gp_$i\" value=\"$gp\"></td>
592: </tr>
593: ");
594: }
595: $r->print(" </table>
596: </td>
597: </tr>
598: </table>
599: ");
600: }
601: else {
602: $r->print("
603: Currently no crosslisted courses are recorded for $enrollvar{coursecode}.
604: </td>
605: </tr>
606: </table>
607: ");
608: }
609: $r->print("
610: <br/>
611: <table width=\"100%\" border=\"0\" cellpadding=\"3\" cellspacing=\"3\">
612: <tr>
613: <td align=\"left\">
614: <b>Add new crosslistings.</b><br/>
615: Number of new crosslistings to add: <input type=\"text\" size=\"2\" name=\"numcross\" value=\"0\" />
616: </td>
617: </tr>
618: </table>
619: <br/>
620: <table width=\"100%\" border=\"0\" cellspadding=\"2\" cellspacing=\"2\">
621: <tr>
622: <td align=\"right\">
623: <input type=\"button\" name=\"crosslist\" value=\"Go\" onClick=\"process('crosslist')\" />
624: </td>
625: </tr>
626: </table>
627: <input type=\"hidden\" name=\"action\" value=\"$action\">
628: <input type=\"hidden\" name=\"state\" value=\"process\">
629: </form>
630: ");
631: } elsif ($action eq "sections") {
632: my @sections = &localenroll::get_sections($enrollvar{coursecode});
633: my @storedsections = ();
634: my @currsections = ();
635: my %sec_id = ();
636: if ($enrollvar{sectionnums} =~ m/,/) {
637: @storedsections = split/,/,$enrollvar{sectionnums};
638: } else {
639: $storedsections[0] = $enrollvar{sectionnums};
640: }
641: foreach (@storedsections) {
642: if ($_ =~ m/^(\w+):(\w*)$/) {
643: push @currsections, $1;
644: $sec_id{$1} = $2;
645: }
646: }
647: if (@sections > 0) {
648: if (@sections > 1) {
649: my $secshow = @sections;
650: $r->print("
651: <form name=\"enter\" method=\"post\"><br/>
652: <table width=\"100%\" border=\"0\" cellpadding=\"3\" cellspacing=\"3\">
653: <tr>
654: <td align=\"left\">
655: <b>$$tasktitleref{$action}</b><br/>
656: Your institution's course catalog includes $secshow sections for course code: $enrollvar{coursecode}.
657: </td>
658: </tr>
659: <tr>
1.5 raeburn 660: <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
661: your changes.</td>
1.1 raeburn 662: </tr>
663: </table>
664: <br/>
1.7 ! raeburn 665: <table border=\"0\" cellpadding=\"3\" cellspacing=\"3\">
! 666: <tr bgcolor=\"#CCCCFF\">
! 667: <td><b>Section</b></td>
! 668: <td><b>Current status</b></td>
! 669: <td><b>LON-CAPA section/group ID</b></td>
! 670: <td><b>Enrollment in this course?</b></td>
! 671: </tr>
1.1 raeburn 672: ");
673: for (my $i=0; $i<@sections; $i++) {
674: my $colflag = $i%2;
675: my $shrflag = 0;
1.5 raeburn 676: $r->print("<tr bgcolor=\"$bgcolors[$colflag]\" align=\"left\">
677: <td>$sections[$i]<input type=\"hidden\" name=\"secnum_$i\" value=\"$sections[$i]\" /></td>
1.1 raeburn 678: <td>
679: ");
680: if (grep/^$sections[$i]$/,@currsections) {
681: $r->print("Enrollment active");
682: $shrflag = 1;
683: } else {
684: $r->print("Enrollment inactive");
685: }
686: if ($shrflag) {
1.7 ! raeburn 687: $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>");
1.1 raeburn 688: } else {
1.7 ! raeburn 689: $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 690: }
691: }
692: $r->print("
1.7 ! raeburn 693: </table>
! 694: <br/>
! 695: <table width=\"100%\" border=\"0\" cellspacing=\"3\" cellpadding=\"3\">
! 696: <tr>
! 697: <td align=\"right\">
! 698: <input type=\"hidden\" name=\"secshow\" value=\"$secshow\" />
! 699: <input type=\"button\" name=\"sections\" value=\"Go\" onClick=\"process('sections')\" />
! 700: </td>
! 701: </tr>
! 702: </table>
! 703: <input type=\"hidden\" name=\"action\" value=\"$action\">
! 704: <input type=\"hidden\" name=\"state\" value=\"process\">
! 705: </form>
1.1 raeburn 706: ");
707: } else {
708: $r->print("<br/>
709: <table width=\"100%\" border=\"0\" cellpadding=\"3\" cellspacing=\"3\">
710: <tr>
711: <td align=\"left\">
712: <b>$$tasktitleref{$action}</b><br/>
713: </td>
714: </tr>
715: </table>
716: <table border=\"0\" cellspacing=\"2\" cellpadding=\"2\">
717: <tr>
718: <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>
719: </tr>
1.7 ! raeburn 720: </table>
1.1 raeburn 721: ");
722: }
723: } else {
724: $r->print("
725: <form name=\"enter\" method=\"post\"><br/>
726: <table width=\"100%\" border=\"0\" cellpadding=\"2\" cellspacing=\"2\">
727: <tr>
728: <td align=\"left\"><b>$$tasktitleref{$action}</b><br/>
729: ");
730: if (@currsections) {
731: my $secshow = @currsections;
732: $r->print("
1.7 ! raeburn 733: 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 734: </td>
735: </tr>
736: </table>
737: <br/>
738: <table border=\"0\" cellpadding=\"3\" cellspacing=\"3\">
739: <tr>
740: <td>
741: <table border=\"0\" width=\"100%\" cellspacing=\"3\" cellpadding=\"3\">
742: <tr bgcolor=\"#CCCCFF\">
743: <td><b>Enrollment?</b></td>
744: <td><b>Section</b></td>
745: <td><b>LON-CAPA section/groupID</b></td>
746: </tr>
747: ");
748: for (my $j=0; $j<@currsections; $j++) {
749: my $colflag = $j%2;
750: $r->print("
751: <tr bgcolor=\"$bgcolors[$colflag]\" align=\"left\">
752: <td><input type=\"checkbox\" name=\"sec_$j\" checked=\"true\"/></td>
753: <td>$currsections[$j]</td>
754: <td><input type=\"text\" name=\"secgp_$j\" size=\"10\" value=\"$sec_id{$currsections[$j]}\"></td>
755: </tr>
756: ");
757: }
758: $r->print(" </table>
759: </td>
760: </tr>
761: </table>
762: ");
763: } else {
764: $r->print("
765: Currently no sections of $realm ($enrollvar{coursecode}) are contributing enrollment to the LON-CAPA class roster.
766: </td>
767: </tr>
768: </table>
769: ");
770: }
771: $r->print("
772: <br/>
773: <table width=\"100%\" border=\"0\" cellpadding=\"3\" cellspacing=\"3\">
774: <tr>
775: <td align=\"left\">
776: <b>Add enrollment from additional sections.</b><br/>
777: Number of new sections to add: <input type=\"text\" size=\"2\" name=\"numsec\" value=\"0\" />
778: </td>
779: </tr>
780: </table>
781: <br/>
782: <table width=\"100%\" border=\"0\" cellspadding=\"2\" cellspacing=\"2\">
783: <tr>
784: <td align=\"right\">
785: <input type=\"button\" name=\"sections\" value=\"Go\" onClick=\"process('sections')\" />
786: </td>
787: </tr>
788: </table>
789: <input type=\"hidden\" name=\"action\" value=\"$action\">
790: <input type=\"hidden\" name=\"state\" value=\"process\">
791: </form>
792: ");
793: }
794: } elsif ($action eq "photos") {
795: my @photosets = ("OFF","ON");
796: $r->print("
797: <form name=\"enter\" method=\"post\"><br/>
798: <table width=\"100%\" border=\"0\" cellpadding=\"2\" cellspacing=\"2\">
799: <tr>
800: <td align=\"left\"><b>$$tasktitleref{$action}</b><br/>
801: Currently: Student photo import: <i>$photosets[$enrollvar{showphotos}]</i>
802: </td>
803: </tr>
804: </table>
805: <table width=\"100%\" border=\"0\" cellpadding=\"3\" cellspacing=\"3\">
806: <tr>
807: <td>
808: Automatic import of student photos from institutional data repository:
809:
810: ");
811: if ($enrollvar{showphotos}) {
812: $r->print("
813: <input type=\"radio\" name=\"showphotos\" value=\"1\" checked=\"true\" /> Yes
814: <input type=\"radio\" name=\"showphotos\" value=\"0\" /> No
815: ");
816: } else {
817: $r->print("
818: <input type=\"radio\" name=\"showphotos\" value=\"1\" /> Yes
819: <input type=\"radio\" name=\"showphotos\" value=\"0\" checked=\"true\" /> No
820: ");
821: }
822: $r->print("
823: </td>
824: </tr>
825: <tr>
826: <td>
827: <font color=\"#888888\">
828: 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.
829: </font>
830: </td>
831: </tr>
832: <tr>
833: </td> </td>
834: </tr>
835: <tr>
836: <td align=\"right\">
837: <input type=\"button\" name=\"showphotos\" value=\"Go\" onClick=\"process('photos')\">
838: </td>
839: </tr>
840: </table>
841: <input type=\"hidden\" name=\"action\" value=\"$action\">
842: <input type=\"hidden\" name=\"state\" value=\"process\">
843: </form>
844: ");
845: } elsif ($action eq "updatenow") {
846: $r->print("
847: <form name=\"enter\" method=\"post\"><br/>
848: <table width=\"100%\" border=\"0\" cellpadding=\"2\" cellspacing=\"2\">
849: <tr>
850: <td align=\"left\"><b>$$tasktitleref{$action}</b>
851: </td>
852: </tr>
853: </table>
854: <table width=\"100%\" border=\"0\" cellpadding=\"3\" cellspacing=\"3\">
855: <tr>
856: <td>
857: Add any students currently included in institutional classlist(s) but not enrolled in your LON-CAPA course.
858: <input type=\"radio\" name=\"updateadds\" value=\"1\"> Yes
859: <input type=\"radio\" name=\"updateadds\" value=\"0\"> No
860: </td>
861: </tr>
862: <tr>
863: <td>
864: Expire students previously added by nightly enrollment process, but no longer listed in institutional classlist(s).
865: <input type=\"radio\" name=\"updatedrops\" value=\"1\"> Yes
866: <input type=\"radio\" name=\"updatedrops\" value=\"0\"> No <br/>
867: </td>
868: </tr>
869: <tr>
870: <td>
871: <font color=\"#888888\">
872: 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.
873: </font>
874: </td>
875: </tr>
876: <tr>
877: <td align=\"right\">
878: <input type=\"button\" name=\"updatenow\" value=\"Go\" onClick=\"process('updatenow')\">
879: </td>
880: </tr>
881: </table>
882: <input type=\"hidden\" name=\"action\" value=\"$action\">
883: <input type=\"hidden\" name=\"state\" value=\"process\">
884: </form>
885: ");
886: }
887: }
888:
889: ###############################################################
890: sub print_doc_base {
891: my $r = shift;
892: $r->print(<<ENDBASE);
893: </td>
894: </tr>
895: </table>
896: <br/>
897: </body>
898: </html>
899: ENDBASE
900: }
901:
902: ###################################################################
903: sub print_chgsettings_response {
904: my ($r,$realm,$dom,$crs,$action,$tasktitleref) = @_;
905: my %settings = &Apache::lonnet::get('environment',['internal.autoadds','internal.autodrops'],$dom,$crs);
906: my $curradds = $settings{'internal.autoadds'};
907: my $currdrops = $settings{'internal.autodrops'};
908: my $autoadds = '';
909: my $autodrops = '';
910:
911: if ( exists($ENV{'form.autoadds'}) ) {
912: $autoadds=$ENV{'form.autoadds'};
913: }
914: if ( exists($ENV{'form.autodrops'}) ) {
915: $autodrops=$ENV{'form.autodrops'};
916: }
917:
918: my $response = "";
919: my %cenv = ('internal.autoadds' => $autoadds,
920: 'internal.autodrops' => $autodrops);
921: my $reply = &Apache::lonnet::put('environment',\%cenv,$dom,$crs);
922: if ($reply !~ /^ok$/) {
923: $response = "There was a problem processing your requested changes. The automated enrollment settings for this course have been left unchanged.<br/>";
924: } else {
925: if ($autoadds) {
926: if ($curradds) {
927: $response = "Nightly additions based on classlist changes still <b>enabled</b><br/>";
928: } else {
929: $response = "Nightly additions based on classlist changes now <b>enabled</b><br/>";
930: }
931: } else {
932: if ($curradds) {
933: $response = "Nightly additions based on classlist changes now <b>disabled</b><br/>";
934: } else {
935: $response = "Nightly additions based on classlist changes still <b>disabled</b><br/>";
936: }
937: }
938: if ($autodrops) {
939: if ($currdrops) {
940: $response .= "Nightly removals based on classlist changes still <b>enabled</b><br>";
941: } else {
942: $response .= "Nightly removals based on classlist changes now <b>enabled</b><br/>";
943: }
944: } else {
945: if ($currdrops) {
946: $response .= "Nightly removals based on classlist changes now <b>disabled</b><br>";
947: } else {
948: $response .= "Nightly removals based on classlist changes still <b>disabled</b>";
949: }
950: }
951: }
952: &print_reply($r,$response,$$tasktitleref{$action});
953: return;
954: }
955:
956: sub print_setdates_response {
957: my ($r,$realm,$dom,$crs,$action,$tasktitleref) = @_;
958: my %settings = &Apache::lonnet::get('environment',['internal.autostart','internal.autoend'],$dom,$crs);
959: my $currstart = $settings{'internal.autostart'};
960: my $currend = $settings{'internal.autoend'};
961: my $response = '';
962: my ($autostart,$autoend) = &get_dates_from_form();
963: my $showstart = localtime($autostart);
964: my $showend = '';
965: if ($autoend) {
966: $showend = localtime($autoend);
967: } else {
968: $showend = "'No end date'";
969: }
970:
971: my %cenv = ('internal.autostart' => $autostart,
972: 'internal.autoend' => $autoend);
973: my $reply = &Apache::lonnet::put('environment',\%cenv,$dom,$crs);
974: if ($reply !~ /^ok$/) {
975: $response = "There was a problem processing your requested changes. The automated enrollment settings for this course have been left unchanged.<br/>";
976: } else {
977: if ($currstart == $autostart) {
978: $response = "The first date for automated enrollment has been left unchanged as $showstart.<br/>";
979: } else {
980: $response = "The first date for automated enrollment has been changed to $showstart.<br/>";
981: }
982: if ($currend == $autoend) {
983: $response .= "The last date for automated enrollment has been left unchanged as $showend.<br/>";
984: } else {
985: $response .= "The last date for enrollment has been left unchanged as $showend.<br/>";
986: }
987:
988: # Generate message in case where old first access date was later than today, but new first access date is now today or earlier.
989:
990: my $rosterupdated = 0;
991: my $firstaccess = "";
992: my $nextupdate = "";
993: my $lastupdate = "";
994:
995: my $nowstamp = time;
996: my @date_list=localtime(time);
997: my $cur_year = $date_list[5];
998: my $curday = $date_list[3];
999: my $curmonth = $date_list[4];
1000: my $lastmidnt = timelocal(0,0,0,$date_list[3],$date_list[4],$date_list[5]);
1001: my $nextmidnt = 86400 + $lastmidnt;
1002:
1003: my $todayupdate = timelocal(0,40,4,$date_list[3],$date_list[4],$date_list[5]);
1004: my $lastupdate = $todayupdate - 86400;
1005: if ($nowstamp < $todayupdate) {
1006: $nextupdate = "today";
1007: } else {
1008: $nextupdate = "tomorrow";
1009: }
1010: if ($currstart < $lastupdate) {
1011: $rosterupdated = 1;
1012: }
1013: if ($autostart < $nextmidnt ) {
1014: if ( $autostart >= $lastmidnt) {
1015: $firstaccess = "today";
1016: } else {
1017: $firstaccess = "a date prior to today";
1018: }
1019: if (($nowstamp >= $autostart) && ($rosterupdated == 0)) {
1020: $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 4.40 am $nextupdate. If you wish to grant immediate course access for registered students included in the institutional classlist for this class, please visit the <a href="/adm/populate?action=updatenow">roster update page</a>.<br>|;
1021: }
1022: }
1023: }
1024: &print_reply($r,$response,$$tasktitleref{$action});
1025: return;
1026: }
1027:
1028: sub print_notify_response {
1029: my ($r,$realm,$dom,$crs,$action,$tasktitleref) = @_;
1030:
1031: # Get current settings
1032: my %settings = &Apache::lonnet::get('environment',['internal.notifylist','internal.coursecode'],$dom,$crs);
1033: my $notifylist = $settings{'internal.notifylist'};
1034: my $coursecode = $settings{'internal.coursecode'};
1035: my @currpeople = ();
1036: my $notify = 0;
1037: my @people = ();
1.7 ! raeburn 1038: my $peoplestr = "";
! 1039: my $response = "";
! 1040: my $noprocess = 0;
1.1 raeburn 1041:
1042: if ($notifylist =~ m/,/) {
1043: @currpeople = split/,/,$notifylist;
1044: } else {
1.7 ! raeburn 1045: $currpeople[0] = $notifylist;
1.1 raeburn 1046: }
1047: my $currcount = 0;
1048: foreach (@currpeople) {
1049: unless ($_ eq '') { $currcount ++; }
1050: }
1051:
1052: if ( exists($ENV{'form.notify'}) ) {
1053: $notify=$ENV{'form.notify'};
1054: }
1.7 ! raeburn 1055: if ( exists($ENV{'form.notifyshow'}) ) {
! 1056: my $notifyshow = $ENV{'form.notifyshow'};
! 1057: for (my $i=0; $i<$notifyshow; $i++) {
! 1058: if ( exists($ENV{"form.note_$i"}) ) {
! 1059: if ( exists($ENV{"form.notifyname_$i"}) ) {
! 1060: unless ( $ENV{"form.notifyname_$i"} eq '' ) {
! 1061: push @people, $ENV{"form.notifyname_$i"};
! 1062: }
! 1063: }
! 1064: }
! 1065: }
! 1066: if ($notify) { $peoplestr = join(",",@people); }
1.1 raeburn 1067: } else {
1068: if ($notify) {
1.7 ! raeburn 1069: if ($currcount) {
! 1070: $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/>.";
! 1071: $peoplestr = $notifylist;
! 1072: @people = @currpeople;
! 1073: $noprocess = 1;
! 1074: }
! 1075: }
! 1076: }
! 1077: unless ($noprocess == 1) {
! 1078: my %cenv = ('internal.notifylist' => $peoplestr);
! 1079: my $reply = &Apache::lonnet::put('environment',\%cenv,$dom,$crs);
! 1080: if ($reply !~ /^ok$/) {
! 1081: $response = "There was a problem processing your requested changes. The notification settings for this course have been left unchanged.<br/>";
! 1082: } else {
! 1083: if ($notify) {
! 1084: if (@people) {
! 1085: if ($currcount) {
! 1086: $response .= "Notification of enrollment changes still <b>enabled</b><br/>";
! 1087: } else {
! 1088: $response .= "Notification of enrollment changes now <b>enabled</b><br/>";
! 1089: }
! 1090: $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";
! 1091: foreach my $person (@people) {
! 1092: $response .= "<li>$person</li>\n";
! 1093: }
! 1094: $response .= "</ul>\n";
! 1095: } else {
! 1096: $response = "Notification of enrollment changes was <b> not enabled</b> as no course coordinators were selected as recipients.<br/>";
! 1097: }
! 1098: } else {
1.1 raeburn 1099: if ($currcount) {
1.7 ! raeburn 1100: $response = "Notification of enrollment changes now <b>disabled</b><br/>";
1.1 raeburn 1101: } else {
1.7 ! raeburn 1102: $response = "Notification of enrollment changes still <b>disabled</b><br/>";
1.1 raeburn 1103: }
1104: }
1105: }
1106: }
1107: &print_reply($r,$response,$$tasktitleref{$action});
1108: return;
1109: }
1110:
1111: sub print_crosslistings_menu () {
1112: my ($r,$realm,$dom,$crs,$action,$tasktitleref) = @_;
1113: my %settings = &Apache::lonnet::get('environment',['internal.crosslistings','internal.coursecode'],$dom,$crs);
1114: my @currxlists = ();
1115: my @xlists = ();
1116: my $crosscount = 0;
1117: my $removecount = 0;
1118: my $xliststr = '';
1119: my $response = '';
1120: my $coursecode = $settings{'internal.coursecode'};
1121: if ($settings{'internal.crosslistings'} =~ m/,/) {
1122: @currxlists = split/,/,$settings{'internal.crosslistings'};
1123: } elsif ($settings{'internal.crosslistings'} ne '') {
1124: $currxlists[0] = $settings{'internal.crosslistings'};
1125: }
1126:
1127: if (@currxlists > 0) {
1128: for (my $i=0; $i<@currxlists; $i++) {
1129: my $xlist = "cross_".$i;
1130: my $gp = "gp_".$i;
1131: if ( exists($ENV{"form.$xlist"}) ) {
1132: my $xlistentry = '';
1133: if ($currxlists[$i] =~ m/^(\w+:)/) {
1134: $xlistentry = $1;
1135: }
1136: if ( exists($ENV{"form.$gp"}) ) {
1137: $xlistentry .= $ENV{"form.$gp"};
1138: }
1139: push @xlists,$xlistentry;
1140: $crosscount ++;
1141: } else {
1142: $removecount ++;
1143: }
1144: }
1145: }
1146:
1147: if ($crosscount > 1) {
1148: $xliststr = join(",",@xlists);
1149: } else {
1150: $xliststr = $xlists[0];
1151: }
1152: my %cenv = ('internal.crosslistings' => $xliststr);
1153: my $reply = &Apache::lonnet::put('environment',\%cenv,$dom,$crs);
1154: if ($reply !~ /^ok$/) {
1155: $response = "There was a problem processing your requested changes. The automated enrollment settings for this course have been left unchanged.<br/>";
1156: } else {
1157: if ($removecount > 0) {
1.5 raeburn 1158: $response = "A total of $removecount courses are no longer crosslisted with LON-CAPA course: $realm ($coursecode).<br/><br/>";
1.1 raeburn 1159: }
1160: if ($crosscount > 0) {
1161: $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";
1162: foreach (@xlists) {
1163: my ($xlist,$gp) = split/:/,$_;
1164: $response .= "<li>$xlist - ID: $gp</li>\n";
1165: }
1166: $response .= "</ul><br/>\n";
1167: }
1168: }
1169: if ( exists($ENV{'form.numcross'}) ) {
1170: my $numcross = $ENV{'form.numcross'};
1171: if ($numcross > 0) {
1172: my @bgcolors=("#eeeeee","#cccccc");
1173: $response .= qq(
1174: 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/>
1175: <form name="enter" method="post">
1176: <table border="0" cellpadding="2" cellspacing="2" width="100%">
1177: <tr>
1178: <td>
1179: <table border="0" cellspacing="3" cellpadding="3">
1180: <tr bgcolor="#CCCCFF" align="left">
1181: <td><b>Crosslisting</b></td>
1182: <td><b>LON-CAPA section/groupID</b></td>
1183: </tr>
1184: );
1185: for (my $i=0; $i<$numcross; $i++) {
1186: my $colflag = $i%2;
1187: $response .= qq(
1188: <tr bgcolor="$bgcolors[$colflag]" align="left">
1189: <td><input type="text" size="15" name="newcross_$i" /></td>
1190: <td><input type="text" size="10" name="newgroupid_$i" /></td>
1191: </tr>
1192: );
1193: }
1194: $response .= qq( </table>
1195: </td>
1196: </tr>
1197: <tr>
1198: <td align="right">
1199: <input type="button" name="newcross" value="Go" onClick="process('newcross')" />
1200: </td>
1201: </tr>
1202: </table>
1203: <input type=\"hidden\" name=\"numcross\" value=\"$numcross\">
1204: <input type=\"hidden\" name=\"action\" value=\"newcross\">
1205: <input type=\"hidden\" name=\"state\" value=\"process\">
1206: </form>
1207: );
1208: }
1209: }
1210: &print_reply($r,$response,$$tasktitleref{$action});
1211: return;
1212: }
1213:
1214: sub print_crosslistings_response () {
1215: my ($r,$realm,$dom,$crs,$action,$tasktitleref) = @_;
1.5 raeburn 1216: my %settings = &Apache::lonnet::get('environment',['internal.crosslistings','internal.coursecode','internal.courseowner'],$dom,$crs);
1.1 raeburn 1217: my @currxlists = ();
1218: my @xlists = ();
1219: my @allxlists = ();
1.5 raeburn 1220: my @badxlists = ();
1221: my @badowner = ();
1.1 raeburn 1222: my $numcross = 0;
1223: my $xliststr = $settings{'internal.crosslistings'};
1224: my $coursecode = $settings{'internal.coursecode'};
1.5 raeburn 1225: my $owner = $settings{'internal.courseowner'};
1.1 raeburn 1226: my $response = '';
1227:
1228: if ($xliststr =~ m/,/) {
1229: @allxlists = split/,/,$xliststr;
1230: } else {
1231: unless ($xliststr eq '') { $allxlists[0] = $xliststr; }
1232: }
1233:
1234: if ( exists($ENV{'form.numcross'}) ) {
1235: $numcross = $ENV{'form.numcross'};
1236: }
1237:
1238: if ($numcross > 0) {
1239: for (my $i=0; $i<$numcross; $i++) {
1240: my $xl = "newcross_".$i;
1241: my $gp = "newgroupid_".$i;
1242: if ( exists($ENV{"form.$xl"}) ) {
1.5 raeburn 1243: my $coursecheck = &localenroll::validate_courseID($ENV{"form.$xl"});
1244: if ($coursecheck eq 'ok') {
1245: my $addcheck = &localenroll::new_course($ENV{"form.$xl"},$owner);
1246: if ($addcheck eq 'ok') {
1247: push @xlists,$ENV{"form.$xl"}.":".$ENV{"form.$gp"};
1248: } else {
1249: push @badowner,$ENV{"form.$xl"}.":".$ENV{"form.$gp"};
1250: }
1251: } else {
1.6 raeburn 1252: push @badxlists, $ENV{"form.$xl"}.":".$ENV{"form.$gp"}.":".$coursecheck;
1.5 raeburn 1253: }
1.1 raeburn 1254: }
1255: }
1256: push @allxlists, @xlists;
1257: }
1258:
1259: if (@xlists > 0 ) {
1260: unless ($xliststr eq '') { $xliststr .= ","; }
1261: if (@xlists > 1) {
1262: $xliststr .= join(",",@xlists);
1263: } else {
1264: $xliststr .= $xlists[0];
1265: }
1266: my %cenv = ('internal.crosslistings' => $xliststr);
1267: my $reply = &Apache::lonnet::put('environment',\%cenv,$dom,$crs);
1268: if ($reply !~ /^ok$/) {
1.6 raeburn 1269: $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 1270: } else {
1271: $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 1272: foreach (@allxlists) {
1273: my ($xlist,$gp) = split/:/,$_;
1274: $response .= "<li>$xlist - ID: $gp</li>\n";
1275: }
1276: $response .= "</ul><br/><br/>\n";
1277: }
1278: } else {
1279: if ($xliststr =~ m/:/) {
1280: my @oldxlists = ();
1281: if ($xliststr =~ m/,/) {
1282: @oldxlists = split/,/,$xliststr;
1283: } else {
1284: $oldxlists[0] = $xliststr;
1285: }
1286: $response .= "Although no new crosslistings were added, the courses listed below continue to be crosslisted with your LON-CAPA course.<br/><ul>\n";
1287: foreach (@oldxlists) {
1288: my ($xlist,$gp) = split/:/,$_;
1289: $response .= "<li>$xlist - ID: $gp</li>\n";
1290: }
1291: $response .= "</ul><br/><br/>\n";
1.1 raeburn 1292: }
1293: }
1.5 raeburn 1294: if (@badxlists > 0) {
1295: $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";
1296: foreach (@badxlists) {
1.6 raeburn 1297: my ($xlist,$gp,$prob) = split/:/,$_;
1298: $response .= "<li>$xlist - ID: $gp - Error: $prob</li>\n";
1.5 raeburn 1299: }
1300: $response .= "</ul><br/><br/>\n";
1301: }
1302:
1303: if (@badowner > 0) {
1304: $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";
1305: foreach (@badowner) {
1306: my ($xlist,$gp) = split/:/,$_;
1307: $response .= "<li>$xlist - ID: $gp</li>\n";
1308: }
1309: $response .= "</ul><br/><br/>\n";
1310: }
1.1 raeburn 1311:
1312: &print_reply($r,$response,$$tasktitleref{$action});
1313: return;
1314: }
1315:
1316: sub print_sections_menu () {
1317: my ($r,$realm,$dom,$crs,$action,$tasktitleref) = @_;
1318: my %settings = &Apache::lonnet::get('environment',['internal.sectionnums','internal.coursecode'],$dom,$crs);
1319: my @currsections = ();
1320: my @sections = ();
1321: my $seccount = 0;
1322: my $removecount = 0;
1.6 raeburn 1323: my $addcount = 0;
1.1 raeburn 1324: my $secstr = '';
1325: my $response = '';
1326: my $coursecode = $settings{'internal.coursecode'};
1327: if ($settings{'internal.sectionnums'} =~ m/,/) {
1328: @currsections = split/,/,$settings{'internal.sectionnums'};
1329: } elsif ($settings{'internal.sectionnums'} ne '') {
1330: $currsections[0] = $settings{'internal.sectionnums'};
1331: }
1.6 raeburn 1332:
1333: if ( exists($ENV{'form.secshow'}) ) {
1334: for (my $i=0; $i<$ENV{'form.secshow'}; $i++) {
1335: my $gp = "loncapasec_".$i;
1336: my $secnum = "secnum_".$i;
1337: my $sec = "sec_".$i;
1338: if ( exists( $ENV{"form.$sec"} ) ) {
1339: my $secentry;
1340: if ( exists( $ENV{"form.$secnum"} ) ) {
1341: $secentry = $ENV{"form.$secnum"}.':';
1342: }
1343: if ( exists( $ENV{"form.$gp"} ) ) {
1344: $secentry .= $ENV{"form.$gp"};
1345: }
1346: push @sections, $secentry;
1347: $seccount ++;
1348: unless (grep/^$ENV{"form.$secnum"}:/,@currsections) {
1349: $addcount ++;
1350: }
1351: }
1352: }
1353: if (@currsections > 0) {
1354: for (my $i=0; $i<@currsections; $i++) {
1355: if ($currsections[$i] =~ m/^(\w+:)/ ) {
1356: my $oldsec = $1;
1357: unless (grep/^$oldsec/,@sections) {
1358: $removecount ++;
1359: }
1360: }
1361: }
1362: }
1363: } elsif (@currsections > 0) {
1.1 raeburn 1364: for (my $i=0; $i<@currsections; $i++) {
1365: my $sec = "sec_".$i;
1366: my $gp = "secgp_".$i;
1367: if ( exists($ENV{"form.$sec"}) ) {
1368: my $secentry = '';
1.6 raeburn 1369: if ($currsections[$i] =~ m/^(\w+:)/ ) {
1.1 raeburn 1370: $secentry = $1;
1371: }
1372: if ( exists($ENV{"form.$gp"}) ) {
1373: $secentry .= $ENV{"form.$gp"};
1374: }
1375: push @sections,$secentry;
1376: $seccount ++;
1377: } else {
1378: $removecount ++;
1379: }
1380: }
1381: }
1382:
1383: if ($seccount > 1) {
1384: $secstr = join(",",@sections);
1385: } else {
1386: $secstr = $sections[0];
1387: }
1388: my %cenv = ('internal.sectionnums' => $secstr);
1389: my $reply = &Apache::lonnet::put('environment',\%cenv,$dom,$crs);
1390: if ($reply !~ /^ok$/) {
1391: $response = "There was a problem processing your requested changes. The automated enrollment settings for this course have been left unchanged.<br/>";
1392: } else {
1393: if ($removecount > 0) {
1394: $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/>";
1395: }
1.6 raeburn 1396: if ($addcount > 0) {
1397: $response .= "A total of $addcount sections have been added to the list of
1398: sections which contribute to enrollment in LON-CAPA course: $realm ($coursecode).<br/><br/>";
1399: }
1.1 raeburn 1400: if ($seccount > 0) {
1.6 raeburn 1401: $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 1402: foreach (@sections) {
1403: my ($sec,$gp) = split/:/,$_;
1404: $response .= "<li>$sec - ID: $gp</li>\n";
1405: }
1406: $response .= "</ul><br/>\n";
1407: }
1408: }
1409:
1410: if ( exists($ENV{'form.numsec'}) ) {
1411: my $numsec = $ENV{'form.numsec'};
1412: if ($numsec > 0) {
1413: my @bgcolors=("#eeeeee","#cccccc");
1414: $response .= qq(
1415: 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/>
1416: <form name="enter" method="post">
1417: <table border="0" cellpadding="2" cellspacing="2" width="100%">
1418: <tr>
1419: <td>
1420: <table border="0" cellspacing="3" cellpadding="3">
1421: <tr bgcolor="#CCCCFF" align="left">
1422: <td><b>Section number</b></td>
1423: <td><b>LON-CAPA section/groupID</b></td>
1424: </tr>
1425: );
1426: for (my $i=0; $i<$numsec; $i++) {
1427: my $colflag = $i%2;
1428: $response .= qq(
1429: <tr bgcolor="$bgcolors[$colflag]" align="left">
1430: <td><input type="text" size="15" name="newsec_$i" /></td>
1431: <td><input type="text" size="10" name="newsecgp_$i" /></td>
1432: </tr>
1433: );
1434: }
1435: $response .= qq( </table>
1436: </td>
1437: </tr>
1438: <tr>
1439: <td align="right">
1440: <input type="button" name="newsections" value="Go" onClick="process('newsections')" />
1441: </td>
1442: </tr>
1443: </table>
1444: <input type=\"hidden\" name=\"numsec\" value=\"$numsec\">
1445: <input type=\"hidden\" name=\"action\" value=\"newsections\">
1446: <input type=\"hidden\" name=\"state\" value=\"process\">
1447: </form>
1448: );
1449: }
1450: }
1451: &print_reply($r,$response,$$tasktitleref{$action});
1452: return;
1453: }
1454:
1455: sub print_sections_response () {
1456: my ($r,$realm,$dom,$crs,$action,$tasktitleref) = @_;
1457: my %settings = &Apache::lonnet::get('environment',['internal.sectionnums','internal.coursecode'],$dom,$crs);
1458: my @currsections = ();
1459: my @sections = ();
1460: my @allsections = ();
1461: my $numsec = 0;
1462: my $secstr = $settings{'internal.sectionnums'};
1463: my $coursecode = $settings{'internal.coursecode'};
1464: my $response = '';
1465:
1466: if ($secstr =~ m/,/) {
1467: @allsections = split/,/,$secstr;
1468: } else {
1469: unless ($secstr eq '') { $allsections[0] = $secstr; }
1470: }
1471:
1472: if ( exists($ENV{'form.numsec'}) ) {
1473: $numsec = $ENV{'form.numsec'};
1474: }
1475:
1476: if ($numsec > 0) {
1477: for (my $i=0; $i<$numsec; $i++) {
1478: my $sec = "newsec_".$i;
1479: my $gp = "newsecgp_".$i;
1480: if ( exists($ENV{"form.$sec"}) ) {
1481: push @sections,$ENV{"form.$sec"}.":".$ENV{"form.$gp"};
1482: }
1483: }
1484: push @allsections, @sections;
1485: }
1486:
1487: if (@sections > 0 ) {
1488: unless ($secstr eq '') { $secstr .= ","; }
1489: if (@sections > 1) {
1490: $secstr .= join(",",@sections);
1491: } else {
1492: $secstr .= $sections[0];
1493: }
1494: my %cenv = ('internal.sectionnums' => $secstr);
1495: my $reply = &Apache::lonnet::put('environment',\%cenv,$dom,$crs);
1496: if ($reply !~ /^ok$/) {
1497: $response = "There was a problem processing your requested changes. The automated enrollment settings for this course have been left unchanged.<br/>";
1498: } else {
1499: $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";
1500: }
1501: }
1502:
1503: foreach (@allsections) {
1504: my ($sec,$gp) = split/:/,$_;
1505: $response .= "<li>$sec - ID: $gp</li>\n";
1506: }
1507: $response .= "</ul><br/>\n";
1508:
1509: &print_reply($r,$response,$$tasktitleref{$action});
1510: return;
1511: }
1512:
1513: sub print_photos_response () {
1514: my ($r,$realm,$dom,$crs,$action,$tasktitleref) = @_;
1515: my %settings = &Apache::lonnet::get('environment',['internal.showphotos'],$dom,$crs);
1516: my $currphotos = $settings{'internal.showphotos'};
1517: my $showphotos = '';
1518: if ( exists($ENV{'form.showphotos'}) ) {
1519: $showphotos=$ENV{'form.showphotos'};
1520: }
1521:
1522: my $response = "";
1523: my %cenv = ('internal.showphotos' => $showphotos);
1524: my $reply = &Apache::lonnet::put('environment',\%cenv,$dom,$crs);
1525: if ($reply !~ /^ok$/) {
1526: $response = "There was a problem processing your requested change. The student photo import setting for this course has been left unchanged.<br/>";
1527: } else {
1528: if ($showphotos) {
1529: if ($currphotos) {
1530: $response = "Retrieval of student photos is still <b>enabled</b><br/>";
1531: } else {
1532: $response = "Retrieval of student photos in now <b>enabled</b><br/>";
1533: }
1534: } else {
1535: if ($currphotos) {
1536: $response = "Retrieval of student photos is now <b>disabled</b><br/>";
1537: } else {
1538: $response = "Retrieval of student photos is still <b>disabled</b><br/>";
1539: }
1540: }
1541: }
1542: &print_reply($r,$response,$$tasktitleref{$action});
1543: return;
1544: }
1545:
1546: sub print_update_result () {
1547: my ($r,$realm,$dom,$crs,$action,$tasktitleref) = @_;
1548: my $response = '';
1549: my $updateadds = 0;
1550: my $updatedrops = 0;
1551: my $changecount = 0;
1552: my %affiliates = ();
1553: my %reply = ();
1554: my @allcourses = ();
1555: my %LC_code = ();
1556: my $logmsg = '';
1.5 raeburn 1557: my $newusermsg = '';
1.1 raeburn 1558:
1559: my %settings = &Apache::lonnet::get('environment',['internal.coursecode','internal.sectionnums','internal.crosslistings','internal.authtype','internal.autharg','internal.autostart','internal.autoend'],$dom,$crs);
1560: my $coursecode = $settings{'internal.coursecode'};
1561: my $authtype = $settings{'internal.authtype'};
1562: my $autharg = $settings{'internal.autharg'};
1563: my $autostart = $settings{'internal.autostart'};
1564: my $autoend = $settings{'internal.autoend'};
1565:
1566: if ( exists($ENV{'form.updateadds'}) ) {
1567: $updateadds = $ENV{'form.updateadds'};
1568: }
1569: if ( exists($ENV{'form.updatedrops'}) ) {
1570: $updatedrops = $ENV{'form.updatedrops'};
1571: }
1572: if (!$updateadds && !$updatedrops) {
1573: $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.";
1574: } elsif ($coursecode eq '') {
1575: $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";
1576: } else {
1577: # Get complete list of course sections to update
1578: my @currsections = ();
1579: my @currxlists = ();
1580:
1581: if ($settings{'internal.sectionnums'} =~ m/,/) {
1582: @currsections = split/,/,$settings{'internal.sectionnums'};
1583: } elsif ($settings{'internal.sectionnums'} ne '') {
1584: $currsections[0] = $settings{'internal.sectionnums'};
1585: }
1586:
1587: if ($settings{'internal.crosslistings'} =~ m/,/) {
1588: @currxlists = split/,/,$settings{'internal.crosslistings'};
1589: } elsif ($settings{'internal.crosslistings'} ne '') {
1590: $currxlists[0] = $settings{'internal.crosslistings'};
1591: }
1592:
1593: if (@currxlists > 0) {
1594: foreach (@currxlists) {
1595: if (m/^(\w+):(\w*)$/) {
1596: unless (grep/^$1$/,@allcourses) {
1597: push @allcourses,$1;
1598: $LC_code{$1} = $2;
1599: }
1600: }
1601: }
1602: }
1603:
1604: if (@currsections > 0) {
1605: foreach (@currsections) {
1606: if (m/^(\w+):(\w*)$/) {
1607: my $sec = $coursecode.$1;
1608: my $gp = $2;
1609: unless (grep/^$sec$/,@allcourses) {
1610: push @allcourses,$sec;
1611: $LC_code{$sec} = $gp;
1612: }
1613: }
1614: }
1615: }
1616:
1617: if (@allcourses > 0) {
1618: @{$affiliates{$crs}} = @allcourses;
1619: &localenroll::fetch_enrollment($dom,\%affiliates,\%reply);
1620: if ($reply{$crs} > 0) {
1.5 raeburn 1621: ($changecount,$response) = &LONCAPA::Enrollment::update_LC($dom,$crs,$updateadds,$updatedrops,$autostart,$autoend,$authtype,$autharg,\@allcourses,\%LC_code,\$logmsg,\$newusermsg,"updatenow");
1.1 raeburn 1622: } else {
1623: $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.";
1624: }
1625: } else {
1626: $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)";
1627: }
1628: }
1629: unless ($logmsg eq '') {
1630: my $loglength = length($logmsg);
1631: $logmsg = substr($logmsg,0,$loglength-4);
1632: $logmsg = "<br/><br/>The following messages were generated by the roster update process: <br/><ul><li>".$logmsg."</ul><br/>";
1633: }
1.5 raeburn 1634: unless ($newusermsg eq '') {
1635: $newusermsg = substr( $newusermsg,0,rindex($newusermsg,'<li>') );
1636: $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/>";
1637: }
1638: $response .= $logmsg.$newusermsg;
1.1 raeburn 1639: &print_reply($r,$response,$$tasktitleref{$action});
1640: return;
1641: }
1642:
1643: sub print_reply () {
1644: my ($r,$response,$caller) = @_;
1645: $r->print("
1646: <br/><table width=\"100%\" border=\"0\" cellpadding=\"2\" cellspacing=\"2\">
1647: <tr>
1648: <tr align=\"left\"><b>$caller</b> - result<br/><br/>$response</td>
1649: </td>
1650: </tr>
1651: </table>
1652: ");
1653: return;
1654: }
1655:
1656: sub setup_date_selectors {
1657: my ($starttime,$endtime) = @_;
1658: if ($endtime == 0) {
1659: $endtime = 1999915200;
1660: }
1661: if (! defined($starttime)) {
1662: $starttime = time;
1663: if (exists($ENV{'course.'.$ENV{'request.course.id'}.
1664: '.default_enrollment_start_date'})) {
1665: $starttime = $ENV{'course.'.$ENV{'request.course.id'}.
1666: '.default_enrollment_start_date'};
1667: }
1668: }
1669: if (! defined($endtime)) {
1670: $endtime = time+(6*30*24*60*60); # 6 months from now, approx
1671: if (exists($ENV{'course.'.$ENV{'request.course.id'}.
1672: '.default_enrollment_end_date'})) {
1673: $endtime = $ENV{'course.'.$ENV{'request.course.id'}.
1674: '.default_enrollment_end_date'};
1675: }
1676: }
1677: my $startdateform = &Apache::lonhtmlcommon::date_setter('enter',
1678: 'startdate',
1679: $starttime);
1680: my $enddateform = &Apache::lonhtmlcommon::date_setter('enter',
1681: 'enddate',
1682: $endtime);
1683: return ($startdateform,$enddateform);
1684: }
1685:
1686: sub get_dates_from_form {
1687: my $startdate = &Apache::lonhtmlcommon::get_date_from_form('startdate');
1688: my $enddate = &Apache::lonhtmlcommon::get_date_from_form('enddate');
1689: if ( exists ($ENV{'form.no_end_date'}) ) {
1690: $enddate = 0;
1691: }
1692: return ($startdate,$enddate);
1693: }
1694:
1695: sub date_setting_table {
1696: my ($starttime,$endtime) = @_;
1697: my ($startform,$endform) = &setup_date_selectors($starttime,$endtime);
1698: my $perpetual = '<nobr><input type="checkbox" name="no_end_date"';
1699: if (defined($endtime) && $endtime == 0) {
1700: $perpetual .= ' checked';
1701: }
1702: $perpetual.= ' />'.' no ending date</nobr>';
1703: my $start_table = '';
1704: $start_table .= "<table>\n";
1705: $start_table .= '<tr><td align="right">Starting Date</td>'.
1706: '<td>'.$startform.'</td>'.
1707: '<td> </td>'."</tr>\n";
1708: $start_table .= "</table>";
1709: my $end_table = '';
1710: $end_table .= "<table>\n";
1711: $end_table .= '<tr><td align="right">Ending Date</td>'.
1712: '<td>'.$endform.'</td>'.
1713: '<td>'.$perpetual.'</td>'."</tr>\n";
1714: $end_table .= "</table>\n";
1715: return ($start_table, $end_table);
1716: }
1717:
1718: ###################################################################
1719: sub handler {
1720: my $r = shift;
1721: if ($r->header_only) {
1722: $r->content_type('text/html');
1723: $r->send_http_header;
1724: return OK;
1725: }
1726: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['action','state']);
1727: # Needs to be in a course
1728: if (! (($ENV{'request.course.fn'}) && (&Apache::lonnet::allowed('cst',$ENV{'request.course.id'})))) {
1729: # Not in a course, or not allowed to modify parms
1730: $ENV{'user.error.msg'}="/adm/populate:cst:0:0:Cannot drop or add students";
1731: return HTTP_NOT_ACCEPTABLE;
1732: }
1733: # Start page
1734: $r->content_type('text/html');
1735: $r->send_http_header;
1736:
1737: my @tasks = ("information","chgsettings","setdates","notify","crosslist","sections","photos","updatenow");
1738:
1739: my %tasklong = (
1740: information => "Task information",
1741: chgsettings => "Automated adds/drops",
1742: setdates => "Change enrollment dates",
1743: notify => "Notification of changes",
1744: crosslist => "Change crosslistings",
1745: sections => "Section settings",
1746: photos => "Student photos",
1747: updatenow => "Update roster now",
1748: newcross => "Add crosslistings",
1749: newsections => "Add sections"
1750: );
1751:
1752: my %tasktitle = (
1753: chgsettings => "Changes to nightly automated enrollments",
1754: setdates => "Changes to first and/or last automated enrollment dates",
1755: notify => "Notification of enrollment changes",
1756: crosslist => "Changes to crosslistings",
1757: sections => "Changes to section settings",
1758: photos => "Automatic import of student photos",
1759: updatenow => "Immediate course roster update",
1760: newcross => "Adding new crosslisted courses",
1761: newsections => "Adding new course sections"
1762: );
1763:
1764: my $realm = '';
1765: if ( exists($ENV{'request.course.id'}) ) {
1766: $realm= $ENV{'course.'.$ENV{'request.course.id'}.'.description'};
1767: }
1768: unless ($realm) { $realm=' '; }
1769: my $dom = $ENV{'course.'.$ENV{'request.course.id'}.'.domain'};
1770: my $crs = $ENV{'course.'.$ENV{'request.course.id'}.'.num'};
1771:
1772: #
1773: # Main switch on form.action and form.state, as appropriate
1774: #
1775:
1776: my $action = "information";
1777: if ( exists($ENV{'form.action'}) ) {
1778: $action = $ENV{'form.action'};
1779: }
1780: my $state = "choose";
1781:
1782: if ( exists($ENV{'form.state'}) ) {
1783: $state = $ENV{'form.state'};
1784: }
1785:
1786: if ($action eq "information") {
1787: $r->print(&header());
1788: } else {
1789: if ($state eq "choose") {
1790: $r->print(&choose_header());
1791: } else {
1792: if ($action eq "crosslist") {
1793: if ( exists($ENV{'form.numcross'}) ) {
1794: if ( $ENV{'form.numcross'} > 0 ) {
1795: $r->print(&choose_header());
1796: } else {
1797: $r->print(&header());
1798: }
1799: } else {
1800: $r->print(&header());
1801: }
1802: } elsif ($action eq "sections") {
1803: if ( exists($ENV{'form.numsec'}) ) {
1804: if ( $ENV{'form.numsec'} > 0 ) {
1805: $r->print(&choose_header());
1806: } else {
1807: $r->print(&header());
1808: }
1809: } else {
1810: $r->print(&header());
1811: }
1812: } else {
1813: $r->print(&header());
1814: }
1815: }
1816: }
1817:
1818: my $reply = 0;
1819: unless ($state eq "choose") { $reply = 1; }
1820:
1821: &print_mainbox($r,\%tasklong,$realm,$reply);
1822: &print_navmenu($r,\@tasks,\%tasklong);
1823:
1824: if (($state eq "choose") || ($action eq "information")) {
1825: &print_main_frame($r,$realm,$dom,$crs,\%tasktitle);
1826: } elsif ($action eq "chgsettings") {
1827: &print_chgsettings_response($r,$realm,$dom,$crs,$action,\%tasktitle);
1828: } elsif ($action eq "setdates") {
1829: &print_setdates_response($r,$realm,$dom,$crs,$action,\%tasktitle);
1830: } elsif ($action eq "notify") {
1831: &print_notify_response($r,$realm,$dom,$crs,$action,\%tasktitle);
1832: } elsif ($action eq "sections") {
1833: &print_sections_menu($r,$realm,$dom,$crs,$action,\%tasktitle);
1834: } elsif ($action eq "crosslist") {
1835: &print_crosslistings_menu($r,$realm,$dom,$crs,$action,\%tasktitle);
1836: } elsif ($action eq "updatenow") {
1837: &print_update_result($r,$realm,$dom,$crs,$action,\%tasktitle);
1838: } elsif ($action eq "photos") {
1839: &print_photos_response($r,$realm,$dom,$crs,$action,\%tasktitle);
1840: } elsif ($action eq "newcross") {
1841: &print_crosslistings_response($r,$realm,$dom,$crs,$action,\%tasktitle);
1842: } elsif ($action eq "newsections") {
1843: &print_sections_response($r,$realm,$dom,$crs,$action,\%tasktitle);
1844: }
1845: &print_doc_base($r);
1846: return OK;
1847: }
1848: ###################################################################
1849: 1;
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>