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