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