Annotation of loncom/interface/lonpopulate.pm, revision 1.35
1.4 albertel 1: # automated enrollment configuration handler
1.35 ! albertel 2: # $Id: lonpopulate.pm,v 1.34 2006/02/07 05:08:32 raeburn Exp $
1.4 albertel 3: #
4: # Copyright Michigan State University Board of Trustees
5: #
6: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
7: #
8: # LON-CAPA is free software; you can redistribute it and/or modify
9: # it under the terms of the GNU General Public License as published by
10: # the Free Software Foundation; either version 2 of the License, or
11: # (at your option) any later version.
12: #
13: # LON-CAPA is distributed in the hope that it will be useful,
14: # but WITHOUT ANY WARRANTY; without even the implied warranty of
15: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16: # GNU General Public License for more details.
17: #
18: # You should have received a copy of the GNU General Public License
19: # along with LON-CAPA; if not, write to the Free Software
20: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21: #
22: # /home/httpd/html/adm/gpl.txt
23: #
24: # http://www.lon-capa.org/
25: #
1.1 raeburn 26: package Apache::lonpopulate;
27:
28: use strict;
29: use lib qw(/home/httpd/lib/perl);
1.7 raeburn 30: use Apache::lonnet;
31: use Apache::loncommon;
32: use Apache::lonhtmlcommon;
1.3 albertel 33: use Apache::lonlocal;
1.14 raeburn 34: use Apache::loncoursedata;
1.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("
356: <input type=\"radio\" name=\"autoadds\" value=\"1\" checked=\"true\" /> Enable
357: <input type=\"radio\" name=\"autoadds\" value=\"0\" /> Disable
358: ");
359: } else {
360: $r->print("
361: <input type=\"radio\" name=\"autoadds\" value=\"1\" /> Enable
362: <input type=\"radio\" name=\"autoadds\" value=\"0\" checked=\"true\" /> Disable
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("
373: <input type=\"radio\" name=\"autodrops\" value=\"1\" checked=\"true\" /> Enable
374: <input type=\"radio\" name=\"autodrops\" value=\"0\" /> Disable");
375: } else {
376: $r->print("
377: <input type=\"radio\" name=\"autodrops\" value=\"1\" /> Enable
378: <input type=\"radio\" name=\"autodrops\" value=\"0\" checked=\"true\" /> Disable");
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\">
392: <input type=\"button\" name=\"chgsettings\" value=\"Go\" onClick=\"process('chgsettings')\" />
393: </td>
394: </tr>
395: </table>
396: <input type=\"hidden\" name=\"action\" value=\"$action\">
397: <input type=\"hidden\" name=\"state\" value=\"process\">
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">
469: <input type="button" name="setdates" value="Go" onClick="process('setdates')" />
470: </td>
471: </tr>
472: </table>
1.14 raeburn 473: <input type="hidden" name="action" value="$action">
474: <input type="hidden" name="state" value="process">
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">
483: <input type="button" name="$action" value="Go" onClick="process('$action')" />
484: </td>
485: </tr>
486: </table>
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("
520: <input type=\"radio\" name=\"notify\" value=\"1\" checked=\"true\" /> Yes
521: <input type=\"radio\" name=\"notify\" value=\"0\" /> No
522: ");
523: } else {
524: $r->print("
525: <input type=\"radio\" name=\"notify\" value=\"1\" /> Yes
526: <input type=\"radio\" name=\"notify\" value=\"0\" checked=\"true\" /> No
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\">
617: <input type=\"button\" name=\"notifyset\" value=\"Go\" onClick=\"process('notify')\" />
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>
634: <input type=\"hidden\" name=\"notifyshow\" value=\"$notifyshow\">
635: <input type=\"hidden\" name=\"action\" value=\"$action\">
636: <input type=\"hidden\" name=\"state\" value=\"process\">
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\">
678: <td><input type=\"checkbox\" name=\"cross_$i\" checked=\"true\"/></td>
679: <td>$xl</td>
680: <td><input type =\"text\" size=\"10\" name=\"gp_$i\" value=\"$gp\"></td>
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\">
712: <input type=\"button\" name=\"crosslist\" value=\"Go\" onClick=\"process('crosslist')\" />
713: </td>
714: </tr>
715: </table>
716: <input type=\"hidden\" name=\"action\" value=\"$action\">
717: <input type=\"hidden\" name=\"state\" value=\"process\">
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 {
773: $r->print("</td><td><input type=\"text\" size=\"10\" name=\"loncapasec_$i\" value=\"\"><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\" />
783: <input type=\"button\" name=\"sections\" value=\"Go\" onClick=\"process('sections')\" />
784: </td>
785: </tr>
786: </table>
787: <input type=\"hidden\" name=\"action\" value=\"$action\">
788: <input type=\"hidden\" name=\"state\" value=\"process\">
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\">
820: <td><input type=\"checkbox\" name=\"sec_$j\" checked=\"true\"/></td>
821: <td>$currsections[$j]</td>
822: <td><input type=\"text\" name=\"secgp_$j\" size=\"10\" value=\"$sec_id{$currsections[$j]}\"></td>
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\">
853: <input type=\"button\" name=\"sections\" value=\"Go\" onClick=\"process('sections')\" />
854: </td>
855: </tr>
856: </table>
857: <input type=\"hidden\" name=\"action\" value=\"$action\">
858: <input type=\"hidden\" name=\"state\" value=\"process\">
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/>
869: Currently: Student photo import: <i>$photosets[$enrollvar{showphotos}]</i>
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: ");
879: if ($enrollvar{showphotos}) {
880: $r->print("
881: <input type=\"radio\" name=\"showphotos\" value=\"1\" checked=\"true\" /> Yes
882: <input type=\"radio\" name=\"showphotos\" value=\"0\" /> No
883: ");
884: } else {
885: $r->print("
886: <input type=\"radio\" name=\"showphotos\" value=\"1\" /> Yes
887: <input type=\"radio\" name=\"showphotos\" value=\"0\" checked=\"true\" /> No
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>'.
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);" />
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'});
946: $r->print('
947: <tr>
948: <td>'.
949: &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).'<br /><br /><input type="button" name=mainmenu" value="Go back" onclick="javascript:history.go(-1);" />
950: </td>
951: </tr>
952: </form>
953: ');
954: return;
955: }
956: }
957: $r->print('
1.1 raeburn 958: <tr>
959: </td> </td>
960: </tr>
961: <tr>
1.34 raeburn 962: <td align="right">
963: <input type="button" name="showphotos" value="Go" onClick="process('."'photos'".')">
1.1 raeburn 964: </td>
965: </tr>
966: </table>
1.34 raeburn 967: <input type="hidden" name="action" value="'.$action.'">
968: <input type="hidden" name="state" value="process">
1.1 raeburn 969: </form>
1.34 raeburn 970: ');
1.1 raeburn 971: } elsif ($action eq "updatenow") {
972: $r->print("
973: <form name=\"enter\" method=\"post\"><br/>
974: <table width=\"100%\" border=\"0\" cellpadding=\"2\" cellspacing=\"2\">
975: <tr>
976: <td align=\"left\"><b>$$tasktitleref{$action}</b>
977: </td>
978: </tr>
979: </table>
980: <table width=\"100%\" border=\"0\" cellpadding=\"3\" cellspacing=\"3\">
981: <tr>
982: <td>
1.17 raeburn 983: Add any students currently included in institutional classlist(s) but not enrolled in your LON-CAPA course.<br />
984: <input type=\"radio\" name=\"updateadds\" value=\"1\"> Yes <input type=\"radio\" name=\"updateadds\" value=\"0\"> No
1.1 raeburn 985: </td>
986: </tr>
987: <tr>
988: <td>
1.17 raeburn 989: Expire students previously added by nightly enrollment process, but no longer listed in institutional classlist(s).<br />
1.14 raeburn 990: <input type=\"radio\" name=\"updatedrops\" value=\"1\"> Yes
991: <input type=\"radio\" name=\"updatedrops\" value=\"0\"> No <br/>
992: </td>
993: </tr>
994: <tr>
995: <td><font color=\"#888888\">
1.1 raeburn 996: 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 997: </font>
998: </td>
999: </tr>
1000: <tr>
1001: <td>
1002: ");
1003: &print_accessdate_table($r,\%enrollvar,$tasktitleref,$action);
1004: $r->print("
1005: </td>
1006: </tr>
1007: <tr>
1008: <td align=\"right\">
1009: <input type=\"button\" name=\"updatenow\" value=\"Go\" onClick=\"process('updatenow')\" />
1010: </td>
1011: </tr>
1012: </table>
1013: <input type=\"hidden\" name=\"action\" value=\"$action\" />
1014: <input type=\"hidden\" name=\"state\" value=\"process\" />
1015: </form>
1016: ");
1.34 raeburn 1017: } elsif ($action eq 'updatephotos') {
1018: $r->print("
1019: <table width=\"100%\" border=\"0\" cellpadding=\"2\" cellspacing=\"2\">
1020: <tr>
1021: <td align=\"left\"><b>$$tasktitleref{$action}</b>
1022: </td>
1023: </tr><tr><td>");
1024: if ($enrollvar{'showphotos'}) {
1.35 ! albertel 1025: my ($update,$commentary) = &Apache::lonnet::auto_photochoice($crs,
! 1026: $dom);
1.34 raeburn 1027: $r->print('<br />'.$commentary.'<br /><br />
1028: <form name="photoupdate" method="post">
1029: <input type ="button" name="retrieve" value="'.&mt('Update photo repository').'"
1030: onclick="javascript:document.photoupdate.submit()" />
1031: <input type ="hidden" name="action" value="'.$action.'" />
1032: <input type ="hidden" name="state" value="process" />
1033: </form>');
1034: } else {
1035: $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>');
1036: }
1037: $r->print('</td></tr>
1038: <tr><td> </td></tr>
1039: </table>');
1.14 raeburn 1040: } elsif ($action eq 'viewclass') {
1041: $r->print("
1042: <form name=\"studentform\" method=\"post\"><br/>
1043: <table width=\"100%\" border=\"0\" cellpadding=\"2\" cellspacing=\"2\">
1044: <tr>
1045: <td align=\"left\"><b>$$tasktitleref{$action}</b>
1046: </td>
1047: </tr>
1.16 raeburn 1048: <tr>
1049: <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>
1050: </tr>
1051: <tr><td> </td></tr>
1.14 raeburn 1052: </table>
1053: <table>
1054: <tr>
1055: <td>
1.1 raeburn 1056: ");
1.23 albertel 1057: if (! exists($env{'form.sortby'})) {
1058: $env{'form.sortby'} = 'username';
1.14 raeburn 1059: }
1.23 albertel 1060: if ($env{'form.Status'} !~ /^(Any|Expired|Active)$/) {
1061: $env{'form.Status'} = 'Active';
1.14 raeburn 1062: }
1.23 albertel 1063: my $status_select = &Apache::lonhtmlcommon::StatusOptions($env{'form.Status'});
1.14 raeburn 1064: # Get current classlist
1065: my ($classlist,$keylist)=&Apache::loncoursedata::get_classlist();
1066: if (! defined($classlist)) {
1067: $r->print(&mt('There are no students either currently or previously enrolled.').
1068: "\n");
1069: } else {
1070: $r->print(&mt('Student Status: [_1]',$status_select)."\n");
1071: $r->print('<input type="submit" value="'.&mt('Update Display').'" />'.
1072: "\n</p>\n");
1073:
1.23 albertel 1074: my ($studentcount,$autocount,$manualcount,$lockcount,$unlockcount) = &Apache::londropadd::show_class_list($r,'autoenroll','nothing',$env{'form.Status'},$classlist,$keylist);
1.14 raeburn 1075: $r->print("
1076: </td>
1077: </tr>
1078: ");
1079: if ($studentcount > 0) {
1080: $r->print("
1.16 raeburn 1081: <tr><td><table border=\"0\" cellpadding=\"5\"><tr>
1082: ");
1083: my $cellcount = 0;
1084: if ($autocount > 0) {
1085: $cellcount ++;
1086: $r->print(<<END);
1087: <td><fieldset><legend> <b>Change auto</b></legend><input type="button" value="check all" onclick="javascript:checkAll(document.studentform.chgauto)" />
1088: <input type="button" value="uncheck all" onclick="javascript:uncheckAll(document.studentform.chgauto)" /></fieldset></td>
1089: END
1090: }
1091: if ($manualcount > 0) {
1092: $cellcount ++;
1093: $r->print(<<END);
1094: <td><fieldset><legend> <b>Change manual</b></legend><input type="button" value="check all" onclick="javascript:checkAll(document.studentform.chgmanual)" />
1095: <input type="button" value="uncheck all" onclick="javascript:uncheckAll(document.studentform.chgmanual)" /></fieldset></td>
1096: END
1097: }
1098: if ($lockcount > 0) {
1099: if ($cellcount == 2) {
1100: $r->print("</tr><tr>");
1101: }
1102: $cellcount ++;
1103: $r->print(<<END);
1104: <td><fieldset><legend> <b>Lock manual</b></legend><input type="button" value="check all" onclick="javascript:checkAll(document.studentform.lockchg)" />
1105: <input type="button" value="uncheck all" onclick="javascript:uncheckAll(document.studentform.lockchg)" /></fieldset></td>
1106: END
1107: }
1108: if ($unlockcount > 0) {
1109: if ($cellcount == 2) {
1110: $r->print("</tr><tr>");
1111: }
1112: $cellcount ++;
1113: $r->print(<<END);
1114: <td><fieldset><legend> <b>Unlock manual</b></legend><input type="button" value="check all" onclick="javascript:checkAll(document.studentform.unlockchg)" />
1115: <input type="button" value="uncheck all" onclick="javascript:uncheckAll(document.studentform.unlockchg)" /></fieldset></td>
1116: END
1117: }
1118: $r->print("
1119: </tr>
1120: </table>
1.14 raeburn 1121: <td> </td>
1122: </tr>
1123: <tr>
1124: <td align=\"right\">
1.16 raeburn 1125: <input type=\"button\" name=\"viewclass\" value=\"Go\" onClick=\"process('viewclass','$autocount','$manualcount','$lockcount','$unlockcount')\" />
1.14 raeburn 1126: </td>
1127: </tr>
1128: ");
1129: }
1130: $r->print("
1131: </table>
1132: <input type=\"hidden\" name=\"action\" value=\"$action\" />
1133: <input type=\"hidden\" name=\"state\" value=\"choose\" />
1134: </form>
1135: ");
1136: }
1.1 raeburn 1137: }
1138: }
1139:
1.14 raeburn 1140: sub print_accessdate_table {
1141: my ($r,$enrollvar,$tasktitleref,$action) = @_;
1142: my ($start_table,$end_table) = &date_setting_table($$enrollvar{'default_enrollment_start_date'},$$enrollvar{'default_enrollment_end_date'},$action);
1143: my $oldstartshow = '';
1144: my $oldendshow = '';
1145: if ( defined($$enrollvar{'default_enrollment_start_date'}) ) {
1146: $oldstartshow = &Apache::lonlocal::locallocaltime($$enrollvar{'default_enrollment_start_date'});
1147: }
1148: if ( defined($$enrollvar{'default_enrollment_end_date'}) ) {
1149: $oldendshow = &Apache::lonlocal::locallocaltime($$enrollvar{default_enrollment_end_date});
1150: if ($$enrollvar{'default_enrollment_end_date'} eq '0') {
1151: $oldendshow = "No ending date";
1152: }
1153: }
1154: my %lt =&Apache::lonlocal::texthash(
1155: 'cuno' => 'Currently NO default first access or last access dates are set.',
1156: '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.',
1157: '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.',
1158: 'setf' => 'Set date of first access',
1159: 'setl' => 'Set date of last access',
1160: 'freg' => 'for registered students added via automated enrollment',
1161: 'fnew' => 'for new students added when you update the class roster',
1.16 raeburn 1162: '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.',
1163: '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.'
1164:
1.14 raeburn 1165: );
1166: my $dateshow;
1167: if ( ($oldendshow eq '') && ($oldstartshow eq '') ) {
1168: $dateshow = "<br/><font size='+1'>".&mt('Warning')."</font>. ".$lt{'cuno'}." ";
1169: if ($action eq 'setaccess') {
1170: $dateshow .= $lt{'ifyo'}."\n";
1171: } elsif ($action eq 'updatenow') {
1172: $dateshow .= $lt{'ifyd'}."\n";
1173: }
1174: } else {
1175: $dateshow = &mt('Currently: default first access').": <b><i>$oldstartshow</i></b>, ".&mt('default last access').": <b><i>$oldendshow</i></b>\n";
1176: }
1177: if ($action eq 'setaccess') {
1178: $r->print(<<ENDONE);
1179: <form name="enter" method="post"><br/>
1180: <table width="100%" border="0" cellpadding="2" cellspacing="2">
1181: <tr>
1182: <td align="left"><b>$$tasktitleref{$action}</b>
1183: <br /><br />
1184: $dateshow
1185: </td>
1186: </tr>
1187: </table>
1188: ENDONE
1189: } elsif ($action eq 'updatenow') {
1190: $r->print("
1191: <br /><br />$dateshow\n");
1192: }
1193: $r->print(<<ENDTWO);
1194: <table width="100%" border="0" cellpadding="3" cellspacing="3">
1195: <tr>
1196: <td align="left" colspan="2">
1197: <table border="0" cellspacing="0" cellpadding="2">
1198: <tr>
1199: <td colspan="3">
1200: ENDTWO
1201: if ($action eq 'setaccess') {
1202: $r->print("<i>$lt{'setf'} $lt{'freg'}</i>");
1203: } elsif ($action eq 'updatenow') {
1204: $r->print("<i>$lt{'setf'} $lt{'fnew'}</i>");
1205: }
1206: $r->print(<<ENDTHREE);
1207: </td>
1208: </tr>
1209: <tr>
1210: <td>$start_table
1211: </td>
1212: </tr>
1213: </table>
1214: </td>
1215: </tr>
1216: <tr>
1217: <td align="left" colspan="2">
1.15 albertel 1218: <table border="0" cellspacing="0" cellpadding="2">
1.14 raeburn 1219: <tr>
1220: <td colspan="3">
1221: ENDTHREE
1222: if ($action eq 'setaccess') {
1223: $r->print("<i>$lt{'setl'} $lt{'freg'}</i>");
1224: } elsif ($action eq 'updatenow') {
1225: $r->print("<i>$lt{'setl'} $lt{'fnew'}</i>");
1226: }
1227: $r->print(<<ENDFOUR);
1228: </td>
1229: </tr>
1230: <tr>
1231: <td>$end_table
1232: </td>
1233: </tr>
1234: </table>
1235: </td>
1236: </tr>
1237: ENDFOUR
1238: if ($action eq 'setaccess') {
1239: $r->print("
1240: <tr>
1241: <td colspan=\"2\"><font color=\"#888888\">$lt{'ifad'}</font></td>
1242: </tr>
1.16 raeburn 1243: <tr>
1244: <td colspan=\"2\"> </td>
1245: </tr>
1246: <tr>
1247: <td colspan=\"2\"><b>".&mt('Note').":</b> ".$lt{'ncds'}."</td>
1248: </tr>
1.14 raeburn 1249: </table>
1250: ");
1251: } elsif ($action eq 'updatenow') {
1252: $r->print("
1253: </tr>
1254: </table>
1255: ");
1256: }
1257: }
1258:
1.1 raeburn 1259: ###############################################################
1260: sub print_doc_base {
1.15 albertel 1261: my $r = shift;
1262: $r->print(<<ENDBASE);
1.1 raeburn 1263: </td>
1264: </tr>
1265: </table>
1266: <br/>
1267: </body>
1268: </html>
1269: ENDBASE
1270: }
1271:
1272: ###################################################################
1273: sub print_chgsettings_response {
1.15 albertel 1274: my ($r,$realm,$dom,$crs,$action,$tasktitleref) = @_;
1275: my %settings = &Apache::lonnet::get('environment',['internal.sectionnums','internal.crosslistings','internal.autostart','internal.autoend','internal.autoadds','internal.autodrops'],$dom,$crs);
1276: my $currend = '';
1277: my $currstart = '';
1278: my $currsecs = '';
1279: my $currxlists = '';
1280: my $curradds = '';
1281: my $currdrops = '';
1282: if ( defined($settings{'internal.autoadds'}) ) {
1283: $curradds = $settings{'internal.autoadds'};
1284: }
1285: if ( defined($settings{'internal.autodrops'}) ) {
1286: $currdrops = $settings{'internal.autodrops'};
1287: }
1288: if ( defined($settings{'internal.autostart'}) ) {
1289: $currstart = $settings{'internal.autostart'};
1290: }
1291: if ( defined($settings{'internal.autoend'}) ) {
1292: $currend = $settings{'internal.autoend'};
1293: }
1294: if ( defined($settings{'internal.sectionnums'}) ) {
1295: $currsecs = $settings{'internal.sectionnums'};
1296: }
1297: if ( defined($settings{'internal.crosslistings'}) ) {
1298: $currxlists = $settings{'internal.crosslistings'}
1299: }
1300: my $autoadds = '';
1301: my $autodrops = '';
1.1 raeburn 1302:
1.23 albertel 1303: if ( exists($env{'form.autoadds'}) ) {
1304: $autoadds=$env{'form.autoadds'};
1.15 albertel 1305: }
1.23 albertel 1306: if ( exists($env{'form.autodrops'}) ) {
1307: $autodrops=$env{'form.autodrops'};
1.15 albertel 1308: }
1309:
1310: my $response = "";
1311: my $warning = "";
1312: my $warn_prefix = "";
1313: my $warn_suffix = "";
1314: my $warnfiller = "";
1315: my %cenv = ('internal.autoadds' => $autoadds,
1316: 'internal.autodrops' => $autodrops);
1317: my $reply = &Apache::lonnet::put('environment',\%cenv,$dom,$crs);
1318: if ($reply !~ /^ok$/) {
1319: $response = "There was a problem processing your requested changes. The automated enrollment settings for this course have been left unchanged.<br/>";
1320: } else {
1321: if ($autoadds) {
1322: if ($curradds) {
1323: $response = "Nightly additions based on classlist changes still <b>enabled</b><br/>";
1324: } else {
1325: $response = "Nightly additions based on classlist changes now <b>enabled</b><br/>";
1326: }
1327: } else {
1328: if ($curradds) {
1329: $response = "Nightly additions based on classlist changes now <b>disabled</b><br/>";
1330: } else {
1331: $response = "Nightly additions based on classlist changes still <b>disabled</b><br/>";
1332: }
1333: }
1334: if ($autodrops) {
1335: if ($currdrops) {
1336: $response .= "Nightly removals based on classlist changes still <b>enabled</b><br>";
1337: } else {
1338: $response .= "Nightly removals based on classlist changes now <b>enabled</b><br/>";
1339: }
1340: } else {
1341: if ($currdrops) {
1342: $response .= "Nightly removals based on classlist changes now <b>disabled</b><br>";
1343: } else {
1344: $response .= "Nightly removals based on classlist changes still <b>disabled</b>";
1345: }
1346: }
1347: if ($autoadds || $autodrops) {
1348: $warning = &warning_message($dom,$crs,$action);
1349: $warn_prefix = "<br/><font size ='+1'><b>Warning</b></font>. Although you indicated that nightly ";
1350: $warn_suffix = " should be enabled, additional action is required.<br/>";
1351: }
1352: if ($autoadds) {
1353: if ($autodrops) {
1354: $warnfiller = "adds and drops";
1355: } else {
1356: $warnfiller = "adds";
1357: }
1358: } else {
1359: if ($autodrops) {
1360: $warnfiller = "drops";
1361: }
1362: }
1363: unless ($warning eq '') {
1364: $response = $warn_prefix.$warnfiller.$warn_suffix.$warning;
1365: }
1366: }
1367: &print_reply($r,$response,$$tasktitleref{$action});
1368: return;
1.1 raeburn 1369: }
1370:
1371: sub print_setdates_response {
1.15 albertel 1372: my ($r,$realm,$dom,$crs,$action,$tasktitleref) = @_;
1373: my %settings = &Apache::lonnet::get('environment',['internal.autostart','internal.autoend'],$dom,$crs);
1374: my $currstart = $settings{'internal.autostart'};
1375: my $currend = $settings{'internal.autoend'};
1376: my $response = '';
1.19 raeburn 1377: my $showstart = '';
1.15 albertel 1378: my $showend = '';
1379: my $warning = '';
1380: my $warn_prefix = '';
1.19 raeburn 1381: my ($autostart,$autoend) = &get_dates_from_form();
1382: if ( ($autostart eq '') || ($autoend eq '') ) {
1383: $response = "There was a problem processing your requested changes. The automated enrollment settings for this course have been left unchanged.<br/>";
1384: } elsif (($autoend > 0) && ($autoend <= $autostart)) {
1385: $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";
1386: } else {
1387: $showstart = &Apache::lonlocal::locallocaltime($autostart);
1388: if ($autoend) {
1389: $showend = &Apache::lonlocal::locallocaltime($autoend);
1390: } else {
1391: $showend = "'No end date'";
1392: }
1.15 albertel 1393:
1.19 raeburn 1394: my %cenv = ('internal.autostart' => $autostart,
1395: 'internal.autoend' => $autoend);
1396: my $reply = &Apache::lonnet::put('environment',\%cenv,$dom,$crs);
1397: if ($reply !~ /^ok$/) {
1398: $response = "There was a problem processing your requested changes. The automated enrollment settings for this course have been left unchanged.<br/>";
1399: } else {
1400: if ($currstart == $autostart) {
1401: $response = "The first date for automated enrollment has been left unchanged as $showstart.<br/>";
1402: } else {
1403: $response = "The first date for automated enrollment has been changed to $showstart.<br/>";
1404: }
1405: if ($currend == $autoend) {
1406: $response .= "The last date for automated enrollment has been left unchanged as $showend.<br/>";
1407: } else {
1408: $response .= "The last date for automated enrollment has been changed to $showend.<br/>";
1409: }
1.1 raeburn 1410:
1.14 raeburn 1411: # 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 1412:
1.19 raeburn 1413: my $rosterupdated = 0;
1414: my $firstaccess = "";
1415: my $nextupdate = "";
1416: my $lastupdate = "";
1417:
1418: my $nowstamp = time;
1419: my @date_list=localtime(time);
1420: my $cur_year = $date_list[5];
1421: my $curday = $date_list[3];
1422: my $curmonth = $date_list[4];
1423: my $lastmidnt = timelocal(0,0,0,$date_list[3],$date_list[4],$date_list[5]);
1424: my $nextmidnt = 86400 + $lastmidnt;
1425:
1426: my $todayupdate = timelocal(0,30,1,$date_list[3],$date_list[4],$date_list[5]);
1427: my $lastupdate = $todayupdate - 86400;
1428: if ($nowstamp < $todayupdate) {
1429: $nextupdate = "today";
1.15 albertel 1430: } else {
1.19 raeburn 1431: $nextupdate = "tomorrow";
1.15 albertel 1432: }
1.19 raeburn 1433: if ($currstart < $lastupdate) {
1434: $rosterupdated = 1;
1.15 albertel 1435: }
1.19 raeburn 1436: if ($autostart < $nextmidnt ) {
1437: if ( $autostart >= $lastmidnt) {
1438: $firstaccess = "today";
1439: } else {
1440: $firstaccess = "a date prior to today";
1441: }
1442: if (($nowstamp >= $autostart) && ($rosterupdated == 0)) {
1443: $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>|;
1444: }
1445: }
1446: $warning = &warning_message($dom,$crs,$action);
1447: $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/>";
1448: unless ($warning eq '') {
1449: $response .= $warn_prefix.$warning;
1450: }
1451: }
1.15 albertel 1452: }
1453: &print_reply($r,$response,$$tasktitleref{$action});
1454: return;
1.1 raeburn 1455: }
1456:
1.14 raeburn 1457: sub print_setaccess_response {
1.15 albertel 1458: my ($r,$realm,$dom,$crs,$action,$tasktitleref) = @_;
1459: my %settings = &Apache::lonnet::get('environment',['default_enrollment_start_date','default_enrollment_end_date','internal.autostart'],$dom,$crs);
1460: my $currstart = $settings{'default_enrollment_start_date'};
1461: my $currend = $settings{'default_enrollment_end_date'};
1462: my $autostart = $settings{'internal.autostart'};
1463: my $response = '';
1464: my ($startaccess,$endaccess) = &get_dates_from_form();
1.19 raeburn 1465: if (($startaccess eq '') || ($endaccess eq '')) {
1466: $response = "There was a problem processing your requested changes. The default
1467: start and end access dates for this course have been left unchanged.<br/>";
1468: } elsif (($endaccess > 0) && ($endaccess <= $startaccess)) {
1469: $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 1470: } else {
1.19 raeburn 1471: my $showstart = &Apache::lonlocal::locallocaltime($startaccess);
1472: my $showend = '';
1473: my $warning = '';
1474: my $warn_prefix = '';
1475: if ($endaccess) {
1476: $showend = &Apache::lonlocal::locallocaltime($endaccess);
1477: } else {
1478: $showend = "'No end date'";
1479: }
1.15 albertel 1480:
1.19 raeburn 1481: my %cenv = ('default_enrollment_start_date' => $startaccess,
1.15 albertel 1482: 'default_enrollment_end_date' => $endaccess);
1.19 raeburn 1483: my $reply = &Apache::lonnet::put('environment',\%cenv,$dom,$crs);
1484: if ($reply !~ /^ok$/) {
1485: $response = "There was a problem processing your requested changes. The automated enrollment settings for this course have been left unchanged.<br/>";
1486: } else {
1487: if ($currstart == $startaccess) {
1488: $response = "The first access date for students added via automated enrollment has been left unchanged as $showstart.<br/>";
1489: } else {
1490: $response = "The first access date for students added via automated enrollment has been changed to
1.14 raeburn 1491: $showstart.<br/>";
1.19 raeburn 1492: }
1493: if ($currend == $endaccess) {
1494: $response .= "The last access date for students added via automated enrollment has been left unchanged as $showend.<br/>";
1495: } else {
1496: $response .= "The last access date for students automated enrollment has been changed to
1.14 raeburn 1497: $showend.<br/>";
1.19 raeburn 1498: }
1.15 albertel 1499:
1.14 raeburn 1500: # 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 1501:
1.19 raeburn 1502: my $accessgiven= 0;
1503: my $firstaccess = "";
1504: my $nextupdate = "";
1505: my $lastupdate = "";
1506:
1507: my $nowstamp = time;
1508: my @date_list=localtime(time);
1509: my $cur_year = $date_list[5];
1510: my $curday = $date_list[3];
1511: my $curmonth = $date_list[4];
1512: my $lastmidnt = timelocal(0,0,0,$date_list[3],$date_list[4],$date_list[5]);
1513: my $nextmidnt = 86400 + $lastmidnt;
1514:
1515: my $todayupdate = timelocal(0,30,1,$date_list[3],$date_list[4],$date_list[5]);
1516: my $tomorrowupdate = $todayupdate + 86400;
1517: my $lastupdate = $todayupdate - 86400;
1518:
1519: if ($autostart < $nextmidnt) {
1520: if ($nowstamp < $todayupdate) {
1521: $nextupdate = "at 1.30 am today";
1522: } else {
1523: $nextupdate = "at 1.30 am tomorrow";
1524: }
1.15 albertel 1525: } else {
1.19 raeburn 1526: my @enrollstart = localtime($autostart);
1527: $nextupdate = timelocal(0,30,1,$enrollstart[3],$enrollstart[4],$enrollstart[5]);
1528: unless (($enrollstart[2] < 1) || ($enrollstart[2] == 1 && $enrollstart[1] <=30)) {
1529: $nextupdate += 86400;
1530: }
1531: $nextupdate = &Apache::lonlocal::locallocaltime($nextupdate);
1532: }
1533: if (($currstart < $lastupdate) && ($autostart < $lastupdate)) {
1534: $accessgiven = 1;
1535: }
1536: if ($startaccess < $nextmidnt ) {
1537: if ( $startaccess >= $lastmidnt) {
1538: $firstaccess = "today";
1539: } else {
1540: $firstaccess = "a date prior to today";
1541: }
1542: if (($nowstamp >= $startaccess) && ($accessgiven == 0)) {
1543: $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>|;
1544: }
1.15 albertel 1545: }
1.19 raeburn 1546: $warning = &warning_message($dom,$crs,$action);
1547: $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/>";
1548: unless ($warning eq '') {
1549: $response .= $warn_prefix.$warning;
1.15 albertel 1550: }
1.19 raeburn 1551: }
1.15 albertel 1552: }
1553: &print_reply($r,$response,$$tasktitleref{$action});
1554: return;
1.14 raeburn 1555: }
1556:
1.1 raeburn 1557: sub print_notify_response {
1.15 albertel 1558: my ($r,$realm,$dom,$crs,$action,$tasktitleref) = @_;
1.1 raeburn 1559:
1560: # Get current settings
1.15 albertel 1561: my %settings = &Apache::lonnet::get('environment',['internal.notifylist','internal.coursecode'],$dom,$crs);
1562: my $notifylist = $settings{'internal.notifylist'};
1563: my $coursecode = $settings{'internal.coursecode'};
1.28 albertel 1564: my @currpeople = split(/,/,$notifylist);
1.15 albertel 1565: my $notify = 0;
1566: my @people = ();
1567: my $peoplestr = "";
1568: my $response = "";
1569: my $noprocess = 0;
1.1 raeburn 1570:
1.15 albertel 1571: my $currcount = 0;
1572: foreach (@currpeople) {
1573: unless ($_ eq '') { $currcount ++; }
1574: }
1575:
1.23 albertel 1576: if ( exists($env{'form.notify'}) ) {
1577: $notify=$env{'form.notify'};
1.15 albertel 1578: }
1.23 albertel 1579: if ( exists($env{'form.notifyshow'}) ) {
1580: my $notifyshow = $env{'form.notifyshow'};
1.15 albertel 1581: for (my $i=0; $i<$notifyshow; $i++) {
1.23 albertel 1582: if ( exists($env{"form.note_$i"}) ) {
1583: if ( exists($env{"form.notifyname_$i"}) ) {
1584: unless ( $env{"form.notifyname_$i"} eq '' ) {
1585: push @people, $env{"form.notifyname_$i"};
1.15 albertel 1586: }
1587: }
1588: }
1589: }
1590: if ($notify) { $peoplestr = join(",",@people); }
1591: } else {
1592: if ($notify) {
1593: if ($currcount) {
1594: $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/>.";
1595: $peoplestr = $notifylist;
1596: @people = @currpeople;
1597: $noprocess = 1;
1598: }
1599: }
1600: }
1601: unless ($noprocess == 1) {
1602: my %cenv = ('internal.notifylist' => $peoplestr);
1603: my $reply = &Apache::lonnet::put('environment',\%cenv,$dom,$crs);
1604: if ($reply !~ /^ok$/) {
1605: $response = "There was a problem processing your requested changes. The notification settings for this course have been left unchanged.<br/>";
1606: } else {
1607: if ($notify) {
1608: if (@people) {
1609: if ($currcount) {
1610: $response .= "Notification of enrollment changes still <b>enabled</b><br/>";
1611: } else {
1612: $response .= "Notification of enrollment changes now <b>enabled</b><br/>";
1613: }
1614: $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";
1615: foreach my $person (@people) {
1616: $response .= "<li>$person</li>\n";
1617: }
1618: $response .= "</ul>\n";
1619: } else {
1620: $response = "Notification of enrollment changes was <b> not enabled</b> as no course coordinators were selected as recipients.<br/>";
1621: }
1622: } else {
1623: if ($currcount) {
1624: $response = "Notification of enrollment changes now <b>disabled</b><br/>";
1625: } else {
1626: $response = "Notification of enrollment changes still <b>disabled</b><br/>";
1627: }
1628: }
1629: }
1630: }
1631: &print_reply($r,$response,$$tasktitleref{$action});
1632: return;
1.1 raeburn 1633: }
1634:
1635: sub print_crosslistings_menu () {
1.15 albertel 1636: my ($r,$realm,$dom,$crs,$action,$tasktitleref) = @_;
1637: my %settings = &Apache::lonnet::get('environment',['internal.crosslistings','internal.coursecode'],$dom,$crs);
1638: my @currxlists = ();
1639: my @xlists = ();
1640: my $crosscount = 0;
1641: my $removecount = 0;
1642: my $xliststr = '';
1643: my $response = '';
1644: my $coursecode = $settings{'internal.coursecode'};
1.28 albertel 1645: if ($settings{'internal.crosslistings'} ne '') {
1646: @currxlists = split(/,/,$settings{'internal.crosslistings'});
1.15 albertel 1647: }
1648:
1649: if (@currxlists > 0) {
1650: for (my $i=0; $i<@currxlists; $i++) {
1651: my $xlist = "cross_".$i;
1652: my $gp = "gp_".$i;
1.23 albertel 1653: if ( exists($env{"form.$xlist"}) ) {
1.15 albertel 1654: my $xlistentry = '';
1655: if ($currxlists[$i] =~ m/^([^:]+)/) {
1656: $xlistentry = $1.':';
1657: }
1.23 albertel 1658: if ( exists($env{"form.$gp"}) ) {
1659: $xlistentry .= $env{"form.$gp"};
1.15 albertel 1660: }
1661: push @xlists,$xlistentry;
1662: $crosscount ++;
1663: } else {
1664: $removecount ++;
1665: }
1666: }
1667: }
1.1 raeburn 1668:
1.28 albertel 1669: $xliststr = join(",",@xlists);
1670:
1.15 albertel 1671: my %cenv = ('internal.crosslistings' => $xliststr);
1672: my $reply = &Apache::lonnet::put('environment',\%cenv,$dom,$crs);
1673: if ($reply !~ /^ok$/) {
1674: $response = "There was a problem processing your requested changes. The automated enrollment settings for this course have been left unchanged.<br/>";
1675: } else {
1676: if ($removecount > 0) {
1677: $response = "A total of $removecount courses are no longer crosslisted with LON-CAPA course: $realm ($coursecode).<br/><br/>";
1678: }
1679: if ($crosscount > 0) {
1680: $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";
1681: foreach (@xlists) {
1682: my ($xlist,$gp) = split/:/,$_;
1683: $response .= "<li>$xlist - ID: $gp</li>\n";
1684: }
1685: $response .= "</ul><br/>\n";
1686: }
1687: }
1.23 albertel 1688: if ( exists($env{'form.numcross'}) ) {
1689: my $numcross = $env{'form.numcross'};
1.15 albertel 1690: if ($numcross > 0) {
1691: my @bgcolors=("#eeeeee","#cccccc");
1692: $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 1693: <form name="enter" method="post">
1694: <table border="0" cellpadding="2" cellspacing="2" width="100%">
1695: <tr>
1696: <td>
1697: <table border="0" cellspacing="3" cellpadding="3">
1698: <tr bgcolor="#CCCCFF" align="left">
1699: <td><b>Crosslisting</b></td>
1700: <td><b>LON-CAPA section/groupID</b></td>
1701: </tr>
1.15 albertel 1702: );
1703: for (my $i=0; $i<$numcross; $i++) {
1704: my $colflag = $i%2;
1705: $response .= qq(
1.1 raeburn 1706: <tr bgcolor="$bgcolors[$colflag]" align="left">
1707: <td><input type="text" size="15" name="newcross_$i" /></td>
1708: <td><input type="text" size="10" name="newgroupid_$i" /></td>
1709: </tr>
1.15 albertel 1710: );
1711: }
1712: $response .= qq( </table>
1.1 raeburn 1713: </td>
1714: </tr>
1715: <tr>
1716: <td align="right">
1717: <input type="button" name="newcross" value="Go" onClick="process('newcross')" />
1718: </td>
1719: </tr>
1720: </table>
1721: <input type=\"hidden\" name=\"numcross\" value=\"$numcross\">
1722: <input type=\"hidden\" name=\"action\" value=\"newcross\">
1723: <input type=\"hidden\" name=\"state\" value=\"process\">
1724: </form>
1.15 albertel 1725: );
1726: }
1727: }
1728: &print_reply($r,$response,$$tasktitleref{$action});
1729: return;
1.1 raeburn 1730: }
1731:
1732: sub print_crosslistings_response () {
1.15 albertel 1733: my ($r,$realm,$dom,$crs,$action,$tasktitleref) = @_;
1734: my %settings = &Apache::lonnet::get('environment',['internal.crosslistings','internal.coursecode','internal.courseowner'],$dom,$crs);
1735: my @currxlists = ();
1736: my @xlists = ();
1737: my @allxlists = ();
1738: my @badxlists = ();
1739: my @badowner = ();
1740: my $numcross = 0;
1741: my $xliststr = $settings{'internal.crosslistings'};
1742: my $coursecode = $settings{'internal.coursecode'};
1743: my $owner = $settings{'internal.courseowner'};
1744: my $response = '';
1745: my $warning = '';
1746: my $warn_prefix = '';
1.1 raeburn 1747:
1.28 albertel 1748: if ($xliststr ne '') {
1749: @allxlists = split(/,/,$xliststr);
1.15 albertel 1750: }
1.1 raeburn 1751:
1.23 albertel 1752: if ( exists($env{'form.numcross'}) ) {
1753: $numcross = $env{'form.numcross'};
1.15 albertel 1754: }
1.1 raeburn 1755:
1.15 albertel 1756: if ($numcross > 0) {
1757: for (my $i=0; $i<$numcross; $i++) {
1758: my $xl = "newcross_".$i;
1759: my $gp = "newgroupid_".$i;
1.23 albertel 1760: if ( exists($env{"form.$xl"}) ) {
1.15 albertel 1761: my $coursecheck = '';
1.23 albertel 1762: $coursecheck = &Apache::lonnet::auto_validate_courseID($crs,$dom,$env{"form.$xl"});
1.15 albertel 1763: if ($coursecheck eq 'ok') {
1764: my $addcheck = '';
1.23 albertel 1765: $addcheck = &Apache::lonnet::auto_new_course($crs,$dom,$env{"form.$xl"},$owner);
1.15 albertel 1766: if ($addcheck eq 'ok') {
1.23 albertel 1767: push @xlists,$env{"form.$xl"}.":".$env{"form.$gp"};
1.15 albertel 1768: } else {
1.23 albertel 1769: push @badowner,$env{"form.$xl"}.":".$env{"form.$gp"};
1.15 albertel 1770: }
1771: } else {
1.23 albertel 1772: push @badxlists, $env{"form.$xl"}.":".$env{"form.$gp"}.":".$coursecheck;
1.15 albertel 1773: }
1774: }
1775: }
1776: push @allxlists, @xlists;
1777: }
1778:
1779: if (@xlists > 0 ) {
1780: unless ($xliststr eq '') { $xliststr .= ","; }
1.28 albertel 1781: $xliststr .= join(",",@xlists);
1782:
1.15 albertel 1783: my %cenv = ('internal.crosslistings' => $xliststr);
1784: my $reply = &Apache::lonnet::put('environment',\%cenv,$dom,$crs);
1785: if ($reply !~ /^ok$/) {
1786: $response = "There was a problem processing your requested changes. The automated enrollment settings for this course have been left unchanged.<br/><br/>";
1787: } else {
1788: $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";
1789: foreach (@allxlists) {
1790: my ($xlist,$gp) = split/:/,$_;
1791: $response .= "<li>$xlist - ID: $gp</li>\n";
1792: }
1793: $response .= "</ul><br/><br/>\n";
1794: }
1795: } else {
1796: if ($xliststr =~ m/:/) {
1.28 albertel 1797: my @oldxlists = (split/,/,$xliststr);
1.15 albertel 1798: $response .= "Although no new crosslistings were added, the courses listed below continue to be crosslisted with your LON-CAPA course.<br/><ul>\n";
1799: foreach (@oldxlists) {
1800: my ($xlist,$gp) = split/:/,$_;
1801: $response .= "<li>$xlist - ID: $gp</li>\n";
1802: }
1803: $response .= "</ul><br/><br/>\n";
1804: }
1805: }
1806: if (@badxlists > 0) {
1807: $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";
1808: foreach (@badxlists) {
1809: my ($xlist,$gp,$prob) = split/:/,$_;
1810: $response .= "<li>$xlist - ID: $gp - Error: $prob</li>\n";
1811: }
1812: $response .= "</ul><br/><br/>\n";
1813: }
1814:
1815: if (@badowner > 0) {
1816: $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";
1817: foreach (@badowner) {
1818: my ($xlist,$gp) = split/:/,$_;
1819: $response .= "<li>$xlist - ID: $gp</li>\n";
1820: }
1821: $response .= "</ul><br/><br/>\n";
1822: }
1.5 raeburn 1823:
1.15 albertel 1824: if (@allxlists > 0) {
1825: $warning = &warning_message($dom,$crs,$action);
1826: $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/>";
1827: unless ($warning eq '') {
1828: $response .= $warn_prefix.$warning;
1829: }
1830: }
1.1 raeburn 1831:
1.15 albertel 1832: &print_reply($r,$response,$$tasktitleref{$action});
1833: return;
1.1 raeburn 1834: }
1835:
1836: sub print_sections_menu () {
1.15 albertel 1837: my ($r,$realm,$dom,$crs,$action,$tasktitleref) = @_;
1838: my %settings = &Apache::lonnet::get('environment',['internal.sectionnums','internal.coursecode','internal.courseowner'],$dom,$crs);
1839: my @currsections = ();
1840: my @sections = ();
1841: my @badowner = ();
1842: my @badsections = ();
1843: my $seccount = 0;
1844: my $removecount = 0;
1845: my $addcount = 0;
1846: my $secstr = '';
1847: my $response = '';
1848: my $warning = "";
1849: my $warn_prefix = "";
1850: my $coursecode = $settings{'internal.coursecode'};
1851: my $owner = $settings{'internal.courseowner'};
1.28 albertel 1852: if ($settings{'internal.sectionnums'} ne '') {
1853: @currsections = split(/,/,$settings{'internal.sectionnums'});
1.15 albertel 1854: }
1855:
1.23 albertel 1856: if ( exists($env{'form.secshow'}) ) {
1857: for (my $i=0; $i<$env{'form.secshow'}; $i++) {
1.15 albertel 1858: my $gp = "loncapasec_".$i;
1859: my $secnum = "secnum_".$i;
1860: my $sec = "sec_".$i;
1.23 albertel 1861: if ( exists( $env{"form.$sec"} ) ) {
1.15 albertel 1862: my $secentry;
1.23 albertel 1863: if ( exists( $env{"form.$secnum"} ) ) {
1864: $secentry = $env{"form.$secnum"}.':';
1.15 albertel 1865: }
1.23 albertel 1866: if ( exists( $env{"form.$gp"} ) ) {
1867: $secentry .= $env{"form.$gp"};
1.15 albertel 1868: }
1.23 albertel 1869: if ( grep/^$env{"form.$secnum"}:/,@currsections) {
1.15 albertel 1870: push @sections, $secentry;
1871: $seccount ++;
1872: } else {
1.23 albertel 1873: my $newsec = $coursecode.$env{"form.$secnum"};
1.15 albertel 1874: my $coursecheck = &Apache::lonnet::auto_validate_courseID($crs,$dom,$newsec);
1875: if ($coursecheck eq 'ok') {
1876: my $addcheck = &Apache::lonnet::auto_new_course($crs,$dom,$newsec,$owner);
1877: if ($addcheck eq 'ok') {
1.23 albertel 1878: push @sections,$env{"form.$secnum"}.":".$env{"form.$gp"};
1.15 albertel 1879: $seccount ++;
1880: $addcount ++;
1881: } else {
1.23 albertel 1882: push @badowner,$env{"form.$secnum"}.":".$env{"form.$gp"};
1.15 albertel 1883: }
1884: } else {
1.23 albertel 1885: push @badsections, $env{"form.$secnum"}.":".$env{"form.$gp"}.":".$coursecheck;
1.15 albertel 1886: }
1887: }
1888: }
1889: }
1890: if (@currsections > 0) {
1891: for (my $i=0; $i<@currsections; $i++) {
1892: if ($currsections[$i] =~ m/^(\w+:)/ ) {
1893: my $oldsec = $1;
1894: unless (grep/^$oldsec/,@sections) {
1895: $removecount ++;
1896: }
1897: }
1898: }
1899: }
1900: } elsif (@currsections > 0) {
1901: for (my $i=0; $i<@currsections; $i++) {
1902: my $sec = "sec_".$i;
1903: my $gp = "secgp_".$i;
1.23 albertel 1904: if ( exists($env{"form.$sec"}) ) {
1.15 albertel 1905: my $secentry = '';
1906: if ($currsections[$i] =~ m/^(\w+:)/ ) {
1907: $secentry = $1;
1908: }
1.23 albertel 1909: if ( exists($env{"form.$gp"}) ) {
1910: $secentry .= $env{"form.$gp"};
1.15 albertel 1911: }
1912: push @sections,$secentry;
1913: $seccount ++;
1914: } else {
1915: $removecount ++;
1916: }
1917: }
1918: }
1919:
1.28 albertel 1920: $secstr = join(",",@sections);
1921:
1.15 albertel 1922: my %cenv = ('internal.sectionnums' => $secstr);
1923: my $reply = &Apache::lonnet::put('environment',\%cenv,$dom,$crs);
1924: if ($reply !~ /^ok$/) {
1925: $response = "There was a problem processing your requested changes. The automated enrollment settings for this course have been left unchanged.<br/>";
1926: } else {
1927: if ($removecount > 0) {
1928: $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/>";
1929: }
1930: if ($addcount > 0) {
1931: $response .= "A total of $addcount sections have been added to the list of
1.6 raeburn 1932: sections which contribute to enrollment in LON-CAPA course: $realm ($coursecode).<br/><br/>";
1.15 albertel 1933: }
1934: if ($seccount > 0) {
1935: $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";
1936: foreach (@sections) {
1937: my ($sec,$gp) = split/:/,$_;
1938: $response .= "<li>$sec - ID: $gp</li>\n";
1939: }
1940: $response .= "</ul><br/>\n";
1941: }
1942: }
1943:
1944: if (@badsections > 0) {
1945: $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";
1946: foreach (@badsections) {
1947: my ($secnum,$gp,$prob) = split/:/,$_;
1948: $response .= "<li>$secnum - ID: $gp - Error: $prob</li>\n";
1949: }
1950: $response .= "</ul><br/><br/>\n";
1951: }
1952:
1953: if (@badowner > 0) {
1954: $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";
1955: foreach (@badowner) {
1956: my ($secnum,$gp) = split/:/,$_;
1957: $response .= "<li>$secnum - ID: $gp</li>\n";
1958: }
1959: $response .= "</ul><br/><br/>\n";
1960: }
1961:
1962: if ($seccount > 0) {
1963: $warning = &warning_message($dom,$crs,$action);
1964: $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/>";
1965: unless ($warning eq '') {
1966: $response .= $warn_prefix.$warning;
1967: }
1968: }
1969:
1.23 albertel 1970: if ( exists($env{'form.numsec'}) ) {
1971: my $numsec = $env{'form.numsec'};
1.15 albertel 1972: if ($numsec > 0) {
1973: my @bgcolors=("#eeeeee","#cccccc");
1974: $response .= qq(
1975: 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 1976: <form name="enter" method="post">
1977: <table border="0" cellpadding="2" cellspacing="2" width="100%">
1978: <tr>
1979: <td>
1980: <table border="0" cellspacing="3" cellpadding="3">
1981: <tr bgcolor="#CCCCFF" align="left">
1982: <td><b>Section number</b></td>
1983: <td><b>LON-CAPA section/groupID</b></td>
1984: </tr>
1.15 albertel 1985: );
1986: for (my $i=0; $i<$numsec; $i++) {
1987: my $colflag = $i%2;
1988: $response .= qq(
1.1 raeburn 1989: <tr bgcolor="$bgcolors[$colflag]" align="left">
1990: <td><input type="text" size="15" name="newsec_$i" /></td>
1991: <td><input type="text" size="10" name="newsecgp_$i" /></td>
1992: </tr>
1.15 albertel 1993: );
1994: }
1995: $response .= qq( </table>
1.1 raeburn 1996: </td>
1997: </tr>
1998: <tr>
1999: <td align="right">
2000: <input type="button" name="newsections" value="Go" onClick="process('newsections')" />
2001: </td>
2002: </tr>
2003: </table>
2004: <input type=\"hidden\" name=\"numsec\" value=\"$numsec\">
2005: <input type=\"hidden\" name=\"action\" value=\"newsections\">
2006: <input type=\"hidden\" name=\"state\" value=\"process\">
2007: </form>
1.15 albertel 2008: );
2009: }
2010: }
2011: &print_reply($r,$response,$$tasktitleref{$action});
2012: return;
1.1 raeburn 2013: }
2014:
2015: sub print_sections_response () {
1.15 albertel 2016: my ($r,$realm,$dom,$crs,$action,$tasktitleref) = @_;
2017: my %settings = &Apache::lonnet::get('environment',['internal.sectionnums','internal.coursecode','internal.courseowner'],$dom,$crs);
2018: my @currsections = ();
2019: my @sections = ();
2020: my @allsections = ();
2021: my @badowner = ();
2022: my @badsections = ();
2023: my $numsec = 0;
2024: my $secstr = $settings{'internal.sectionnums'};
2025: my $coursecode = $settings{'internal.coursecode'};
2026: my $owner = $settings{'internal.courseowner'};
2027: my $response = '';
2028: my $putreply = '';
2029: my $warning = '';
2030: my $warn_prefix = '';
1.28 albertel 2031: if ($secstr ne '') {
2032: @allsections = split(/,/,$secstr);
1.15 albertel 2033: }
2034:
1.23 albertel 2035: if ( exists($env{'form.numsec'}) ) {
2036: $numsec = $env{'form.numsec'};
1.15 albertel 2037: }
2038:
2039: if ($numsec > 0) {
2040: for (my $i=0; $i<$numsec; $i++) {
2041: my $sec = "newsec_".$i;
2042: my $gp = "newsecgp_".$i;
1.23 albertel 2043: if ( exists($env{"form.$sec"}) ) {
2044: unless ( (grep/^$env{"form.$sec"}:/,@allsections) || (grep/^$env{"form.$sec"}:/,@sections) ) {
2045: my $newsec = $coursecode.$env{"form.$sec"};
1.15 albertel 2046: my $coursecheck = &Apache::lonnet::auto_validate_courseID($crs,$dom,$newsec);
2047: if ($coursecheck eq 'ok') {
2048: my $addcheck = &Apache::lonnet::auto_new_course($crs,$dom,$newsec,$owner);
2049: if ($addcheck eq 'ok') {
1.23 albertel 2050: push @sections,$env{"form.$sec"}.":".$env{"form.$gp"};
1.15 albertel 2051: } else {
1.23 albertel 2052: push @badowner,$env{"form.$sec"}.":".$env{"form.$gp"};
1.15 albertel 2053: }
2054: } else {
1.23 albertel 2055: push @badsections, $env{"form.$sec"}.":".$env{"form.$gp"}.":".$coursecheck;
1.15 albertel 2056: }
2057: }
2058: }
2059: }
2060: push @allsections, @sections;
2061: }
2062:
2063: if (@sections > 0 ) {
2064: unless ($secstr eq '') { $secstr .= ","; }
1.28 albertel 2065: $secstr .= join(",",@sections);
1.15 albertel 2066: my %cenv = ('internal.sectionnums' => $secstr);
2067: $putreply = &Apache::lonnet::put('environment',\%cenv,$dom,$crs);
2068: if ($putreply !~ /^ok$/) {
2069: $response = "There was a problem processing your requested changes. The automated enrollment settings for this course have been left unchanged.<br/><br/>";
2070: }
2071: }
2072:
2073: if ($putreply =~ /^ok/) {
2074: $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";
2075: foreach (@allsections) {
2076: my ($sec,$gp) = split/:/,$_;
2077: $response .= "<li>$sec - ID: $gp</li>\n";
2078: }
2079: $response .= "</ul><br/><br/>\n";
2080: }
2081:
2082: if (@badsections > 0) {
2083: $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";
2084: foreach (@badsections) {
2085: my ($secnum,$gp,$prob) = split/:/,$_;
2086: $response .= "<li>$secnum - ID: $gp - Error: $prob</li>\n";
2087: }
2088: $response .= "</ul><br/><br/>\n";
2089: }
2090:
2091: if (@badowner > 0) {
2092: $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";
2093: foreach (@badowner) {
2094: my ($secnum,$gp) = split/:/,$_;
2095: $response .= "<li>$secnum - ID: $gp</li>\n";
2096: }
2097: $response .= "</ul><br/><br/>\n";
2098: }
2099:
2100: if (@allsections > 0) {
2101: $warning = &warning_message($dom,$crs,$action);
2102: $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/>";
2103: unless ($warning eq '') {
2104: $response .= $warn_prefix.$warning;
2105: }
2106: }
1.1 raeburn 2107:
1.15 albertel 2108: &print_reply($r,$response,$$tasktitleref{$action});
2109: return;
1.1 raeburn 2110: }
2111:
1.34 raeburn 2112: sub photo_permission {
1.15 albertel 2113: my ($r,$realm,$dom,$crs,$action,$tasktitleref) = @_;
1.35 ! albertel 2114: my %settings = &Apache::lonnet::get('environment',
! 2115: ['internal.courseowner',
! 2116: 'internal.photopermission',
! 2117: 'internal.showphotos'],
! 2118: $dom,$crs);
1.34 raeburn 2119: my ($showphotos,$response);
2120: if (exists($env{'form.cancel_agreement'})) {
2121: if ($env{'user.name'} eq $settings{'internal.courseowner'}) {
2122: my %cenv = (
2123: 'internal.photopermission' => 'no',
2124: );
2125: my $reply = &Apache::lonnet::put('environment',\%cenv,$dom,$crs);
2126: if ($reply !~ /^ok$/) {
2127: $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";
2128: &print_reply($r,$response,$$tasktitleref{$action});
2129: } else {
2130: &print_photos_response($r,$realm,$dom,$crs,$action,
2131: $tasktitleref,$showphotos,'no',\%cenv);
2132: }
2133: return;
2134: }
2135: }
2136: if (exists($env{'form.showphotos'})) {
2137: $showphotos=$env{'form.showphotos'};
2138: }
2139: if ($showphotos) {
2140: if ($env{'form.photopermission'}) {
2141: my %cenv = (
2142: 'internal.photopermission' => $env{'form.photopermission'},
2143: );
2144: my $reply = &Apache::lonnet::put('environment',\%cenv,$dom,$crs);
2145: if ($reply !~ /^ok$/) {
2146: $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";
2147: } else {
2148: &print_photos_response($r,$realm,$dom,$crs,$action,
1.35 ! albertel 2149: $tasktitleref,$showphotos,
! 2150: $env{'form.photopermission'},\%cenv);
1.34 raeburn 2151: }
2152: } else {
2153: my ($result,$perm_reqd,$conditions) =
1.35 ! albertel 2154: &Apache::lonnet::auto_photo_permission($crs,$dom);
1.34 raeburn 2155: my $permcheck;
2156: if ($result eq 'ok') {
2157: if ($perm_reqd eq 'yes') {
2158: if ($settings{'internal.photopermission'} eq 'yes') {
2159: &print_photos_response($r,$realm,$dom,$crs,$action,
1.35 ! albertel 2160: $tasktitleref,$showphotos);
1.34 raeburn 2161: } else {
2162: return(&print_photo_agreement($r,$realm,$dom,$crs,
1.35 ! albertel 2163: $action,$tasktitleref,
! 2164: $conditions,
! 2165: $settings{'internal.courseowner'}));
1.34 raeburn 2166: }
2167: } elsif ($perm_reqd eq 'no') {
2168: &print_photos_response($r,$realm,$dom,$crs,$action,
1.35 ! albertel 2169: $tasktitleref,$showphotos);
1.34 raeburn 2170: } else {
2171: $permcheck = 'fail';
2172: }
2173: } else {
2174: $permcheck = 'fail';
2175: }
2176: if ($permcheck eq 'fail') {
2177: 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/>';
2178: &print_reply($r,$response,$$tasktitleref{$action});
2179: }
2180: }
2181: } else {
2182: &print_photos_response($r,$realm,$dom,$crs,$action,$tasktitleref);
2183: }
2184: return;
2185: }
2186:
2187: sub print_photo_agreement {
2188: my ($r,$realm,$dom,$crs,$action,$tasktitleref,$conditions,$courseowner)=@_;
2189: my $response;
2190: my $institution = $Apache::lonnet::domaindescription{$dom};
2191: if ($env{'user.name'} eq $courseowner) {
2192: $response = '
2193: <script type="text/javascript">
2194: function agreement_result(caller) {
2195: document.permission.photopermission.value = caller;
2196: if (caller == 0) {
2197: document.location.href="/adm/populate";
2198: } else {
2199: document.permission.submit();
2200: }
2201: return;
2202: }
2203: </script>
2204: <form name="permission" method="post">
2205: <table width="100%" border="0" cellpadding="2" cellspacing="2">
2206: <tr>
2207: <td align="left"><b>Use of student photos</b><br/>'."\n".
2208: &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).'
2209: </td>
2210: </tr>
2211: </table>
2212: <table border="0" cellpadding="3" cellspacing="3">
2213: <tr>
2214: <td colspan="2">
2215: <textarea rows="20" cols="80">'.$conditions.'</textarea>
2216: </td>
2217: <tr>
2218: <td align="left">
2219: <input type="button" name="disagree" value="I do not agree" onclick="javascript:agreement_result('."'no'".');" />
2220: </td>
2221: <td align="right">
2222: <input type="button" name="agree" value="I agree" onclick="javscript:agreement_result('."'yes'".');" />
2223: </td>
2224: </tr>
2225: </table>
2226: <input type ="hidden" name="action" value="'.$action.'" />
2227: <input type ="hidden" name="state" value="process" />
2228: <input type ="hidden" name="showphotos" value="1" />
2229: <input type= "hidden" name="photopermission" value="" />
2230: </form>
2231: ';
2232: } else {
2233: my ($ownername,$owneremail) = &get_oenerinfo($dom,$courseowner);
2234: $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);
2235: }
2236: &print_reply($r,$response,$$tasktitleref{$action});
2237: }
2238:
2239: sub print_photos_response {
2240: my ($r,$realm,$dom,$crs,$action,$tasktitleref,$showphotos,$photopermission,
1.35 ! albertel 2241: $permissionenv)=@_;
1.34 raeburn 2242: my %newenv;
2243: if (defined($permissionenv)) {
2244: foreach my $key (keys(%{$permissionenv})) {
2245: if (exists($env{'request.course.id'})) {
2246: $newenv{$env{'request.course.id'}.'.'.$key} =
1.35 ! albertel 2247: $$permissionenv{$key};
1.34 raeburn 2248: }
2249: }
2250: }
2251: my %settings = &Apache::lonnet::get('environment',['internal.showphotos'],
1.35 ! albertel 2252: $dom,$crs);
1.15 albertel 2253: my $currphotos = $settings{'internal.showphotos'};
1.34 raeburn 2254: my $response = "";
2255: if (defined($photopermission)) {
2256: if ($photopermission eq 'yes') {
2257: $response = &mt('Acceptance of photo use policy recorded.').'<br />'."\n";
2258: } else {
2259: $response = &mt('Non-acceptance of photo use policy recorded.').'<br />'."\n";
2260: $showphotos = 0;
2261: }
1.15 albertel 2262: }
2263: my %cenv = ('internal.showphotos' => $showphotos);
2264: my $reply = &Apache::lonnet::put('environment',\%cenv,$dom,$crs);
2265: if ($reply !~ /^ok$/) {
1.34 raeburn 2266: $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 2267: } else {
2268: if ($showphotos) {
2269: if ($currphotos) {
1.34 raeburn 2270: $response .= "Retrieval of student photos is still <b>enabled</b>.<br/>";
1.15 albertel 2271: } else {
1.34 raeburn 2272: $response .= "Retrieval of student photos in now <b>enabled</b>.<br/>";
1.35 ! albertel 2273: my ($update,$commentary) =
! 2274: &Apache::lonnet::auto_photochoice($crs,$dom);
1.34 raeburn 2275: if ($update) {
2276: $response .= '<br />'.$commentary.'<br /><br />
2277: <form name="photoupdate" method="post">
2278: <input type ="button" name="retrieve" value="'.&mt('Update photo repository').'"
2279: onclick="javascript:document.photoupdate.submit()" />
2280: <input type ="hidden" name="action" value="'.$action.'" />
2281: <input type ="hidden" name="state" value="photoupdate" />
2282: </form>';
2283: }
1.15 albertel 2284: }
2285: } else {
2286: if ($currphotos) {
1.34 raeburn 2287: $response .= "Retrieval of student photos is now <b>disabled</b>.<br/>";
1.15 albertel 2288: } else {
1.34 raeburn 2289: $response .= "Retrieval of student photos is still <b>disabled</b>.<br/>";
1.15 albertel 2290: }
2291: }
1.34 raeburn 2292: foreach my $key (keys(%cenv)) {
2293: if (exists($env{'request.course.id'})) {
2294: $newenv{'course.'.$env{'request.course.id'}.'.'.$key} =
1.35 ! albertel 2295: $cenv{$key};
1.34 raeburn 2296: }
2297: }
2298: }
2299: if (keys(%newenv) > 0) {
2300: &Apache::lonnet::appenv(%newenv);
2301: }
2302: &print_reply($r,$response,$$tasktitleref{$action});
2303: return;
2304: }
2305:
2306: sub print_photoupdate_response {
2307: my ($r,$realm,$dom,$crs,$action,$tasktitleref) = @_;
2308: my $response;
2309: my %changes;
2310: my %lt = &LONCAPA::Enrollment::photo_response_types();
1.35 ! albertel 2311: my %settings = &Apache::lonnet::get('environment',
! 2312: ['internal.coursecode',
! 2313: 'internal.sectionnums',
! 2314: 'internal.crosslistings'],
! 2315: $dom,$crs);
1.34 raeburn 2316: my @allcourses = ();
2317: my %LC_code;
2318: my %affiliates;
2319: my $outcome;
2320: &get_institutional_codes(\%settings,,\@allcourses,\%LC_code);
2321: if (@allcourses > 0) {
2322: @{$affiliates{$crs}} = @allcourses;
2323: $outcome = &Apache::lonnet::auto_photoupdate(\%affiliates,$dom,$crs,\%changes);
2324: unless ($outcome eq 'ok') {
2325: &Apache::lonnet::logthis("lonpopulate::print_photoupdate_response".
1.35 ! albertel 2326: "failed to update student photos".
! 2327: " for ".$crs."\@".$dom." by ".
! 2328: $env{'user.name'}." \@ ".$env{'user.domain'}.
! 2329: ": ".$outcome);
1.34 raeburn 2330: }
2331: if ($outcome eq 'ok') {
2332: if (keys(%changes) > 0) {
2333: $response = &mt('Update of photos for registered students resulted in the following ').': <br /><script type="text/javascript">
2334: function photowindow(photolink) {
2335: var title = "Photo_Viewer";
2336: var options = "scrollbars=1,resizable=1,menubar=0";
2337: options += ",width=240,height=240";
2338: stdeditbrowser = open(photolink,title,options,"1");
2339: stdeditbrowser.focus();
2340: }
2341: </script>
2342: ';
2343: foreach my $type (sort(keys(%changes))) {
2344: my @usernames = sort(split(/\&/,$changes{$type}));
2345: my $count = @usernames;
2346: $response .= '<b>'.&mt('For [_1] students, photos ',
1.35 ! albertel 2347: $count).$lt{$type}.'</b><ul>';
1.34 raeburn 2348: foreach my $username (@usernames) {
2349: $response .= '<li>'.$username;
2350: if (($type eq 'new') || ($type eq 'same') || ($type eq 'update')) {
2351: $response .= ' <a href="javascript:photowindow('."'".&Apache::lonnet::studentphoto($dom,$username,'jpg')."'".')">View</a></li>';
2352: }
2353: }
2354: $response .= '</ul><br />';
2355: }
2356: } else {
2357: $response = &mt('No updates of photos of registered students occurred').
2358: '<br />';
2359: }
2360: } else {
2361: $response = "There was a problem updating student photos for registered students in this course. <br/>";
2362: }
2363: } else {
2364: $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 2365: }
2366: &print_reply($r,$response,$$tasktitleref{$action});
2367: return;
1.1 raeburn 2368: }
2369:
1.34 raeburn 2370: sub get_ownerinfo {
2371: my ($dom,$owner) = @_;
2372: my ($ownername,$owneremail);
2373: if ($owner) {
2374: $ownername=&Apache::loncommon::plainname($owner,$dom,'firstname');
2375: my %ownerinfo = &Apache::lonnet::get('environment','permanentemail',
1.35 ! albertel 2376: $dom,$owner);
1.34 raeburn 2377: $owneremail = $ownerinfo{'permanentemail'};
2378: }
2379: return ($ownername,$owneremail);
2380: }
2381:
1.1 raeburn 2382: sub print_update_result () {
1.15 albertel 2383: my ($r,$realm,$dom,$crs,$action,$tasktitleref) = @_;
2384: my $response = '';
2385: my $updateadds = 0;
2386: my $updatedrops = 0;
2387: my $changecount = 0;
2388: my %affiliates = ();
2389: my %reply = ();
2390: my @allcourses = ();
2391: my %LC_code = ();
2392: my $logmsg = '';
2393: my $newusermsg = '';
1.34 raeburn 2394: my %phototypes = ();
2395: my %settings = &Apache::lonnet::get('environment',['internal.coursecode','internal.sectionnums','internal.crosslistings','internal.authtype','internal.autharg','internal.showphotos'],$dom,$crs);
1.15 albertel 2396: my $coursecode = $settings{'internal.coursecode'};
2397: my $authtype = $settings{'internal.authtype'};
2398: my $autharg = $settings{'internal.autharg'};
1.34 raeburn 2399: my $showphotos = $settings{'internal.showphotos'};
1.15 albertel 2400: my ($startaccess,$endaccess) = &get_dates_from_form();
1.23 albertel 2401: if ( exists($env{'form.updateadds'}) ) {
2402: $updateadds = $env{'form.updateadds'};
1.15 albertel 2403: }
1.23 albertel 2404: if ( exists($env{'form.updatedrops'}) ) {
2405: $updatedrops = $env{'form.updatedrops'};
1.15 albertel 2406: }
1.19 raeburn 2407: if (($startaccess eq '') || ($endaccess eq '')) {
2408: $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 />";
2409: } elsif ($updateadds && (($endaccess > 0) && ($endaccess <= $startaccess))) {
2410: $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";
2411: } elsif (!$updateadds && !$updatedrops) {
1.15 albertel 2412: $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.";
2413: } elsif ($coursecode eq '') {
2414: $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";
2415: } else {
1.34 raeburn 2416: &get_institutional_codes(\%settings,\@allcourses,\%LC_code);
1.15 albertel 2417: if (@allcourses > 0) {
2418: @{$affiliates{$crs}} = @allcourses;
2419: my $outcome = &Apache::lonnet::fetch_enrollment_query('updatenow',\%affiliates,\%reply,$dom,$crs);
1.19 raeburn 2420: unless ($outcome eq 'ok') {
2421: &Apache::lonnet::logthis("lonpopulate:update roster".
2422: "failed to retrieve classlist".
2423: " data for ".$crs."\@".$dom." by ".
1.23 albertel 2424: $env{'user.name'}." \@ ".$env{'user.domain'}.
1.19 raeburn 2425: ": ".$outcome);
2426: }
1.15 albertel 2427: if ($reply{$crs} > 0) {
1.34 raeburn 2428: ($changecount,$response) = &LONCAPA::Enrollment::update_LC($dom,$crs,$updateadds,$updatedrops,$startaccess,$endaccess,$authtype,$autharg,\@allcourses,\%LC_code,\$logmsg,\$newusermsg,"updatenow",\%phototypes);
1.15 albertel 2429: } else {
2430: $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.";
2431: }
2432: } else {
2433: $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)";
2434: }
2435: }
2436: unless ($logmsg eq '') {
2437: my $loglength = length($logmsg);
2438: $logmsg = substr($logmsg,0,$loglength-4);
2439: $logmsg = "<br/><br/>The following messages were generated by the roster update process: <br/><ul><li>".$logmsg."</ul><br/>";
2440: }
2441: unless ($newusermsg eq '') {
2442: $newusermsg = substr( $newusermsg,0,rindex($newusermsg,'<li>') );
1.19 raeburn 2443: $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 2444: }
2445: $response .= $logmsg.$newusermsg;
2446: &print_reply($r,$response,$$tasktitleref{$action});
2447: return;
1.10 raeburn 2448: }
2449:
1.34 raeburn 2450: sub get_institutional_codes {
2451: my ($settings,$allcourses,$LC_code) = @_;
2452: # Get complete list of course sections to update
2453: my @currsections = ();
2454: my @currxlists = ();
2455: my $coursecode = $$settings{'internal.coursecode'};
2456:
2457: if ($$settings{'internal.sectionnums'} ne '') {
2458: @currsections = split(/,/,$$settings{'internal.sectionnums'});
2459: }
2460:
2461: if ($$settings{'internal.crosslistings'} ne '') {
2462: @currxlists = split(/,/,$$settings{'internal.crosslistings'});
2463: }
2464:
2465: if (@currxlists > 0) {
2466: foreach (@currxlists) {
2467: if (m/^([^:]+):(\w*)$/) {
2468: unless (grep/^$1$/,@{$allcourses}) {
2469: push @{$allcourses},$1;
2470: $$LC_code{$1} = $2;
2471: }
2472: }
2473: }
2474: }
2475:
2476: if (@currsections > 0) {
2477: foreach (@currsections) {
2478: if (m/^(\w+):(\w*)$/) {
2479: my $sec = $coursecode.$1;
2480: my $gp = $2;
2481: unless (grep/^$sec$/,@{$allcourses}) {
2482: push @{$allcourses},$sec;
2483: $$LC_code{$sec} = $gp;
2484: }
2485: }
2486: }
2487: }
2488: return;
2489: }
2490:
2491:
1.14 raeburn 2492: sub print_viewclass_response {
2493: my ($r,$realm,$dom,$crs,$action,$tasktitleref) = @_;
2494: my $response;
2495: my $chgtotal = 0;
2496: my $chgok = 0;
2497: my $chgfail = 0;
2498: my $othdom = 0;
1.16 raeburn 2499: my $locktotal = 0;
2500: my $lockok = 0;
2501: my $lockfail = 0;
1.14 raeburn 2502: my $cid = $dom."_".$crs;
2503: my %chg = ();
2504: my %nochg = ();
2505: my %otherdom = ();
1.16 raeburn 2506: my %lockchg = ();
2507: my %nolockchg = ();
1.27 albertel 2508: my $classlist = &Apache::loncoursedata::get_classlist($dom,$crs);
1.14 raeburn 2509: my $endidx = &Apache::loncoursedata::CL_END;
2510: my $startidx = &Apache::loncoursedata::CL_START;
2511: my $ididx=&Apache::loncoursedata::CL_ID;
2512: my $secidx=&Apache::loncoursedata::CL_SECTION;
2513: my $typeidx=&Apache::loncoursedata::CL_TYPE;
1.16 raeburn 2514: my $lockedidx=&Apache::loncoursedata::CL_LOCKEDTYPE;
2515: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['chgauto','chgmanual','lockchg','unlockchg']);
1.24 albertel 2516: my @typechglist = (&Apache::loncommon::get_env_multiple('form.chgauto'),
2517: &Apache::loncommon::get_env_multiple('form.chgmanual'));
2518: my @lockchglist = (&Apache::loncommon::get_env_multiple('form.lockchg'),
2519: &Apache::loncommon::get_env_multiple('form.unlockchg'));
2520:
1.16 raeburn 2521: foreach my $student (sort @typechglist) {
2522: my ($uname,$udom) = split/:/,$student;
2523: my $sdata = $classlist->{$student};
2524: my $section = $sdata->[$secidx];
2525: my $uid = $sdata->[$ididx];
2526: my $start = $sdata->[$startidx];
2527: my $end = $sdata->[$endidx];
2528: my $type = $sdata->[$typeidx];
2529: my $lock = $sdata->[$lockedidx];
2530: my $newlock = $lock;
2531: $chgtotal ++;
2532: my $newtype = 'auto';
2533: my $change = 'auto';
2534: my $oldtype = 'manual';
2535: if ($type eq 'auto') {
2536: $oldtype = 'auto';
2537: $newtype = '';
2538: $change = 'manual';
2539: }
2540: if ($udom eq $dom) {
2541: if ($newtype eq 'auto') {
2542: $newlock = '';
2543: } elsif ($newtype eq '') {
2544: $newlock = '1';
1.14 raeburn 2545: }
1.16 raeburn 2546: my $modreply = &Apache::lonnet::modify_student_enrollment($udom,$uname,$uid,'','','','',$section,$end,$start,$newtype,$newlock,$cid);
2547: if ($modreply eq 'ok') {
2548: $chgok ++;
2549: $chg{$student} = "Changed to $change";
2550: } else {
2551: $chgfail ++;
2552: $nochg{$student} = "Still set to $oldtype";
2553: }
2554: } else {
2555: $othdom ++;
2556: $otherdom{$student} = "Still set to $oldtype";
2557: }
2558: }
2559: foreach my $student (@lockchglist) {
2560: my ($uname,$udom) = split/:/,$student;
2561: my $sdata = $classlist->{$student};
2562: my $section = $sdata->[$secidx];
2563: my $uid = $sdata->[$ididx];
2564: my $start = $sdata->[$startidx];
2565: my $end = $sdata->[$endidx];
2566: my $type = $sdata->[$typeidx];
2567: my $lock = $sdata->[$lockedidx];
2568: my $newlock = 1;
2569: my $oldlockname = &mt('unlocked');
2570: my $newlockname = &mt('locked');
2571: $locktotal++;
2572: unless ($type eq 'auto') {
2573: if ($lock) {
2574: $newlock = '';
2575: $newlockname = &mt('unlocked');
2576: $oldlockname = &mt('locked');
2577: }
2578: my $lockreply = &Apache::lonnet::modify_student_enrollment($udom,$uname,$uid,'','','','',$section,$end,$start,$type,$newlock,$cid);
2579: if ($lockreply eq 'ok') {
2580: $lockok ++;
2581: $lockchg{$student} = 'Changed to '.$newlockname;
1.14 raeburn 2582: } else {
1.16 raeburn 2583: $lockfail ++;
2584: $nolockchg{$student} = 'Still set to '.$oldlockname;
1.14 raeburn 2585: }
2586: }
2587: }
2588: if ($chgtotal > 0) {
2589: $response = "You requested a change in enrollment type for $chgtotal students.<br /><br />\n";
1.27 albertel 2590: $classlist = &Apache::loncoursedata::get_classlist($dom,$crs);
1.14 raeburn 2591: if ($chgok > 0) {
2592: $response .= "The following $chgok changes were successful:<br />";
2593: $response .= &enrolltype_result(\%chg,$classlist,$endidx,$startidx,$ididx,$secidx,$typeidx);
2594: }
2595: if ($chgfail > 0) {
2596: $response .= "The following $chgfail students were not modified successfully: <br />";
2597: $response .= &enrolltype_result(\%nochg,$classlist,$endidx,$startidx,$ididx,$secidx,$typeidx);
2598: }
2599: if ($othdom > 0) {
2600: $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 />";
2601: $response .= &enrolltype_result(\%otherdom,$classlist,$endidx,$startidx,$ididx,$secidx,$typeidx);
2602: }
1.16 raeburn 2603: $response .= "<br /><br />";
2604: }
2605: if ($locktotal > 0) {
2606: $response .= "You requested locking/unlocking for $locktotal manually enrolled students.<br /><br />\n";
1.27 albertel 2607: $classlist = &Apache::loncoursedata::get_classlist($dom,$crs);
1.16 raeburn 2608: if ($lockok > 0) {
2609: $response .= "The following $lockok changes were successful:<br />";
2610: $response .= &enrolltype_result(\%lockchg,$classlist,$endidx,$startidx,$ididx,$secidx,$typeidx,$lockedidx);
2611: }
2612: if ($lockfail > 0) {
2613: $response .= "The following $lockfail students were not modified successfully: <br />";
2614: $response .= &enrolltype_result(\%nolockchg,$classlist,$endidx,$startidx,$ididx,$secidx,$typeidx,$lockedidx);
2615: }
1.14 raeburn 2616: }
2617: &print_reply($r,$response,$$tasktitleref{$action});
2618: return;
2619: }
2620:
2621: sub enrolltype_result {
1.16 raeburn 2622: my ($changes,$classlist,$endidx,$startidx,$ididx,$secidx,$typeidx,$lockedidx) = @_;
1.14 raeburn 2623: my $reply = "
2624: <table border='2'>
2625: <tr>
2626: <th>username</th>
2627: <th>domain</th>
2628: <th>ID</th>
2629: <th>student name</th>
2630: <th>section</th>
2631: <th>start date</th>
2632: <th>end date</th>
2633: <th>enrollment change</th>
2634: </tr>";
2635: foreach (sort keys %{$changes}) {
2636: my $sdata = $classlist->{$_};
2637: my ($uname,$udom) = split/:/,$_;
2638: my $section = $sdata->[$secidx];
2639: my $uid = $sdata->[$ididx];
2640: my $start = $sdata->[$startidx];
2641: my $end = $sdata->[$endidx];
2642: my $type = $sdata->[$typeidx];
2643: if (! defined($start) || $start == 0) {
2644: $start = &mt('none');
2645: } else {
2646: $start = &Apache::lonlocal::locallocaltime($start);
2647: }
2648: if (! defined($end) || $end == 0) {
2649: $end = &mt('none');
2650: } else {
2651: $end = &Apache::lonlocal::locallocaltime($end);
2652: }
2653: if (!defined($section) || ($section eq '')) {
2654: $section eq ' ';
2655: }
2656: if (!defined($uid) || ($uid eq '')) {
2657: $uid = ' ';
2658: }
2659: $reply .= "
2660: <tr>
2661: <td>$uname</td>
2662: <td>$udom</td>
2663: <td>$uid</td>
2664: <td>".&Apache::loncommon::plainname($uname,$udom)."</td>
2665: <td>$section</td>
2666: <td>$start</td>
2667: <td>$end</td>
2668: <td>$$changes{$_}</td>
2669: </tr>";
2670: }
2671: $reply .= "</table>";
2672: return $reply;
2673: }
2674:
1.10 raeburn 2675: sub warning_message {
2676: my ($dom,$crs,$caller) = @_;
2677: my %settings = &Apache::lonnet::get('environment',['internal.autoadds','internal.autodrops','internal.sectionnums','internal.crosslistings','internal.autostart','internal.autoend'],$dom,$crs);
2678: my $currend = '';
2679: my $currstart = '';
2680: my $currsecs = '';
2681: my $currxlists = '';
2682: my $warning = '';
2683: my $curradds = '';
2684: my $currdrops = '';
2685: if ( defined($settings{'internal.autoadds'}) ) {
2686: $curradds = $settings{'internal.autoadds'};
2687: }
2688: if (defined($settings{'internal.autodrops'}) ) {
2689: $currdrops = $settings{'internal.autodrops'};
2690: }
2691: if ( defined($settings{'internal.autostart'}) ) {
2692: $currstart = $settings{'internal.autostart'};
2693: }
2694: if ( defined($settings{'internal.autoend'}) ) {
2695: $currend = $settings{'internal.autoend'};
2696: }
2697: if ( defined($settings{'internal.sectionnums'}) ) {
2698: $currsecs = $settings{'internal.sectionnums'};
2699: }
2700: if ( defined($settings{'internal.crosslistings'}) ) {
2701: $currxlists = $settings{'internal.crosslistings'}
2702: }
2703: unless ($caller eq 'setdates') {
2704: if ( ($currstart eq '') && ($currend eq '') ) {
2705: $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>";
2706: }
2707: }
2708: unless ( ($caller eq 'sections') || ($caller eq 'crosslist') ) {
2709: if ( ($currsecs eq '') && ($currxlists eq '') ) {
2710: $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/>";
2711: }
2712: }
2713: unless ( $caller eq 'chgsettings') {
2714: if ( (!$curradds) && (!$currdrops) ) {
2715: $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/>.";
2716: }
2717: }
2718: return $warning;
1.1 raeburn 2719: }
2720:
2721: sub print_reply () {
2722: my ($r,$response,$caller) = @_;
2723: $r->print("
2724: <br/><table width=\"100%\" border=\"0\" cellpadding=\"2\" cellspacing=\"2\">
2725: <tr>
1.14 raeburn 2726: <td align=\"left\"><b>$caller</b> - result<br/><br/>$response</td>
1.1 raeburn 2727: </tr>
2728: </table>
2729: ");
2730: return;
2731: }
2732:
2733: sub setup_date_selectors {
1.14 raeburn 2734: my ($starttime,$endtime,$action) = @_;
1.1 raeburn 2735: if (! defined($starttime)) {
2736: $starttime = time;
1.14 raeburn 2737: if ($action eq 'setdates') {
1.23 albertel 2738: if (exists($env{'course.'.$env{'request.course.id'}.
1.1 raeburn 2739: '.default_enrollment_start_date'})) {
1.23 albertel 2740: $starttime = $env{'course.'.$env{'request.course.id'}.
1.1 raeburn 2741: '.default_enrollment_start_date'};
1.14 raeburn 2742: }
1.1 raeburn 2743: }
2744: }
2745: if (! defined($endtime)) {
2746: $endtime = time+(6*30*24*60*60); # 6 months from now, approx
1.14 raeburn 2747: if ($action eq 'setdates') {
1.23 albertel 2748: if (exists($env{'course.'.$env{'request.course.id'}.
1.1 raeburn 2749: '.default_enrollment_end_date'})) {
1.23 albertel 2750: $endtime = $env{'course.'.$env{'request.course.id'}.
1.1 raeburn 2751: '.default_enrollment_end_date'};
1.14 raeburn 2752: }
1.1 raeburn 2753: }
2754: }
2755: my $startdateform = &Apache::lonhtmlcommon::date_setter('enter',
2756: 'startdate',
2757: $starttime);
2758: my $enddateform = &Apache::lonhtmlcommon::date_setter('enter',
2759: 'enddate',
2760: $endtime);
2761: return ($startdateform,$enddateform);
2762: }
2763:
2764: sub get_dates_from_form {
1.14 raeburn 2765: my $startdate;
2766: my $enddate;
2767: $startdate = &Apache::lonhtmlcommon::get_date_from_form('startdate');
2768: $enddate = &Apache::lonhtmlcommon::get_date_from_form('enddate');
1.23 albertel 2769: if ( exists ($env{'form.no_end_date'}) ) {
1.1 raeburn 2770: $enddate = 0;
2771: }
2772: return ($startdate,$enddate);
2773: }
2774:
2775: sub date_setting_table {
1.14 raeburn 2776: my ($starttime,$endtime,$action) = @_;
2777: my ($startform,$endform) = &setup_date_selectors($starttime,$endtime,$action);
1.1 raeburn 2778: my $perpetual = '<nobr><input type="checkbox" name="no_end_date"';
1.14 raeburn 2779: if (($action eq 'setdates' && defined($endtime) && $endtime == 0) || (($action eq 'setaccess' || $action eq 'updatenow') && ($endtime eq '' || $endtime == 0)) ) {
1.1 raeburn 2780: $perpetual .= ' checked';
2781: }
2782: $perpetual.= ' />'.' no ending date</nobr>';
2783: my $start_table = '';
2784: $start_table .= "<table>\n";
2785: $start_table .= '<tr><td align="right">Starting Date</td>'.
2786: '<td>'.$startform.'</td>'.
2787: '<td> </td>'."</tr>\n";
2788: $start_table .= "</table>";
2789: my $end_table = '';
2790: $end_table .= "<table>\n";
2791: $end_table .= '<tr><td align="right">Ending Date</td>'.
2792: '<td>'.$endform.'</td>'.
2793: '<td>'.$perpetual.'</td>'."</tr>\n";
2794: $end_table .= "</table>\n";
2795: return ($start_table, $end_table);
2796: }
2797:
2798: ###################################################################
2799: sub handler {
2800: my $r = shift;
2801: if ($r->header_only) {
1.22 albertel 2802: &Apache::loncommon::content_type($r,'text/html');
1.1 raeburn 2803: $r->send_http_header;
2804: return OK;
2805: }
2806: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['action','state']);
2807: # Needs to be in a course
1.23 albertel 2808: if (! (($env{'request.course.fn'}) && (&Apache::lonnet::allowed('cst',$env{'request.course.id'})))) {
1.1 raeburn 2809: # Not in a course, or not allowed to modify parms
1.23 albertel 2810: $env{'user.error.msg'}="/adm/populate:cst:0:0:Cannot drop or add students";
1.34 raeburn 2811: return HTTP_NOT_ACCEPTABLE;
1.1 raeburn 2812: }
2813: # Start page
1.22 albertel 2814: &Apache::loncommon::content_type($r,'text/html');
1.1 raeburn 2815: $r->send_http_header;
2816:
1.34 raeburn 2817: my @tasks = ("information","chgsettings","setdates","setaccess","notify","crosslist","sections","photos","updatenow","updatephotos","viewclass");
1.1 raeburn 2818:
2819: my %tasklong = (
2820: information => "Task information",
2821: chgsettings => "Automated adds/drops",
2822: setdates => "Change enrollment dates",
1.14 raeburn 2823: setaccess => "Change access dates",
1.1 raeburn 2824: notify => "Notification of changes",
2825: crosslist => "Change crosslistings",
2826: sections => "Section settings",
1.34 raeburn 2827: photos => "Student photo settings",
2828: updatephotos => "Update student photos",
1.1 raeburn 2829: updatenow => "Update roster now",
2830: newcross => "Add crosslistings",
1.14 raeburn 2831: newsections => "Add sections",
1.16 raeburn 2832: viewclass => "View students and change type",
1.1 raeburn 2833: );
2834:
2835: my %tasktitle = (
2836: chgsettings => "Changes to nightly automated enrollments",
2837: setdates => "Changes to first and/or last automated enrollment dates",
1.14 raeburn 2838: setaccess => "Changes to default start and/or end dates for student access",
1.1 raeburn 2839: notify => "Notification of enrollment changes",
2840: crosslist => "Changes to crosslistings",
2841: sections => "Changes to section settings",
1.34 raeburn 2842: photos => "Student photo settings",
2843: updatephotos => "Update student photos",
1.1 raeburn 2844: updatenow => "Immediate course roster update",
2845: newcross => "Adding new crosslisted courses",
1.14 raeburn 2846: newsections => "Adding new course sections",
2847: viewclass => "Viewing class roster and enrollment type"
1.1 raeburn 2848: );
2849:
2850: my $realm = '';
1.23 albertel 2851: if ( exists($env{'request.course.id'}) ) {
2852: $realm= $env{'course.'.$env{'request.course.id'}.'.description'};
1.1 raeburn 2853: }
2854: unless ($realm) { $realm=' '; }
1.23 albertel 2855: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
2856: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.1 raeburn 2857:
2858: #
2859: # Main switch on form.action and form.state, as appropriate
2860: #
2861:
2862: my $action = "information";
1.23 albertel 2863: if ( exists($env{'form.action'}) ) {
2864: $action = $env{'form.action'};
1.1 raeburn 2865: }
2866: my $state = "choose";
2867:
1.23 albertel 2868: if ( exists($env{'form.state'}) ) {
2869: $state = $env{'form.state'};
1.1 raeburn 2870: }
2871:
2872: if ($action eq "information") {
2873: $r->print(&header());
2874: } else {
2875: if ($state eq "choose") {
1.16 raeburn 2876: $r->print(&choose_header($action));
1.1 raeburn 2877: } else {
2878: if ($action eq "crosslist") {
1.23 albertel 2879: if ( exists($env{'form.numcross'}) ) {
2880: if ( $env{'form.numcross'} > 0 ) {
1.16 raeburn 2881: $r->print(&choose_header($action));
1.1 raeburn 2882: } else {
2883: $r->print(&header());
2884: }
2885: } else {
2886: $r->print(&header());
2887: }
2888: } elsif ($action eq "sections") {
1.23 albertel 2889: if ( exists($env{'form.numsec'}) ) {
2890: if ( $env{'form.numsec'} > 0 ) {
1.16 raeburn 2891: $r->print(&choose_header($action));
1.1 raeburn 2892: } else {
2893: $r->print(&header());
2894: }
2895: } else {
2896: $r->print(&header());
2897: }
2898: } else {
2899: $r->print(&header());
2900: }
2901: }
2902: }
1.12 raeburn 2903:
1.1 raeburn 2904: my $reply = 0;
2905: unless ($state eq "choose") { $reply = 1; }
2906:
2907: &print_mainbox($r,\%tasklong,$realm,$reply);
2908: &print_navmenu($r,\@tasks,\%tasklong);
2909:
2910: if (($state eq "choose") || ($action eq "information")) {
1.13 raeburn 2911: &print_main_frame($r,$realm,$dom,$crs,\%tasktitle);
1.1 raeburn 2912: } elsif ($action eq "chgsettings") {
2913: &print_chgsettings_response($r,$realm,$dom,$crs,$action,\%tasktitle);
2914: } elsif ($action eq "setdates") {
2915: &print_setdates_response($r,$realm,$dom,$crs,$action,\%tasktitle);
1.14 raeburn 2916: } elsif ($action eq "setaccess") {
2917: &print_setaccess_response($r,$realm,$dom,$crs,$action,\%tasktitle);
1.1 raeburn 2918: } elsif ($action eq "notify") {
2919: &print_notify_response($r,$realm,$dom,$crs,$action,\%tasktitle);
2920: } elsif ($action eq "sections") {
1.13 raeburn 2921: &print_sections_menu($r,$realm,$dom,$crs,$action,\%tasktitle);
1.1 raeburn 2922: } elsif ($action eq "crosslist") {
1.13 raeburn 2923: &print_crosslistings_menu($r,$realm,$dom,$crs,$action,\%tasktitle);
1.1 raeburn 2924: } elsif ($action eq "updatenow") {
1.13 raeburn 2925: &print_update_result($r,$realm,$dom,$crs,$action,\%tasktitle);
1.1 raeburn 2926: } elsif ($action eq "photos") {
1.34 raeburn 2927: if ($state eq "photoupdate") {
2928: &print_photoupdate_response($r,$realm,$dom,$crs,$action,\%tasktitle);
2929: } else {
2930: &photo_permission($r,$realm,$dom,$crs,$action,\%tasktitle);
2931: }
2932: } elsif ($action eq "updatephotos") {
2933: &print_photoupdate_response($r,$realm,$dom,$crs,$action,\%tasktitle);
1.1 raeburn 2934: } elsif ($action eq "newcross") {
1.13 raeburn 2935: &print_crosslistings_response($r,$realm,$dom,$crs,$action,\%tasktitle);
1.1 raeburn 2936: } elsif ($action eq "newsections") {
1.13 raeburn 2937: &print_sections_response($r,$realm,$dom,$crs,$action,\%tasktitle);
1.14 raeburn 2938: } elsif ($action eq "viewclass") {
2939: &print_viewclass_response($r,$realm,$dom,$crs,$action,\%tasktitle);
1.1 raeburn 2940: }
2941: &print_doc_base($r);
2942: return OK;
2943: }
2944: ###################################################################
2945: 1;
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>