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