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