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