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