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