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