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