File:
[LON-CAPA] /
loncom /
interface /
lonpopulate.pm
Revision
1.1:
download - view:
text,
annotated -
select for diffs
Mon Dec 8 16:16:03 2003 UTC (20 years, 8 months ago) by
raeburn
Branches:
MAIN
CVS tags:
HEAD
Module to build interface for management of automated enrollment by course coordinators. Can also be used to perform reconciliation of classlist with institutional data (via "update roster now" option - calls the same LONCAPA::Enrollment.pm module as the automated enrollment script). Requires addition of following to /etc/httpd/conf/loncapa_apache.conf -
<Location /adm/populate>
PerlAccessHandler Apache::lonacc
SetHandler perl-script
PerlHandler Apache::lonpopulate
ErrorDocument 403 /adm/login
ErrorDocument 406 /adm/roles
ErrorDocument 500 /adm/errorhandler
</Location>
1: package Apache::lonpopulate;
2:
3: use strict;
4: use lib qw(/home/httpd/lib/perl);
5: use Apache::lonnet ();
6: use Apache::loncommon ();
7: use Apache::lonhtmlcommon ();
8: use Apache::Constants qw(:common :http REDIRECT);
9: use Time::Local;
10: use LONCAPA::Enrollment ();
11: use localenroll;
12:
13: ###############################################################
14: sub header {
15: my $bodytag=&Apache::loncommon::bodytag('Classlist Manager');
16: return(<<ENDHEAD);
17: <html>
18: <head>
19: <title>LON-CAPA Classlist Manager</title>
20: </head>
21: $bodytag
22: ENDHEAD
23: }
24:
25: ###############################################################
26:
27: sub choose_header {
28: my $bodytag=&Apache::loncommon::bodytag('Classlist Manager');
29: my $scripttag = qq|
30: <script language='javascript' type='text/javascript'>
31: <!--
32: function process(calling) {
33: var checker = 1
34: var rad1 = 0
35: var rad2 = 0
36: var formName = document.forms.enter
37: formName.action.value = calling
38: if (calling == "chgsettings") {
39: for (var j=0; j<formName.autoadds.length; j++) {
40: if (formName.autoadds[j].checked) {
41: rad1 = 1
42: }
43: }
44: for (var k=0; k<formName.autodrops.length; k++) {
45: if (formName.autodrops[k].checked) {
46: rad2 = 1
47: }
48: }
49: if (rad1 == 0) {
50: alert("You must check either 'Enable' or 'Disable' for nightly additions based on classlist changes")
51: checker = 0
52: }
53: if (rad2 == 0) {
54: alert("You must check either 'Enable' or 'Disable' for nightly removals based on classlist changes")
55: checker = 0
56: }
57: }
58: if (calling == "updatenow") {
59: var enrolldis
60: var unenrolldis
61: for (var j=0; j<formName.updateadds.length; j++) {
62: if (formName.updateadds[j].value == 0) {
63: enrolldis = j
64: }
65: if (formName.updateadds[j].checked) {
66: rad1 = 1
67: }
68: }
69: for (var k=0; k<formName.updatedrops.length; k++) {
70: if (formName.updatedrops[k].value == 0) {
71: unenrolldis = k
72: }
73: if (formName.updatedrops[k].checked) {
74: rad2 = 1
75: }
76: }
77: if (rad1 == 0) {
78: alert("You must check either 'Enable' or 'Disable' for nightly additions based on classlist changes")
79: checker = 0
80: }
81: if (rad2 == 0) {
82: alert("You must check either 'Enable' or 'Disable' for nightly removals based on classlist changes")
83: checker = 0
84: }
85: if (formName.updatedrops[unenrolldis].checked && formName.updateadds[enrolldis].checked ) {
86: alert("You have checked 'Disable' for both addition and removal of students\\n in the Registrar's classlist but not in your LON-CAPA course. \\nHence there is no update to carry out")
87: checker = 0
88: }
89: }
90: if (checker == 1) {
91: formName.submit();
92: }
93: }
94: // End hiding -->
95: </script>
96: |;
97: return(<<ENDHEAD);
98: <html>
99: <head>
100: <title>LON-CAPA Classlist Manager</title>
101: $scripttag
102: $bodytag
103: ENDHEAD
104: }
105:
106: sub print_mainbox {
107: my ($r,$tasklongref,$realm,$reply) = @_;
108: my $action = "information";
109: if ( exists($ENV{'form.action'}) ) {
110: $action = $ENV{'form.action'};
111: }
112: my $page = '';
113: if ($action eq "information") {
114: $page = "<b>Automated Enrollment</b>";
115: } else {
116: $page = '<a href="/adm/populate">Automated Enrollment</a>';
117: if ($reply) {
118: if ($action eq "newcross") {
119: $action = "crosslist";
120: } elsif ($action eq "newsections") {
121: $action = "sections";
122: }
123: $page .= "-> <a href=\"/adm/populate?action=$action\">".$$tasklongref{$action}."</a> -> <b>result</b>";
124: } else {
125: $page .= " -> <b>".$$tasklongref{$action}."</b>";
126: }
127: }
128: $r->print(<<ENDTHIS);
129: <table width="100%" border="0" cellpadding="0" cellspacing="0">
130: <tr>
131: <td bgcolor="#CCCCFF">
132: <font size="2"><a href="/adm/menu">$realm</a> -> <a href="/adm/dropadd">Enrollment Manager</a> -> $page</font><br/>
133: </td>
134: <td align="right" bgcolor="#CCCCFF" valign="top">
135: <font size="+1">Automated Enrollment Manager </font>
136: </td>
137: </tr>
138: </table>
139: <table width="100%" border="0" cellpadding="0" cellspacing="0">
140: <tr>
141: ENDTHIS
142: }
143:
144: sub print_navmenu {
145: my ($r,$tasksref,$tasklongref) = @_;
146: my $action = "information";
147: if (exists($ENV{'form.action'}) ) {
148: $action = $ENV{'form.action'};
149: }
150: $r->print(<<ENDONE);
151: <td width="10" valign="top" bgcolor="#DDFFFF"> </td>
152: <td width="20%" valign="top" bgcolor="#DDFFFF">
153: <br/>
154: ENDONE
155: foreach my $task (@{$tasksref}) {
156: if ($task eq $action) {
157: $r->print("
158: <p>
159: <font color=\"#999999\">
160: <b>$$tasklongref{$task}</b><br/>
161: </font>
162: </p>");
163: } else {
164: $r->print("
165: <p>
166: <font color=\"#004263\">
167: <b><a href=\"/adm/populate?action=$task\">$$tasklongref{$task}</a></b><br/>
168: </font>
169: </p>");
170:
171: }
172: }
173: $r->print("
174: <p> </p>
175: </td>
176: <td width=\"10\" valign=\"top\" bgcolor=\"#CCCCFF\"> </td>
177: <td width=\"10\" valign=\"top\" bgcolor=\"#FFFFFF\"> </td>
178: <td bgcolor=\"#ffffff\" valign=\"top\">");
179: }
180:
181: ###############################################################
182:
183: sub print_main_frame {
184: my ($r,$realm,$dom,$crs,$tasktitleref) = @_;
185: my $action = "information";
186: if (exists($ENV{'form.action'}) ) {
187: $action = $ENV{'form.action'};
188: }
189:
190: # Get course settings
191: my %enrollvar;
192: my @bgcolors=("#eeeeee","#cccccc");
193: my %settings = &Apache::lonnet::dump('environment',$dom,$crs);
194: foreach my $item (keys %settings) {
195: if ($item =~ m/^internal\.(.+)$/) {
196: $enrollvar{$1} = $settings{$item};
197: }
198: }
199:
200: if ($action eq "information") {
201: $r->print(<<ENDONE);
202: <table border='0' width='100%'>
203: <tr>
204: <td> </td>
205: <td><b>Use the menu on the left to choose an enrollment management task.</b><br/><br/></td>
206: <tr>
207: <td> </td>
208: <td>Use <i>"Automated adds/drops"</i> to enable or disable automatic nightly adds or drops in your LON-CAPA course based on instututional enrollment information.</td>
209: </tr>
210: <tr>
211: <td> </td>
212: <td>Use <i>"Change enrollment dates"</i> to change the date of first automated enrollment and/or the date of last automated enrollment for registered students.</td>
213: </tr>
214: <tr>
215: <td> </td>
216: <td>Use <i>"Notification of changes"</i> to enable or disable notification of enrollment changes and to add or remove course coordinators from the recipient list.</td>
217: </tr>
218: <tr>
219: <td> </td>
220: <td>Use <i>"Change crosslisting"</i> to include or exclude enrollment from crosslisted classes.</td>
221: </tr>
222: <tr>
223: <td> </td>
224: <td>Use <i>"Section settings"</i> to make changes to the choice of sections included for enrollment in your LON-CAPA course.</td>
225: </tr>
226: <td> </td>
227: <td>Use <i>"Student photos"</i> to enable or disable the use of student photos in your course.</td>
228: </tr>
229: <tr>
230: <td> </td>
231: <td>Use <i>"Update roster now"</i> to add and/or drop students from your course based on the <b>most current</b> institutional classlist information.</td>
232: </tr>
233: <tr>
234: <td colspan='2'> </td>
235: </tr>
236: <tr>
237: <td> </td>
238: <td><b>Note: if automated adds and/or drops are enabled, the nightly enrollment update will ONLY occur once the first enrollment date has been reached.</b></td>
239: </tr>
240: </table>
241: ENDONE
242: } elsif ($action eq "chgsettings") {
243: my @autosets = ("OFF","ON");
244: $r->print(<<ENDTWO);
245: <form name="enter" method="post"><br/>
246: <table width="100%" border="0" cellpadding="2" cellspacing="2">
247: <tr>
248: <td align="left"><b>$$tasktitleref{$action}</b><br/>
249: Currently: Nightly adds: <i>$autosets[$enrollvar{autoadds}]</i>, Nightly drops: <i>$autosets[$enrollvar{autodrops}]</i>
250: </td>
251: </tr>
252: </table>
253: <table width="100%" border="0" cellpadding="3" cellspacing="3">
254: <tr>
255: <td>
256: Additions based on classlist changes:
257: ENDTWO
258: if ($enrollvar{autoadds}) {
259: $r->print("
260: <input type=\"radio\" name=\"autoadds\" value=\"1\" checked=\"true\" /> Enable
261: <input type=\"radio\" name=\"autoadds\" value=\"0\" /> Disable
262: ");
263: } else {
264: $r->print("
265: <input type=\"radio\" name=\"autoadds\" value=\"1\" /> Enable
266: <input type=\"radio\" name=\"autoadds\" value=\"0\" checked=\"true\" /> Disable
267: ");
268: }
269: $r->print("
270: </td>
271: </tr>
272: <tr>
273: <td>
274: Removals based on classlist changes: ");
275: if ($enrollvar{autodrops}) {
276: $r->print("
277: <input type=\"radio\" name=\"autodrops\" value=\"1\" checked=\"true\" /> Enable
278: <input type=\"radio\" name=\"autodrops\" value=\"0\" /> Disable");
279: } else {
280: $r->print("
281: <input type=\"radio\" name=\"autodrops\" value=\"1\" /> Enable
282: <input type=\"radio\" name=\"autodrops\" value=\"0\" checked=\"true\" /> Disable");
283: }
284: $r->print("
285: </td>
286: </tr>
287: <tr>
288: <td>
289: <font color=\"#888888\">
290: Note: Any students added manually by course coordinators using the Enrollment Manager will be unaffected by the nightly removal process if you choose to enable it.
291: </font>
292: </td>
293: </tr>
294: <tr>
295: <td align=\"right\">
296: <input type=\"button\" name=\"chgsettings\" value=\"Go\" onClick=\"process('chgsettings')\" />
297: </td>
298: </tr>
299: </table>
300: <input type=\"hidden\" name=\"action\" value=\"$action\">
301: <input type=\"hidden\" name=\"state\" value=\"process\">
302: </form>
303: ");
304: } elsif ($action eq "setdates") {
305: my ($start_table,$end_table) = &date_setting_table($enrollvar{autostart},$enrollvar{autoend});
306: my $oldstartshow = localtime($enrollvar{autostart});
307: my $oldendshow = localtime($enrollvar{autoend});
308: if ($enrollvar{autoend} == 0) {
309: $oldendshow = "No ending date";
310: }
311: $r->print(<<ENDTWO);
312: <form name="enter" method="post"><br/>
313: <table width="100%" border="0" cellpadding="2" cellspacing="2">
314: <tr>
315: <td align="left"><b>$$tasktitleref{$action}</b><br/>
316: Currently: First enrollment: <i>$oldstartshow</i>, Last enrollment: <i>$oldendshow</i>
317: </td>
318: </tr>
319: </table>
320: <table width="100%" border="0" cellpadding="3" cellspacing="3">
321: <tr>
322: <td align="left" colspan="2">
323: <table border="0" cellspacing="0" cellpadding="2">
324: <tr>
325: <td colspan="3">
326: <i>Set date of first automated enrollment for registered students</i>
327: </td>
328: </tr>
329: <tr>
330: <td>$start_table
331: </td>
332: </tr>
333: </table>
334: </td>
335: </tr>
336: <tr>
337: <td colspan="2"><font color="#888888">If automated adds and/or drops are enabled, then your class roster will be automatically updated nightly, once the first enrollment date has been reached. Prior to this date, the class roster will only contain students you have added directly using the standard LON-CAPA enrollment tools</font></td>
338: </tr>
339: <tr>
340: <td align="left" colspan="2">
341: <table border="0' cellspacing="0" cellpadding="2">
342: <tr>
343: <td colspan="3">
344: <i>Set date of last automated enrollment for registered students</i>
345: </td>
346: </tr>
347: <tr>
348: <td>$end_table
349: </td>
350: </tr>
351: </table>
352: </td>
353: </tr>
354: <tr>
355: <td colspan="2"><font color="#888888">If automated adds and/or drops are enabled, then your class roster will be automatically updated nightly, until the last enrollment date has been reached.</font></td>
356: </tr>
357: </table>
358: <table width="100%">
359: <tr>
360: <td align="right">
361: <input type="button" name="setdates" value="Go" onClick="process('setdates')" />
362: </td>
363: </tr>
364: </table>
365: <input type=\"hidden\" name=\"action\" value=\"$action\">
366: <input type=\"hidden\" name=\"state\" value=\"process\">
367: </form>
368: ENDTWO
369: } elsif ($action eq "notify") {
370: my @notified = ();
371: if ($enrollvar{notifylist} =~ m/,/) {
372: @notified = split/,/,$enrollvar{notifylist};
373: } else {
374: @notified = $enrollvar{notifylist};
375: }
376: my $notifycount = 0;
377: foreach (@notified) {
378: unless ($_ eq '') { $notifycount ++; }
379: }
380: my $noteset = '';
381: if ($notifycount) {
382: $noteset = "ON";
383: } else {
384: $noteset = "OFF";
385: }
386:
387: $r->print("
388: <form name=\"enter\" method=\"post\"><br/>
389: <table width=\"100%\" border=\"0\" cellpadding=\"6\" cellspacing=\"0\">
390: <tr>
391: <td align=\"left\"><b>$$tasktitleref{$action}</b><br/>
392: Currently: Notification: $noteset
393: </td>
394: </tr>
395: </table>
396: <table width=\"100%\" border=\"0\" cellpadding=\"3\" cellspacing=\"3\">
397: <tr>
398: <td>
399: Notification of LON-CAPA course roster changes resulting from nightly automated enrollment process?
400: ");
401: if ($notifycount) {
402: $r->print("
403: <input type=\"radio\" name=\"notify\" value=\"1\" checked=\"true\" /> Yes
404: <input type=\"radio\" name=\"notify\" value=\"0\" /> No
405: ");
406: } else {
407: $r->print("
408: <input type=\"radio\" name=\"notify\" value=\"1\" /> Yes
409: <input type=\"radio\" name=\"notify\" value=\"0\" checked=\"true\" /> No
410: ");
411: }
412: $r->print("
413: </td>
414: </tr>
415: ");
416: my $option_str = '';
417: my $lastpname = '';
418: my $option_count = 0;
419:
420: my %coursepersonnel=&Apache::lonnet::get_course_adv_roles($dom.'/'.$crs);
421: foreach (sort keys %coursepersonnel) {
422: if ($_ eq "Course Coordinator")
423: {
424: my @ccs = ();
425: if ($coursepersonnel{$_} =~ m/,/) {
426: @ccs = split(/,/,$coursepersonnel{$_});
427: } else {
428: @ccs = $coursepersonnel{$_};
429: }
430: foreach (@ccs) {
431: my ($puname,$pudom)=split(/\:/,$_);
432: my $pname = &Apache::loncommon::plainname($puname,$pudom);
433: if (grep/^$puname\@$pudom$/,@notified) {
434: $option_str .="<option value=\"$puname\@$pudom\" selected>$pname</option>\n";
435: } else {
436: $option_str .="<option value=\"$puname\@$pudom\">$pname</option>\n";
437: }
438: $option_count ++;
439: $lastpname = $pname.'@'.$pudom;
440: }
441: }
442: }
443: if ($option_count > 1) {
444: my $optionsize = $option_count;
445: if ($optionsize > 6) {
446: $optionsize = 6;
447: }
448: $r->print("
449: <tr>
450: <td>
451: Select which course coordinators should receive information about roster changes whenever any adds or drops occur during the nightly enrollment check.<br/><br/>
452: <select name=\"notifylist\" multiple size=\"$optionsize\">$option_str</select>
453: </td>
454: </tr>
455: <tr>
456: <td>
457: Select more than one recipient by using the following keyboard and mouse combinations:<br/>
458: <ul>
459: <li>Apple-click: MacOS</li>
460: <li>Ctrl-click: Windows</li>
461: <li>Left click: Linux</li>
462: </ul>
463: </td>
464: </tr>
465: ");
466: } else {
467: $r->print("
468: <tr>
469: <td>
470: As you are the only user with the role of course coordinator in this course, if you choose to enable notification of roster changes, you will be the sole recipient of LON-CAPA messages generated whenever any adds or drops occur during the nightly enrollment check.
471: <input type=\"hidden\" name=\"notifylist\" value=\"$lastpname\" />
472: </td>
473: </tr>
474: ");
475: }
476: $r->print("
477: <tr>
478: <td align=\"right\">
479: <input type=\"button\" name=\"notifyset\" value=\"Go\" onClick=\"process('notify')\" />
480: </td>
481: </tr>
482: </table>
483: <input type=\"hidden\" name=\"action\" value=\"$action\">
484: <input type=\"hidden\" name=\"state\" value=\"process\">
485: </form>
486: ");
487: } elsif ($action eq "crosslist") {
488: my @xlists = ();
489: if ($enrollvar{crosslistings} =~ m/,/) {
490: @xlists = split/,/,$enrollvar{crosslistings};
491: } elsif ($enrollvar{crosslistings} ne '') {
492: $xlists[0] = $enrollvar{crosslistings};
493: }
494: my $cross_str = @xlists;
495: $r->print("
496: <form name=\"enter\" method=\"post\"><br/>
497: <table width=\"100%\" border=\"0\" cellpadding=\"2\" cellspacing=\"2\">
498: <tr>
499: <td align=\"left\"><b>$$tasktitleref{$action}</b><br/>
500: ");
501: if ($cross_str > 0) {
502: $r->print("
503: Currently, LON-CAPA course: $realm ($enrollvar{coursecode}) is crosslisted with $cross_str course section(s). Students enrolling in these course sections will be automatically added to the class roster for the course, if you have chosen to enable a nightly automated enrollment update. For each crosslisting, leave the checkbox checked if you want registered students in that course to be included in the student roster for LON-CAPA course: <b>$realm ($enrollvar{coursecode})</b>; otherwise uncheck it. If you wish to change the section/group ID assigned in your LON-CAPA course for a crosslisted course, enter the new section/group ID in the appropriate textbox. The LON-CAPA section/group ID can be left (or set to) empty, if you do not wish to tie a section/group ID to this crosslisting. Click 'Go' to store your changes.
504: </td>
505: </tr>
506: </table>
507: <br/>
508: <table border=\"0\" cellpadding=\"3\" cellspacing=\"3\">
509: <tr>
510: <td>
511: <table border=\"0\" width=\"100%\" cellspacing=\"3\" cellpadding=\"3\">
512: <tr bgcolor=\"#CCCCFF\" align=\"left\">
513: <td><b>Enrollment?</b></td>
514: <td><b>Crosslisted course</b></td>
515: <td><b>LON-CAPA section/groupID</b></td>
516: </tr>
517: ");
518: for (my $i=0; $i<@xlists; $i++) {
519: my $xl = ' ';
520: my $gp = ' ';
521: if ($xlists[$i] =~ /(\w+):(.+)$/) {
522: $xl = $1;
523: $gp = $2;
524: }
525: my $colflag = $i%2;
526: $r->print("
527: <tr bgcolor=\"$bgcolors[$colflag]\" align=\"left\">
528: <td><input type=\"checkbox\" name=\"cross_$i\" checked=\"true\"/></td>
529: <td>$xl</td>
530: <td><input type =\"text\" size=\"10\" name=\"gp_$i\" value=\"$gp\"></td>
531: </tr>
532: ");
533: }
534: $r->print(" </table>
535: </td>
536: </tr>
537: </table>
538: ");
539: }
540: else {
541: $r->print("
542: Currently no crosslisted courses are recorded for $enrollvar{coursecode}.
543: </td>
544: </tr>
545: </table>
546: ");
547: }
548: $r->print("
549: <br/>
550: <table width=\"100%\" border=\"0\" cellpadding=\"3\" cellspacing=\"3\">
551: <tr>
552: <td align=\"left\">
553: <b>Add new crosslistings.</b><br/>
554: Number of new crosslistings to add: <input type=\"text\" size=\"2\" name=\"numcross\" value=\"0\" />
555: </td>
556: </tr>
557: </table>
558: <br/>
559: <table width=\"100%\" border=\"0\" cellspadding=\"2\" cellspacing=\"2\">
560: <tr>
561: <td align=\"right\">
562: <input type=\"button\" name=\"crosslist\" value=\"Go\" onClick=\"process('crosslist')\" />
563: </td>
564: </tr>
565: </table>
566: <input type=\"hidden\" name=\"action\" value=\"$action\">
567: <input type=\"hidden\" name=\"state\" value=\"process\">
568: </form>
569: ");
570: } elsif ($action eq "sections") {
571: my @sections = &localenroll::get_sections($enrollvar{coursecode});
572: my @storedsections = ();
573: my @currsections = ();
574: my %sec_id = ();
575: if ($enrollvar{sectionnums} =~ m/,/) {
576: @storedsections = split/,/,$enrollvar{sectionnums};
577: } else {
578: $storedsections[0] = $enrollvar{sectionnums};
579: }
580: foreach (@storedsections) {
581: if ($_ =~ m/^(\w+):(\w*)$/) {
582: push @currsections, $1;
583: $sec_id{$1} = $2;
584: }
585: }
586: if (@sections > 0) {
587: if (@sections > 1) {
588: my $secshow = @sections;
589: $r->print("
590: <form name=\"enter\" method=\"post\"><br/>
591: <table width=\"100%\" border=\"0\" cellpadding=\"3\" cellspacing=\"3\">
592: <tr>
593: <td align=\"left\">
594: <b>$$tasktitleref{$action}</b><br/>
595: Your institution's course catalog includes $secshow sections for course code: $enrollvar{coursecode}.
596: </td>
597: </tr>
598: <tr>
599: <td>For each section, check the checkbox if you want registered students in that section to be included in the student roster for LON-CAPA course: <b>$realm ($enrollvar{coursecode})</b>; otherwise uncheck it. If you want to change the section/group designation used for this section in LON-CAPA, delete the currecnt value in the LON-CAPA section/group textbox and enter the new value. Click 'Go' to store your changes.</td>
600: </tr>
601: </table>
602: <br/>
603: <table border=\"0\" width=\"100%\" cellspacing=\"3\" cellpadding=\"3\">
604: <tr>
605: <td>
606: <table width=\"100%\" border=\"0\" cellpadding=\"3\" cellspacing=\"3\">
607: <tr bgcolor=\"#CCCCFF\">
608: <td><b>Course code</b>/td>
609: <td><b>Current status</b></td>
610: <td><b>LON-CAPA section/group ID</b></td>
611: <td><b>Enrollment in this course?</b></td>
612: </tr>
613: ");
614: for (my $i=0; $i<@sections; $i++) {
615: my $colflag = $i%2;
616: my $shrflag = 0;
617: $r->print("<tr bgcolor=\"$bgcolors[$colflag]\" align=\"center\">
618: <td>$sections[$i]<input type=\"hidden\" name=\"secnum_$i\" value=\"$sections[$i]\" />/td>
619: <td>
620: ");
621: if (grep/^$sections[$i]$/,@currsections) {
622: $r->print("Enrollment active");
623: $shrflag = 1;
624: } else {
625: $r->print("Enrollment inactive");
626: }
627: if ($shrflag) {
628: $r->print("</td><td><input type=\"text\" name=\"loncapasec_$i\" value=\"$sec_id{$sections[$i]}\"></td><td><input type=\"checkbox\" name=\"sec_$i\" checked=\"true\" /></td></tr>");
629: } else {
630: $r->print("</td><td><input type=\"text\" name=\"loncapasec_$i\" value=\"\"><td><input type=\"checkbox\" name=\"sec_$i\" /></td></tr>");
631: }
632: }
633: $r->print("
634: </tr>
635: </table>
636: </td>
637: </tr>
638: </table>
639: <br/>
640: <table width=\"100%\" border=\"0\" cellspacing=\"3\" cellpadding=\"3\">
641: <tr>
642: <td align=\"right\">
643: <input type=\"hidden\" name=\"secshow\" value=\"$secshow\" />
644: <input type=\"button\" name=\"sections\" value=\"Go\" onClick=\"process('sections')\" />
645: </td>
646: </tr>
647: </table>
648: <input type=\"hidden\" name=\"action\" value=\"$action\">
649: <input type=\"hidden\" name=\"state\" value=\"process\">
650: </form>
651: ");
652: } else {
653: $r->print("<br/>
654: <table width=\"100%\" border=\"0\" cellpadding=\"3\" cellspacing=\"3\">
655: <tr>
656: <td align=\"left\">
657: <b>$$tasktitleref{$action}</b><br/>
658: </td>
659: </tr>
660: </table>
661: <table border=\"0\" cellspacing=\"2\" cellpadding=\"2\">
662: <tr>
663: <td>As your institution's course catalog only includes a single section for this course, there are no additional sections that can be set for inclusion in the LON-CAPA roster for the course.</td>
664: </tr>
665: </table>
666: ");
667: }
668: } else {
669: $r->print("
670: <form name=\"enter\" method=\"post\"><br/>
671: <table width=\"100%\" border=\"0\" cellpadding=\"2\" cellspacing=\"2\">
672: <tr>
673: <td align=\"left\"><b>$$tasktitleref{$action}</b><br/>
674: ");
675: if (@currsections) {
676: my $secshow = @currsections;
677: $r->print("
678: Currently, LON-CAPA course: $realm ($enrollvar{coursecode}) incorporates enrollment from $secshow sections. Students enrolling in any of these course sections will be automatically added to the class roster for the course, if you have chosen to enable a nightly automated enrollment update. For each section, uncheck the checkbox if you want registered students in that section to cease being included in the student roster for LON-CAPA course: <b>$realm ($enrollvar{coursecode})</b>; otherwise leave it checked. If you want to change the section/group designation used for this section in LON-CAPA, delete the current value in the LON-CAPA section/groupID textbox and enter the new value. Click 'Go' to store your changes.
679: </td>
680: </tr>
681: </table>
682: <br/>
683: <table border=\"0\" cellpadding=\"3\" cellspacing=\"3\">
684: <tr>
685: <td>
686: <table border=\"0\" width=\"100%\" cellspacing=\"3\" cellpadding=\"3\">
687: <tr bgcolor=\"#CCCCFF\">
688: <td><b>Enrollment?</b></td>
689: <td><b>Section</b></td>
690: <td><b>LON-CAPA section/groupID</b></td>
691: </tr>
692: ");
693: for (my $j=0; $j<@currsections; $j++) {
694: my $colflag = $j%2;
695: $r->print("
696: <tr bgcolor=\"$bgcolors[$colflag]\" align=\"left\">
697: <td><input type=\"checkbox\" name=\"sec_$j\" checked=\"true\"/></td>
698: <td>$currsections[$j]</td>
699: <td><input type=\"text\" name=\"secgp_$j\" size=\"10\" value=\"$sec_id{$currsections[$j]}\"></td>
700: </tr>
701: ");
702: }
703: $r->print(" </table>
704: </td>
705: </tr>
706: </table>
707: ");
708: } else {
709: $r->print("
710: Currently no sections of $realm ($enrollvar{coursecode}) are contributing enrollment to the LON-CAPA class roster.
711: </td>
712: </tr>
713: </table>
714: ");
715: }
716: $r->print("
717: <br/>
718: <table width=\"100%\" border=\"0\" cellpadding=\"3\" cellspacing=\"3\">
719: <tr>
720: <td align=\"left\">
721: <b>Add enrollment from additional sections.</b><br/>
722: Number of new sections to add: <input type=\"text\" size=\"2\" name=\"numsec\" value=\"0\" />
723: </td>
724: </tr>
725: </table>
726: <br/>
727: <table width=\"100%\" border=\"0\" cellspadding=\"2\" cellspacing=\"2\">
728: <tr>
729: <td align=\"right\">
730: <input type=\"button\" name=\"sections\" value=\"Go\" onClick=\"process('sections')\" />
731: </td>
732: </tr>
733: </table>
734: <input type=\"hidden\" name=\"action\" value=\"$action\">
735: <input type=\"hidden\" name=\"state\" value=\"process\">
736: </form>
737: ");
738: }
739: } elsif ($action eq "photos") {
740: my @photosets = ("OFF","ON");
741: $r->print("
742: <form name=\"enter\" method=\"post\"><br/>
743: <table width=\"100%\" border=\"0\" cellpadding=\"2\" cellspacing=\"2\">
744: <tr>
745: <td align=\"left\"><b>$$tasktitleref{$action}</b><br/>
746: Currently: Student photo import: <i>$photosets[$enrollvar{showphotos}]</i>
747: </td>
748: </tr>
749: </table>
750: <table width=\"100%\" border=\"0\" cellpadding=\"3\" cellspacing=\"3\">
751: <tr>
752: <td>
753: Automatic import of student photos from institutional data repository:
754:
755: ");
756: if ($enrollvar{showphotos}) {
757: $r->print("
758: <input type=\"radio\" name=\"showphotos\" value=\"1\" checked=\"true\" /> Yes
759: <input type=\"radio\" name=\"showphotos\" value=\"0\" /> No
760: ");
761: } else {
762: $r->print("
763: <input type=\"radio\" name=\"showphotos\" value=\"1\" /> Yes
764: <input type=\"radio\" name=\"showphotos\" value=\"0\" checked=\"true\" /> No
765: ");
766: }
767: $r->print("
768: </td>
769: </tr>
770: <tr>
771: <td>
772: <font color=\"#888888\">
773: Note: if you enable automatic import of student photos, your course will automatically have access to photos stored by your institution for all officially registered students, via a conduit established by your LON-CAPA domain coordinator.
774: </font>
775: </td>
776: </tr>
777: <tr>
778: </td> </td>
779: </tr>
780: <tr>
781: <td align=\"right\">
782: <input type=\"button\" name=\"showphotos\" value=\"Go\" onClick=\"process('photos')\">
783: </td>
784: </tr>
785: </table>
786: <input type=\"hidden\" name=\"action\" value=\"$action\">
787: <input type=\"hidden\" name=\"state\" value=\"process\">
788: </form>
789: ");
790: } elsif ($action eq "updatenow") {
791: $r->print("
792: <form name=\"enter\" method=\"post\"><br/>
793: <table width=\"100%\" border=\"0\" cellpadding=\"2\" cellspacing=\"2\">
794: <tr>
795: <td align=\"left\"><b>$$tasktitleref{$action}</b>
796: </td>
797: </tr>
798: </table>
799: <table width=\"100%\" border=\"0\" cellpadding=\"3\" cellspacing=\"3\">
800: <tr>
801: <td>
802: Add any students currently included in institutional classlist(s) but not enrolled in your LON-CAPA course.
803: <input type=\"radio\" name=\"updateadds\" value=\"1\"> Yes
804: <input type=\"radio\" name=\"updateadds\" value=\"0\"> No
805: </td>
806: </tr>
807: <tr>
808: <td>
809: Expire students previously added by nightly enrollment process, but no longer listed in institutional classlist(s).
810: <input type=\"radio\" name=\"updatedrops\" value=\"1\"> Yes
811: <input type=\"radio\" name=\"updatedrops\" value=\"0\"> No <br/>
812: </td>
813: </tr>
814: <tr>
815: <td>
816: <font color=\"#888888\">
817: 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.
818: </font>
819: </td>
820: </tr>
821: <tr>
822: <td align=\"right\">
823: <input type=\"button\" name=\"updatenow\" value=\"Go\" onClick=\"process('updatenow')\">
824: </td>
825: </tr>
826: </table>
827: <input type=\"hidden\" name=\"action\" value=\"$action\">
828: <input type=\"hidden\" name=\"state\" value=\"process\">
829: </form>
830: ");
831: }
832: }
833:
834: ###############################################################
835: sub print_doc_base {
836: my $r = shift;
837: $r->print(<<ENDBASE);
838: </td>
839: </tr>
840: </table>
841: <br/>
842: </body>
843: </html>
844: ENDBASE
845: }
846:
847: ###################################################################
848: sub print_chgsettings_response {
849: my ($r,$realm,$dom,$crs,$action,$tasktitleref) = @_;
850: my %settings = &Apache::lonnet::get('environment',['internal.autoadds','internal.autodrops'],$dom,$crs);
851: my $curradds = $settings{'internal.autoadds'};
852: my $currdrops = $settings{'internal.autodrops'};
853: my $autoadds = '';
854: my $autodrops = '';
855:
856: if ( exists($ENV{'form.autoadds'}) ) {
857: $autoadds=$ENV{'form.autoadds'};
858: }
859: if ( exists($ENV{'form.autodrops'}) ) {
860: $autodrops=$ENV{'form.autodrops'};
861: }
862:
863: my $response = "";
864: my %cenv = ('internal.autoadds' => $autoadds,
865: 'internal.autodrops' => $autodrops);
866: my $reply = &Apache::lonnet::put('environment',\%cenv,$dom,$crs);
867: if ($reply !~ /^ok$/) {
868: $response = "There was a problem processing your requested changes. The automated enrollment settings for this course have been left unchanged.<br/>";
869: } else {
870: if ($autoadds) {
871: if ($curradds) {
872: $response = "Nightly additions based on classlist changes still <b>enabled</b><br/>";
873: } else {
874: $response = "Nightly additions based on classlist changes now <b>enabled</b><br/>";
875: }
876: } else {
877: if ($curradds) {
878: $response = "Nightly additions based on classlist changes now <b>disabled</b><br/>";
879: } else {
880: $response = "Nightly additions based on classlist changes still <b>disabled</b><br/>";
881: }
882: }
883: if ($autodrops) {
884: if ($currdrops) {
885: $response .= "Nightly removals based on classlist changes still <b>enabled</b><br>";
886: } else {
887: $response .= "Nightly removals based on classlist changes now <b>enabled</b><br/>";
888: }
889: } else {
890: if ($currdrops) {
891: $response .= "Nightly removals based on classlist changes now <b>disabled</b><br>";
892: } else {
893: $response .= "Nightly removals based on classlist changes still <b>disabled</b>";
894: }
895: }
896: }
897: &print_reply($r,$response,$$tasktitleref{$action});
898: return;
899: }
900:
901: sub print_setdates_response {
902: my ($r,$realm,$dom,$crs,$action,$tasktitleref) = @_;
903: my %settings = &Apache::lonnet::get('environment',['internal.autostart','internal.autoend'],$dom,$crs);
904: my $currstart = $settings{'internal.autostart'};
905: my $currend = $settings{'internal.autoend'};
906: my $response = '';
907: my ($autostart,$autoend) = &get_dates_from_form();
908: my $showstart = localtime($autostart);
909: my $showend = '';
910: if ($autoend) {
911: $showend = localtime($autoend);
912: } else {
913: $showend = "'No end date'";
914: }
915:
916: my %cenv = ('internal.autostart' => $autostart,
917: 'internal.autoend' => $autoend);
918: my $reply = &Apache::lonnet::put('environment',\%cenv,$dom,$crs);
919: if ($reply !~ /^ok$/) {
920: $response = "There was a problem processing your requested changes. The automated enrollment settings for this course have been left unchanged.<br/>";
921: } else {
922: if ($currstart == $autostart) {
923: $response = "The first date for automated enrollment has been left unchanged as $showstart.<br/>";
924: } else {
925: $response = "The first date for automated enrollment has been changed to $showstart.<br/>";
926: }
927: if ($currend == $autoend) {
928: $response .= "The last date for automated enrollment has been left unchanged as $showend.<br/>";
929: } else {
930: $response .= "The last date for enrollment has been left unchanged as $showend.<br/>";
931: }
932:
933: # Generate message in case where old first access date was later than today, but new first access date is now today or earlier.
934:
935: my $rosterupdated = 0;
936: my $firstaccess = "";
937: my $nextupdate = "";
938: my $lastupdate = "";
939:
940: my $nowstamp = time;
941: my @date_list=localtime(time);
942: my $cur_year = $date_list[5];
943: my $curday = $date_list[3];
944: my $curmonth = $date_list[4];
945: my $lastmidnt = timelocal(0,0,0,$date_list[3],$date_list[4],$date_list[5]);
946: my $nextmidnt = 86400 + $lastmidnt;
947:
948: my $todayupdate = timelocal(0,40,4,$date_list[3],$date_list[4],$date_list[5]);
949: my $lastupdate = $todayupdate - 86400;
950: if ($nowstamp < $todayupdate) {
951: $nextupdate = "today";
952: } else {
953: $nextupdate = "tomorrow";
954: }
955: if ($currstart < $lastupdate) {
956: $rosterupdated = 1;
957: }
958: if ($autostart < $nextmidnt ) {
959: if ( $autostart >= $lastmidnt) {
960: $firstaccess = "today";
961: } else {
962: $firstaccess = "a date prior to today";
963: }
964: if (($nowstamp >= $autostart) && ($rosterupdated == 0)) {
965: $response .= qq|<br>Although you have now set the first enrollment date to $firstaccess, automatic enrollment will <b>not</b> occur until the next automatic enrollment update occurs for all LON-CAPA courses at 4.40 am $nextupdate. If you wish to grant immediate course access for registered students included in the institutional classlist for this class, please visit the <a href="/adm/populate?action=updatenow">roster update page</a>.<br>|;
966: }
967: }
968: }
969: &print_reply($r,$response,$$tasktitleref{$action});
970: return;
971: }
972:
973: sub print_notify_response {
974: my ($r,$realm,$dom,$crs,$action,$tasktitleref) = @_;
975:
976: # Get current settings
977: my %settings = &Apache::lonnet::get('environment',['internal.notifylist','internal.coursecode'],$dom,$crs);
978: my $notifylist = $settings{'internal.notifylist'};
979: my $coursecode = $settings{'internal.coursecode'};
980: my @currpeople = ();
981: my $notify = 0;
982: my @people = ();
983:
984: if ($notifylist =~ m/,/) {
985: @currpeople = split/,/,$notifylist;
986: } else {
987: @currpeople = $notifylist;
988: }
989: my $currcount = 0;
990: foreach (@currpeople) {
991: unless ($_ eq '') { $currcount ++; }
992: }
993:
994: if ( exists($ENV{'form.notify'}) ) {
995: $notify=$ENV{'form.notify'};
996: }
997: if ( exists($ENV{'form.notifylist'}) ) {
998: if (ref($ENV{'form.notifylist'})) {
999: @people=@{ $ENV{'form.notifylist'} };
1000: } else {
1001: $people[0]=$ENV{'form.notifylist'};
1002: }
1003: }
1004: my $response = "";
1005: my $peoplestr = "";
1006: if ($notify) { $peoplestr = join(",",@people); }
1007: my %cenv = ('internal.notifylist' => $peoplestr);
1008: my $reply = &Apache::lonnet::put('environment',\%cenv,$dom,$crs);
1009: if ($reply !~ /^ok$/) {
1010: $response = "There was a problem processing your requested changes. The notification settings for this course have been left unchanged.<br/>";
1011: } else {
1012: if ($notify) {
1013: if (@people) {
1014: if ($currcount) {
1015: $response = "Notification of enrollment changes still <b>enabled</b><br/>";
1016: } else {
1017: $response = "Notification of enrollment changes now <b>enabled</b><br/>";
1018: }
1019: $response .= "<br/>The following will receive notification if there are any changes in enrollment in LON-CAPA course: $realm ($coursecode) as a result of
1020: the nightly enrollment check: <br/><ul>\n";
1021: foreach my $person (@people) {
1022: $response .= "<li>$person</li>\n";
1023: }
1024: $response .= "</ul>\n";
1025: } else {
1026: $response = "Notification of enrollment changes was <b> not enabled</b> as no course coordinators were selected as recipients.<br/>";
1027: }
1028: } else {
1029: if ($currcount) {
1030: $response = "Notification of enrollment changes now <b>disabled</b><br/>";
1031: } else {
1032: $response = "Notification of enrollment changes still <b>disabled</b><br/>";
1033: }
1034: }
1035: }
1036: &print_reply($r,$response,$$tasktitleref{$action});
1037: return;
1038: }
1039:
1040: sub print_crosslistings_menu () {
1041: my ($r,$realm,$dom,$crs,$action,$tasktitleref) = @_;
1042: my %settings = &Apache::lonnet::get('environment',['internal.crosslistings','internal.coursecode'],$dom,$crs);
1043: my @currxlists = ();
1044: my @xlists = ();
1045: my $crosscount = 0;
1046: my $removecount = 0;
1047: my $xliststr = '';
1048: my $response = '';
1049: my $coursecode = $settings{'internal.coursecode'};
1050: if ($settings{'internal.crosslistings'} =~ m/,/) {
1051: @currxlists = split/,/,$settings{'internal.crosslistings'};
1052: } elsif ($settings{'internal.crosslistings'} ne '') {
1053: $currxlists[0] = $settings{'internal.crosslistings'};
1054: }
1055:
1056: if (@currxlists > 0) {
1057: for (my $i=0; $i<@currxlists; $i++) {
1058: my $xlist = "cross_".$i;
1059: my $gp = "gp_".$i;
1060: if ( exists($ENV{"form.$xlist"}) ) {
1061: my $xlistentry = '';
1062: if ($currxlists[$i] =~ m/^(\w+:)/) {
1063: $xlistentry = $1;
1064: }
1065: if ( exists($ENV{"form.$gp"}) ) {
1066: $xlistentry .= $ENV{"form.$gp"};
1067: }
1068: push @xlists,$xlistentry;
1069: $crosscount ++;
1070: } else {
1071: $removecount ++;
1072: }
1073: }
1074: }
1075:
1076: if ($crosscount > 1) {
1077: $xliststr = join(",",@xlists);
1078: } else {
1079: $xliststr = $xlists[0];
1080: }
1081: my %cenv = ('internal.crosslistings' => $xliststr);
1082: my $reply = &Apache::lonnet::put('environment',\%cenv,$dom,$crs);
1083: if ($reply !~ /^ok$/) {
1084: $response = "There was a problem processing your requested changes. The automated enrollment settings for this course have been left unchanged.<br/>";
1085: } else {
1086: if ($removecount > 0) {
1087: $response = "A total of $removecount courses are no longer crosslisted with LON-CAPA course: $realm ($coursecode).<br>/<br/>";
1088: }
1089: if ($crosscount > 0) {
1090: $response .= "The $crosscount courses listed below remain crosslisted with this LON-CAPA course, and students enrolling in these course sections will be automatically added to the class roster for the course, if you have chosen to enable a nightly automated enrollment update.<br/><ul>\n";
1091: foreach (@xlists) {
1092: my ($xlist,$gp) = split/:/,$_;
1093: $response .= "<li>$xlist - ID: $gp</li>\n";
1094: }
1095: $response .= "</ul><br/>\n";
1096: }
1097: }
1098: if ( exists($ENV{'form.numcross'}) ) {
1099: my $numcross = $ENV{'form.numcross'};
1100: if ($numcross > 0) {
1101: my @bgcolors=("#eeeeee","#cccccc");
1102: $response .= qq(
1103: You indicated that you wish to add an additional $numcross crosslisting(s). For each new crosslisting enter the insititutional course section code (e.g., fs03zol101001, for section 001 of zol101 for fs03 semester), and the LON-CAPA section/group ID you wish to assign to students who will be enrolled in your LON-CAPA class as a result of their registration in the crosslisted course section. The LON-CAPA section/group ID can be left blank, if you do not wish to tie a section/group ID to this crosslisting. The institutional course section code should only contain letters and/or numbers, and must be consistent with the scheme adopted by your Domain Coordinator to map course codes (and section numbers) to your institution's student information system.<br/><br/>
1104: <form name="enter" method="post">
1105: <table border="0" cellpadding="2" cellspacing="2" width="100%">
1106: <tr>
1107: <td>
1108: <table border="0" cellspacing="3" cellpadding="3">
1109: <tr bgcolor="#CCCCFF" align="left">
1110: <td><b>Crosslisting</b></td>
1111: <td><b>LON-CAPA section/groupID</b></td>
1112: </tr>
1113: );
1114: for (my $i=0; $i<$numcross; $i++) {
1115: my $colflag = $i%2;
1116: $response .= qq(
1117: <tr bgcolor="$bgcolors[$colflag]" align="left">
1118: <td><input type="text" size="15" name="newcross_$i" /></td>
1119: <td><input type="text" size="10" name="newgroupid_$i" /></td>
1120: </tr>
1121: );
1122: }
1123: $response .= qq( </table>
1124: </td>
1125: </tr>
1126: <tr>
1127: <td align="right">
1128: <input type="button" name="newcross" value="Go" onClick="process('newcross')" />
1129: </td>
1130: </tr>
1131: </table>
1132: <input type=\"hidden\" name=\"numcross\" value=\"$numcross\">
1133: <input type=\"hidden\" name=\"action\" value=\"newcross\">
1134: <input type=\"hidden\" name=\"state\" value=\"process\">
1135: </form>
1136: );
1137: }
1138: }
1139: &print_reply($r,$response,$$tasktitleref{$action});
1140: return;
1141: }
1142:
1143: sub print_crosslistings_response () {
1144: my ($r,$realm,$dom,$crs,$action,$tasktitleref) = @_;
1145: my %settings = &Apache::lonnet::get('environment',['internal.crosslistings','internal.coursecode'],$dom,$crs);
1146: my @currxlists = ();
1147: my @xlists = ();
1148: my @allxlists = ();
1149: my $numcross = 0;
1150: my $xliststr = $settings{'internal.crosslistings'};
1151: my $coursecode = $settings{'internal.coursecode'};
1152: my $response = '';
1153:
1154: if ($xliststr =~ m/,/) {
1155: @allxlists = split/,/,$xliststr;
1156: } else {
1157: unless ($xliststr eq '') { $allxlists[0] = $xliststr; }
1158: }
1159:
1160: if ( exists($ENV{'form.numcross'}) ) {
1161: $numcross = $ENV{'form.numcross'};
1162: }
1163:
1164: if ($numcross > 0) {
1165: for (my $i=0; $i<$numcross; $i++) {
1166: my $xl = "newcross_".$i;
1167: my $gp = "newgroupid_".$i;
1168: if ( exists($ENV{"form.$xl"}) ) {
1169: push @xlists,$ENV{"form.$xl"}.":".$ENV{"form.$gp"};
1170: }
1171: }
1172: push @allxlists, @xlists;
1173: }
1174:
1175: if (@xlists > 0 ) {
1176: unless ($xliststr eq '') { $xliststr .= ","; }
1177: if (@xlists > 1) {
1178: $xliststr .= join(",",@xlists);
1179: } else {
1180: $xliststr .= $xlists[0];
1181: }
1182: my %cenv = ('internal.crosslistings' => $xliststr);
1183: my $reply = &Apache::lonnet::put('environment',\%cenv,$dom,$crs);
1184: if ($reply !~ /^ok$/) {
1185: $response = "There was a problem processing your requested changes. The automated enrollment settings for this course have been left unchanged.<br/>";
1186: } else {
1187: $response = "The courses listed below are now crosslisted with this LON-CAPA course, and students enrolling in these course sections will be automatically added to the class roster for the course, if you have chosen to enable a nightly automated enrollment update.<br/><ul>\n";
1188: }
1189: }
1190:
1191: foreach (@allxlists) {
1192: my ($xlist,$gp) = split/:/,$_;
1193: $response .= "<li>$xlist - ID: $gp</li>\n";
1194: }
1195: $response .= "</ul><br/>\n";
1196:
1197: &print_reply($r,$response,$$tasktitleref{$action});
1198: return;
1199: }
1200:
1201: sub print_sections_menu () {
1202: my ($r,$realm,$dom,$crs,$action,$tasktitleref) = @_;
1203: my %settings = &Apache::lonnet::get('environment',['internal.sectionnums','internal.coursecode'],$dom,$crs);
1204: my @currsections = ();
1205: my @sections = ();
1206: my $seccount = 0;
1207: my $removecount = 0;
1208: my $secstr = '';
1209: my $response = '';
1210: my $coursecode = $settings{'internal.coursecode'};
1211: if ($settings{'internal.sectionnums'} =~ m/,/) {
1212: @currsections = split/,/,$settings{'internal.sectionnums'};
1213: } elsif ($settings{'internal.sectionnums'} ne '') {
1214: $currsections[0] = $settings{'internal.sectionnums'};
1215: }
1216:
1217: if (@currsections > 0) {
1218: for (my $i=0; $i<@currsections; $i++) {
1219: my $sec = "sec_".$i;
1220: my $gp = "secgp_".$i;
1221: if ( exists($ENV{"form.$sec"}) ) {
1222: my $secentry = '';
1223: if ($currsections[$i] =~ m/^(\w+:)/) {
1224: $secentry = $1;
1225: }
1226: if ( exists($ENV{"form.$gp"}) ) {
1227: $secentry .= $ENV{"form.$gp"};
1228: }
1229: push @sections,$secentry;
1230: $seccount ++;
1231: } else {
1232: $removecount ++;
1233: }
1234: }
1235: }
1236:
1237: if ($seccount > 1) {
1238: $secstr = join(",",@sections);
1239: } else {
1240: $secstr = $sections[0];
1241: }
1242: my %cenv = ('internal.sectionnums' => $secstr);
1243: my $reply = &Apache::lonnet::put('environment',\%cenv,$dom,$crs);
1244: if ($reply !~ /^ok$/) {
1245: $response = "There was a problem processing your requested changes. The automated enrollment settings for this course have been left unchanged.<br/>";
1246: } else {
1247: if ($removecount > 0) {
1248: $response = "A total of $removecount sections have been removed from the list of sections which contribute to enrollment in LON-CAPA course: $realm ($coursecode).<br/><br/>";
1249: }
1250: if ($seccount > 0) {
1251: $response .= "Students enrolling in the $seccount section(s) listed below will continue to be automatically added to the class roster for the course, if you have chosen to enable a nightly automated enrollment update.<br/><ul>\n";
1252: foreach (@sections) {
1253: my ($sec,$gp) = split/:/,$_;
1254: $response .= "<li>$sec - ID: $gp</li>\n";
1255: }
1256: $response .= "</ul><br/>\n";
1257: }
1258: }
1259:
1260: if ( exists($ENV{'form.numsec'}) ) {
1261: my $numsec = $ENV{'form.numsec'};
1262: if ($numsec > 0) {
1263: my @bgcolors=("#eeeeee","#cccccc");
1264: $response .= qq(
1265: You indicated that you wish to incorporate student enrollment in your LON-CAPA course from an additional $numsec section(s). For each new section enter the insititutional section code (e.g., 004), and the LON-CAPA section/group ID you wish to assign to students who will be enrolled in your LON-CAPA class as a result of their registration in this particular section. The LON-CAPA section/group ID can be left blank, if you do not wish to designate a section/group ID for this course section. The institutional section code should only contain letters and/or numbers, and must be consistent with the scheme adopted by your Domain Coordinator to map course section numbers to your institution's student information system.<br/><br/>
1266: <form name="enter" method="post">
1267: <table border="0" cellpadding="2" cellspacing="2" width="100%">
1268: <tr>
1269: <td>
1270: <table border="0" cellspacing="3" cellpadding="3">
1271: <tr bgcolor="#CCCCFF" align="left">
1272: <td><b>Section number</b></td>
1273: <td><b>LON-CAPA section/groupID</b></td>
1274: </tr>
1275: );
1276: for (my $i=0; $i<$numsec; $i++) {
1277: my $colflag = $i%2;
1278: $response .= qq(
1279: <tr bgcolor="$bgcolors[$colflag]" align="left">
1280: <td><input type="text" size="15" name="newsec_$i" /></td>
1281: <td><input type="text" size="10" name="newsecgp_$i" /></td>
1282: </tr>
1283: );
1284: }
1285: $response .= qq( </table>
1286: </td>
1287: </tr>
1288: <tr>
1289: <td align="right">
1290: <input type="button" name="newsections" value="Go" onClick="process('newsections')" />
1291: </td>
1292: </tr>
1293: </table>
1294: <input type=\"hidden\" name=\"numsec\" value=\"$numsec\">
1295: <input type=\"hidden\" name=\"action\" value=\"newsections\">
1296: <input type=\"hidden\" name=\"state\" value=\"process\">
1297: </form>
1298: );
1299: }
1300: }
1301: &print_reply($r,$response,$$tasktitleref{$action});
1302: return;
1303: }
1304:
1305: sub print_sections_response () {
1306: my ($r,$realm,$dom,$crs,$action,$tasktitleref) = @_;
1307: my %settings = &Apache::lonnet::get('environment',['internal.sectionnums','internal.coursecode'],$dom,$crs);
1308: my @currsections = ();
1309: my @sections = ();
1310: my @allsections = ();
1311: my $numsec = 0;
1312: my $secstr = $settings{'internal.sectionnums'};
1313: my $coursecode = $settings{'internal.coursecode'};
1314: my $response = '';
1315:
1316: if ($secstr =~ m/,/) {
1317: @allsections = split/,/,$secstr;
1318: } else {
1319: unless ($secstr eq '') { $allsections[0] = $secstr; }
1320: }
1321:
1322: if ( exists($ENV{'form.numsec'}) ) {
1323: $numsec = $ENV{'form.numsec'};
1324: }
1325:
1326: if ($numsec > 0) {
1327: for (my $i=0; $i<$numsec; $i++) {
1328: my $sec = "newsec_".$i;
1329: my $gp = "newsecgp_".$i;
1330: if ( exists($ENV{"form.$sec"}) ) {
1331: push @sections,$ENV{"form.$sec"}.":".$ENV{"form.$gp"};
1332: }
1333: }
1334: push @allsections, @sections;
1335: }
1336:
1337: if (@sections > 0 ) {
1338: unless ($secstr eq '') { $secstr .= ","; }
1339: if (@sections > 1) {
1340: $secstr .= join(",",@sections);
1341: } else {
1342: $secstr .= $sections[0];
1343: }
1344: my %cenv = ('internal.sectionnums' => $secstr);
1345: my $reply = &Apache::lonnet::put('environment',\%cenv,$dom,$crs);
1346: if ($reply !~ /^ok$/) {
1347: $response = "There was a problem processing your requested changes. The automated enrollment settings for this course have been left unchanged.<br/>";
1348: } else {
1349: $response = "Students enrolling in the sections listed below will be automatically added to the class roster for LON-CAPA course $realm ($coursecode), if you have chosen to enable a nightly automated enrollment update.<br/><ul>\n";
1350: }
1351: }
1352:
1353: foreach (@allsections) {
1354: my ($sec,$gp) = split/:/,$_;
1355: $response .= "<li>$sec - ID: $gp</li>\n";
1356: }
1357: $response .= "</ul><br/>\n";
1358:
1359: &print_reply($r,$response,$$tasktitleref{$action});
1360: return;
1361: }
1362:
1363: sub print_photos_response () {
1364: my ($r,$realm,$dom,$crs,$action,$tasktitleref) = @_;
1365: my %settings = &Apache::lonnet::get('environment',['internal.showphotos'],$dom,$crs);
1366: my $currphotos = $settings{'internal.showphotos'};
1367: my $showphotos = '';
1368: if ( exists($ENV{'form.showphotos'}) ) {
1369: $showphotos=$ENV{'form.showphotos'};
1370: }
1371:
1372: my $response = "";
1373: my %cenv = ('internal.showphotos' => $showphotos);
1374: my $reply = &Apache::lonnet::put('environment',\%cenv,$dom,$crs);
1375: if ($reply !~ /^ok$/) {
1376: $response = "There was a problem processing your requested change. The student photo import setting for this course has been left unchanged.<br/>";
1377: } else {
1378: if ($showphotos) {
1379: if ($currphotos) {
1380: $response = "Retrieval of student photos is still <b>enabled</b><br/>";
1381: } else {
1382: $response = "Retrieval of student photos in now <b>enabled</b><br/>";
1383: }
1384: } else {
1385: if ($currphotos) {
1386: $response = "Retrieval of student photos is now <b>disabled</b><br/>";
1387: } else {
1388: $response = "Retrieval of student photos is still <b>disabled</b><br/>";
1389: }
1390: }
1391: }
1392: &print_reply($r,$response,$$tasktitleref{$action});
1393: return;
1394: }
1395:
1396: sub print_update_result () {
1397: my ($r,$realm,$dom,$crs,$action,$tasktitleref) = @_;
1398: my $response = '';
1399: my $updateadds = 0;
1400: my $updatedrops = 0;
1401: my $changecount = 0;
1402: my %affiliates = ();
1403: my %reply = ();
1404: my @allcourses = ();
1405: my %LC_code = ();
1406: my $logmsg = '';
1407:
1408: my %settings = &Apache::lonnet::get('environment',['internal.coursecode','internal.sectionnums','internal.crosslistings','internal.authtype','internal.autharg','internal.autostart','internal.autoend'],$dom,$crs);
1409: my $coursecode = $settings{'internal.coursecode'};
1410: my $authtype = $settings{'internal.authtype'};
1411: my $autharg = $settings{'internal.autharg'};
1412: my $autostart = $settings{'internal.autostart'};
1413: my $autoend = $settings{'internal.autoend'};
1414:
1415: if ( exists($ENV{'form.updateadds'}) ) {
1416: $updateadds = $ENV{'form.updateadds'};
1417: }
1418: if ( exists($ENV{'form.updatedrops'}) ) {
1419: $updatedrops = $ENV{'form.updatedrops'};
1420: }
1421: if (!$updateadds && !$updatedrops) {
1422: $response = "An update of the class roster has not been carried out because you indicated that you wanted to neither add new students, nor expire dropped students based on a comparison between the institutional class lists for the course sections and crosslisted courses that contribure enrollment to this LON-CAPA course.";
1423: } elsif ($coursecode eq '') {
1424: $response = "There was a problem retrieving the course code for this LON-CAPA course. An update of the class roster has not been carried out, and enrollment remains unchanged";
1425: } else {
1426: # Get complete list of course sections to update
1427: my @currsections = ();
1428: my @currxlists = ();
1429:
1430: if ($settings{'internal.sectionnums'} =~ m/,/) {
1431: @currsections = split/,/,$settings{'internal.sectionnums'};
1432: } elsif ($settings{'internal.sectionnums'} ne '') {
1433: $currsections[0] = $settings{'internal.sectionnums'};
1434: }
1435:
1436: if ($settings{'internal.crosslistings'} =~ m/,/) {
1437: @currxlists = split/,/,$settings{'internal.crosslistings'};
1438: } elsif ($settings{'internal.crosslistings'} ne '') {
1439: $currxlists[0] = $settings{'internal.crosslistings'};
1440: }
1441:
1442: if (@currxlists > 0) {
1443: foreach (@currxlists) {
1444: if (m/^(\w+):(\w*)$/) {
1445: unless (grep/^$1$/,@allcourses) {
1446: push @allcourses,$1;
1447: $LC_code{$1} = $2;
1448: }
1449: }
1450: }
1451: }
1452:
1453: if (@currsections > 0) {
1454: foreach (@currsections) {
1455: if (m/^(\w+):(\w*)$/) {
1456: my $sec = $coursecode.$1;
1457: my $gp = $2;
1458: unless (grep/^$sec$/,@allcourses) {
1459: push @allcourses,$sec;
1460: $LC_code{$sec} = $gp;
1461: }
1462: }
1463: }
1464: }
1465:
1466: if (@allcourses > 0) {
1467: @{$affiliates{$crs}} = @allcourses;
1468: &localenroll::fetch_enrollment($dom,\%affiliates,\%reply);
1469: if ($reply{$crs} > 0) {
1470: ($changecount,$response) = &LONCAPA::Enrollment::update_LC($dom,$crs,$updateadds,$updatedrops,$autostart,$autoend,$authtype,$autharg,\@allcourses,\%LC_code,\$logmsg,"updatenow");
1471: unless ($changecount == 0) {
1472: my $responselength = length($response);
1473: $response = substr($response,0,$responselength-4);
1474: }
1475: } else {
1476: $response = "There was a problem retrieving institutional class list data for the course sections and crosslisted courses which contribute enrollment to this course. No updates have been carried out, and the roster remains unchanged.";
1477: }
1478: } else {
1479: $response = "There are currently no course sections or crosslisted courses designated as contributors to enrollment in this LON-CAPA course. As a result a student roster update has not been carried out for $realm ($coursecode)";
1480: }
1481: }
1482: unless ($logmsg eq '') {
1483: my $loglength = length($logmsg);
1484: $logmsg = substr($logmsg,0,$loglength-4);
1485: $logmsg = "<br/><br/>The following messages were generated by the roster update process: <br/><ul><li>".$logmsg."</ul><br/>";
1486: }
1487: $response .= $logmsg;
1488: &print_reply($r,$response,$$tasktitleref{$action});
1489: return;
1490: }
1491:
1492: sub print_reply () {
1493: my ($r,$response,$caller) = @_;
1494: $r->print("
1495: <br/><table width=\"100%\" border=\"0\" cellpadding=\"2\" cellspacing=\"2\">
1496: <tr>
1497: <tr align=\"left\"><b>$caller</b> - result<br/><br/>$response</td>
1498: </td>
1499: </tr>
1500: </table>
1501: ");
1502: return;
1503: }
1504:
1505: sub setup_date_selectors {
1506: my ($starttime,$endtime) = @_;
1507: if ($endtime == 0) {
1508: $endtime = 1999915200;
1509: }
1510: if (! defined($starttime)) {
1511: $starttime = time;
1512: if (exists($ENV{'course.'.$ENV{'request.course.id'}.
1513: '.default_enrollment_start_date'})) {
1514: $starttime = $ENV{'course.'.$ENV{'request.course.id'}.
1515: '.default_enrollment_start_date'};
1516: }
1517: }
1518: if (! defined($endtime)) {
1519: $endtime = time+(6*30*24*60*60); # 6 months from now, approx
1520: if (exists($ENV{'course.'.$ENV{'request.course.id'}.
1521: '.default_enrollment_end_date'})) {
1522: $endtime = $ENV{'course.'.$ENV{'request.course.id'}.
1523: '.default_enrollment_end_date'};
1524: }
1525: }
1526: my $startdateform = &Apache::lonhtmlcommon::date_setter('enter',
1527: 'startdate',
1528: $starttime);
1529: my $enddateform = &Apache::lonhtmlcommon::date_setter('enter',
1530: 'enddate',
1531: $endtime);
1532: return ($startdateform,$enddateform);
1533: }
1534:
1535: sub get_dates_from_form {
1536: my $startdate = &Apache::lonhtmlcommon::get_date_from_form('startdate');
1537: my $enddate = &Apache::lonhtmlcommon::get_date_from_form('enddate');
1538: if ( exists ($ENV{'form.no_end_date'}) ) {
1539: $enddate = 0;
1540: }
1541: return ($startdate,$enddate);
1542: }
1543:
1544: sub date_setting_table {
1545: my ($starttime,$endtime) = @_;
1546: my ($startform,$endform) = &setup_date_selectors($starttime,$endtime);
1547: my $perpetual = '<nobr><input type="checkbox" name="no_end_date"';
1548: if (defined($endtime) && $endtime == 0) {
1549: $perpetual .= ' checked';
1550: }
1551: $perpetual.= ' />'.' no ending date</nobr>';
1552: my $start_table = '';
1553: $start_table .= "<table>\n";
1554: $start_table .= '<tr><td align="right">Starting Date</td>'.
1555: '<td>'.$startform.'</td>'.
1556: '<td> </td>'."</tr>\n";
1557: $start_table .= "</table>";
1558: my $end_table = '';
1559: $end_table .= "<table>\n";
1560: $end_table .= '<tr><td align="right">Ending Date</td>'.
1561: '<td>'.$endform.'</td>'.
1562: '<td>'.$perpetual.'</td>'."</tr>\n";
1563: $end_table .= "</table>\n";
1564: return ($start_table, $end_table);
1565: }
1566:
1567: ###################################################################
1568: sub handler {
1569: my $r = shift;
1570: if ($r->header_only) {
1571: $r->content_type('text/html');
1572: $r->send_http_header;
1573: return OK;
1574: }
1575: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['action','state']);
1576: # Needs to be in a course
1577: if (! (($ENV{'request.course.fn'}) && (&Apache::lonnet::allowed('cst',$ENV{'request.course.id'})))) {
1578: # Not in a course, or not allowed to modify parms
1579: $ENV{'user.error.msg'}="/adm/populate:cst:0:0:Cannot drop or add students";
1580: return HTTP_NOT_ACCEPTABLE;
1581: }
1582: # Start page
1583: $r->content_type('text/html');
1584: $r->send_http_header;
1585:
1586: my @tasks = ("information","chgsettings","setdates","notify","crosslist","sections","photos","updatenow");
1587:
1588: my %tasklong = (
1589: information => "Task information",
1590: chgsettings => "Automated adds/drops",
1591: setdates => "Change enrollment dates",
1592: notify => "Notification of changes",
1593: crosslist => "Change crosslistings",
1594: sections => "Section settings",
1595: photos => "Student photos",
1596: updatenow => "Update roster now",
1597: newcross => "Add crosslistings",
1598: newsections => "Add sections"
1599: );
1600:
1601: my %tasktitle = (
1602: chgsettings => "Changes to nightly automated enrollments",
1603: setdates => "Changes to first and/or last automated enrollment dates",
1604: notify => "Notification of enrollment changes",
1605: crosslist => "Changes to crosslistings",
1606: sections => "Changes to section settings",
1607: photos => "Automatic import of student photos",
1608: updatenow => "Immediate course roster update",
1609: newcross => "Adding new crosslisted courses",
1610: newsections => "Adding new course sections"
1611: );
1612:
1613: my $realm = '';
1614: if ( exists($ENV{'request.course.id'}) ) {
1615: $realm= $ENV{'course.'.$ENV{'request.course.id'}.'.description'};
1616: }
1617: unless ($realm) { $realm=' '; }
1618: my $dom = $ENV{'course.'.$ENV{'request.course.id'}.'.domain'};
1619: my $crs = $ENV{'course.'.$ENV{'request.course.id'}.'.num'};
1620:
1621: #
1622: # Main switch on form.action and form.state, as appropriate
1623: #
1624:
1625: my $action = "information";
1626: if ( exists($ENV{'form.action'}) ) {
1627: $action = $ENV{'form.action'};
1628: }
1629: my $state = "choose";
1630:
1631: if ( exists($ENV{'form.state'}) ) {
1632: $state = $ENV{'form.state'};
1633: }
1634:
1635: if ($action eq "information") {
1636: $r->print(&header());
1637: } else {
1638: if ($state eq "choose") {
1639: $r->print(&choose_header());
1640: } else {
1641: if ($action eq "crosslist") {
1642: if ( exists($ENV{'form.numcross'}) ) {
1643: if ( $ENV{'form.numcross'} > 0 ) {
1644: $r->print(&choose_header());
1645: } else {
1646: $r->print(&header());
1647: }
1648: } else {
1649: $r->print(&header());
1650: }
1651: } elsif ($action eq "sections") {
1652: if ( exists($ENV{'form.numsec'}) ) {
1653: if ( $ENV{'form.numsec'} > 0 ) {
1654: $r->print(&choose_header());
1655: } else {
1656: $r->print(&header());
1657: }
1658: } else {
1659: $r->print(&header());
1660: }
1661: } else {
1662: $r->print(&header());
1663: }
1664: }
1665: }
1666:
1667: my $reply = 0;
1668: unless ($state eq "choose") { $reply = 1; }
1669:
1670: &print_mainbox($r,\%tasklong,$realm,$reply);
1671: &print_navmenu($r,\@tasks,\%tasklong);
1672:
1673: if (($state eq "choose") || ($action eq "information")) {
1674: &print_main_frame($r,$realm,$dom,$crs,\%tasktitle);
1675: } elsif ($action eq "chgsettings") {
1676: &print_chgsettings_response($r,$realm,$dom,$crs,$action,\%tasktitle);
1677: } elsif ($action eq "setdates") {
1678: &print_setdates_response($r,$realm,$dom,$crs,$action,\%tasktitle);
1679: } elsif ($action eq "notify") {
1680: &print_notify_response($r,$realm,$dom,$crs,$action,\%tasktitle);
1681: } elsif ($action eq "sections") {
1682: &print_sections_menu($r,$realm,$dom,$crs,$action,\%tasktitle);
1683: } elsif ($action eq "crosslist") {
1684: &print_crosslistings_menu($r,$realm,$dom,$crs,$action,\%tasktitle);
1685: } elsif ($action eq "updatenow") {
1686: &print_update_result($r,$realm,$dom,$crs,$action,\%tasktitle);
1687: } elsif ($action eq "photos") {
1688: &print_photos_response($r,$realm,$dom,$crs,$action,\%tasktitle);
1689: } elsif ($action eq "newcross") {
1690: &print_crosslistings_response($r,$realm,$dom,$crs,$action,\%tasktitle);
1691: } elsif ($action eq "newsections") {
1692: &print_sections_response($r,$realm,$dom,$crs,$action,\%tasktitle);
1693: }
1694: &print_doc_base($r);
1695: return OK;
1696: }
1697: ###################################################################
1698: 1;
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>