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