Annotation of loncom/interface/lonpopulate.pm, revision 1.14
1.4 albertel 1: # automated enrollment configuration handler
1.14 ! raeburn 2: # $Id: lonpopulate.pm,v 1.13 2004/06/09 17:01:56 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.14 ! raeburn 34: use Apache::loncoursedata;
1.1 raeburn 35: use Apache::Constants qw(:common :http REDIRECT);
36: use Time::Local;
1.7 raeburn 37: use LONCAPA::Enrollment;
1.1 raeburn 38: use localenroll;
39:
40: ###############################################################
41: sub header {
42: my $bodytag=&Apache::loncommon::bodytag('Classlist Manager');
43: return(<<ENDHEAD);
44: <html>
45: <head>
46: <title>LON-CAPA Classlist Manager</title>
47: </head>
48: $bodytag
49: ENDHEAD
50: }
51:
52: ###############################################################
53:
54: sub choose_header {
55: my $bodytag=&Apache::loncommon::bodytag('Classlist Manager');
56: my $scripttag = qq|
57: <script language='javascript' type='text/javascript'>
58: <!--
59: function process(calling) {
60: var checker = 1
61: var rad1 = 0
62: var rad2 = 0
63: var formName = document.forms.enter
1.14 ! raeburn 64: if (calling == "viewclass") {
! 65: formName = document.forms.studentform
! 66: }
1.1 raeburn 67: formName.action.value = calling
68: if (calling == "chgsettings") {
69: for (var j=0; j<formName.autoadds.length; j++) {
70: if (formName.autoadds[j].checked) {
71: rad1 = 1
72: }
73: }
74: for (var k=0; k<formName.autodrops.length; k++) {
75: if (formName.autodrops[k].checked) {
76: rad2 = 1
77: }
78: }
79: if (rad1 == 0) {
80: alert("You must check either 'Enable' or 'Disable' for nightly additions based on classlist changes")
81: checker = 0
82: }
83: if (rad2 == 0) {
84: alert("You must check either 'Enable' or 'Disable' for nightly removals based on classlist changes")
85: checker = 0
86: }
87: }
88: if (calling == "updatenow") {
89: var enrolldis
90: var unenrolldis
91: for (var j=0; j<formName.updateadds.length; j++) {
92: if (formName.updateadds[j].value == 0) {
93: enrolldis = j
94: }
95: if (formName.updateadds[j].checked) {
96: rad1 = 1
97: }
98: }
99: for (var k=0; k<formName.updatedrops.length; k++) {
100: if (formName.updatedrops[k].value == 0) {
101: unenrolldis = k
102: }
103: if (formName.updatedrops[k].checked) {
104: rad2 = 1
105: }
106: }
107: if (rad1 == 0) {
108: alert("You must check either 'Enable' or 'Disable' for nightly additions based on classlist changes")
109: checker = 0
110: }
111: if (rad2 == 0) {
112: alert("You must check either 'Enable' or 'Disable' for nightly removals based on classlist changes")
113: checker = 0
114: }
115: if (formName.updatedrops[unenrolldis].checked && formName.updateadds[enrolldis].checked ) {
116: 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")
117: checker = 0
118: }
119: }
1.14 ! raeburn 120: if (calling == "viewclass") {
! 121: document.forms.studentform.state.value = "process";
! 122: checker = 1;
! 123: }
1.1 raeburn 124: if (checker == 1) {
125: formName.submit();
126: }
127: }
128: // End hiding -->
129: </script>
130: |;
131: return(<<ENDHEAD);
132: <html>
133: <head>
134: <title>LON-CAPA Classlist Manager</title>
135: $scripttag
136: $bodytag
137: ENDHEAD
138: }
139:
140: sub print_mainbox {
141: my ($r,$tasklongref,$realm,$reply) = @_;
142: my $action = "information";
143: if ( exists($ENV{'form.action'}) ) {
144: $action = $ENV{'form.action'};
145: }
146: my $page = '';
147: if ($action eq "information") {
148: $page = "<b>Automated Enrollment</b>";
149: } else {
150: $page = '<a href="/adm/populate">Automated Enrollment</a>';
151: if ($reply) {
152: if ($action eq "newcross") {
153: $action = "crosslist";
154: } elsif ($action eq "newsections") {
155: $action = "sections";
156: }
157: $page .= "-> <a href=\"/adm/populate?action=$action\">".$$tasklongref{$action}."</a> -> <b>result</b>";
158: } else {
159: $page .= " -> <b>".$$tasklongref{$action}."</b>";
160: }
161: }
162: $r->print(<<ENDTHIS);
163: <table width="100%" border="0" cellpadding="0" cellspacing="0">
164: <tr>
165: <td bgcolor="#CCCCFF">
166: <font size="2"><a href="/adm/menu">$realm</a> -> <a href="/adm/dropadd">Enrollment Manager</a> -> $page</font><br/>
167: </td>
168: <td align="right" bgcolor="#CCCCFF" valign="top">
169: <font size="+1">Automated Enrollment Manager </font>
170: </td>
171: </tr>
172: </table>
173: <table width="100%" border="0" cellpadding="0" cellspacing="0">
174: <tr>
175: ENDTHIS
176: }
177:
178: sub print_navmenu {
179: my ($r,$tasksref,$tasklongref) = @_;
180: my $action = "information";
181: if (exists($ENV{'form.action'}) ) {
182: $action = $ENV{'form.action'};
183: }
184: $r->print(<<ENDONE);
185: <td width="10" valign="top" bgcolor="#DDFFFF"> </td>
186: <td width="20%" valign="top" bgcolor="#DDFFFF">
187: <br/>
188: ENDONE
189: foreach my $task (@{$tasksref}) {
190: if ($task eq $action) {
191: $r->print("
192: <p>
193: <font color=\"#999999\">
194: <b>$$tasklongref{$task}</b><br/>
195: </font>
196: </p>");
197: } else {
198: $r->print("
199: <p>
200: <font color=\"#004263\">
201: <b><a href=\"/adm/populate?action=$task\">$$tasklongref{$task}</a></b><br/>
202: </font>
203: </p>");
204:
205: }
206: }
207: $r->print("
208: <p> </p>
209: </td>
210: <td width=\"10\" valign=\"top\" bgcolor=\"#CCCCFF\"> </td>
211: <td width=\"10\" valign=\"top\" bgcolor=\"#FFFFFF\"> </td>
212: <td bgcolor=\"#ffffff\" valign=\"top\">");
213: }
214:
215: ###############################################################
216:
217: sub print_main_frame {
1.13 raeburn 218: my ($r,$realm,$dom,$crs,$tasktitleref) = @_;
1.1 raeburn 219: my $action = "information";
220: if (exists($ENV{'form.action'}) ) {
221: $action = $ENV{'form.action'};
222: }
223:
224: # Get course settings
225: my %enrollvar;
226: my @bgcolors=("#eeeeee","#cccccc");
227: my %settings = &Apache::lonnet::dump('environment',$dom,$crs);
228: foreach my $item (keys %settings) {
229: if ($item =~ m/^internal\.(.+)$/) {
230: $enrollvar{$1} = $settings{$item};
1.14 ! raeburn 231: } elsif ($item =~ /^default_enrollment_(start|end)_date$/) {
! 232: $enrollvar{$item} = $settings{$item};
1.1 raeburn 233: }
234: }
235:
236: if ($action eq "information") {
237: $r->print(<<ENDONE);
1.2 raeburn 238: <br/><table border='0' width='100%'>
1.1 raeburn 239: <tr>
240: <td> </td>
241: <td><b>Use the menu on the left to choose an enrollment management task.</b><br/><br/></td>
242: <tr>
243: <td> </td>
244: <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>
245: </tr>
246: <tr>
247: <td> </td>
248: <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>
249: </tr>
250: <tr>
251: <td> </td>
1.14 ! raeburn 252: <td>Use <i>"Change access dates"</i> to change the default start and/or end dates for student roles created by automated enrollment.</td>
! 253: </tr>
! 254: <tr>
! 255: <td> </td>
1.1 raeburn 256: <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>
257: </tr>
258: <tr>
259: <td> </td>
260: <td>Use <i>"Change crosslisting"</i> to include or exclude enrollment from crosslisted classes.</td>
261: </tr>
262: <tr>
263: <td> </td>
264: <td>Use <i>"Section settings"</i> to make changes to the choice of sections included for enrollment in your LON-CAPA course.</td>
265: </tr>
266: <td> </td>
1.2 raeburn 267: <td>Use <i>"Student photos"</i> to enable or disable automatic upload of student photos to your course.</td>
1.1 raeburn 268: </tr>
269: <tr>
270: <td> </td>
271: <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>
272: </tr>
273: <tr>
274: <td colspan='2'> </td>
275: </tr>
276: <tr>
277: <td> </td>
278: <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>
279: </tr>
280: </table>
281: ENDONE
282: } elsif ($action eq "chgsettings") {
283: my @autosets = ("OFF","ON");
284: $r->print(<<ENDTWO);
285: <form name="enter" method="post"><br/>
286: <table width="100%" border="0" cellpadding="2" cellspacing="2">
287: <tr>
288: <td align="left"><b>$$tasktitleref{$action}</b><br/>
289: Currently: Nightly adds: <i>$autosets[$enrollvar{autoadds}]</i>, Nightly drops: <i>$autosets[$enrollvar{autodrops}]</i>
290: </td>
291: </tr>
292: </table>
293: <table width="100%" border="0" cellpadding="3" cellspacing="3">
294: <tr>
295: <td>
296: Additions based on classlist changes:
297: ENDTWO
298: if ($enrollvar{autoadds}) {
299: $r->print("
300: <input type=\"radio\" name=\"autoadds\" value=\"1\" checked=\"true\" /> Enable
301: <input type=\"radio\" name=\"autoadds\" value=\"0\" /> Disable
302: ");
303: } else {
304: $r->print("
305: <input type=\"radio\" name=\"autoadds\" value=\"1\" /> Enable
306: <input type=\"radio\" name=\"autoadds\" value=\"0\" checked=\"true\" /> Disable
307: ");
308: }
309: $r->print("
310: </td>
311: </tr>
312: <tr>
313: <td>
314: Removals based on classlist changes: ");
315: if ($enrollvar{autodrops}) {
316: $r->print("
317: <input type=\"radio\" name=\"autodrops\" value=\"1\" checked=\"true\" /> Enable
318: <input type=\"radio\" name=\"autodrops\" value=\"0\" /> Disable");
319: } else {
320: $r->print("
321: <input type=\"radio\" name=\"autodrops\" value=\"1\" /> Enable
322: <input type=\"radio\" name=\"autodrops\" value=\"0\" checked=\"true\" /> Disable");
323: }
324: $r->print("
325: </td>
326: </tr>
327: <tr>
328: <td>
329: <font color=\"#888888\">
330: 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.
331: </font>
332: </td>
333: </tr>
334: <tr>
335: <td align=\"right\">
336: <input type=\"button\" name=\"chgsettings\" value=\"Go\" onClick=\"process('chgsettings')\" />
337: </td>
338: </tr>
339: </table>
340: <input type=\"hidden\" name=\"action\" value=\"$action\">
341: <input type=\"hidden\" name=\"state\" value=\"process\">
342: </form>
343: ");
344: } elsif ($action eq "setdates") {
1.14 ! raeburn 345: my ($start_table,$end_table) = &date_setting_table($enrollvar{autostart},$enrollvar{autoend},$action);
1.10 raeburn 346: my $oldstartshow = '';
347: my $oldendshow = '';
348: if ( defined($enrollvar{autostart}) ) {
1.14 ! raeburn 349: $oldstartshow = &Apache::lonlocal::locallocaltime($enrollvar{autostart});
1.10 raeburn 350: }
351: if ( defined($enrollvar{autoend}) ) {
1.14 ! raeburn 352: $oldendshow = &Apache::lonlocal::locallocaltime($enrollvar{autoend});
1.10 raeburn 353: if ($enrollvar{autoend} == 0) {
354: $oldendshow = "No ending date";
355: }
356: }
357: my $dateshow;
358: if ( ($oldendshow eq '') && ($oldstartshow eq '') ) {
1.14 ! raeburn 359: $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 if you plan to utilise automated adds and/or drops in this course.\n";
1.10 raeburn 360: } else {
361: $dateshow = "Currently: First enrollment: <b><i>$oldstartshow</i></b>, Last enrollment: <b><i>$oldendshow</i></b>\n";
1.1 raeburn 362: }
363: $r->print(<<ENDTWO);
364: <form name="enter" method="post"><br/>
365: <table width="100%" border="0" cellpadding="2" cellspacing="2">
366: <tr>
1.10 raeburn 367: <td align="left"><b>$$tasktitleref{$action}</b><br/><br/>
368: $dateshow
1.1 raeburn 369: </td>
370: </tr>
371: </table>
372: <table width="100%" border="0" cellpadding="3" cellspacing="3">
373: <tr>
374: <td align="left" colspan="2">
375: <table border="0" cellspacing="0" cellpadding="2">
376: <tr>
377: <td colspan="3">
378: <i>Set date of first automated enrollment for registered students</i>
379: </td>
380: </tr>
381: <tr>
382: <td>$start_table
383: </td>
384: </tr>
385: </table>
386: </td>
387: </tr>
388: <tr>
389: <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>
390: </tr>
391: <tr>
392: <td align="left" colspan="2">
393: <table border="0' cellspacing="0" cellpadding="2">
394: <tr>
395: <td colspan="3">
396: <i>Set date of last automated enrollment for registered students</i>
397: </td>
398: </tr>
399: <tr>
400: <td>$end_table
401: </td>
402: </tr>
403: </table>
404: </td>
405: </tr>
406: <tr>
407: <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>
408: </tr>
409: </table>
410: <table width="100%">
411: <tr>
412: <td align="right">
413: <input type="button" name="setdates" value="Go" onClick="process('setdates')" />
414: </td>
415: </tr>
416: </table>
1.14 ! raeburn 417: <input type="hidden" name="action" value="$action">
! 418: <input type="hidden" name="state" value="process">
! 419: </form>
! 420: ENDTWO
! 421: } elsif ($action eq "setaccess") {
! 422: &print_accessdate_table($r,\%enrollvar,$tasktitleref,$action);
! 423: $r->print(<<ENDTWO);
! 424: <table width="100%">
! 425: <tr>
! 426: <td align="right">
! 427: <input type="button" name="$action" value="Go" onClick="process('$action')" />
! 428: </td>
! 429: </tr>
! 430: </table>
! 431: <input type="hidden" name="action" value="$action">
! 432: <input type="hidden" name="state" value="process">
1.1 raeburn 433: </form>
434: ENDTWO
435: } elsif ($action eq "notify") {
436: my @notified = ();
437: if ($enrollvar{notifylist} =~ m/,/) {
438: @notified = split/,/,$enrollvar{notifylist};
439: } else {
440: @notified = $enrollvar{notifylist};
441: }
442: my $notifycount = 0;
443: foreach (@notified) {
444: unless ($_ eq '') { $notifycount ++; }
445: }
446: my $noteset = '';
447: if ($notifycount) {
448: $noteset = "ON";
449: } else {
450: $noteset = "OFF";
451: }
452:
453: $r->print("
454: <form name=\"enter\" method=\"post\"><br/>
455: <table width=\"100%\" border=\"0\" cellpadding=\"6\" cellspacing=\"0\">
456: <tr>
457: <td align=\"left\"><b>$$tasktitleref{$action}</b><br/>
458: Currently: Notification: $noteset
459: </td>
460: </tr>
461: </table>
462: <table width=\"100%\" border=\"0\" cellpadding=\"3\" cellspacing=\"3\">
463: <tr>
464: <td>
465: Notification of LON-CAPA course roster changes resulting from nightly automated enrollment process?
466: ");
467: if ($notifycount) {
468: $r->print("
469: <input type=\"radio\" name=\"notify\" value=\"1\" checked=\"true\" /> Yes
470: <input type=\"radio\" name=\"notify\" value=\"0\" /> No
471: ");
472: } else {
473: $r->print("
474: <input type=\"radio\" name=\"notify\" value=\"1\" /> Yes
475: <input type=\"radio\" name=\"notify\" value=\"0\" checked=\"true\" /> No
476: ");
477: }
478: $r->print("
479: </td>
480: </tr>
481: ");
1.7 raeburn 482: my @coursepersonnel = &Apache::lonnet::getkeys('nohist_userroles',$dom,$crs);
483: my @ccs = ();
484: my @oldccs = ();
485: my %pname = ();
486: my %notifystate = ();
487: foreach (@coursepersonnel) {
488: my @roleinfo = split/:/,$_;
489: if ($roleinfo[0] eq 'cc') {
490: unless (grep/^$roleinfo[1]\@$roleinfo[2]/,@ccs) {
491: my $active_cc = &LONCAPA::Enrollment::check_user_status($roleinfo[2],$roleinfo[1],$dom,$crs,'cc');
492: if ($active_cc eq 'ok') {
493: push @ccs, "$roleinfo[1]\@$roleinfo[2]";
494: $pname{"$roleinfo[1]\@$roleinfo[2]"} = &Apache::loncommon::plainname($roleinfo[1],$roleinfo[2]);
495: if (grep/^$roleinfo[1]\@$roleinfo[2]$/,@notified) {
496: $notifystate{"$roleinfo[1]\@$roleinfo[2]"} = 1;
497: } else {
498: $notifystate{"$roleinfo[1]\@$roleinfo[2]"} = 0;
499: }
1.1 raeburn 500: } else {
1.7 raeburn 501: push @oldccs, "$roleinfo[1]\@$roleinfo[2]";
1.1 raeburn 502: }
503: }
504: }
505: }
1.7 raeburn 506: if ($notifycount > 0) {
507: foreach my $person (@notified) {
508: unless ( (grep/^$person$/,@ccs) || ($person eq '') || (grep/^$person$/,@oldccs) ) {
509: push @ccs, $person;
510: my ($puname,$pdom) = split/\@/,$person;
511: $pname{$person} = &Apache::loncommon::plainname($puname,$pdom);
512: $notifystate{$person} = 1;
513: }
514: }
515: }
516: my $viewer = $ENV{'user.name'}.'@'.$ENV{'user.domain'};
517: unless ( (grep/^$viewer$/,@ccs) || ($viewer eq '') ) {
518: push @ccs,$viewer;
519: $pname{$viewer} = &Apache::loncommon::plainname($ENV{'user.name'},$ENV{'user.domain'});
520: $notifystate{$viewer} = 0;
521: }
522:
523: my $notifyshow = @ccs;
524:
525: if (@ccs > 0) {
526: @ccs = sort @ccs;
1.1 raeburn 527: $r->print("
528: <tr>
1.7 raeburn 529: <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 530: </td>
531: </tr>
532: <tr>
533: <td>
1.7 raeburn 534: <table border=\"0\" cellpadding=\"3\" cellspacing=\"3\">
535: <tr bgcolor=\"#CCCCFF\">
536: <td><b>Name</b></td>
537: <td><b>username</b></td>
538: <td><b>Current status</b></td>
539: <td><b>Notification?</b></td>
540: </tr>
541: ");
542: for (my $i=0; $i<@ccs; $i++) {
543: my $colflag = $i%2;
544: $r->print("<tr bgcolor=\"$bgcolors[$colflag]\" align=\"left\">
545: <td>$pname{$ccs[$i]}</td>
546: <td><input type=\"hidden\" name=\"notifyname_$i\" value=\"$ccs[$i]\" />$ccs[$i]</td>
547: <td>
548: ");
549: if ($notifystate{$ccs[$i]} == 1) {
550: $r->print("Notification active");
551: } else {
552: $r->print("Notification inactive");
553: }
554: if ($notifystate{$ccs[$i]} == 1) {
555: $r->print("</td><td><input type=\"checkbox\" name=\"note_$i\" checked=\"true\" /></td></tr>");
556: } else {
557: $r->print("</td><td><input type=\"checkbox\" name=\"note_$i\" /></td></tr>");
558: }
559: }
560: $r->print("
561: </table>
562: <br/>
563: <table width=\"100%\" border=\"0\" cellspadding=\"2\" cellspacing=\"2\">
564: <tr>
565: <td align=\"right\">
566: <input type=\"button\" name=\"notifyset\" value=\"Go\" onClick=\"process('notify')\" />
567: </td>
568: </tr>
569: </table>
570: </td>
571: </tr>
1.1 raeburn 572: ");
1.7 raeburn 573: } else {
1.1 raeburn 574: $r->print("
1.7 raeburn 575: <tr>
576: <td>
577: No course coordinators found.
1.1 raeburn 578: </td>
1.7 raeburn 579: </tr>");
1.1 raeburn 580: }
581: $r->print("
1.7 raeburn 582: </table>
583: <input type=\"hidden\" name=\"notifyshow\" value=\"$notifyshow\">
584: <input type=\"hidden\" name=\"action\" value=\"$action\">
585: <input type=\"hidden\" name=\"state\" value=\"process\">
586: </form>
1.1 raeburn 587: ");
588: } elsif ($action eq "crosslist") {
589: my @xlists = ();
590: if ($enrollvar{crosslistings} =~ m/,/) {
591: @xlists = split/,/,$enrollvar{crosslistings};
592: } elsif ($enrollvar{crosslistings} ne '') {
593: $xlists[0] = $enrollvar{crosslistings};
594: }
595: my $cross_str = @xlists;
596: $r->print("
597: <form name=\"enter\" method=\"post\"><br/>
598: <table width=\"100%\" border=\"0\" cellpadding=\"2\" cellspacing=\"2\">
599: <tr>
600: <td align=\"left\"><b>$$tasktitleref{$action}</b><br/>
601: ");
602: if ($cross_str > 0) {
603: $r->print("
1.7 raeburn 604: 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 605: </td>
606: </tr>
607: </table>
608: <br/>
609: <table border=\"0\" cellpadding=\"3\" cellspacing=\"3\">
610: <tr>
611: <td>
612: <table border=\"0\" width=\"100%\" cellspacing=\"3\" cellpadding=\"3\">
613: <tr bgcolor=\"#CCCCFF\" align=\"left\">
614: <td><b>Enrollment?</b></td>
615: <td><b>Crosslisted course</b></td>
616: <td><b>LON-CAPA section/groupID</b></td>
617: </tr>
618: ");
619: for (my $i=0; $i<@xlists; $i++) {
620: my $xl = ' ';
621: my $gp = ' ';
1.14 ! raeburn 622: if ($xlists[$i] =~ /(\w+):?(.*)$/) {
1.1 raeburn 623: $xl = $1;
624: $gp = $2;
625: }
626: my $colflag = $i%2;
627: $r->print("
628: <tr bgcolor=\"$bgcolors[$colflag]\" align=\"left\">
629: <td><input type=\"checkbox\" name=\"cross_$i\" checked=\"true\"/></td>
630: <td>$xl</td>
631: <td><input type =\"text\" size=\"10\" name=\"gp_$i\" value=\"$gp\"></td>
632: </tr>
633: ");
634: }
635: $r->print(" </table>
636: </td>
637: </tr>
638: </table>
639: ");
640: }
641: else {
642: $r->print("
643: Currently no crosslisted courses are recorded for $enrollvar{coursecode}.
644: </td>
645: </tr>
646: </table>
647: ");
648: }
649: $r->print("
650: <br/>
651: <table width=\"100%\" border=\"0\" cellpadding=\"3\" cellspacing=\"3\">
652: <tr>
653: <td align=\"left\">
654: <b>Add new crosslistings.</b><br/>
655: Number of new crosslistings to add: <input type=\"text\" size=\"2\" name=\"numcross\" value=\"0\" />
656: </td>
657: </tr>
658: </table>
659: <br/>
660: <table width=\"100%\" border=\"0\" cellspadding=\"2\" cellspacing=\"2\">
661: <tr>
662: <td align=\"right\">
663: <input type=\"button\" name=\"crosslist\" value=\"Go\" onClick=\"process('crosslist')\" />
664: </td>
665: </tr>
666: </table>
667: <input type=\"hidden\" name=\"action\" value=\"$action\">
668: <input type=\"hidden\" name=\"state\" value=\"process\">
669: </form>
670: ");
671: } elsif ($action eq "sections") {
1.12 raeburn 672: my @sections = ();
1.13 raeburn 673: @sections = &Apache::lonnet::auto_get_sections($crs,$dom,$enrollvar{coursecode});
1.1 raeburn 674: my @storedsections = ();
675: my @currsections = ();
676: my %sec_id = ();
677: if ($enrollvar{sectionnums} =~ m/,/) {
678: @storedsections = split/,/,$enrollvar{sectionnums};
679: } else {
680: $storedsections[0] = $enrollvar{sectionnums};
681: }
682: foreach (@storedsections) {
683: if ($_ =~ m/^(\w+):(\w*)$/) {
684: push @currsections, $1;
685: $sec_id{$1} = $2;
686: }
687: }
688: if (@sections > 0) {
1.8 raeburn 689: my $secshow = @sections;
690: $r->print("
1.1 raeburn 691: <form name=\"enter\" method=\"post\"><br/>
692: <table width=\"100%\" border=\"0\" cellpadding=\"3\" cellspacing=\"3\">
693: <tr>
694: <td align=\"left\">
695: <b>$$tasktitleref{$action}</b><br/>
696: Your institution's course catalog includes $secshow sections for course code: $enrollvar{coursecode}.
697: </td>
698: </tr>
699: <tr>
1.5 raeburn 700: <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
701: your changes.</td>
1.1 raeburn 702: </tr>
703: </table>
704: <br/>
1.7 raeburn 705: <table border=\"0\" cellpadding=\"3\" cellspacing=\"3\">
706: <tr bgcolor=\"#CCCCFF\">
707: <td><b>Section</b></td>
708: <td><b>Current status</b></td>
709: <td><b>LON-CAPA section/group ID</b></td>
710: <td><b>Enrollment in this course?</b></td>
711: </tr>
1.8 raeburn 712: ");
713: for (my $i=0; $i<@sections; $i++) {
714: my $colflag = $i%2;
715: my $shrflag = 0;
716: $r->print("<tr bgcolor=\"$bgcolors[$colflag]\" align=\"left\">
1.5 raeburn 717: <td>$sections[$i]<input type=\"hidden\" name=\"secnum_$i\" value=\"$sections[$i]\" /></td>
1.1 raeburn 718: <td>
1.8 raeburn 719: ");
720: if (grep/^$sections[$i]$/,@currsections) {
721: $r->print("Enrollment active");
722: $shrflag = 1;
723: } else {
724: $r->print("Enrollment inactive");
725: }
726: if ($shrflag) {
727: $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>");
728: } else {
729: $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 730: }
1.8 raeburn 731: }
732: $r->print("
1.7 raeburn 733: </table>
734: <br/>
735: <table width=\"100%\" border=\"0\" cellspacing=\"3\" cellpadding=\"3\">
736: <tr>
737: <td align=\"right\">
738: <input type=\"hidden\" name=\"secshow\" value=\"$secshow\" />
739: <input type=\"button\" name=\"sections\" value=\"Go\" onClick=\"process('sections')\" />
740: </td>
741: </tr>
742: </table>
743: <input type=\"hidden\" name=\"action\" value=\"$action\">
744: <input type=\"hidden\" name=\"state\" value=\"process\">
745: </form>
1.8 raeburn 746: ");
1.1 raeburn 747: } else {
748: $r->print("
749: <form name=\"enter\" method=\"post\"><br/>
750: <table width=\"100%\" border=\"0\" cellpadding=\"2\" cellspacing=\"2\">
751: <tr>
752: <td align=\"left\"><b>$$tasktitleref{$action}</b><br/>
753: ");
754: if (@currsections) {
755: my $secshow = @currsections;
756: $r->print("
1.7 raeburn 757: 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 758: </td>
759: </tr>
760: </table>
761: <br/>
762: <table border=\"0\" cellpadding=\"3\" cellspacing=\"3\">
763: <tr>
764: <td>
765: <table border=\"0\" width=\"100%\" cellspacing=\"3\" cellpadding=\"3\">
766: <tr bgcolor=\"#CCCCFF\">
767: <td><b>Enrollment?</b></td>
768: <td><b>Section</b></td>
769: <td><b>LON-CAPA section/groupID</b></td>
770: </tr>
771: ");
772: for (my $j=0; $j<@currsections; $j++) {
773: my $colflag = $j%2;
774: $r->print("
775: <tr bgcolor=\"$bgcolors[$colflag]\" align=\"left\">
776: <td><input type=\"checkbox\" name=\"sec_$j\" checked=\"true\"/></td>
777: <td>$currsections[$j]</td>
778: <td><input type=\"text\" name=\"secgp_$j\" size=\"10\" value=\"$sec_id{$currsections[$j]}\"></td>
779: </tr>
780: ");
781: }
782: $r->print(" </table>
783: </td>
784: </tr>
785: </table>
786: ");
787: } else {
788: $r->print("
789: Currently no sections of $realm ($enrollvar{coursecode}) are contributing enrollment to the LON-CAPA class roster.
790: </td>
791: </tr>
792: </table>
793: ");
794: }
795: $r->print("
796: <br/>
797: <table width=\"100%\" border=\"0\" cellpadding=\"3\" cellspacing=\"3\">
798: <tr>
799: <td align=\"left\">
800: <b>Add enrollment from additional sections.</b><br/>
801: Number of new sections to add: <input type=\"text\" size=\"2\" name=\"numsec\" value=\"0\" />
802: </td>
803: </tr>
804: </table>
805: <br/>
806: <table width=\"100%\" border=\"0\" cellspadding=\"2\" cellspacing=\"2\">
807: <tr>
808: <td align=\"right\">
809: <input type=\"button\" name=\"sections\" value=\"Go\" onClick=\"process('sections')\" />
810: </td>
811: </tr>
812: </table>
813: <input type=\"hidden\" name=\"action\" value=\"$action\">
814: <input type=\"hidden\" name=\"state\" value=\"process\">
815: </form>
816: ");
817: }
818: } elsif ($action eq "photos") {
819: my @photosets = ("OFF","ON");
820: $r->print("
821: <form name=\"enter\" method=\"post\"><br/>
822: <table width=\"100%\" border=\"0\" cellpadding=\"2\" cellspacing=\"2\">
823: <tr>
824: <td align=\"left\"><b>$$tasktitleref{$action}</b><br/>
825: Currently: Student photo import: <i>$photosets[$enrollvar{showphotos}]</i>
826: </td>
827: </tr>
828: </table>
829: <table width=\"100%\" border=\"0\" cellpadding=\"3\" cellspacing=\"3\">
830: <tr>
831: <td>
832: Automatic import of student photos from institutional data repository:
833:
834: ");
835: if ($enrollvar{showphotos}) {
836: $r->print("
837: <input type=\"radio\" name=\"showphotos\" value=\"1\" checked=\"true\" /> Yes
838: <input type=\"radio\" name=\"showphotos\" value=\"0\" /> No
839: ");
840: } else {
841: $r->print("
842: <input type=\"radio\" name=\"showphotos\" value=\"1\" /> Yes
843: <input type=\"radio\" name=\"showphotos\" value=\"0\" checked=\"true\" /> No
844: ");
845: }
846: $r->print("
847: </td>
848: </tr>
849: <tr>
850: <td>
851: <font color=\"#888888\">
852: 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.
853: </font>
854: </td>
855: </tr>
856: <tr>
857: </td> </td>
858: </tr>
859: <tr>
860: <td align=\"right\">
861: <input type=\"button\" name=\"showphotos\" value=\"Go\" onClick=\"process('photos')\">
862: </td>
863: </tr>
864: </table>
865: <input type=\"hidden\" name=\"action\" value=\"$action\">
866: <input type=\"hidden\" name=\"state\" value=\"process\">
867: </form>
868: ");
869: } elsif ($action eq "updatenow") {
870: $r->print("
871: <form name=\"enter\" method=\"post\"><br/>
872: <table width=\"100%\" border=\"0\" cellpadding=\"2\" cellspacing=\"2\">
873: <tr>
874: <td align=\"left\"><b>$$tasktitleref{$action}</b>
875: </td>
876: </tr>
877: </table>
878: <table width=\"100%\" border=\"0\" cellpadding=\"3\" cellspacing=\"3\">
879: <tr>
880: <td>
881: Add any students currently included in institutional classlist(s) but not enrolled in your LON-CAPA course.
882: <input type=\"radio\" name=\"updateadds\" value=\"1\"> Yes
883: <input type=\"radio\" name=\"updateadds\" value=\"0\"> No
884: </td>
885: </tr>
886: <tr>
887: <td>
888: Expire students previously added by nightly enrollment process, but no longer listed in institutional classlist(s).
1.14 ! raeburn 889: <input type=\"radio\" name=\"updatedrops\" value=\"1\"> Yes
! 890: <input type=\"radio\" name=\"updatedrops\" value=\"0\"> No <br/>
! 891: </td>
! 892: </tr>
! 893: <tr>
! 894: <td><font color=\"#888888\">
1.1 raeburn 895: 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.
1.14 ! raeburn 896: </font>
! 897: </td>
! 898: </tr>
! 899: <tr>
! 900: <td>
! 901: ");
! 902: &print_accessdate_table($r,\%enrollvar,$tasktitleref,$action);
! 903: $r->print("
! 904: </td>
! 905: </tr>
! 906: <tr>
! 907: <td align=\"right\">
! 908: <input type=\"button\" name=\"updatenow\" value=\"Go\" onClick=\"process('updatenow')\" />
! 909: </td>
! 910: </tr>
! 911: </table>
! 912: <input type=\"hidden\" name=\"action\" value=\"$action\" />
! 913: <input type=\"hidden\" name=\"state\" value=\"process\" />
! 914: </form>
! 915: ");
! 916: } elsif ($action eq 'viewclass') {
! 917: $r->print("
! 918: <form name=\"studentform\" method=\"post\"><br/>
! 919: <table width=\"100%\" border=\"0\" cellpadding=\"2\" cellspacing=\"2\">
! 920: <tr>
! 921: <td align=\"left\"><b>$$tasktitleref{$action}</b>
! 922: </td>
! 923: </tr>
! 924: </table>
! 925: <table>
! 926: <tr>
! 927: <td>
1.1 raeburn 928: ");
1.14 ! raeburn 929: if (! exists($ENV{'form.sortby'})) {
! 930: $ENV{'form.sortby'} = 'username';
! 931: }
! 932: if ($ENV{'form.Status'} !~ /^(Any|Expired|Active)$/) {
! 933: $ENV{'form.Status'} = 'Active';
! 934: }
! 935: my $status_select = &Apache::lonhtmlcommon::StatusOptions($ENV{'form.Status'});
! 936: # Get current classlist
! 937: my ($classlist,$keylist)=&Apache::loncoursedata::get_classlist();
! 938: if (! defined($classlist)) {
! 939: $r->print(&mt('There are no students either currently or previously enrolled.').
! 940: "\n");
! 941: } else {
! 942: $r->print(&mt('Student Status: [_1]',$status_select)."\n");
! 943: $r->print('<input type="submit" value="'.&mt('Update Display').'" />'.
! 944: "\n</p>\n");
! 945:
! 946: my $studentcount = &Apache::londropadd::show_class_list($r,'autoenroll','nothing',$ENV{'form.Status'},$classlist,$keylist);
! 947: $r->print("
! 948: </td>
! 949: </tr>
! 950: ");
! 951: if ($studentcount > 0) {
! 952: $r->print("
! 953: <tr>
! 954: <td> </td>
! 955: </tr>
! 956: <tr>
! 957: <td align=\"right\">
! 958: <input type=\"button\" name=\"viewclass\" value=\"Go\" onClick=\"process('viewclass')\" />
! 959: </td>
! 960: </tr>
! 961: ");
! 962: }
! 963: $r->print("
! 964: </table>
! 965: <input type=\"hidden\" name=\"action\" value=\"$action\" />
! 966: <input type=\"hidden\" name=\"state\" value=\"choose\" />
! 967: </form>
! 968: ");
! 969: }
1.1 raeburn 970: }
971: }
972:
1.14 ! raeburn 973: sub print_accessdate_table {
! 974: my ($r,$enrollvar,$tasktitleref,$action) = @_;
! 975: my ($start_table,$end_table) = &date_setting_table($$enrollvar{'default_enrollment_start_date'},$$enrollvar{'default_enrollment_end_date'},$action);
! 976: my $oldstartshow = '';
! 977: my $oldendshow = '';
! 978: if ( defined($$enrollvar{'default_enrollment_start_date'}) ) {
! 979: $oldstartshow = &Apache::lonlocal::locallocaltime($$enrollvar{'default_enrollment_start_date'});
! 980: }
! 981: if ( defined($$enrollvar{'default_enrollment_end_date'}) ) {
! 982: $oldendshow = &Apache::lonlocal::locallocaltime($$enrollvar{default_enrollment_end_date});
! 983: if ($$enrollvar{'default_enrollment_end_date'} eq '0') {
! 984: $oldendshow = "No ending date";
! 985: }
! 986: }
! 987: my %lt =&Apache::lonlocal::texthash(
! 988: 'cuno' => 'Currently NO default first access or last access dates are set.',
! 989: 'ifyo' => 'If you do not set a start date and an end date, then student roles for students added by the automated enrollment process will start immediately when the student is added and will never become inactive.',
! 990: 'ifyd' => 'If you do not set an access start date and an end date, then student roles for new students added when you click "Go" will become active immediately and will never become inactive.',
! 991: 'setf' => 'Set date of first access',
! 992: 'setl' => 'Set date of last access',
! 993: 'freg' => 'for registered students added via automated enrollment',
! 994: 'fnew' => 'for new students added when you update the class roster',
! 995: 'ifad' => 'If automated adds are enabled, then when students are added their student roles will become active on the date set here for first access, and their roles will become inactive on the date set here for last access. These default access dates will be overridden for specific students if the institutional classlist data supplied to the automatic enrollment process includes entries for the startdate and enddate fields for those students.'
! 996: );
! 997: my $dateshow;
! 998: if ( ($oldendshow eq '') && ($oldstartshow eq '') ) {
! 999: $dateshow = "<br/><font size='+1'>".&mt('Warning')."</font>. ".$lt{'cuno'}." ";
! 1000: if ($action eq 'setaccess') {
! 1001: $dateshow .= $lt{'ifyo'}."\n";
! 1002: } elsif ($action eq 'updatenow') {
! 1003: $dateshow .= $lt{'ifyd'}."\n";
! 1004: }
! 1005: } else {
! 1006: $dateshow = &mt('Currently: default first access').": <b><i>$oldstartshow</i></b>, ".&mt('default last access').": <b><i>$oldendshow</i></b>\n";
! 1007: }
! 1008: if ($action eq 'setaccess') {
! 1009: $r->print(<<ENDONE);
! 1010: <form name="enter" method="post"><br/>
! 1011: <table width="100%" border="0" cellpadding="2" cellspacing="2">
! 1012: <tr>
! 1013: <td align="left"><b>$$tasktitleref{$action}</b>
! 1014: <br /><br />
! 1015: $dateshow
! 1016: </td>
! 1017: </tr>
! 1018: </table>
! 1019: ENDONE
! 1020: } elsif ($action eq 'updatenow') {
! 1021: $r->print("
! 1022: <br /><br />$dateshow\n");
! 1023: }
! 1024: $r->print(<<ENDTWO);
! 1025: <table width="100%" border="0" cellpadding="3" cellspacing="3">
! 1026: <tr>
! 1027: <td align="left" colspan="2">
! 1028: <table border="0" cellspacing="0" cellpadding="2">
! 1029: <tr>
! 1030: <td colspan="3">
! 1031: ENDTWO
! 1032: if ($action eq 'setaccess') {
! 1033: $r->print("<i>$lt{'setf'} $lt{'freg'}</i>");
! 1034: } elsif ($action eq 'updatenow') {
! 1035: $r->print("<i>$lt{'setf'} $lt{'fnew'}</i>");
! 1036: }
! 1037: $r->print(<<ENDTHREE);
! 1038: </td>
! 1039: </tr>
! 1040: <tr>
! 1041: <td>$start_table
! 1042: </td>
! 1043: </tr>
! 1044: </table>
! 1045: </td>
! 1046: </tr>
! 1047: <tr>
! 1048: <td align="left" colspan="2">
! 1049: <table border="0' cellspacing="0" cellpadding="2">
! 1050: <tr>
! 1051: <td colspan="3">
! 1052: ENDTHREE
! 1053: if ($action eq 'setaccess') {
! 1054: $r->print("<i>$lt{'setl'} $lt{'freg'}</i>");
! 1055: } elsif ($action eq 'updatenow') {
! 1056: $r->print("<i>$lt{'setl'} $lt{'fnew'}</i>");
! 1057: }
! 1058: $r->print(<<ENDFOUR);
! 1059: </td>
! 1060: </tr>
! 1061: <tr>
! 1062: <td>$end_table
! 1063: </td>
! 1064: </tr>
! 1065: </table>
! 1066: </td>
! 1067: </tr>
! 1068: ENDFOUR
! 1069: if ($action eq 'setaccess') {
! 1070: $r->print("
! 1071: <tr>
! 1072: <td colspan=\"2\"><font color=\"#888888\">$lt{'ifad'}</font></td>
! 1073: </tr>
! 1074: </table>
! 1075: ");
! 1076: } elsif ($action eq 'updatenow') {
! 1077: $r->print("
! 1078: </tr>
! 1079: </table>
! 1080: ");
! 1081: }
! 1082: }
! 1083:
1.1 raeburn 1084: ###############################################################
1085: sub print_doc_base {
1086: my $r = shift;
1087: $r->print(<<ENDBASE);
1088: </td>
1089: </tr>
1090: </table>
1091: <br/>
1092: </body>
1093: </html>
1094: ENDBASE
1095: }
1096:
1097: ###################################################################
1098: sub print_chgsettings_response {
1099: my ($r,$realm,$dom,$crs,$action,$tasktitleref) = @_;
1.10 raeburn 1100: my %settings = &Apache::lonnet::get('environment',['internal.sectionnums','internal.crosslistings','internal.autostart','internal.autoend','internal.autoadds','internal.autodrops'],$dom,$crs);
1101: my $currend = '';
1102: my $currstart = '';
1103: my $currsecs = '';
1104: my $currxlists = '';
1105: my $curradds = '';
1106: my $currdrops = '';
1107: if ( defined($settings{'internal.autoadds'}) ) {
1108: $curradds = $settings{'internal.autoadds'};
1109: }
1110: if ( defined($settings{'internal.autodrops'}) ) {
1111: $currdrops = $settings{'internal.autodrops'};
1112: }
1113: if ( defined($settings{'internal.autostart'}) ) {
1114: $currstart = $settings{'internal.autostart'};
1115: }
1116: if ( defined($settings{'internal.autoend'}) ) {
1117: $currend = $settings{'internal.autoend'};
1118: }
1119: if ( defined($settings{'internal.sectionnums'}) ) {
1120: $currsecs = $settings{'internal.sectionnums'};
1121: }
1122: if ( defined($settings{'internal.crosslistings'}) ) {
1123: $currxlists = $settings{'internal.crosslistings'}
1124: }
1.1 raeburn 1125: my $autoadds = '';
1126: my $autodrops = '';
1127:
1128: if ( exists($ENV{'form.autoadds'}) ) {
1129: $autoadds=$ENV{'form.autoadds'};
1130: }
1131: if ( exists($ENV{'form.autodrops'}) ) {
1132: $autodrops=$ENV{'form.autodrops'};
1133: }
1134:
1135: my $response = "";
1.10 raeburn 1136: my $warning = "";
1137: my $warn_prefix = "";
1138: my $warn_suffix = "";
1139: my $warnfiller = "";
1.1 raeburn 1140: my %cenv = ('internal.autoadds' => $autoadds,
1141: 'internal.autodrops' => $autodrops);
1142: my $reply = &Apache::lonnet::put('environment',\%cenv,$dom,$crs);
1143: if ($reply !~ /^ok$/) {
1144: $response = "There was a problem processing your requested changes. The automated enrollment settings for this course have been left unchanged.<br/>";
1145: } else {
1146: if ($autoadds) {
1147: if ($curradds) {
1148: $response = "Nightly additions based on classlist changes still <b>enabled</b><br/>";
1149: } else {
1150: $response = "Nightly additions based on classlist changes now <b>enabled</b><br/>";
1.10 raeburn 1151: }
1.1 raeburn 1152: } else {
1153: if ($curradds) {
1154: $response = "Nightly additions based on classlist changes now <b>disabled</b><br/>";
1155: } else {
1156: $response = "Nightly additions based on classlist changes still <b>disabled</b><br/>";
1157: }
1158: }
1159: if ($autodrops) {
1160: if ($currdrops) {
1161: $response .= "Nightly removals based on classlist changes still <b>enabled</b><br>";
1162: } else {
1163: $response .= "Nightly removals based on classlist changes now <b>enabled</b><br/>";
1164: }
1165: } else {
1166: if ($currdrops) {
1167: $response .= "Nightly removals based on classlist changes now <b>disabled</b><br>";
1168: } else {
1169: $response .= "Nightly removals based on classlist changes still <b>disabled</b>";
1170: }
1171: }
1.10 raeburn 1172: if ($autoadds || $autodrops) {
1173: $warning = &warning_message($dom,$crs,$action);
1174: $warn_prefix = "<br/><font size ='+1'><b>Warning</b></font>. Although you indicated that nightly ";
1175: $warn_suffix = " should be enabled, additional action is required.<br/>";
1176: }
1177: if ($autoadds) {
1178: if ($autodrops) {
1179: $warnfiller = "adds and drops";
1180: } else {
1181: $warnfiller = "adds";
1182: }
1183: } else {
1184: if ($autodrops) {
1185: $warnfiller = "drops";
1186: }
1187: }
1188: unless ($warning eq '') {
1189: $response = $warn_prefix.$warnfiller.$warn_suffix.$warning;
1190: }
1.1 raeburn 1191: }
1192: &print_reply($r,$response,$$tasktitleref{$action});
1193: return;
1194: }
1195:
1196: sub print_setdates_response {
1197: my ($r,$realm,$dom,$crs,$action,$tasktitleref) = @_;
1198: my %settings = &Apache::lonnet::get('environment',['internal.autostart','internal.autoend'],$dom,$crs);
1199: my $currstart = $settings{'internal.autostart'};
1200: my $currend = $settings{'internal.autoend'};
1201: my $response = '';
1202: my ($autostart,$autoend) = &get_dates_from_form();
1.14 ! raeburn 1203: my $showstart = &Apache::lonlocal::locallocaltime($autostart);
1.1 raeburn 1204: my $showend = '';
1.10 raeburn 1205: my $warning = '';
1206: my $warn_prefix = '';
1.1 raeburn 1207: if ($autoend) {
1.14 ! raeburn 1208: $showend = &Apache::lonlocal::locallocaltime($autoend);
1.1 raeburn 1209: } else {
1210: $showend = "'No end date'";
1211: }
1212:
1213: my %cenv = ('internal.autostart' => $autostart,
1214: 'internal.autoend' => $autoend);
1215: my $reply = &Apache::lonnet::put('environment',\%cenv,$dom,$crs);
1216: if ($reply !~ /^ok$/) {
1217: $response = "There was a problem processing your requested changes. The automated enrollment settings for this course have been left unchanged.<br/>";
1218: } else {
1219: if ($currstart == $autostart) {
1220: $response = "The first date for automated enrollment has been left unchanged as $showstart.<br/>";
1221: } else {
1222: $response = "The first date for automated enrollment has been changed to $showstart.<br/>";
1223: }
1224: if ($currend == $autoend) {
1225: $response .= "The last date for automated enrollment has been left unchanged as $showend.<br/>";
1226: } else {
1.9 raeburn 1227: $response .= "The last date for automated enrollment has been changed to $showend.<br/>";
1.1 raeburn 1228: }
1229:
1.14 ! raeburn 1230: # Generate message in case where old first enrollment date was later than today, but new first enrollment date is now today or earlier.
1.1 raeburn 1231:
1232: my $rosterupdated = 0;
1233: my $firstaccess = "";
1234: my $nextupdate = "";
1235: my $lastupdate = "";
1236:
1237: my $nowstamp = time;
1238: my @date_list=localtime(time);
1239: my $cur_year = $date_list[5];
1240: my $curday = $date_list[3];
1241: my $curmonth = $date_list[4];
1242: my $lastmidnt = timelocal(0,0,0,$date_list[3],$date_list[4],$date_list[5]);
1243: my $nextmidnt = 86400 + $lastmidnt;
1244:
1.10 raeburn 1245: my $todayupdate = timelocal(0,30,1,$date_list[3],$date_list[4],$date_list[5]);
1.1 raeburn 1246: my $lastupdate = $todayupdate - 86400;
1247: if ($nowstamp < $todayupdate) {
1248: $nextupdate = "today";
1249: } else {
1250: $nextupdate = "tomorrow";
1251: }
1252: if ($currstart < $lastupdate) {
1253: $rosterupdated = 1;
1254: }
1255: if ($autostart < $nextmidnt ) {
1256: if ( $autostart >= $lastmidnt) {
1257: $firstaccess = "today";
1258: } else {
1259: $firstaccess = "a date prior to today";
1260: }
1261: if (($nowstamp >= $autostart) && ($rosterupdated == 0)) {
1.14 ! raeburn 1262: $response .= qq|<br>Although you have now set the first enrollment date to $firstaccess, automatic enrollment will <b>not</b> occur until the next automatic enrollment update occurs for all LON-CAPA courses at 1.30 am $nextupdate. If you wish to immediately enroll registered students included in the institutional classlist for this class, please visit the <a href="/adm/populate?action=updatenow">roster update page</a>.<br>|;
1.1 raeburn 1263: }
1264: }
1.10 raeburn 1265: $warning = &warning_message($dom,$crs,$action);
1266: $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/>";
1267: unless ($warning eq '') {
1268: $response .= $warn_prefix.$warning;
1269: }
1.1 raeburn 1270: }
1271: &print_reply($r,$response,$$tasktitleref{$action});
1272: return;
1273: }
1274:
1.14 ! raeburn 1275: sub print_setaccess_response {
! 1276: my ($r,$realm,$dom,$crs,$action,$tasktitleref) = @_;
! 1277: my %settings = &Apache::lonnet::get('environment',['default_enrollment_start_date','default_enrollment_end_date','internal.autostart'],$dom,$crs);
! 1278: my $currstart = $settings{'default_enrollment_start_date'};
! 1279: my $currend = $settings{'default_enrollment_end_date'};
! 1280: my $autostart = $settings{'internal.autostart'};
! 1281: my $response = '';
! 1282: my ($startaccess,$endaccess) = &get_dates_from_form();
! 1283: my $showstart = &Apache::lonlocal::locallocaltime($startaccess);
! 1284: my $showend = '';
! 1285: my $warning = '';
! 1286: my $warn_prefix = '';
! 1287: if ($endaccess) {
! 1288: $showend = &Apache::lonlocal::locallocaltime($endaccess);
! 1289: } else {
! 1290: $showend = "'No end date'";
! 1291: }
! 1292:
! 1293: my %cenv = ('default_enrollment_start_date' => $startaccess,
! 1294: 'default_enrollment_end_date' => $endaccess);
! 1295: my $reply = &Apache::lonnet::put('environment',\%cenv,$dom,$crs);
! 1296: if ($reply !~ /^ok$/) {
! 1297: $response = "There was a problem processing your requested changes. The automated enrollment settings for this course have been left unchanged.<br/>";
! 1298: } else {
! 1299: if ($currstart == $startaccess) {
! 1300: $response = "The first access date for students added via automated enrollment has been left unchanged as $showstart.<br/>";
! 1301: } else {
! 1302: $response = "The first access date for students added via automated enrollment has been changed to
! 1303: $showstart.<br/>";
! 1304: }
! 1305: if ($currend == $endaccess) {
! 1306: $response .= "The last access date for students added via automated enrollment has been left unchanged as $showend.<br/>";
! 1307: } else {
! 1308: $response .= "The last access date for students automated enrollment has been changed to
! 1309: $showend.<br/>";
! 1310: }
! 1311:
! 1312: # Generate message in case where old first access date was later than today, but new first access date is now today or earlier.
! 1313:
! 1314: my $accessgiven= 0;
! 1315: my $firstaccess = "";
! 1316: my $nextupdate = "";
! 1317: my $lastupdate = "";
! 1318:
! 1319: my $nowstamp = time;
! 1320: my @date_list=localtime(time);
! 1321: my $cur_year = $date_list[5];
! 1322: my $curday = $date_list[3];
! 1323: my $curmonth = $date_list[4];
! 1324: my $lastmidnt = timelocal(0,0,0,$date_list[3],$date_list[4],$date_list[5]);
! 1325: my $nextmidnt = 86400 + $lastmidnt;
! 1326:
! 1327: my $todayupdate = timelocal(0,30,1,$date_list[3],$date_list[4],$date_list[5]);
! 1328: my $tomorrowupdate = $todayupdate + 86400;
! 1329: my $lastupdate = $todayupdate - 86400;
! 1330:
! 1331: if ($autostart < $nextmidnt) {
! 1332: if ($nowstamp < $todayupdate) {
! 1333: $nextupdate = "at 1.30 am today";
! 1334: } else {
! 1335: $nextupdate = "at 1.30 am tomorrow";
! 1336: }
! 1337: } else {
! 1338: my @enrollstart = &Apache::lonlocal::locallocaltime($autostart);
! 1339: $nextupdate = timelocal(0,30,1,$enrollstart[3],$enrollstart[4],$enrollstart[5]);
! 1340: unless (($enrollstart[2] < 1) || ($enrollstart[2] == 1 && $enrollstart[1] <=30)) {
! 1341: $nextupdate += 86400;
! 1342: }
! 1343: $nextupdate = &Apache::lonlocal::locallocaltime($nextupdate);
! 1344: }
! 1345: if (($currstart < $lastupdate) && ($autostart < $lastupdate)) {
! 1346: $accessgiven = 1;
! 1347: }
! 1348: if ($startaccess < $nextmidnt ) {
! 1349: if ( $startaccess >= $lastmidnt) {
! 1350: $firstaccess = "today";
! 1351: } else {
! 1352: $firstaccess = "a date prior to today";
! 1353: }
! 1354: if (($nowstamp >= $startaccess) && ($accessgiven == 0)) {
! 1355: $response .= qq|<br>Although you have now set the first access date to $firstaccess, automatic enrollment will <b>not</b> occur until the next automatic enrollment update occurs for all LON-CAPA courses $nextupdate. If you wish to grant immediate course access for registered students included in the institutional classlist for this class, please visit the <a href="/adm/populate?action=updatenow">roster update page</a>.<br>|;
! 1356: }
! 1357: }
! 1358: $warning = &warning_message($dom,$crs,$action);
! 1359: $warn_prefix = "<br/><font size ='+1'><b>Warning</b></font>. Although you have set default first and last access dates for students who are added via automatic enrollment, additional action is required.<br/>";
! 1360: unless ($warning eq '') {
! 1361: $response .= $warn_prefix.$warning;
! 1362: }
! 1363: }
! 1364: &print_reply($r,$response,$$tasktitleref{$action});
! 1365: return;
! 1366: }
! 1367:
1.1 raeburn 1368: sub print_notify_response {
1369: my ($r,$realm,$dom,$crs,$action,$tasktitleref) = @_;
1370:
1371: # Get current settings
1372: my %settings = &Apache::lonnet::get('environment',['internal.notifylist','internal.coursecode'],$dom,$crs);
1373: my $notifylist = $settings{'internal.notifylist'};
1374: my $coursecode = $settings{'internal.coursecode'};
1375: my @currpeople = ();
1376: my $notify = 0;
1377: my @people = ();
1.7 raeburn 1378: my $peoplestr = "";
1379: my $response = "";
1380: my $noprocess = 0;
1.1 raeburn 1381:
1382: if ($notifylist =~ m/,/) {
1383: @currpeople = split/,/,$notifylist;
1384: } else {
1.7 raeburn 1385: $currpeople[0] = $notifylist;
1.1 raeburn 1386: }
1387: my $currcount = 0;
1388: foreach (@currpeople) {
1389: unless ($_ eq '') { $currcount ++; }
1390: }
1391:
1392: if ( exists($ENV{'form.notify'}) ) {
1393: $notify=$ENV{'form.notify'};
1394: }
1.7 raeburn 1395: if ( exists($ENV{'form.notifyshow'}) ) {
1396: my $notifyshow = $ENV{'form.notifyshow'};
1397: for (my $i=0; $i<$notifyshow; $i++) {
1398: if ( exists($ENV{"form.note_$i"}) ) {
1399: if ( exists($ENV{"form.notifyname_$i"}) ) {
1400: unless ( $ENV{"form.notifyname_$i"} eq '' ) {
1401: push @people, $ENV{"form.notifyname_$i"};
1402: }
1403: }
1404: }
1405: }
1406: if ($notify) { $peoplestr = join(",",@people); }
1.1 raeburn 1407: } else {
1408: if ($notify) {
1.7 raeburn 1409: if ($currcount) {
1410: $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/>.";
1411: $peoplestr = $notifylist;
1412: @people = @currpeople;
1413: $noprocess = 1;
1414: }
1415: }
1416: }
1417: unless ($noprocess == 1) {
1418: my %cenv = ('internal.notifylist' => $peoplestr);
1419: my $reply = &Apache::lonnet::put('environment',\%cenv,$dom,$crs);
1420: if ($reply !~ /^ok$/) {
1421: $response = "There was a problem processing your requested changes. The notification settings for this course have been left unchanged.<br/>";
1422: } else {
1423: if ($notify) {
1424: if (@people) {
1425: if ($currcount) {
1426: $response .= "Notification of enrollment changes still <b>enabled</b><br/>";
1427: } else {
1428: $response .= "Notification of enrollment changes now <b>enabled</b><br/>";
1429: }
1430: $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";
1431: foreach my $person (@people) {
1432: $response .= "<li>$person</li>\n";
1433: }
1434: $response .= "</ul>\n";
1435: } else {
1436: $response = "Notification of enrollment changes was <b> not enabled</b> as no course coordinators were selected as recipients.<br/>";
1437: }
1438: } else {
1.1 raeburn 1439: if ($currcount) {
1.7 raeburn 1440: $response = "Notification of enrollment changes now <b>disabled</b><br/>";
1.1 raeburn 1441: } else {
1.7 raeburn 1442: $response = "Notification of enrollment changes still <b>disabled</b><br/>";
1.1 raeburn 1443: }
1444: }
1445: }
1446: }
1447: &print_reply($r,$response,$$tasktitleref{$action});
1448: return;
1449: }
1450:
1451: sub print_crosslistings_menu () {
1.13 raeburn 1452: my ($r,$realm,$dom,$crs,$action,$tasktitleref) = @_;
1.1 raeburn 1453: my %settings = &Apache::lonnet::get('environment',['internal.crosslistings','internal.coursecode'],$dom,$crs);
1454: my @currxlists = ();
1455: my @xlists = ();
1456: my $crosscount = 0;
1457: my $removecount = 0;
1458: my $xliststr = '';
1459: my $response = '';
1460: my $coursecode = $settings{'internal.coursecode'};
1461: if ($settings{'internal.crosslistings'} =~ m/,/) {
1462: @currxlists = split/,/,$settings{'internal.crosslistings'};
1463: } elsif ($settings{'internal.crosslistings'} ne '') {
1464: $currxlists[0] = $settings{'internal.crosslistings'};
1465: }
1466:
1467: if (@currxlists > 0) {
1468: for (my $i=0; $i<@currxlists; $i++) {
1469: my $xlist = "cross_".$i;
1470: my $gp = "gp_".$i;
1471: if ( exists($ENV{"form.$xlist"}) ) {
1472: my $xlistentry = '';
1.14 ! raeburn 1473: if ($currxlists[$i] =~ m/^([^:]+)/) {
! 1474: $xlistentry = $1.':';
1.1 raeburn 1475: }
1476: if ( exists($ENV{"form.$gp"}) ) {
1477: $xlistentry .= $ENV{"form.$gp"};
1478: }
1479: push @xlists,$xlistentry;
1480: $crosscount ++;
1481: } else {
1482: $removecount ++;
1483: }
1484: }
1485: }
1486:
1487: if ($crosscount > 1) {
1488: $xliststr = join(",",@xlists);
1489: } else {
1490: $xliststr = $xlists[0];
1491: }
1492: my %cenv = ('internal.crosslistings' => $xliststr);
1493: my $reply = &Apache::lonnet::put('environment',\%cenv,$dom,$crs);
1494: if ($reply !~ /^ok$/) {
1495: $response = "There was a problem processing your requested changes. The automated enrollment settings for this course have been left unchanged.<br/>";
1496: } else {
1497: if ($removecount > 0) {
1.5 raeburn 1498: $response = "A total of $removecount courses are no longer crosslisted with LON-CAPA course: $realm ($coursecode).<br/><br/>";
1.1 raeburn 1499: }
1500: if ($crosscount > 0) {
1501: $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";
1502: foreach (@xlists) {
1503: my ($xlist,$gp) = split/:/,$_;
1504: $response .= "<li>$xlist - ID: $gp</li>\n";
1505: }
1506: $response .= "</ul><br/>\n";
1507: }
1508: }
1509: if ( exists($ENV{'form.numcross'}) ) {
1510: my $numcross = $ENV{'form.numcross'};
1511: if ($numcross > 0) {
1512: my @bgcolors=("#eeeeee","#cccccc");
1513: $response .= qq(
1514: 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/>
1515: <form name="enter" method="post">
1516: <table border="0" cellpadding="2" cellspacing="2" width="100%">
1517: <tr>
1518: <td>
1519: <table border="0" cellspacing="3" cellpadding="3">
1520: <tr bgcolor="#CCCCFF" align="left">
1521: <td><b>Crosslisting</b></td>
1522: <td><b>LON-CAPA section/groupID</b></td>
1523: </tr>
1524: );
1525: for (my $i=0; $i<$numcross; $i++) {
1526: my $colflag = $i%2;
1527: $response .= qq(
1528: <tr bgcolor="$bgcolors[$colflag]" align="left">
1529: <td><input type="text" size="15" name="newcross_$i" /></td>
1530: <td><input type="text" size="10" name="newgroupid_$i" /></td>
1531: </tr>
1532: );
1533: }
1534: $response .= qq( </table>
1535: </td>
1536: </tr>
1537: <tr>
1538: <td align="right">
1539: <input type="button" name="newcross" value="Go" onClick="process('newcross')" />
1540: </td>
1541: </tr>
1542: </table>
1543: <input type=\"hidden\" name=\"numcross\" value=\"$numcross\">
1544: <input type=\"hidden\" name=\"action\" value=\"newcross\">
1545: <input type=\"hidden\" name=\"state\" value=\"process\">
1546: </form>
1547: );
1548: }
1549: }
1550: &print_reply($r,$response,$$tasktitleref{$action});
1551: return;
1552: }
1553:
1554: sub print_crosslistings_response () {
1.13 raeburn 1555: my ($r,$realm,$dom,$crs,$action,$tasktitleref) = @_;
1.5 raeburn 1556: my %settings = &Apache::lonnet::get('environment',['internal.crosslistings','internal.coursecode','internal.courseowner'],$dom,$crs);
1.1 raeburn 1557: my @currxlists = ();
1558: my @xlists = ();
1559: my @allxlists = ();
1.5 raeburn 1560: my @badxlists = ();
1561: my @badowner = ();
1.1 raeburn 1562: my $numcross = 0;
1563: my $xliststr = $settings{'internal.crosslistings'};
1564: my $coursecode = $settings{'internal.coursecode'};
1.5 raeburn 1565: my $owner = $settings{'internal.courseowner'};
1.1 raeburn 1566: my $response = '';
1.10 raeburn 1567: my $warning = '';
1568: my $warn_prefix = '';
1.1 raeburn 1569:
1570: if ($xliststr =~ m/,/) {
1571: @allxlists = split/,/,$xliststr;
1572: } else {
1573: unless ($xliststr eq '') { $allxlists[0] = $xliststr; }
1574: }
1575:
1576: if ( exists($ENV{'form.numcross'}) ) {
1577: $numcross = $ENV{'form.numcross'};
1578: }
1579:
1580: if ($numcross > 0) {
1581: for (my $i=0; $i<$numcross; $i++) {
1582: my $xl = "newcross_".$i;
1583: my $gp = "newgroupid_".$i;
1584: if ( exists($ENV{"form.$xl"}) ) {
1.12 raeburn 1585: my $coursecheck = '';
1.13 raeburn 1586: $coursecheck = &Apache::lonnet::auto_validate_courseID($crs,$dom,$ENV{"form.$xl"});
1.5 raeburn 1587: if ($coursecheck eq 'ok') {
1.12 raeburn 1588: my $addcheck = '';
1.13 raeburn 1589: $addcheck = &Apache::lonnet::auto_new_course($crs,$dom,$ENV{"form.$xl"},$owner);
1.5 raeburn 1590: if ($addcheck eq 'ok') {
1591: push @xlists,$ENV{"form.$xl"}.":".$ENV{"form.$gp"};
1592: } else {
1593: push @badowner,$ENV{"form.$xl"}.":".$ENV{"form.$gp"};
1.12 raeburn 1594: }
1.5 raeburn 1595: } else {
1.6 raeburn 1596: push @badxlists, $ENV{"form.$xl"}.":".$ENV{"form.$gp"}.":".$coursecheck;
1.5 raeburn 1597: }
1.1 raeburn 1598: }
1599: }
1600: push @allxlists, @xlists;
1601: }
1602:
1603: if (@xlists > 0 ) {
1604: unless ($xliststr eq '') { $xliststr .= ","; }
1605: if (@xlists > 1) {
1606: $xliststr .= join(",",@xlists);
1607: } else {
1608: $xliststr .= $xlists[0];
1609: }
1610: my %cenv = ('internal.crosslistings' => $xliststr);
1611: my $reply = &Apache::lonnet::put('environment',\%cenv,$dom,$crs);
1612: if ($reply !~ /^ok$/) {
1.6 raeburn 1613: $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 1614: } else {
1615: $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 1616: foreach (@allxlists) {
1617: my ($xlist,$gp) = split/:/,$_;
1618: $response .= "<li>$xlist - ID: $gp</li>\n";
1619: }
1620: $response .= "</ul><br/><br/>\n";
1621: }
1622: } else {
1623: if ($xliststr =~ m/:/) {
1624: my @oldxlists = ();
1625: if ($xliststr =~ m/,/) {
1626: @oldxlists = split/,/,$xliststr;
1627: } else {
1628: $oldxlists[0] = $xliststr;
1629: }
1630: $response .= "Although no new crosslistings were added, the courses listed below continue to be crosslisted with your LON-CAPA course.<br/><ul>\n";
1631: foreach (@oldxlists) {
1632: my ($xlist,$gp) = split/:/,$_;
1633: $response .= "<li>$xlist - ID: $gp</li>\n";
1634: }
1635: $response .= "</ul><br/><br/>\n";
1.1 raeburn 1636: }
1637: }
1.5 raeburn 1638: if (@badxlists > 0) {
1639: $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";
1640: foreach (@badxlists) {
1.6 raeburn 1641: my ($xlist,$gp,$prob) = split/:/,$_;
1642: $response .= "<li>$xlist - ID: $gp - Error: $prob</li>\n";
1.5 raeburn 1643: }
1644: $response .= "</ul><br/><br/>\n";
1645: }
1646:
1647: if (@badowner > 0) {
1648: $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";
1649: foreach (@badowner) {
1650: my ($xlist,$gp) = split/:/,$_;
1651: $response .= "<li>$xlist - ID: $gp</li>\n";
1652: }
1653: $response .= "</ul><br/><br/>\n";
1654: }
1.1 raeburn 1655:
1.10 raeburn 1656: if (@allxlists > 0) {
1657: $warning = &warning_message($dom,$crs,$action);
1658: $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/>";
1659: unless ($warning eq '') {
1660: $response .= $warn_prefix.$warning;
1661: }
1662: }
1663:
1.1 raeburn 1664: &print_reply($r,$response,$$tasktitleref{$action});
1665: return;
1666: }
1667:
1668: sub print_sections_menu () {
1.13 raeburn 1669: my ($r,$realm,$dom,$crs,$action,$tasktitleref) = @_;
1.8 raeburn 1670: my %settings = &Apache::lonnet::get('environment',['internal.sectionnums','internal.coursecode','internal.courseowner'],$dom,$crs);
1.1 raeburn 1671: my @currsections = ();
1672: my @sections = ();
1.8 raeburn 1673: my @badowner = ();
1674: my @badsections = ();
1.1 raeburn 1675: my $seccount = 0;
1676: my $removecount = 0;
1.6 raeburn 1677: my $addcount = 0;
1.1 raeburn 1678: my $secstr = '';
1679: my $response = '';
1.10 raeburn 1680: my $warning = "";
1681: my $warn_prefix = "";
1.1 raeburn 1682: my $coursecode = $settings{'internal.coursecode'};
1.8 raeburn 1683: my $owner = $settings{'internal.courseowner'};
1.1 raeburn 1684: if ($settings{'internal.sectionnums'} =~ m/,/) {
1685: @currsections = split/,/,$settings{'internal.sectionnums'};
1686: } elsif ($settings{'internal.sectionnums'} ne '') {
1687: $currsections[0] = $settings{'internal.sectionnums'};
1688: }
1.6 raeburn 1689:
1690: if ( exists($ENV{'form.secshow'}) ) {
1.8 raeburn 1691: for (my $i=0; $i<$ENV{'form.secshow'}; $i++) {
1692: my $gp = "loncapasec_".$i;
1693: my $secnum = "secnum_".$i;
1694: my $sec = "sec_".$i;
1695: if ( exists( $ENV{"form.$sec"} ) ) {
1696: my $secentry;
1697: if ( exists( $ENV{"form.$secnum"} ) ) {
1698: $secentry = $ENV{"form.$secnum"}.':';
1699: }
1700: if ( exists( $ENV{"form.$gp"} ) ) {
1701: $secentry .= $ENV{"form.$gp"};
1702: }
1703: if ( grep/^$ENV{"form.$secnum"}:/,@currsections) {
1704: push @sections, $secentry;
1705: $seccount ++;
1706: } else {
1707: my $newsec = $coursecode.$ENV{"form.$secnum"};
1.13 raeburn 1708: my $coursecheck = &Apache::lonnet::auto_validate_courseID($crs,$dom,$newsec);
1.8 raeburn 1709: if ($coursecheck eq 'ok') {
1.13 raeburn 1710: my $addcheck = &Apache::lonnet::auto_new_course($crs,$dom,$newsec,$owner);
1.8 raeburn 1711: if ($addcheck eq 'ok') {
1712: push @sections,$ENV{"form.$secnum"}.":".$ENV{"form.$gp"};
1713: $seccount ++;
1714: $addcount ++;
1715: } else {
1716: push @badowner,$ENV{"form.$secnum"}.":".$ENV{"form.$gp"};
1717: }
1718: } else {
1719: push @badsections, $ENV{"form.$secnum"}.":".$ENV{"form.$gp"}.":".$coursecheck;
1720: }
1721: }
1722: }
1723: }
1724: if (@currsections > 0) {
1725: for (my $i=0; $i<@currsections; $i++) {
1726: if ($currsections[$i] =~ m/^(\w+:)/ ) {
1727: my $oldsec = $1;
1728: unless (grep/^$oldsec/,@sections) {
1729: $removecount ++;
1730: }
1731: }
1732: }
1733: }
1.6 raeburn 1734: } elsif (@currsections > 0) {
1.1 raeburn 1735: for (my $i=0; $i<@currsections; $i++) {
1736: my $sec = "sec_".$i;
1737: my $gp = "secgp_".$i;
1738: if ( exists($ENV{"form.$sec"}) ) {
1739: my $secentry = '';
1.6 raeburn 1740: if ($currsections[$i] =~ m/^(\w+:)/ ) {
1.1 raeburn 1741: $secentry = $1;
1742: }
1743: if ( exists($ENV{"form.$gp"}) ) {
1744: $secentry .= $ENV{"form.$gp"};
1745: }
1746: push @sections,$secentry;
1747: $seccount ++;
1748: } else {
1749: $removecount ++;
1750: }
1751: }
1752: }
1753:
1754: if ($seccount > 1) {
1755: $secstr = join(",",@sections);
1756: } else {
1757: $secstr = $sections[0];
1758: }
1759: my %cenv = ('internal.sectionnums' => $secstr);
1760: my $reply = &Apache::lonnet::put('environment',\%cenv,$dom,$crs);
1761: if ($reply !~ /^ok$/) {
1762: $response = "There was a problem processing your requested changes. The automated enrollment settings for this course have been left unchanged.<br/>";
1763: } else {
1764: if ($removecount > 0) {
1765: $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/>";
1766: }
1.6 raeburn 1767: if ($addcount > 0) {
1768: $response .= "A total of $addcount sections have been added to the list of
1769: sections which contribute to enrollment in LON-CAPA course: $realm ($coursecode).<br/><br/>";
1770: }
1.1 raeburn 1771: if ($seccount > 0) {
1.6 raeburn 1772: $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 1773: foreach (@sections) {
1774: my ($sec,$gp) = split/:/,$_;
1775: $response .= "<li>$sec - ID: $gp</li>\n";
1776: }
1777: $response .= "</ul><br/>\n";
1778: }
1779: }
1780:
1.8 raeburn 1781: if (@badsections > 0) {
1782: $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";
1783: foreach (@badsections) {
1784: my ($secnum,$gp,$prob) = split/:/,$_;
1785: $response .= "<li>$secnum - ID: $gp - Error: $prob</li>\n";
1786: }
1787: $response .= "</ul><br/><br/>\n";
1788: }
1789:
1790: if (@badowner > 0) {
1791: $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";
1792: foreach (@badowner) {
1793: my ($secnum,$gp) = split/:/,$_;
1794: $response .= "<li>$secnum - ID: $gp</li>\n";
1795: }
1796: $response .= "</ul><br/><br/>\n";
1797: }
1798:
1.10 raeburn 1799: if ($seccount > 0) {
1800: $warning = &warning_message($dom,$crs,$action);
1801: $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/>";
1802: unless ($warning eq '') {
1803: $response .= $warn_prefix.$warning;
1804: }
1805: }
1806:
1.1 raeburn 1807: if ( exists($ENV{'form.numsec'}) ) {
1808: my $numsec = $ENV{'form.numsec'};
1809: if ($numsec > 0) {
1810: my @bgcolors=("#eeeeee","#cccccc");
1811: $response .= qq(
1812: 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/>
1813: <form name="enter" method="post">
1814: <table border="0" cellpadding="2" cellspacing="2" width="100%">
1815: <tr>
1816: <td>
1817: <table border="0" cellspacing="3" cellpadding="3">
1818: <tr bgcolor="#CCCCFF" align="left">
1819: <td><b>Section number</b></td>
1820: <td><b>LON-CAPA section/groupID</b></td>
1821: </tr>
1822: );
1823: for (my $i=0; $i<$numsec; $i++) {
1824: my $colflag = $i%2;
1825: $response .= qq(
1826: <tr bgcolor="$bgcolors[$colflag]" align="left">
1827: <td><input type="text" size="15" name="newsec_$i" /></td>
1828: <td><input type="text" size="10" name="newsecgp_$i" /></td>
1829: </tr>
1830: );
1831: }
1832: $response .= qq( </table>
1833: </td>
1834: </tr>
1835: <tr>
1836: <td align="right">
1837: <input type="button" name="newsections" value="Go" onClick="process('newsections')" />
1838: </td>
1839: </tr>
1840: </table>
1841: <input type=\"hidden\" name=\"numsec\" value=\"$numsec\">
1842: <input type=\"hidden\" name=\"action\" value=\"newsections\">
1843: <input type=\"hidden\" name=\"state\" value=\"process\">
1844: </form>
1845: );
1846: }
1847: }
1848: &print_reply($r,$response,$$tasktitleref{$action});
1849: return;
1850: }
1851:
1852: sub print_sections_response () {
1.13 raeburn 1853: my ($r,$realm,$dom,$crs,$action,$tasktitleref) = @_;
1.8 raeburn 1854: my %settings = &Apache::lonnet::get('environment',['internal.sectionnums','internal.coursecode','internal.courseowner'],$dom,$crs);
1.1 raeburn 1855: my @currsections = ();
1856: my @sections = ();
1857: my @allsections = ();
1.8 raeburn 1858: my @badowner = ();
1859: my @badsections = ();
1.1 raeburn 1860: my $numsec = 0;
1861: my $secstr = $settings{'internal.sectionnums'};
1862: my $coursecode = $settings{'internal.coursecode'};
1.8 raeburn 1863: my $owner = $settings{'internal.courseowner'};
1.1 raeburn 1864: my $response = '';
1.8 raeburn 1865: my $putreply = '';
1.10 raeburn 1866: my $warning = '';
1867: my $warn_prefix = '';
1.1 raeburn 1868: if ($secstr =~ m/,/) {
1869: @allsections = split/,/,$secstr;
1870: } else {
1871: unless ($secstr eq '') { $allsections[0] = $secstr; }
1872: }
1873:
1874: if ( exists($ENV{'form.numsec'}) ) {
1875: $numsec = $ENV{'form.numsec'};
1876: }
1.8 raeburn 1877:
1.1 raeburn 1878: if ($numsec > 0) {
1879: for (my $i=0; $i<$numsec; $i++) {
1880: my $sec = "newsec_".$i;
1881: my $gp = "newsecgp_".$i;
1882: if ( exists($ENV{"form.$sec"}) ) {
1.8 raeburn 1883: unless ( (grep/^$ENV{"form.$sec"}:/,@allsections) || (grep/^$ENV{"form.$sec"}:/,@sections) ) {
1884: my $newsec = $coursecode.$ENV{"form.$sec"};
1.13 raeburn 1885: my $coursecheck = &Apache::lonnet::auto_validate_courseID($crs,$dom,$newsec);
1.8 raeburn 1886: if ($coursecheck eq 'ok') {
1.13 raeburn 1887: my $addcheck = &Apache::lonnet::auto_new_course($crs,$dom,$newsec,$owner);
1.8 raeburn 1888: if ($addcheck eq 'ok') {
1889: push @sections,$ENV{"form.$sec"}.":".$ENV{"form.$gp"};
1890: } else {
1891: push @badowner,$ENV{"form.$sec"}.":".$ENV{"form.$gp"};
1892: }
1893: } else {
1894: push @badsections, $ENV{"form.$sec"}.":".$ENV{"form.$gp"}.":".$coursecheck;
1895: }
1896: }
1.1 raeburn 1897: }
1898: }
1899: push @allsections, @sections;
1900: }
1.8 raeburn 1901:
1.1 raeburn 1902: if (@sections > 0 ) {
1903: unless ($secstr eq '') { $secstr .= ","; }
1904: if (@sections > 1) {
1905: $secstr .= join(",",@sections);
1906: } else {
1907: $secstr .= $sections[0];
1908: }
1909: my %cenv = ('internal.sectionnums' => $secstr);
1.8 raeburn 1910: $putreply = &Apache::lonnet::put('environment',\%cenv,$dom,$crs);
1911: if ($putreply !~ /^ok$/) {
1912: $response = "There was a problem processing your requested changes. The automated enrollment settings for this course have been left unchanged.<br/><br/>";
1913: }
1914: }
1915:
1916: if ($putreply =~ /^ok/) {
1917: $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";
1918: foreach (@allsections) {
1919: my ($sec,$gp) = split/:/,$_;
1920: $response .= "<li>$sec - ID: $gp</li>\n";
1921: }
1922: $response .= "</ul><br/><br/>\n";
1923: }
1924:
1925: if (@badsections > 0) {
1926: $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";
1927: foreach (@badsections) {
1928: my ($secnum,$gp,$prob) = split/:/,$_;
1929: $response .= "<li>$secnum - ID: $gp - Error: $prob</li>\n";
1.1 raeburn 1930: }
1.8 raeburn 1931: $response .= "</ul><br/><br/>\n";
1.1 raeburn 1932: }
1.8 raeburn 1933:
1934: if (@badowner > 0) {
1935: $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";
1936: foreach (@badowner) {
1937: my ($secnum,$gp) = split/:/,$_;
1938: $response .= "<li>$secnum - ID: $gp</li>\n";
1939: }
1940: $response .= "</ul><br/><br/>\n";
1.1 raeburn 1941: }
1.8 raeburn 1942:
1.10 raeburn 1943: if (@allsections > 0) {
1944: $warning = &warning_message($dom,$crs,$action);
1945: $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/>";
1946: unless ($warning eq '') {
1947: $response .= $warn_prefix.$warning;
1948: }
1949: }
1950:
1.1 raeburn 1951: &print_reply($r,$response,$$tasktitleref{$action});
1952: return;
1953: }
1954:
1955: sub print_photos_response () {
1956: my ($r,$realm,$dom,$crs,$action,$tasktitleref) = @_;
1957: my %settings = &Apache::lonnet::get('environment',['internal.showphotos'],$dom,$crs);
1958: my $currphotos = $settings{'internal.showphotos'};
1959: my $showphotos = '';
1960: if ( exists($ENV{'form.showphotos'}) ) {
1961: $showphotos=$ENV{'form.showphotos'};
1962: }
1.8 raeburn 1963:
1.1 raeburn 1964: my $response = "";
1965: my %cenv = ('internal.showphotos' => $showphotos);
1966: my $reply = &Apache::lonnet::put('environment',\%cenv,$dom,$crs);
1967: if ($reply !~ /^ok$/) {
1968: $response = "There was a problem processing your requested change. The student photo import setting for this course has been left unchanged.<br/>";
1969: } else {
1970: if ($showphotos) {
1971: if ($currphotos) {
1972: $response = "Retrieval of student photos is still <b>enabled</b><br/>";
1973: } else {
1974: $response = "Retrieval of student photos in now <b>enabled</b><br/>";
1975: }
1976: } else {
1977: if ($currphotos) {
1978: $response = "Retrieval of student photos is now <b>disabled</b><br/>";
1979: } else {
1980: $response = "Retrieval of student photos is still <b>disabled</b><br/>";
1981: }
1982: }
1983: }
1984: &print_reply($r,$response,$$tasktitleref{$action});
1985: return;
1986: }
1987:
1988: sub print_update_result () {
1.13 raeburn 1989: my ($r,$realm,$dom,$crs,$action,$tasktitleref) = @_;
1.1 raeburn 1990: my $response = '';
1991: my $updateadds = 0;
1992: my $updatedrops = 0;
1993: my $changecount = 0;
1994: my %affiliates = ();
1995: my %reply = ();
1996: my @allcourses = ();
1997: my %LC_code = ();
1998: my $logmsg = '';
1.5 raeburn 1999: my $newusermsg = '';
1.1 raeburn 2000:
1.14 ! raeburn 2001: my %settings = &Apache::lonnet::get('environment',['internal.coursecode','internal.sectionnums','internal.crosslistings','internal.authtype','internal.autharg'],$dom,$crs);
1.1 raeburn 2002: my $coursecode = $settings{'internal.coursecode'};
2003: my $authtype = $settings{'internal.authtype'};
2004: my $autharg = $settings{'internal.autharg'};
1.14 ! raeburn 2005: my ($startaccess,$endaccess) = &get_dates_from_form();
! 2006:
1.1 raeburn 2007: if ( exists($ENV{'form.updateadds'}) ) {
2008: $updateadds = $ENV{'form.updateadds'};
2009: }
2010: if ( exists($ENV{'form.updatedrops'}) ) {
2011: $updatedrops = $ENV{'form.updatedrops'};
2012: }
2013: if (!$updateadds && !$updatedrops) {
2014: $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.";
2015: } elsif ($coursecode eq '') {
2016: $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";
2017: } else {
2018: # Get complete list of course sections to update
2019: my @currsections = ();
2020: my @currxlists = ();
2021:
2022: if ($settings{'internal.sectionnums'} =~ m/,/) {
2023: @currsections = split/,/,$settings{'internal.sectionnums'};
2024: } elsif ($settings{'internal.sectionnums'} ne '') {
2025: $currsections[0] = $settings{'internal.sectionnums'};
2026: }
2027:
2028: if ($settings{'internal.crosslistings'} =~ m/,/) {
2029: @currxlists = split/,/,$settings{'internal.crosslistings'};
2030: } elsif ($settings{'internal.crosslistings'} ne '') {
2031: $currxlists[0] = $settings{'internal.crosslistings'};
2032: }
2033:
2034: if (@currxlists > 0) {
2035: foreach (@currxlists) {
2036: if (m/^(\w+):(\w*)$/) {
2037: unless (grep/^$1$/,@allcourses) {
2038: push @allcourses,$1;
2039: $LC_code{$1} = $2;
2040: }
2041: }
2042: }
2043: }
2044:
2045: if (@currsections > 0) {
2046: foreach (@currsections) {
2047: if (m/^(\w+):(\w*)$/) {
2048: my $sec = $coursecode.$1;
2049: my $gp = $2;
2050: unless (grep/^$sec$/,@allcourses) {
2051: push @allcourses,$sec;
2052: $LC_code{$sec} = $gp;
2053: }
2054: }
2055: }
2056: }
2057:
2058: if (@allcourses > 0) {
2059: @{$affiliates{$crs}} = @allcourses;
1.14 ! raeburn 2060: my $outcome = &Apache::lonnet::fetch_enrollment_query('updatenow',\%affiliates,\%reply,$dom,$crs);
1.1 raeburn 2061: if ($reply{$crs} > 0) {
1.14 ! raeburn 2062: ($changecount,$response) = &LONCAPA::Enrollment::update_LC($dom,$crs,$updateadds,$updatedrops,$startaccess,$endaccess,$authtype,$autharg,\@allcourses,\%LC_code,\$logmsg,\$newusermsg,"updatenow");
1.1 raeburn 2063: } else {
2064: $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.";
2065: }
2066: } else {
2067: $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)";
2068: }
2069: }
2070: unless ($logmsg eq '') {
2071: my $loglength = length($logmsg);
2072: $logmsg = substr($logmsg,0,$loglength-4);
2073: $logmsg = "<br/><br/>The following messages were generated by the roster update process: <br/><ul><li>".$logmsg."</ul><br/>";
2074: }
1.5 raeburn 2075: unless ($newusermsg eq '') {
2076: $newusermsg = substr( $newusermsg,0,rindex($newusermsg,'<li>') );
2077: $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/>";
2078: }
2079: $response .= $logmsg.$newusermsg;
1.1 raeburn 2080: &print_reply($r,$response,$$tasktitleref{$action});
2081: return;
1.10 raeburn 2082: }
2083:
1.14 ! raeburn 2084: sub print_viewclass_response {
! 2085: my ($r,$realm,$dom,$crs,$action,$tasktitleref) = @_;
! 2086: my $response;
! 2087: my $chgtotal = 0;
! 2088: my $chgok = 0;
! 2089: my $chgfail = 0;
! 2090: my $othdom = 0;
! 2091: my $cid = $dom."_".$crs;
! 2092: my %chg = ();
! 2093: my %nochg = ();
! 2094: my %otherdom = ();
! 2095: my $modreply = '';
! 2096: my $classlist = &Apache::loncoursedata::get_classlist($cid,$dom,$crs);
! 2097: my $endidx = &Apache::loncoursedata::CL_END;
! 2098: my $startidx = &Apache::loncoursedata::CL_START;
! 2099: my $ididx=&Apache::loncoursedata::CL_ID;
! 2100: my $secidx=&Apache::loncoursedata::CL_SECTION;
! 2101: my $typeidx=&Apache::loncoursedata::CL_TYPE;
! 2102: foreach (sort keys %ENV) {
! 2103: if (/^form\.switch:(.+)$/) {
! 2104: my $student = $1;
! 2105: my ($uname,$udom) = split/:/,$student;
! 2106: my $sdata = $classlist->{$student};
! 2107: my $section = $sdata->[$secidx];
! 2108: my $uid = $sdata->[$ididx];
! 2109: my $start = $sdata->[$startidx];
! 2110: my $end = $sdata->[$endidx];
! 2111: my $type = $sdata->[$typeidx];
! 2112: $chgtotal ++;
! 2113: my $newtype = 'auto';
! 2114: my $change = 'auto';
! 2115: my $oldtype = 'manual';
! 2116: if ($type eq 'auto') {
! 2117: $oldtype = 'auto';
! 2118: $newtype = '';
! 2119: $change = 'manual';
! 2120: }
! 2121: if ($udom eq $dom) {
! 2122: $modreply = &Apache::lonnet::modify_student_enrollment($udom,$uname,$uid,'','','','',$section,$end,$start,$newtype,$cid);
! 2123: if ($modreply eq 'ok') {
! 2124: $chgok ++;
! 2125: $chg{$student} = "Changed to $change";
! 2126: } else {
! 2127: $chgfail ++;
! 2128: $nochg{$student} = "Still set to $oldtype";
! 2129: }
! 2130: } else {
! 2131: $othdom ++;
! 2132: $otherdom{$student} = "Still set to $oldtype";
! 2133: }
! 2134: }
! 2135: }
! 2136: if ($chgtotal > 0) {
! 2137: $response = "You requested a change in enrollment type for $chgtotal students.<br /><br />\n";
! 2138: $classlist = &Apache::loncoursedata::get_classlist($cid,$dom,$crs);
! 2139: if ($chgok > 0) {
! 2140: $response .= "The following $chgok changes were successful:<br />";
! 2141: $response .= &enrolltype_result(\%chg,$classlist,$endidx,$startidx,$ididx,$secidx,$typeidx);
! 2142: }
! 2143: if ($chgfail > 0) {
! 2144: $response .= "The following $chgfail students were not modified successfully: <br />";
! 2145: $response .= &enrolltype_result(\%nochg,$classlist,$endidx,$startidx,$ididx,$secidx,$typeidx);
! 2146: }
! 2147: if ($othdom > 0) {
! 2148: $response .= "The following $othdom students were not modified because students must be in the same LON-CAPA domain as the course, in order to be set to an enrollment type of 'auto':<br />";
! 2149: $response .= &enrolltype_result(\%otherdom,$classlist,$endidx,$startidx,$ididx,$secidx,$typeidx);
! 2150: }
! 2151: }
! 2152: &print_reply($r,$response,$$tasktitleref{$action});
! 2153: return;
! 2154: }
! 2155:
! 2156: sub enrolltype_result {
! 2157: my ($changes,$classlist,$endidx,$startidx,$ididx,$secidx,$typeidx) = @_;
! 2158: my $reply = "
! 2159: <table border='2'>
! 2160: <tr>
! 2161: <th>username</th>
! 2162: <th>domain</th>
! 2163: <th>ID</th>
! 2164: <th>student name</th>
! 2165: <th>section</th>
! 2166: <th>start date</th>
! 2167: <th>end date</th>
! 2168: <th>enrollment change</th>
! 2169: </tr>";
! 2170: foreach (sort keys %{$changes}) {
! 2171: my $sdata = $classlist->{$_};
! 2172: my ($uname,$udom) = split/:/,$_;
! 2173: my $section = $sdata->[$secidx];
! 2174: my $uid = $sdata->[$ididx];
! 2175: my $start = $sdata->[$startidx];
! 2176: my $end = $sdata->[$endidx];
! 2177: my $type = $sdata->[$typeidx];
! 2178: if (! defined($start) || $start == 0) {
! 2179: $start = &mt('none');
! 2180: } else {
! 2181: $start = &Apache::lonlocal::locallocaltime($start);
! 2182: }
! 2183: if (! defined($end) || $end == 0) {
! 2184: $end = &mt('none');
! 2185: } else {
! 2186: $end = &Apache::lonlocal::locallocaltime($end);
! 2187: }
! 2188: if (!defined($section) || ($section eq '')) {
! 2189: $section eq ' ';
! 2190: }
! 2191: if (!defined($uid) || ($uid eq '')) {
! 2192: $uid = ' ';
! 2193: }
! 2194: $reply .= "
! 2195: <tr>
! 2196: <td>$uname</td>
! 2197: <td>$udom</td>
! 2198: <td>$uid</td>
! 2199: <td>".&Apache::loncommon::plainname($uname,$udom)."</td>
! 2200: <td>$section</td>
! 2201: <td>$start</td>
! 2202: <td>$end</td>
! 2203: <td>$$changes{$_}</td>
! 2204: </tr>";
! 2205: }
! 2206: $reply .= "</table>";
! 2207: return $reply;
! 2208: }
! 2209:
1.10 raeburn 2210: sub warning_message {
2211: my ($dom,$crs,$caller) = @_;
2212: my %settings = &Apache::lonnet::get('environment',['internal.autoadds','internal.autodrops','internal.sectionnums','internal.crosslistings','internal.autostart','internal.autoend'],$dom,$crs);
2213: my $currend = '';
2214: my $currstart = '';
2215: my $currsecs = '';
2216: my $currxlists = '';
2217: my $warning = '';
2218: my $curradds = '';
2219: my $currdrops = '';
2220: if ( defined($settings{'internal.autoadds'}) ) {
2221: $curradds = $settings{'internal.autoadds'};
2222: }
2223: if (defined($settings{'internal.autodrops'}) ) {
2224: $currdrops = $settings{'internal.autodrops'};
2225: }
2226: if ( defined($settings{'internal.autostart'}) ) {
2227: $currstart = $settings{'internal.autostart'};
2228: }
2229: if ( defined($settings{'internal.autoend'}) ) {
2230: $currend = $settings{'internal.autoend'};
2231: }
2232: if ( defined($settings{'internal.sectionnums'}) ) {
2233: $currsecs = $settings{'internal.sectionnums'};
2234: }
2235: if ( defined($settings{'internal.crosslistings'}) ) {
2236: $currxlists = $settings{'internal.crosslistings'}
2237: }
2238: unless ($caller eq 'setdates') {
2239: if ( ($currstart eq '') && ($currend eq '') ) {
2240: $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>";
2241: }
2242: }
2243: unless ( ($caller eq 'sections') || ($caller eq 'crosslist') ) {
2244: if ( ($currsecs eq '') && ($currxlists eq '') ) {
2245: $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/>";
2246: }
2247: }
2248: unless ( $caller eq 'chgsettings') {
2249: if ( (!$curradds) && (!$currdrops) ) {
2250: $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/>.";
2251: }
2252: }
2253: return $warning;
1.1 raeburn 2254: }
2255:
2256: sub print_reply () {
2257: my ($r,$response,$caller) = @_;
2258: $r->print("
2259: <br/><table width=\"100%\" border=\"0\" cellpadding=\"2\" cellspacing=\"2\">
2260: <tr>
1.14 ! raeburn 2261: <td align=\"left\"><b>$caller</b> - result<br/><br/>$response</td>
1.1 raeburn 2262: </tr>
2263: </table>
2264: ");
2265: return;
2266: }
2267:
2268: sub setup_date_selectors {
1.14 ! raeburn 2269: my ($starttime,$endtime,$action) = @_;
1.1 raeburn 2270: if (! defined($starttime)) {
2271: $starttime = time;
1.14 ! raeburn 2272: if ($action eq 'setdates') {
! 2273: if (exists($ENV{'course.'.$ENV{'request.course.id'}.
1.1 raeburn 2274: '.default_enrollment_start_date'})) {
1.14 ! raeburn 2275: $starttime = $ENV{'course.'.$ENV{'request.course.id'}.
1.1 raeburn 2276: '.default_enrollment_start_date'};
1.14 ! raeburn 2277: }
1.1 raeburn 2278: }
2279: }
2280: if (! defined($endtime)) {
2281: $endtime = time+(6*30*24*60*60); # 6 months from now, approx
1.14 ! raeburn 2282: if ($action eq 'setdates') {
! 2283: if (exists($ENV{'course.'.$ENV{'request.course.id'}.
1.1 raeburn 2284: '.default_enrollment_end_date'})) {
1.14 ! raeburn 2285: $endtime = $ENV{'course.'.$ENV{'request.course.id'}.
1.1 raeburn 2286: '.default_enrollment_end_date'};
1.14 ! raeburn 2287: }
1.1 raeburn 2288: }
2289: }
2290: my $startdateform = &Apache::lonhtmlcommon::date_setter('enter',
2291: 'startdate',
2292: $starttime);
2293: my $enddateform = &Apache::lonhtmlcommon::date_setter('enter',
2294: 'enddate',
2295: $endtime);
2296: return ($startdateform,$enddateform);
2297: }
2298:
2299: sub get_dates_from_form {
1.14 ! raeburn 2300: my $startdate;
! 2301: my $enddate;
! 2302: $startdate = &Apache::lonhtmlcommon::get_date_from_form('startdate');
! 2303: $enddate = &Apache::lonhtmlcommon::get_date_from_form('enddate');
1.1 raeburn 2304: if ( exists ($ENV{'form.no_end_date'}) ) {
2305: $enddate = 0;
2306: }
2307: return ($startdate,$enddate);
2308: }
2309:
2310: sub date_setting_table {
1.14 ! raeburn 2311: my ($starttime,$endtime,$action) = @_;
! 2312: my ($startform,$endform) = &setup_date_selectors($starttime,$endtime,$action);
1.1 raeburn 2313: my $perpetual = '<nobr><input type="checkbox" name="no_end_date"';
1.14 ! raeburn 2314: if (($action eq 'setdates' && defined($endtime) && $endtime == 0) || (($action eq 'setaccess' || $action eq 'updatenow') && ($endtime eq '' || $endtime == 0)) ) {
1.1 raeburn 2315: $perpetual .= ' checked';
2316: }
2317: $perpetual.= ' />'.' no ending date</nobr>';
2318: my $start_table = '';
2319: $start_table .= "<table>\n";
2320: $start_table .= '<tr><td align="right">Starting Date</td>'.
2321: '<td>'.$startform.'</td>'.
2322: '<td> </td>'."</tr>\n";
2323: $start_table .= "</table>";
2324: my $end_table = '';
2325: $end_table .= "<table>\n";
2326: $end_table .= '<tr><td align="right">Ending Date</td>'.
2327: '<td>'.$endform.'</td>'.
2328: '<td>'.$perpetual.'</td>'."</tr>\n";
2329: $end_table .= "</table>\n";
2330: return ($start_table, $end_table);
2331: }
2332:
2333: ###################################################################
2334: sub handler {
2335: my $r = shift;
2336: if ($r->header_only) {
2337: $r->content_type('text/html');
2338: $r->send_http_header;
2339: return OK;
2340: }
2341: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['action','state']);
2342: # Needs to be in a course
2343: if (! (($ENV{'request.course.fn'}) && (&Apache::lonnet::allowed('cst',$ENV{'request.course.id'})))) {
2344: # Not in a course, or not allowed to modify parms
2345: $ENV{'user.error.msg'}="/adm/populate:cst:0:0:Cannot drop or add students";
2346: return HTTP_NOT_ACCEPTABLE;
2347: }
2348: # Start page
2349: $r->content_type('text/html');
2350: $r->send_http_header;
2351:
1.14 ! raeburn 2352: my @tasks = ("information","chgsettings","setdates","setaccess","notify","crosslist","sections","photos","updatenow","viewclass");
1.1 raeburn 2353:
2354: my %tasklong = (
2355: information => "Task information",
2356: chgsettings => "Automated adds/drops",
2357: setdates => "Change enrollment dates",
1.14 ! raeburn 2358: setaccess => "Change access dates",
1.1 raeburn 2359: notify => "Notification of changes",
2360: crosslist => "Change crosslistings",
2361: sections => "Section settings",
2362: photos => "Student photos",
2363: updatenow => "Update roster now",
2364: newcross => "Add crosslistings",
1.14 ! raeburn 2365: newsections => "Add sections",
! 2366: viewclass => "View students and type",
1.1 raeburn 2367: );
2368:
2369: my %tasktitle = (
2370: chgsettings => "Changes to nightly automated enrollments",
2371: setdates => "Changes to first and/or last automated enrollment dates",
1.14 ! raeburn 2372: setaccess => "Changes to default start and/or end dates for student access",
1.1 raeburn 2373: notify => "Notification of enrollment changes",
2374: crosslist => "Changes to crosslistings",
2375: sections => "Changes to section settings",
2376: photos => "Automatic import of student photos",
2377: updatenow => "Immediate course roster update",
2378: newcross => "Adding new crosslisted courses",
1.14 ! raeburn 2379: newsections => "Adding new course sections",
! 2380: viewclass => "Viewing class roster and enrollment type"
1.1 raeburn 2381: );
2382:
2383: my $realm = '';
2384: if ( exists($ENV{'request.course.id'}) ) {
2385: $realm= $ENV{'course.'.$ENV{'request.course.id'}.'.description'};
2386: }
2387: unless ($realm) { $realm=' '; }
2388: my $dom = $ENV{'course.'.$ENV{'request.course.id'}.'.domain'};
2389: my $crs = $ENV{'course.'.$ENV{'request.course.id'}.'.num'};
2390:
2391: #
2392: # Main switch on form.action and form.state, as appropriate
2393: #
2394:
2395: my $action = "information";
2396: if ( exists($ENV{'form.action'}) ) {
2397: $action = $ENV{'form.action'};
2398: }
2399: my $state = "choose";
2400:
2401: if ( exists($ENV{'form.state'}) ) {
2402: $state = $ENV{'form.state'};
2403: }
2404:
2405: if ($action eq "information") {
2406: $r->print(&header());
2407: } else {
2408: if ($state eq "choose") {
2409: $r->print(&choose_header());
2410: } else {
2411: if ($action eq "crosslist") {
2412: if ( exists($ENV{'form.numcross'}) ) {
2413: if ( $ENV{'form.numcross'} > 0 ) {
2414: $r->print(&choose_header());
2415: } else {
2416: $r->print(&header());
2417: }
2418: } else {
2419: $r->print(&header());
2420: }
2421: } elsif ($action eq "sections") {
2422: if ( exists($ENV{'form.numsec'}) ) {
2423: if ( $ENV{'form.numsec'} > 0 ) {
2424: $r->print(&choose_header());
2425: } else {
2426: $r->print(&header());
2427: }
2428: } else {
2429: $r->print(&header());
2430: }
2431: } else {
2432: $r->print(&header());
2433: }
2434: }
2435: }
1.12 raeburn 2436:
1.1 raeburn 2437: my $reply = 0;
2438: unless ($state eq "choose") { $reply = 1; }
2439:
2440: &print_mainbox($r,\%tasklong,$realm,$reply);
2441: &print_navmenu($r,\@tasks,\%tasklong);
2442:
2443: if (($state eq "choose") || ($action eq "information")) {
1.13 raeburn 2444: &print_main_frame($r,$realm,$dom,$crs,\%tasktitle);
1.1 raeburn 2445: } elsif ($action eq "chgsettings") {
2446: &print_chgsettings_response($r,$realm,$dom,$crs,$action,\%tasktitle);
2447: } elsif ($action eq "setdates") {
2448: &print_setdates_response($r,$realm,$dom,$crs,$action,\%tasktitle);
1.14 ! raeburn 2449: } elsif ($action eq "setaccess") {
! 2450: &print_setaccess_response($r,$realm,$dom,$crs,$action,\%tasktitle);
1.1 raeburn 2451: } elsif ($action eq "notify") {
2452: &print_notify_response($r,$realm,$dom,$crs,$action,\%tasktitle);
2453: } elsif ($action eq "sections") {
1.13 raeburn 2454: &print_sections_menu($r,$realm,$dom,$crs,$action,\%tasktitle);
1.1 raeburn 2455: } elsif ($action eq "crosslist") {
1.13 raeburn 2456: &print_crosslistings_menu($r,$realm,$dom,$crs,$action,\%tasktitle);
1.1 raeburn 2457: } elsif ($action eq "updatenow") {
1.13 raeburn 2458: &print_update_result($r,$realm,$dom,$crs,$action,\%tasktitle);
1.1 raeburn 2459: } elsif ($action eq "photos") {
2460: &print_photos_response($r,$realm,$dom,$crs,$action,\%tasktitle);
2461: } elsif ($action eq "newcross") {
1.13 raeburn 2462: &print_crosslistings_response($r,$realm,$dom,$crs,$action,\%tasktitle);
1.1 raeburn 2463: } elsif ($action eq "newsections") {
1.13 raeburn 2464: &print_sections_response($r,$realm,$dom,$crs,$action,\%tasktitle);
1.14 ! raeburn 2465: } elsif ($action eq "viewclass") {
! 2466: &print_viewclass_response($r,$realm,$dom,$crs,$action,\%tasktitle);
1.1 raeburn 2467: }
2468: &print_doc_base($r);
2469: return OK;
2470: }
2471: ###################################################################
2472: 1;
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>