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