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