1: # The LearningOnline Network with CAPA
2: # handler for DC-only modifiable course settings
3: #
4: # $Id: lonmodifycourse.pm,v 1.92 2017/04/08 14:58:11 raeburn Exp $
5: #
6: # Copyright Michigan State University Board of Trustees
7: #
8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
9: #
10: # LON-CAPA is free software; you can redistribute it and/or modify
11: # it under the terms of the GNU General Public License as published by
12: # the Free Software Foundation; either version 2 of the License, or
13: # (at your option) any later version.
14: #
15: # LON-CAPA is distributed in the hope that it will be useful,
16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18: # GNU General Public License for more details.
19: #
20: # You should have received a copy of the GNU General Public License
21: # along with LON-CAPA; if not, write to the Free Software
22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23: #
24: # /home/httpd/html/adm/gpl.txt
25: #
26: # http://www.lon-capa.org/
27: #
28: package Apache::lonmodifycourse;
29:
30: use strict;
31: use Apache::Constants qw(:common :http);
32: use Apache::lonnet;
33: use Apache::loncommon;
34: use Apache::lonhtmlcommon;
35: use Apache::lonlocal;
36: use Apache::lonuserutils;
37: use Apache::loncreateuser;
38: use Apache::lonpickcourse;
39: use lib '/home/httpd/lib/perl';
40: use LONCAPA qw(:DEFAULT :match);
41:
42: sub get_dc_settable {
43: my ($type,$cdom) = @_;
44: if ($type eq 'Community') {
45: return ('courseowner','selfenrollmgrdc','selfenrollmgrcc');
46: } else {
47: my @items = ('courseowner','coursecode','authtype','autharg','selfenrollmgrdc',
48: 'selfenrollmgrcc','mysqltables');
49: if (&showcredits($cdom)) {
50: push(@items,'defaultcredits');
51: }
52: return @items;
53: }
54: }
55:
56: sub autoenroll_keys {
57: my $internals = ['coursecode','courseowner','authtype','autharg','defaultcredits',
58: 'autoadds','autodrops','autostart','autoend','sectionnums',
59: 'crosslistings','co-owners','autodropfailsafe'];
60: my $accessdates = ['default_enrollment_start_date','default_enrollment_end_date'];
61: return ($internals,$accessdates);
62: }
63:
64: sub catalog_settable {
65: my ($confhash,$type) = @_;
66: my @settable;
67: if (ref($confhash) eq 'HASH') {
68: if ($type eq 'Community') {
69: if ($confhash->{'togglecatscomm'} ne 'comm') {
70: push(@settable,'togglecats');
71: }
72: if ($confhash->{'categorizecomm'} ne 'comm') {
73: push(@settable,'categorize');
74: }
75: } elsif ($type eq 'Placement') {
76: if ($confhash->{'togglecatsplace'} ne 'place') {
77: push(@settable,'togglecats');
78: }
79: if ($confhash->{'categorizeplace'} ne 'place') {
80: push(@settable,'categorize');
81: }
82: } else {
83: if ($confhash->{'togglecats'} ne 'crs') {
84: push(@settable,'togglecats');
85: }
86: if ($confhash->{'categorize'} ne 'crs') {
87: push(@settable,'categorize');
88: }
89: }
90: } else {
91: push(@settable,('togglecats','categorize'));
92: }
93: return @settable;
94: }
95:
96: sub get_enrollment_settings {
97: my ($cdom,$cnum) = @_;
98: my ($internals,$accessdates) = &autoenroll_keys();
99: my @items;
100: if ((ref($internals) eq 'ARRAY') && (ref($accessdates) eq 'ARRAY')) {
101: @items = map { 'internal.'.$_; } (@{$internals});
102: push(@items,@{$accessdates});
103: }
104: my %settings = &Apache::lonnet::get('environment',\@items,$cdom,$cnum);
105: my %enrollvar;
106: $enrollvar{'autharg'} = '';
107: $enrollvar{'authtype'} = '';
108: foreach my $item (keys(%settings)) {
109: if ($item =~ m/^internal\.(.+)$/) {
110: my $type = $1;
111: if ( ($type eq "autoadds") || ($type eq "autodrops") ) {
112: if ($settings{$item} == 1) {
113: $enrollvar{$type} = "ON";
114: } else {
115: $enrollvar{$type} = "OFF";
116: }
117: } elsif ( ($type eq "autostart") || ($type eq "autoend") ) {
118: if ( ($type eq "autoend") && ($settings{$item} == 0) ) {
119: $enrollvar{$type} = &mt('No end date');
120: } else {
121: $enrollvar{$type} = &Apache::lonlocal::locallocaltime($settings{$item});
122: }
123: } elsif (($type eq 'sectionnums') || ($type eq 'co-owners')) {
124: $enrollvar{$type} = $settings{$item};
125: $enrollvar{$type} =~ s/,/, /g;
126: } elsif ($type eq "authtype"
127: || $type eq "autharg" || $type eq "coursecode"
128: || $type eq "crosslistings" || $type eq "selfenrollmgr"
129: || $type eq "autodropfailsafe") {
130: $enrollvar{$type} = $settings{$item};
131: } elsif ($type eq 'defaultcredits') {
132: if (&showcredits($cdom)) {
133: $enrollvar{$type} = $settings{$item};
134: }
135: } elsif ($type eq 'courseowner') {
136: if ($settings{$item} =~ /^[^:]+:[^:]+$/) {
137: $enrollvar{$type} = $settings{$item};
138: } else {
139: if ($settings{$item} ne '') {
140: $enrollvar{$type} = $settings{$item}.':'.$cdom;
141: }
142: }
143: }
144: } elsif ($item =~ m/^default_enrollment_(start|end)_date$/) {
145: my $type = $1;
146: if ( ($type eq 'end') && ($settings{$item} == 0) ) {
147: $enrollvar{$item} = &mt('No end date');
148: } elsif ( ($type eq 'start') && ($settings{$item} eq '') ) {
149: $enrollvar{$item} = 'When enrolled';
150: } else {
151: $enrollvar{$item} = &Apache::lonlocal::locallocaltime($settings{$item});
152: }
153: }
154: }
155: return %enrollvar;
156: }
157:
158: sub print_course_search_page {
159: my ($r,$dom,$domdesc) = @_;
160: my $action = '/adm/modifycourse';
161: my $type = $env{'form.type'};
162: if (!defined($env{'form.type'})) {
163: $type = 'Course';
164: }
165: &print_header($r,$type);
166: my ($filterlist,$filter) = &get_filters($dom);
167: my ($numtitles,$cctitle,$dctitle,@codetitles);
168: my $ccrole = 'cc';
169: if ($type eq 'Community') {
170: $ccrole = 'co';
171: }
172: $cctitle = &Apache::lonnet::plaintext($ccrole,$type);
173: $dctitle = &Apache::lonnet::plaintext('dc');
174: $r->print(&Apache::loncommon::js_changer());
175: if ($type eq 'Community') {
176: $r->print('<h3>'.&mt('Search for a community in the [_1] domain',$domdesc).'</h3>');
177: } elsif ($type eq 'Placement') {
178: $r->print('<h3>'.&mt('Search for a placement test in the [_1] domain',$domdesc).'</h3>');
179: } else {
180: $r->print('<h3>'.&mt('Search for a course in the [_1] domain',$domdesc).'</h3>');
181: }
182: $r->print(&Apache::loncommon::build_filters($filterlist,$type,undef,undef,$filter,$action,
183: \$numtitles,'modifycourse',undef,undef,undef,
184: \@codetitles,$dom));
185:
186: my ($actiontext,$roleoption,$settingsoption);
187: if ($type eq 'Community') {
188: $actiontext = &mt('Actions available after searching for a community:');
189: } elsif ($type eq 'Placement') {
190: $actiontext = &mt('Actions available after searching for a placement test:')
191: } else {
192: $actiontext = &mt('Actions available after searching for a course:');
193: }
194: if (&Apache::lonnet::allowed('ccc',$dom)) {
195: if ($type eq 'Community') {
196: $roleoption = &mt('Enter the community with the role of [_1]',$cctitle);
197: $settingsoption = &mt('View or modify community settings which only a [_1] may modify.',$dctitle);
198: } elsif ($type eq 'Placement') {
199: $roleoption = &mt('Enter the placement test with the role of [_1]',$cctitle);
200: $settingsoption = &mt('View or modify placement test settings which only a [_1] may modify.',$dctitle);
201: } else {
202: $roleoption = &mt('Enter the course with the role of [_1]',$cctitle);
203: $settingsoption = &mt('View or modify course settings which only a [_1] may modify.',$dctitle);
204: }
205: } elsif (&Apache::lonnet::allowed('rar',$dom)) {
206: my ($roles_by_num,$description,$accessref,$accessinfo) = &Apache::lonnet::get_all_adhocroles($dom);
207: if ((ref($roles_by_num) eq 'ARRAY') && (ref($description) eq 'HASH')) {
208: if (@{$roles_by_num} > 1) {
209: if ($type eq 'Community') {
210: $roleoption = &mt('Enter the community with one of the available ad hoc roles');
211: } elsif ($type eq 'Placement') {
212: $roleoption = &mt('Enter the placement test with one of the available ad hoc roles.');
213: } else {
214: $roleoption = &mt('Enter the course with one of the available ad hoc roles.');
215: }
216: } else {
217: my $rolename = $description->{$roles_by_num->[0]};
218: if ($type eq 'Community') {
219: $roleoption = &mt('Enter the community with the ad hoc role of: [_1]',$rolename);
220: } elsif ($type eq 'Placement') {
221: $roleoption = &mt('Enter the placement test with the ad hoc role of: [_1]',$rolename);
222: } else {
223: $roleoption = &mt('Enter the course with the ad hoc role of: [_1]',$rolename);
224: }
225: }
226: }
227: if ($type eq 'Community') {
228: $settingsoption = &mt('View community settings which only a [_1] may modify.',$dctitle);
229: } elsif ($type eq 'Placement') {
230: $settingsoption = &mt('View placement test settings which only a [_1] may modify.',$dctitle);
231: } else {
232: $settingsoption = &mt('View course settings which only a [_1] may modify.',$dctitle);
233: }
234: }
235: $r->print($actiontext.'<ul>');
236: if ($roleoption) {
237: $r->print('<li>'.$roleoption.'</li>'."\n");
238: }
239: $r->print('<li>'.$settingsoption.'</li>'."\n".'</ul>');
240: return;
241: }
242:
243: sub print_course_selection_page {
244: my ($r,$dom,$domdesc,$permission) = @_;
245: my $type = $env{'form.type'};
246: if (!defined($type)) {
247: $type = 'Course';
248: }
249: &print_header($r,$type);
250:
251: if ($permission->{'adhocrole'} eq 'custom') {
252: my %lt = &Apache::lonlocal::texthash(
253: title => 'Ad hoc role selection',
254: preamble => 'Please choose an ad hoc role in the course.',
255: cancel => 'Click "OK" to enter the course, or "Cancel" to choose a different course.',
256: );
257: my %jslt = &Apache::lonlocal::texthash (
258: none => 'You are not eligible to use an ad hoc role for the selected course',
259: ok => 'OK',
260: exit => 'Cancel',
261: );
262: &js_escape(\%jslt);
263: $r->print(<<"END");
264: <script type="text/javascript">
265: // <![CDATA[
266: \$(document).ready(function(){
267: \$( "#LC_adhocrole_chooser" ).dialog({ autoOpen: false });
268: });
269:
270: function gochoose(cname,cdom,cdesc) {
271: document.courselist.pickedcourse.value = cdom+'_'+cname;
272: \$("#LC_choose_adhoc").empty();
273: var pickedaction = \$('input[name=phase]:checked', '#LCcoursepicker').val();
274: if (pickedaction == 'adhocrole') {
275: var http = new XMLHttpRequest();
276: var url = "/adm/pickcourse";
277: var params = "cid="+cdom+"_"+cname+"&context=adhoc";
278: http.open("POST", url, true);
279: http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
280: http.onreadystatechange = function() {
281: if (http.readyState == 4 && http.status == 200) {
282: var data = \$.parseJSON(http.responseText);
283: var len = data.roles.length;
284: if (len == '' || len == null || len == 0) {
285: alert('$jslt{none}');
286: } else {
287: if (len == 1) {
288: \$( '[name="adhocrole"]' )[0].value = data.roles[0].name;
289: document.courselist.submit();
290: } else {
291: var str = '';
292: \$("#LC_choose_adhoc").empty();
293: for (var i=0; i<data.roles.length; i++) {
294: \$("<label><input type='radio' value='"+data.roles[i].name+"' name='LC_get_role' id='LC_get_role_"+i+"' />"+data.roles[i].desc+"</label><span> </span>")
295: .appendTo("#LC_choose_adhoc");
296: }
297: \$( "#LC_adhocrole_chooser" ).toggle( true );
298: \$( "#LC_get_role_0").prop("checked", true);
299: \$( "#LC_adhocrole_chooser" ).dialog({ autoOpen: false });
300: \$( "#LC_adhocrole_chooser" ).dialog("open");
301: \$( "#LC_adhocrole_chooser" ).dialog({
302: height: 400,
303: width: 500,
304: modal: true,
305: resizable: false,
306: buttons: [
307: {
308: text: "$jslt{'ok'}",
309: click: function() {
310: var rolename = \$('input[name=LC_get_role]:checked', '#LChelpdeskpicker').val();
311: \$( '[name="adhocrole"]' )[0].value = rolename;
312: document.courselist.submit();
313: }
314: },
315: {
316: text: "$jslt{'exit'}",
317: click: function() {
318: \$("#LC_adhocrole_chooser").dialog( "close" );
319: }
320: }
321: ],
322: });
323: \$( "#LC_adhocrole_chooser" ).find( "form" ).on( "submit", function( event ) {
324: event.preventDefault();
325: var rolename = \$('input[name=LC_get_role]:checked', '#LChelpdeskpicker').val()
326: \$( '[name="adhocrole"]' )[0].value = rolename;
327: document.courselist.submit();
328: \$("#LC_adhocrole_chooser").dialog( "close" );
329: });
330: }
331: }
332: }
333: }
334: http.send(params);
335: } else {
336: document.courselist.submit();
337: }
338: return;
339: }
340: // ]]>
341: </script>
342:
343: <div id="LC_adhocrole_chooser" title="$lt{'title'}" style="display:none">
344: <p>$lt{'preamble'}</p>
345: <form name="LChelpdeskadhoc" id="LChelpdeskpicker" action="">
346: <div id="LC_choose_adhoc">
347: </div>
348: <input type="hidden" name="adhocrole" id="LCadhocrole" value="" />
349: <input type="submit" tabindex="-1" style="position:absolute; top:-1000px" />
350: </form>
351: <p>$lt{'cancel'}</p>
352: </div>
353: END
354: } elsif ($permission->{'adhocrole'} eq 'coord') {
355: $r->print(<<"END");
356: <script type="text/javascript">
357: // <![CDATA[
358:
359: function gochoose(cname,cdom,cdesc) {
360: document.courselist.pickedcourse.value = cdom+'_'+cname;
361: document.courselist.submit();
362: return;
363: }
364:
365: // ]]>
366: </script>
367: END
368: }
369:
370: # Criteria for course search
371: my ($filterlist,$filter) = &get_filters();
372: my $action = '/adm/modifycourse';
373: my $dctitle = &Apache::lonnet::plaintext('dc');
374: my ($numtitles,@codetitles);
375: $r->print(&Apache::loncommon::js_changer());
376: $r->print(&mt('Revise your search criteria for this domain').' ('.$domdesc.').<br />');
377: $r->print(&Apache::loncommon::build_filters($filterlist,$type,undef,undef,$filter,$action,
378: \$numtitles,'modifycourse',undef,undef,undef,
379: \@codetitles,$dom,$env{'form.form'}));
380: my %courses = &Apache::loncommon::search_courses($dom,$type,$filter,$numtitles,
381: undef,undef,undef,\@codetitles);
382: &Apache::lonpickcourse::display_matched_courses($r,$type,0,$action,undef,undef,undef,
383: $dom,undef,%courses);
384: return;
385: }
386:
387: sub get_filters {
388: my ($dom) = @_;
389: my @filterlist = ('descriptfilter','instcodefilter','ownerfilter',
390: 'ownerdomfilter','coursefilter','sincefilter');
391: # created filter
392: my $loncaparev = &Apache::lonnet::get_server_loncaparev($dom);
393: if ($loncaparev ne 'unknown_cmd') {
394: push(@filterlist,'createdfilter');
395: }
396: my %filter;
397: foreach my $item (@filterlist) {
398: $filter{$item} = $env{'form.'.$item};
399: }
400: return (\@filterlist,\%filter);
401: }
402:
403: sub print_modification_menu {
404: my ($r,$cdesc,$domdesc,$dom,$type,$cid,$coursehash,$permission) = @_;
405: &print_header($r,$type);
406: my ($ccrole,$categorytitle,$setquota_text,$setuploadquota_text,$cdom,$cnum);
407: if (ref($coursehash) eq 'HASH') {
408: $cdom = $coursehash->{'domain'};
409: $cnum = $coursehash->{'num'};
410: } else {
411: ($cdom,$cnum) = split(/_/,$cid);
412: }
413: if ($type eq 'Community') {
414: $ccrole = 'co';
415: } else {
416: $ccrole = 'cc';
417: }
418: my %linktext;
419: if ($permission->{'setparms'} eq 'edit') {
420: %linktext = (
421: 'setquota' => 'View/Modify quotas for group portfolio files, and for uploaded content',
422: 'setanon' => 'View/Modify responders threshold for anonymous survey submissions display',
423: 'selfenroll' => 'View/Modify Self-Enrollment configuration',
424: 'setpostsubmit' => 'View/Modify submit button behavior, post-submission',
425: );
426: } else {
427: %linktext = (
428: 'setquota' => 'View quotas for group portfolio files, and for uploaded content',
429: 'setanon' => 'View responders threshold for anonymous survey submissions display',
430: 'selfenroll' => 'View Self-Enrollment configuration',
431: 'setpostsubmit' => 'View submit button behavior, post-submission',
432: );
433: }
434: if ($type eq 'Community') {
435: if ($permission->{'setparms'} eq 'edit') {
436: $categorytitle = 'View/Modify Community Settings';
437: $linktext{'setparms'} = 'View/Modify community owner';
438: $linktext{'catsettings'} = 'View/Modify catalog settings for community';
439: } else {
440: $categorytitle = 'View Community Settings';
441: $linktext{'setparms'} = 'View community owner';
442: $linktext{'catsettings'} = 'View catalog settings for community';
443: }
444: $setquota_text = &mt('Total disk space allocated for storage of portfolio files in all groups in a community.');
445: $setuploadquota_text = &mt('Disk space allocated for storage of content uploaded directly to a community via Content Editor.');
446: } else {
447: if ($permission->{'setparms'} eq 'edit') {
448: $categorytitle = 'View/Modify Course Settings';
449: $linktext{'catsettings'} = 'View/Modify catalog settings for course';
450: if (($type ne 'Placement') && (&showcredits($dom))) {
451: $linktext{'setparms'} = 'View/Modify course owner, institutional code, default authentication, credits, self-enrollment and table lifetime';
452: } else {
453: $linktext{'setparms'} = 'View/Modify course owner, institutional code, default authentication, self-enrollment and table lifetime';
454: }
455: } else {
456: $categorytitle = 'View Course Settings';
457: $linktext{'catsettings'} = 'View catalog settings for course';
458: if (($type ne 'Placement') && (&showcredits($dom))) {
459: $linktext{'setparms'} = 'View course owner, institutional code, default authentication, credits, self-enrollment and table lifetime';
460: } else {
461: $linktext{'setparms'} = 'View course owner, institutional code, default authentication, self-enrollment and table lifetime';
462: }
463: }
464: $setquota_text = &mt('Total disk space allocated for storage of portfolio files in all groups in a course.');
465: $setuploadquota_text = &mt('Disk space allocated for storage of content uploaded directly to a course via Content Editor.');
466: }
467: my $anon_text = &mt('Responder threshold required to display anonymous survey submissions.');
468: my $postsubmit_text = &mt('Override defaults for submit button behavior post-submission for this specific course.');
469: my $mysqltables_text = &mt('Override default for lifetime of "temporary" MySQL tables containing student performance data.');
470: $linktext{'viewparms'} = 'Display current settings for automated enrollment';
471:
472: my %domconf = &Apache::lonnet::get_dom('configuration',['coursecategories'],$dom);
473: my @additional_params = &catalog_settable($domconf{'coursecategories'},$type);
474:
475: sub manage_selfenrollment {
476: my ($cdom,$cnum,$type,$coursehash,$permission) = @_;
477: if ($permission->{'selfenroll'}) {
478: my ($managed_by_cc,$managed_by_dc) = &Apache::lonuserutils::selfenrollment_administration($cdom,$cnum,$type,$coursehash);
479: if (ref($managed_by_dc) eq 'ARRAY') {
480: if (@{$managed_by_dc}) {
481: return 1;
482: }
483: }
484: }
485: return 0;
486: }
487:
488: sub phaseurl {
489: my $phase = shift;
490: return "javascript:changePage(document.menu,'$phase')"
491: }
492: my @menu =
493: ({ categorytitle => $categorytitle,
494: items => [
495: {
496: linktext => $linktext{'setparms'},
497: url => &phaseurl('setparms'),
498: permission => $permission->{'setparms'},
499: #help => '',
500: icon => 'crsconf.png',
501: linktitle => ''
502: },
503: {
504: linktext => $linktext{'setquota'},
505: url => &phaseurl('setquota'),
506: permission => $permission->{'setquota'},
507: #help => '',
508: icon => 'groupportfolioquota.png',
509: linktitle => ''
510: },
511: {
512: linktext => $linktext{'setanon'},
513: url => &phaseurl('setanon'),
514: permission => $permission->{'setanon'},
515: #help => '',
516: icon => 'anonsurveythreshold.png',
517: linktitle => ''
518: },
519: {
520: linktext => $linktext{'catsettings'},
521: url => &phaseurl('catsettings'),
522: permission => (($permission->{'catsettings'}) && (@additional_params > 0)),
523: #help => '',
524: icon => 'ccatconf.png',
525: linktitle => ''
526: },
527: {
528: linktext => $linktext{'viewparms'},
529: url => &phaseurl('viewparms'),
530: permission => ($permission->{'viewparms'} && ($type ne 'Community') && ($type ne 'Placement')),
531: #help => '',
532: icon => 'roles.png',
533: linktitle => ''
534: },
535: {
536: linktext => $linktext{'selfenroll'},
537: icon => 'self_enroll.png',
538: #help => 'Course_Self_Enrollment',
539: url => &phaseurl('selfenroll'),
540: permission => &manage_selfenrollment($cdom,$cnum,$type,$coursehash,$permission),
541: linktitle => 'Configure user self-enrollment.',
542: },
543: {
544: linktext => $linktext{'setpostsubmit'},
545: icon => 'emblem-readonly.png',
546: #help => '',
547: url => &phaseurl('setpostsubmit'),
548: permission => $permission->{'setpostsubmit'},
549: linktitle => '',
550: },
551: ]
552: },
553: );
554:
555: my $menu_html =
556: '<h3>'
557: .&mt('View/Modify settings for: [_1]',
558: '<span class="LC_nobreak">'.$cdesc.'</span>')
559: .'</h3>'."\n".'<p>';
560: if ($type eq 'Community') {
561: $menu_html .= &mt('Although almost all community settings can be modified by a Coordinator, the following may only be set or modified by a Domain Coordinator:');
562: } else {
563: $menu_html .= &mt('Although almost all course settings can be modified by a Course Coordinator, the following may only be set or modified by a Domain Coordinator:');
564: }
565: $menu_html .= '</p>'."\n".'<ul>';
566: if ($type eq 'Community') {
567: $menu_html .= '<li>'.&mt('Community owner (permitted to assign Coordinator roles in the community).').'</li>'."\n".
568: '<li>'.&mt('Override defaults for who configures self-enrollment for this specific community').'</li>'."\n";
569: } else {
570: $menu_html .= '<li>'.&mt('Course owner (permitted to assign Course Coordinator roles in the course).').'</li>'."\n".
571: '<li>'.&mt("Institutional code and default authentication (both required for auto-enrollment of students from institutional datafeeds).").'</li>'."\n";
572: if (($type ne 'Placement') && &showcredits($dom)) {
573: $menu_html .= '<li>'.&mt('Default credits earned by student on course completion.').'</li>'."\n";
574: }
575: $menu_html .= ' <li>'.&mt('Override defaults for who configures self-enrollment for this specific course.').'</li>'."\n";
576: }
577: $menu_html .= '<li>'.$mysqltables_text.'</li>'."\n".
578: '<li>'.$setquota_text.'</li>'."\n".
579: '<li>'.$setuploadquota_text.'</li>'."\n".
580: '<li>'.$anon_text.'</li>'."\n".
581: '<li>'.$postsubmit_text.'</li>'."\n";
582: my ($categories_link_start,$categories_link_end);
583: if ($permission->{'catsettings'} eq 'edit') {
584: $categories_link_start = '<a href="/adm/domainprefs?actions=coursecategories&phase=display">';
585: $categories_link_end = '</a>';
586: }
587: foreach my $item (@additional_params) {
588: if ($type eq 'Community') {
589: if ($item eq 'togglecats') {
590: $menu_html .= ' <li>'.&mt('Hiding/unhiding a community from the catalog (although can be [_1]configured[_2] to be modifiable by a Coordinator in community context).',$categories_link_start,$categories_link_end).'</li>'."\n";
591: } elsif ($item eq 'categorize') {
592: $menu_html .= ' <li>'.&mt('Manual cataloging of a community (although can be [_1]configured[_2] to be modifiable by a Coordinator in community context).',$categories_link_start,$categories_link_end).'</li>'."\n";
593: }
594: } else {
595: if ($item eq 'togglecats') {
596: $menu_html .= ' <li>'.&mt('Hiding/unhiding a course from the course catalog (although can be [_1]configured[_2] to be modifiable by a Course Coordinator in course context).',$categories_link_start,$categories_link_end).'</li>'."\n";
597: } elsif ($item eq 'categorize') {
598: $menu_html .= ' <li>'.&mt('Manual cataloging of a course (although can be [_1]configured[_2] to be modifiable by a Course Coordinator in course context).',$categories_link_start,$categories_link_end).'</li>'."\n";
599: }
600: }
601: }
602: $menu_html .=
603: ' </ul>'
604: .'<form name="menu" method="post" action="/adm/modifycourse">'
605: ."\n"
606: .&hidden_form_elements();
607:
608: $r->print($menu_html);
609: $r->print(&Apache::lonhtmlcommon::generate_menu(@menu));
610: $r->print('</form>');
611: return;
612: }
613:
614: sub print_adhocrole_selected {
615: my ($r,$type,$permission) = @_;
616: &print_header($r,$type);
617: my ($cdom,$cnum) = split(/_/,$env{'form.pickedcourse'});
618: my ($newrole,$selectrole);
619: if ($permission->{'adhocrole'} eq 'coord') {
620: if ($type eq 'Community') {
621: $newrole = "co./$cdom/$cnum";
622: } else {
623: $newrole = "cc./$cdom/$cnum";
624: }
625: $selectrole = 1;
626: } elsif ($permission->{'adhocrole'} eq 'custom') {
627: my ($okroles,$description) = &Apache::lonnet::get_my_adhocroles($env{'form.pickedcourse'},1);
628: if (ref($okroles) eq 'ARRAY') {
629: my $possrole = $env{'form.adhocrole'};
630: if (($possrole ne '') && (grep(/^\Q$possrole\E$/,@{$okroles}))) {
631: my $confname = &Apache::lonnet::get_domainconfiguser($cdom);
632: $newrole = "cr/$cdom/$confname/$possrole./$cdom/$cnum";
633: $selectrole = 1;
634: }
635: }
636: }
637: if ($selectrole) {
638: $r->print('<form name="adhocrole" method="post" action="/adm/roles">
639: <input type="hidden" name="selectrole" value="'.$selectrole.'" />
640: <input type="hidden" name="newrole" value="'.$newrole.'" />
641: </form>');
642: } else {
643: $r->print('<form name="ccrole" method="post" action="/adm/modifycourse">'.
644: '</form>');
645: }
646: return;
647: }
648:
649: sub print_settings_display {
650: my ($r,$cdom,$cnum,$cdesc,$type,$permission) = @_;
651: my %enrollvar = &get_enrollment_settings($cdom,$cnum);
652: my %longtype = &course_settings_descrip($type);
653: my %lt = &Apache::lonlocal::texthash(
654: 'valu' => 'Current value',
655: 'cour' => 'Current settings are:',
656: 'cose' => "Settings which control auto-enrollment using classlists from your institution's student information system fall into two groups:",
657: 'dcon' => 'Modifiable only by Domain Coordinator',
658: 'back' => 'Pick another action',
659: );
660: my $ccrole = 'cc';
661: if ($type eq 'Community') {
662: $ccrole = 'co';
663: }
664: my $cctitle = &Apache::lonnet::plaintext($ccrole,$type);
665: my $dctitle = &Apache::lonnet::plaintext('dc');
666: my @modifiable_params = &get_dc_settable($type,$cdom);
667: my ($internals,$accessdates) = &autoenroll_keys();
668: my @items;
669: if ((ref($internals) eq 'ARRAY') && (ref($accessdates) eq 'ARRAY')) {
670: @items = (@{$internals},@{$accessdates});
671: }
672: my $disp_table = &Apache::loncommon::start_data_table()."\n".
673: &Apache::loncommon::start_data_table_header_row()."\n".
674: "<th> </th>\n".
675: "<th>$lt{'valu'}</th>\n".
676: "<th>$lt{'dcon'}</th>\n".
677: &Apache::loncommon::end_data_table_header_row()."\n";
678: foreach my $item (@items) {
679: $disp_table .= &Apache::loncommon::start_data_table_row()."\n".
680: "<td><b>$longtype{$item}</b></td>\n".
681: "<td>$enrollvar{$item}</td>\n";
682: if (grep(/^\Q$item\E$/,@modifiable_params)) {
683: $disp_table .= '<td align="right">'.&mt('Yes').'</td>'."\n";
684: } else {
685: $disp_table .= '<td align="right">'.&mt('No').'</td>'."\n";
686: }
687: $disp_table .= &Apache::loncommon::end_data_table_row()."\n";
688: }
689: $disp_table .= &Apache::loncommon::end_data_table()."\n";
690: &print_header($r,$type);
691: my ($enroll_link_start,$enroll_link_end,$setparms_link_start,$setparms_link_end);
692: if (&Apache::lonnet::allowed('ccc',$cdom)) {
693: my $newrole = $ccrole.'./'.$cdom.'/'.$cnum;
694: my $escuri = &HTML::Entities::encode('/adm/roles?selectrole=1&'.$newrole.
695: '=1&destinationurl=/adm/populate','&<>"');
696: $enroll_link_start = '<a href="'.$escuri.'">';
697: $enroll_link_end = '</a>';
698: }
699: if ($permission->{'setparms'}) {
700: $setparms_link_start = '<a href="javascript:changePage(document.viewparms,'."'setparms'".');">';
701: $setparms_link_end = '</a>';
702: }
703: $r->print('<h3>'.&mt('Current automated enrollment settings for:').
704: ' <span class="LC_nobreak">'.$cdesc.'</span></h3>'.
705: '<form action="/adm/modifycourse" method="post" name="viewparms">'."\n".
706: '<p>'.$lt{'cose'}.'<ul>'.
707: '<li>'.&mt('Settings modifiable by a [_1] via the [_2]Automated Enrollment Manager[_3] in a course.',
708: $cctitle,$enroll_link_start,$enroll_link_end).'</li>');
709: if (&showcredits($cdom)) {
710: $r->print('<li>'.&mt('Settings modifiable by a [_1] via [_2]View/Modify course owner, institutional code, default authentication, credits, and self-enrollment[_3].',$dctitle,$setparms_link_start,$setparms_link_end)."\n");
711: } else {
712: $r->print('<li>'.&mt('Settings modifiable by a [_1] via [_2]View/Modify course owner, institutional code, default authentication, and self-enrollment[_3].',$dctitle,$setparms_link_start,$setparms_link_end)."\n");
713: }
714: $r->print('</li></ul></p>'.
715: '<p>'.$lt{'cour'}.'</p><p>'.$disp_table.'</p><p>'.
716: '<a href="javascript:changePage(document.viewparms,'."'menu'".')">'.$lt{'back'}.'</a>'."\n".
717: &hidden_form_elements().
718: '</p></form>'
719: );
720: }
721:
722: sub print_setquota {
723: my ($r,$cdom,$cnum,$cdesc,$type,$readonly) = @_;
724: my $lctype = lc($type);
725: my $headline = &mt("Set disk space quotas for $lctype: [_1]",
726: '<span class="LC_nobreak">'.$cdesc.'</span>');
727: my %lt = &Apache::lonlocal::texthash(
728: 'gpqu' => 'Disk space for storage of group portfolio files',
729: 'upqu' => 'Disk space for storage of content directly uploaded to course via Content Editor',
730: 'modi' => 'Save',
731: 'back' => 'Pick another action',
732: );
733: my %staticdefaults = (
734: coursequota => 20,
735: uploadquota => 500,
736: );
737: my %settings = &Apache::lonnet::get('environment',['internal.coursequota','internal.uploadquota','internal.coursecode'],
738: $cdom,$cnum);
739: my $coursequota = $settings{'internal.coursequota'};
740: my $uploadquota = $settings{'internal.uploadquota'};
741: if ($coursequota eq '') {
742: $coursequota = $staticdefaults{'coursequota'};
743: }
744: if ($uploadquota eq '') {
745: my %domdefs = &Apache::lonnet::get_domain_defaults($cdom);
746: my $quotatype = &Apache::lonuserutils::get_extended_type($cdom,$cnum,$type,\%settings);
747: $uploadquota = $domdefs{$quotatype.'quota'};
748: if ($uploadquota eq '') {
749: $uploadquota = $staticdefaults{'uploadquota'};
750: }
751: }
752: &print_header($r,$type);
753: my $hidden_elements = &hidden_form_elements();
754: my $porthelpitem = &Apache::loncommon::help_open_topic('Modify_Course_Quota');
755: my $uploadhelpitem = &Apache::loncommon::help_open_topic('Modify_Course_Upload_Quota');
756: my ($disabled,$submit);
757: if ($readonly) {
758: $disabled = ' disabled="disabled"';
759: } else {
760: $submit = '<input type="submit" value="'.$lt{'modi'}.'" />';
761: }
762: $r->print(<<ENDDOCUMENT);
763: <form action="/adm/modifycourse" method="post" name="setquota" onsubmit="return verify_quota();">
764: <h3>$headline</h3>
765: <p><span class="LC_nobreak">
766: $porthelpitem $lt{'gpqu'}: <input type="text" size="4" name="coursequota" value="$coursequota" $disabled /> MB
767: </span>
768: <br />
769: <span class="LC_nobreak">
770: $uploadhelpitem $lt{'upqu'}: <input type="text" size="4" name="uploadquota" value="$uploadquota" $disabled /> MB
771: </span>
772: </p>
773: <p>
774: $submit
775: </p>
776: $hidden_elements
777: <a href="javascript:changePage(document.setquota,'menu')">$lt{'back'}</a>
778: </form>
779: ENDDOCUMENT
780: return;
781: }
782:
783: sub print_set_anonsurvey_threshold {
784: my ($r,$cdom,$cnum,$cdesc,$type,$readonly) = @_;
785: my %lt = &Apache::lonlocal::texthash(
786: 'resp' => 'Responder threshold for anonymous survey submissions display:',
787: 'sufa' => 'Anonymous survey submissions displayed when responders exceeds',
788: 'modi' => 'Save',
789: 'back' => 'Pick another action',
790: );
791: my %settings = &Apache::lonnet::get('environment',['internal.anonsurvey_threshold'],$cdom,$cnum);
792: my $threshold = $settings{'internal.anonsurvey_threshold'};
793: if ($threshold eq '') {
794: my %domconfig =
795: &Apache::lonnet::get_dom('configuration',['coursedefaults'],$cdom);
796: if (ref($domconfig{'coursedefaults'}) eq 'HASH') {
797: $threshold = $domconfig{'coursedefaults'}{'anonsurvey_threshold'};
798: if ($threshold eq '') {
799: $threshold = 10;
800: }
801: } else {
802: $threshold = 10;
803: }
804: }
805: &print_header($r,$type);
806: my $hidden_elements = &hidden_form_elements();
807: my ($disabled,$submit);
808: if ($readonly) {
809: $disabled = ' disabled="disabled"';
810: } else {
811: $submit = '<input type="submit" value="'.$lt{'modi'}.'" />';
812: }
813: my $helpitem = &Apache::loncommon::help_open_topic('Modify_Anonsurvey_Threshold');
814: $r->print(<<ENDDOCUMENT);
815: <form action="/adm/modifycourse" method="post" name="setanon" onsubmit="return verify_anon_threshold();">
816: <h3>$lt{'resp'} <span class="LC_nobreak">$cdesc</span></h3>
817: <p>
818: $helpitem $lt{'sufa'}: <input type="text" size="4" name="threshold" value="$threshold" $disabled />
819: $submit
820: </p>
821: $hidden_elements
822: <a href="javascript:changePage(document.setanon,'menu')">$lt{'back'}</a>
823: </form>
824: ENDDOCUMENT
825: return;
826: }
827:
828: sub print_postsubmit_config {
829: my ($r,$cdom,$cnum,$cdesc,$type,$readonly) = @_;
830: my %lt = &Apache::lonlocal::texthash (
831: 'conf' => 'Configure submit button behavior after student makes a submission',
832: 'disa' => 'Disable submit button/keypress following student submission',
833: 'nums' => 'Number of seconds submit is disabled',
834: 'modi' => 'Save',
835: 'back' => 'Pick another action',
836: 'yes' => 'Yes',
837: 'no' => 'No',
838: );
839: my %settings = &Apache::lonnet::get('environment',['internal.postsubmit','internal.postsubtimeout',
840: 'internal.coursecode','internal.textbook'],$cdom,$cnum);
841: my $postsubmit = $settings{'internal.postsubmit'};
842: if ($postsubmit eq '') {
843: my %domconfig =
844: &Apache::lonnet::get_dom('configuration',['coursedefaults'],$cdom);
845: $postsubmit = 1;
846: if (ref($domconfig{'coursedefaults'}) eq 'HASH') {
847: if (ref($domconfig{'coursedefaults'}{'postsubmit'}) eq 'HASH') {
848: if ($domconfig{'coursedefaults'}{'postsubmit'}{'client'} eq 'off') {
849: $postsubmit = 0;
850: }
851: }
852: }
853: }
854: my ($checkedon,$checkedoff,$display);
855: if ($postsubmit) {
856: $checkedon = 'checked="checked"';
857: $display = 'block';
858: } else {
859: $checkedoff = 'checked="checked"';
860: $display = 'none';
861: }
862: my $postsubtimeout = $settings{'internal.postsubtimeout'};
863: my $default = &domain_postsubtimeout($cdom,$type,\%settings);
864: my $zero = &mt('(Enter 0 to disable until next page reload, or leave blank to use the domain default: [_1])',$default);
865: if ($postsubtimeout eq '') {
866: $postsubtimeout = $default;
867: }
868: &print_header($r,$type);
869: my $hidden_elements = &hidden_form_elements();
870: my ($disabled,$submit);
871: if ($readonly) {
872: $disabled = ' disabled="disabled"';
873: } else {
874: $submit = '<input type="submit" value="'.$lt{'modi'}.'" />';
875: }
876: my $helpitem = &Apache::loncommon::help_open_topic('Modify_Postsubmit_Config');
877: $r->print(<<ENDDOCUMENT);
878: <form action="/adm/modifycourse" method="post" name="setpostsubmit" onsubmit="return verify_postsubmit();">
879: <h3>$lt{'conf'} <span class="LC_nobreak">($cdesc)</span></h3>
880: <p>
881: $helpitem $lt{'disa'}:
882: <label><input type="radio" name="postsubmit" $checkedon onclick="togglePostsubmit('studentsubmission');" value="1" $disabled />
883: $lt{'yes'}</label>
884: <label><input type="radio" name="postsubmit" $checkedoff onclick="togglePostsubmit('studentsubmission');" value="0" $disabled />
885: $lt{'no'}</label>
886: <div id="studentsubmission" style="display: $display">
887: $lt{'nums'} <input type="text" name="postsubtimeout" value="$postsubtimeout" $disabled /><br />
888: $zero</div>
889: <br />
890: $submit
891: </p>
892: $hidden_elements
893: <a href="javascript:changePage(document.setpostsubmit,'menu')">$lt{'back'}</a>
894: </form>
895: ENDDOCUMENT
896: return;
897: }
898:
899: sub domain_postsubtimeout {
900: my ($cdom,$type,$settings) = @_;
901: return unless (ref($settings) eq 'HASH');
902: my $lctype = lc($type);
903: unless (($type eq 'Community') || ($type eq 'Placement')) {
904: $lctype = 'unofficial';
905: if ($settings->{'internal.coursecode'}) {
906: $lctype = 'official';
907: } elsif ($settings->{'internal.textbook'}) {
908: $lctype = 'textbook';
909: }
910: }
911: my %domconfig =
912: &Apache::lonnet::get_dom('configuration',['coursedefaults'],$cdom);
913: my $postsubtimeout = 60;
914: if (ref($domconfig{'coursedefaults'}) eq 'HASH') {
915: if (ref($domconfig{'coursedefaults'}{'postsubmit'}) eq 'HASH') {
916: if (ref($domconfig{'coursedefaults'}{'postsubmit'}{'timeout'}) eq 'HASH') {
917: if ($domconfig{'coursedefaults'}{'postsubmit'}{'timeout'}{$lctype} ne '') {
918: $postsubtimeout = $domconfig{'coursedefaults'}{'postsubmit'}{'timeout'}{$lctype};
919: }
920: }
921: }
922: }
923: return $postsubtimeout;
924: }
925:
926: sub print_catsettings {
927: my ($r,$cdom,$cnum,$cdesc,$type,$readonly) = @_;
928: &print_header($r,$type);
929: my %lt = &Apache::lonlocal::texthash(
930: 'back' => 'Pick another action',
931: 'catset' => 'Catalog Settings for Course',
932: 'visi' => 'Visibility in Course/Community Catalog',
933: 'exclude' => 'Exclude from course catalog:',
934: 'categ' => 'Categorize Course',
935: 'assi' => 'Assign one or more categories and/or subcategories to this course.'
936: );
937: if ($type eq 'Community') {
938: $lt{'catset'} = &mt('Catalog Settings for Community');
939: $lt{'exclude'} = &mt('Exclude from course catalog');
940: $lt{'categ'} = &mt('Categorize Community');
941: $lt{'assi'} = &mt('Assign one or more subcategories to this community.');
942: }
943: $r->print('<form action="/adm/modifycourse" method="post" name="catsettings">'.
944: '<h3>'.$lt{'catset'}.' <span class="LC_nobreak">'.$cdesc.'</span></h3>');
945: my %domconf = &Apache::lonnet::get_dom('configuration',['coursecategories'],$cdom);
946: my @cat_params = &catalog_settable($domconf{'coursecategories'},$type);
947: if (@cat_params > 0) {
948: my $disabled;
949: if ($readonly) {
950: $disabled = ' disabled="disabled"';
951: }
952: my %currsettings =
953: &Apache::lonnet::get('environment',['hidefromcat','categories'],$cdom,$cnum);
954: if (grep(/^togglecats$/,@cat_params)) {
955: my $excludeon = '';
956: my $excludeoff = ' checked="checked" ';
957: if ($currsettings{'hidefromcat'} eq 'yes') {
958: $excludeon = $excludeoff;
959: $excludeoff = '';
960: }
961: $r->print('<br /><h4>'.$lt{'visi'}.'</h4>'.
962: $lt{'exclude'}.
963: ' <label><input name="hidefromcat" type="radio" value="yes" '.$excludeon.$disabled.' />'.&mt('Yes').'</label> <label><input name="hidefromcat" type="radio" value="" '.$excludeoff.$disabled.' />'.&mt('No').'</label><br /><p>');
964: if ($type eq 'Community') {
965: $r->print(&mt("If a community has been categorized using at least one of the categories defined for communities in the domain, it will be listed in the domain's publicly accessible Course/Community Catalog, unless excluded."));
966: } elsif ($type eq 'Placement') {
967: $r->print(&mt("If a placement test has been categorized using at least one of the categories defined for placement tests in the domain, it will be listed in the domain's publicly accessible Course/Community Catalog, unless excluded."));
968: } else {
969: $r->print(&mt("Unless excluded, a course will be listed in the domain's publicly accessible Course/Community Catalog, if at least one of the following applies").':<ul>'.
970: '<li>'.&mt('Auto-cataloging is enabled and the course is assigned an institutional code.').'</li>'.
971: '<li>'.&mt('The course has been categorized using at least one of the course categories defined for the domain.').'</li></ul>');
972: }
973: $r->print('</ul></p>');
974: }
975: if (grep(/^categorize$/,@cat_params)) {
976: $r->print('<br /><h4>'.$lt{'categ'}.'</h4>');
977: if (ref($domconf{'coursecategories'}) eq 'HASH') {
978: my $cathash = $domconf{'coursecategories'}{'cats'};
979: if (ref($cathash) eq 'HASH') {
980: $r->print($lt{'assi'}.'<br /><br />'.
981: &Apache::loncommon::assign_categories_table($cathash,
982: $currsettings{'categories'},$type,$disabled));
983: } else {
984: $r->print(&mt('No categories defined for this domain'));
985: }
986: } else {
987: $r->print(&mt('No categories defined for this domain'));
988: }
989: unless (($type eq 'Community') || ($type eq 'Placement')) {
990: $r->print('<p>'.&mt('If auto-cataloging based on institutional code is enabled in the domain, a course will continue to be listed in the catalog of official courses, in addition to receiving a listing under any manually assigned categor(ies).').'</p>');
991: }
992: }
993: unless ($readonly) {
994: $r->print('<p><input type="button" name="chgcatsettings" value="'.
995: &mt('Save').'" onclick="javascript:changePage(document.catsettings,'."'processcat'".');" /></p>');
996: }
997: } else {
998: $r->print('<span class="LC_warning">');
999: if ($type eq 'Community') {
1000: $r->print(&mt('Catalog settings in this domain are set in community context via "Community Configuration".'));
1001: } else {
1002: $r->print(&mt('Catalog settings in this domain are set in course context via "Course Configuration".'));
1003: }
1004: $r->print('</span><br /><br />'."\n".
1005: '<a href="javascript:changePage(document.catsettings,'."'menu'".');">'.
1006: $lt{'back'}.'</a>');
1007: }
1008: $r->print(&hidden_form_elements().'</form>'."\n");
1009: return;
1010: }
1011:
1012: sub print_course_modification_page {
1013: my ($r,$cdom,$cnum,$cdesc,$crstype,$readonly) = @_;
1014: my %lt=&Apache::lonlocal::texthash(
1015: 'actv' => "Active",
1016: 'inac' => "Inactive",
1017: 'ownr' => "Owner",
1018: 'name' => "Name",
1019: 'unme' => "Username:Domain",
1020: 'stus' => "Status",
1021: 'nocc' => 'There is currently no owner set for this course.',
1022: 'gobt' => "Save",
1023: 'sett' => 'Setting',
1024: 'domd' => 'Domain default',
1025: 'whom' => 'Who configures',
1026: );
1027: my ($ownertable,$ccrole,$javascript_validations,$authenitems,$ccname,$disabled);
1028: my %enrollvar = &get_enrollment_settings($cdom,$cnum);
1029: my %settings = &Apache::lonnet::get('environment',['internal.coursecode','internal.textbook',
1030: 'internal.selfenrollmgrdc','internal.selfenrollmgrcc',
1031: 'internal.mysqltables'],$cdom,$cnum);
1032: my $type = &Apache::lonuserutils::get_extended_type($cdom,$cnum,$crstype,\%settings);
1033: my @specific_managebydc = split(/,/,$settings{'internal.selfenrollmgrdc'});
1034: my @specific_managebycc = split(/,/,$settings{'internal.selfenrollmgrcc'});
1035: my %domdefaults = &Apache::lonnet::get_domain_defaults($cdom);
1036: my @default_managebydc = split(/,/,$domdefaults{$type.'selfenrolladmdc'});
1037: if ($crstype eq 'Community') {
1038: $ccrole = 'co';
1039: $lt{'nocc'} = &mt('There is currently no owner set for this community.');
1040: } else {
1041: $ccrole ='cc';
1042: ($javascript_validations,$authenitems) = &gather_authenitems($cdom,\%enrollvar,$readonly);
1043: }
1044: $ccname = &Apache::lonnet::plaintext($ccrole,$crstype);
1045: if ($readonly) {
1046: $disabled = ' disabled="disabled"';
1047: }
1048: my %roleshash = &Apache::lonnet::get_my_roles($cnum,$cdom,'','',[$ccrole]);
1049: my (@local_ccs,%cc_status,%pname);
1050: foreach my $item (keys(%roleshash)) {
1051: my ($uname,$udom) = split(/:/,$item);
1052: if (!grep(/^\Q$uname\E:\Q$udom\E$/,@local_ccs)) {
1053: push(@local_ccs,$uname.':'.$udom);
1054: $pname{$uname.':'.$udom} = &Apache::loncommon::plainname($uname,$udom);
1055: $cc_status{$uname.':'.$udom} = $lt{'actv'};
1056: }
1057: }
1058: if (($enrollvar{'courseowner'} ne '') &&
1059: (!grep(/^$enrollvar{'courseowner'}$/,@local_ccs))) {
1060: push(@local_ccs,$enrollvar{'courseowner'});
1061: my ($owneruname,$ownerdom) = split(/:/,$enrollvar{'courseowner'});
1062: $pname{$enrollvar{'courseowner'}} =
1063: &Apache::loncommon::plainname($owneruname,$ownerdom);
1064: my $active_cc = &Apache::loncommon::check_user_status($ownerdom,$owneruname,
1065: $cdom,$cnum,$ccrole);
1066: if ($active_cc eq 'active') {
1067: $cc_status{$enrollvar{'courseowner'}} = $lt{'actv'};
1068: } else {
1069: $cc_status{$enrollvar{'courseowner'}} = $lt{'inac'};
1070: }
1071: }
1072: @local_ccs = sort(@local_ccs);
1073: if (@local_ccs == 0) {
1074: $ownertable = $lt{'nocc'};
1075: } else {
1076: my $numlocalcc = scalar(@local_ccs);
1077: $ownertable = '<input type="hidden" name="numlocalcc" value="'.$numlocalcc.'" />'.
1078: &Apache::loncommon::start_data_table()."\n".
1079: &Apache::loncommon::start_data_table_header_row()."\n".
1080: '<th>'.$lt{'ownr'}.'</th>'.
1081: '<th>'.$lt{'name'}.'</th>'.
1082: '<th>'.$lt{'unme'}.'</th>'.
1083: '<th>'.$lt{'stus'}.'</th>'.
1084: &Apache::loncommon::end_data_table_header_row()."\n";
1085: foreach my $cc (@local_ccs) {
1086: $ownertable .= &Apache::loncommon::start_data_table_row()."\n";
1087: if ($cc eq $enrollvar{'courseowner'}) {
1088: $ownertable .= '<td><input type="radio" name="courseowner" value="'.$cc.'" checked="checked"'.$disabled.' /></td>'."\n";
1089: } else {
1090: $ownertable .= '<td><input type="radio" name="courseowner" value="'.$cc.'"'.$disabled.' /></td>'."\n";
1091: }
1092: $ownertable .=
1093: '<td>'.$pname{$cc}.'</td>'."\n".
1094: '<td>'.$cc.'</td>'."\n".
1095: '<td>'.$cc_status{$cc}.' '.$ccname.'</td>'."\n".
1096: &Apache::loncommon::end_data_table_row()."\n";
1097: }
1098: $ownertable .= &Apache::loncommon::end_data_table();
1099: }
1100: &print_header($r,$crstype,$javascript_validations);
1101: my $dctitle = &Apache::lonnet::plaintext('dc');
1102: my $mainheader = &modifiable_only_title($crstype);
1103: my $hidden_elements = &hidden_form_elements();
1104: $r->print('<form action="/adm/modifycourse" method="post" name="'.$env{'form.phase'}.'">'."\n".
1105: '<h3>'.$mainheader.' <span class="LC_nobreak">'.$cdesc.'</span></h3><p>'.
1106: &Apache::lonhtmlcommon::start_pick_box());
1107: if ($crstype eq 'Community') {
1108: $r->print(&Apache::lonhtmlcommon::row_title(
1109: &Apache::loncommon::help_open_topic('Modify_Community_Owner').
1110: ' '.&mt('Community Owner'))."\n");
1111: } else {
1112: $r->print(&Apache::lonhtmlcommon::row_title(
1113: &Apache::loncommon::help_open_topic('Modify_Course_Instcode').
1114: ' '.&mt('Course Code'))."\n".
1115: '<input type="text" size="15" name="coursecode" value="'.$enrollvar{'coursecode'}.'"'.$disabled.' />'.
1116: &Apache::lonhtmlcommon::row_closure());
1117: if (($crstype eq 'Course') && (&showcredits($cdom))) {
1118: $r->print(&Apache::lonhtmlcommon::row_title(
1119: &Apache::loncommon::help_open_topic('Modify_Course_Credithours').
1120: ' '.&mt('Credits (students)'))."\n".
1121: '<input type="text" size="3" name="defaultcredits" value="'.$enrollvar{'defaultcredits'}.'"'.$disabled.' />'.
1122: &Apache::lonhtmlcommon::row_closure());
1123: }
1124: $r->print(&Apache::lonhtmlcommon::row_title(
1125: &Apache::loncommon::help_open_topic('Modify_Course_Defaultauth').
1126: ' '.&mt('Default Authentication method'))."\n".
1127: $authenitems."\n".
1128: &Apache::lonhtmlcommon::row_closure().
1129: &Apache::lonhtmlcommon::row_title(
1130: &Apache::loncommon::help_open_topic('Modify_Course_Owner').
1131: ' '.&mt('Course Owner'))."\n");
1132: }
1133: my ($cctitle,$rolename,$currmanages,$ccchecked,$dcchecked,$defaultchecked);
1134: my ($selfenrollrows,$selfenrolltitles) = &Apache::lonuserutils::get_selfenroll_titles();
1135: if ($type eq 'Community') {
1136: $cctitle = &mt('Community personnel');
1137: } else {
1138: $cctitle = &mt('Course personnel');
1139: }
1140:
1141: $r->print($ownertable."\n".&Apache::lonhtmlcommon::row_closure().
1142: &Apache::lonhtmlcommon::row_title(
1143: &Apache::loncommon::help_open_topic('Modify_Course_Selfenrolladmin').
1144: ' '.&mt('Self-enrollment configuration')).
1145: &Apache::loncommon::start_data_table()."\n".
1146: &Apache::loncommon::start_data_table_header_row()."\n".
1147: '<th>'.$lt{'sett'}.'</th>'.
1148: '<th>'.$lt{'domd'}.'</th>'.
1149: '<th>'.$lt{'whom'}.'</th>'.
1150: &Apache::loncommon::end_data_table_header_row()."\n");
1151: my %optionname;
1152: $optionname{''} = &mt('Use domain default');
1153: $optionname{'0'} = $dctitle;
1154: $optionname{'1'} = $cctitle;
1155: foreach my $item (@{$selfenrollrows}) {
1156: my %checked;
1157: my $default = $cctitle;
1158: if (grep(/^\Q$item\E$/,@default_managebydc)) {
1159: $default = $dctitle;
1160: }
1161: if (grep(/^\Q$item\E$/,@specific_managebydc)) {
1162: $checked{'0'} = ' checked="checked"';
1163: } elsif (grep(/^\Q$item\E$/,@specific_managebycc)) {
1164: $checked{'1'} = ' checked="checked"';
1165: } else {
1166: $checked{''} = ' checked="checked"';
1167: }
1168: $r->print(&Apache::loncommon::start_data_table_row()."\n".
1169: '<td>'.$selfenrolltitles->{$item}.'</td>'."\n".
1170: '<td>'.&mt('[_1] configures',$default).'</td>'."\n".
1171: '<td>');
1172: foreach my $option ('','0','1') {
1173: $r->print('<span class="LC_nobreak"><label>'.
1174: '<input type="radio" name="selfenrollmgr_'.$item.'" '.
1175: 'value="'.$option.'"'.$checked{$option}.$disabled.' />'.
1176: $optionname{$option}.'</label></span><br />');
1177: }
1178: $r->print('</td>'."\n".
1179: &Apache::loncommon::end_data_table_row()."\n");
1180: }
1181: $r->print(&Apache::loncommon::end_data_table()."\n".
1182: '<br />'.&Apache::lonhtmlcommon::row_closure().
1183: &Apache::lonhtmlcommon::row_title(
1184: &Apache::loncommon::help_open_topic('Modify_Course_Table_Lifetime').
1185: ' '.&mt('"Temporary" Tables Lifetime (s)'))."\n".
1186: '<input type="text" size="10" name="mysqltables" value="'.$settings{'internal.mysqltables'}.'"'.$disabled.' />'.
1187: &Apache::lonhtmlcommon::row_closure(1).
1188: &Apache::lonhtmlcommon::end_pick_box().'</p><p>'.$hidden_elements);
1189: unless ($readonly) {
1190: $r->print('<input type="button" onclick="javascript:changePage(this.form,'."'processparms'".');');
1191: if ($crstype eq 'Community') {
1192: $r->print('this.form.submit();"');
1193: } else {
1194: $r->print('javascript:verify_message(this.form);"');
1195: }
1196: $r->print(' value="'.$lt{'gobt'}.'" />');
1197: }
1198: $r->print('</p></form>');
1199: return;
1200: }
1201:
1202: sub print_selfenrollconfig {
1203: my ($r,$type,$cdesc,$coursehash,$readonly) = @_;
1204: return unless(ref($coursehash) eq 'HASH');
1205: my $cnum = $coursehash->{'num'};
1206: my $cdom = $coursehash->{'domain'};
1207: my %currsettings = &get_selfenroll_settings($coursehash);
1208: &print_header($r,$type);
1209: $r->print('<h3>'.&mt('Self-enrollment with a student role in: [_1]',
1210: '<span class="LC_nobreak">'.$cdesc.'</span>').'</h3>'."\n");
1211: &Apache::loncreateuser::print_selfenroll_menu($r,'domain',$env{'form.pickedcourse'},
1212: $cdom,$cnum,\%currsettings,
1213: &hidden_form_elements(),$readonly);
1214: return;
1215: }
1216:
1217: sub modify_selfenrollconfig {
1218: my ($r,$type,$cdesc,$coursehash) = @_;
1219: return unless(ref($coursehash) eq 'HASH');
1220: my $cnum = $coursehash->{'num'};
1221: my $cdom = $coursehash->{'domain'};
1222: my %currsettings = &get_selfenroll_settings($coursehash);
1223: &print_header($r,$type);
1224: $r->print('<h3>'.&mt('Self-enrollment with a student role in: [_1]',
1225: '<span class="LC_nobreak">'.$cdesc.'</span>').'</h3>'."\n");
1226: $r->print('<form action="/adm/modifycourse" method="post" name="selfenroll">'."\n".
1227: &hidden_form_elements().'<br />');
1228: &Apache::loncreateuser::update_selfenroll_config($r,$env{'form.pickedcourse'},
1229: $cdom,$cnum,'domain',$type,\%currsettings);
1230: $r->print('</form>');
1231: return;
1232: }
1233:
1234: sub get_selfenroll_settings {
1235: my ($coursehash) = @_;
1236: my %currsettings;
1237: if (ref($coursehash) eq 'HASH') {
1238: %currsettings = (
1239: selfenroll_types => $coursehash->{'internal.selfenroll_types'},
1240: selfenroll_registered => $coursehash->{'internal.selfenroll_registered'},
1241: selfenroll_section => $coursehash->{'internal.selfenroll_section'},
1242: selfenroll_notifylist => $coursehash->{'internal.selfenroll_notifylist'},
1243: selfenroll_approval => $coursehash->{'internal.selfenroll_approval'},
1244: selfenroll_limit => $coursehash->{'internal.selfenroll_limit'},
1245: selfenroll_cap => $coursehash->{'internal.selfenroll_cap'},
1246: selfenroll_start_date => $coursehash->{'internal.selfenroll_start_date'},
1247: selfenroll_end_date => $coursehash->{'internal.selfenroll_end_date'},
1248: selfenroll_start_access => $coursehash->{'internal.selfenroll_start_access'},
1249: selfenroll_end_access => $coursehash->{'internal.selfenroll_end_access'},
1250: default_enrollment_start_date => $coursehash->{'default_enrollment_start_date'},
1251: default_enrollment_end_date => $coursehash->{'default_enrollment_end_date'},
1252: uniquecode => $coursehash->{'internal.uniquecode'},
1253: );
1254: }
1255: return %currsettings;
1256: }
1257:
1258: sub modifiable_only_title {
1259: my ($type) = @_;
1260: my $dctitle = &Apache::lonnet::plaintext('dc');
1261: if ($type eq 'Community') {
1262: return &mt('Community settings modifiable only by [_1] for:',$dctitle);
1263: } else {
1264: return &mt('Course settings modifiable only by [_1] for:',$dctitle);
1265: }
1266: }
1267:
1268: sub gather_authenitems {
1269: my ($cdom,$enrollvar,$readonly) = @_;
1270: my ($krbdef,$krbdefdom)=&Apache::loncommon::get_kerberos_defaults($cdom);
1271: my $curr_authtype = '';
1272: my $curr_authfield = '';
1273: if (ref($enrollvar) eq 'HASH') {
1274: if ($enrollvar->{'authtype'} =~ /^krb/) {
1275: $curr_authtype = 'krb';
1276: } elsif ($enrollvar->{'authtype'} eq 'internal' ) {
1277: $curr_authtype = 'int';
1278: } elsif ($enrollvar->{'authtype'} eq 'localauth' ) {
1279: $curr_authtype = 'loc';
1280: }
1281: }
1282: unless ($curr_authtype eq '') {
1283: $curr_authfield = $curr_authtype.'arg';
1284: }
1285: my $javascript_validations =
1286: &Apache::lonuserutils::javascript_validations('modifycourse',$krbdefdom,
1287: $curr_authtype,$curr_authfield);
1288: my %param = ( formname => 'document.'.$env{'form.phase'},
1289: kerb_def_dom => $krbdefdom,
1290: kerb_def_auth => $krbdef,
1291: mode => 'modifycourse',
1292: curr_authtype => $curr_authtype,
1293: curr_autharg => $enrollvar->{'autharg'},
1294: readonly => $readonly,
1295: );
1296: my (%authform,$authenitems);
1297: $authform{'krb'} = &Apache::loncommon::authform_kerberos(%param);
1298: $authform{'int'} = &Apache::loncommon::authform_internal(%param);
1299: $authform{'loc'} = &Apache::loncommon::authform_local(%param);
1300: foreach my $item ('krb','int','loc') {
1301: if ($authform{$item} ne '') {
1302: $authenitems .= $authform{$item}.'<br />';
1303: }
1304: }
1305: return($javascript_validations,$authenitems);
1306: }
1307:
1308: sub modify_course {
1309: my ($r,$cdom,$cnum,$cdesc,$domdesc,$type) = @_;
1310: my %longtype = &course_settings_descrip($type);
1311: my @items = ('internal.courseowner','description','internal.co-owners',
1312: 'internal.pendingco-owners','internal.selfenrollmgrdc',
1313: 'internal.selfenrollmgrcc','internal.mysqltables');
1314: my ($selfenrollrows,$selfenrolltitles) = &Apache::lonuserutils::get_selfenroll_titles();
1315: unless (($type eq 'Community') || ($type eq 'Placement')) {
1316: push(@items,('internal.coursecode','internal.authtype','internal.autharg',
1317: 'internal.sectionnums','internal.crosslistings'));
1318: if (&showcredits($cdom)) {
1319: push(@items,'internal.defaultcredits');
1320: }
1321: }
1322: my %settings = &Apache::lonnet::get('environment',\@items,$cdom,$cnum);
1323: my $description = $settings{'description'};
1324: my ($ccrole,$response,$chgresponse,$nochgresponse,$reply,%currattr,%newattr,
1325: %cenv,%changed,@changes,@nochanges,@sections,@xlists,@warnings);
1326: my @modifiable_params = &get_dc_settable($type,$cdom);
1327: foreach my $param (@modifiable_params) {
1328: $currattr{$param} = $settings{'internal.'.$param};
1329: }
1330: if ($type eq 'Community') {
1331: %changed = ( owner => 0 );
1332: $ccrole = 'co';
1333: } else {
1334: %changed = ( code => 0,
1335: owner => 0,
1336: );
1337: $ccrole = 'cc';
1338: unless ($settings{'internal.sectionnums'} eq '') {
1339: if ($settings{'internal.sectionnums'} =~ m/,/) {
1340: @sections = split/,/,$settings{'internal.sectionnums'};
1341: } else {
1342: $sections[0] = $settings{'internal.sectionnums'};
1343: }
1344: }
1345: unless ($settings{'internal.crosslistings'} eq '') {
1346: if ($settings{'internal.crosslistings'} =~ m/,/) {
1347: @xlists = split/,/,$settings{'internal.crosslistings'};
1348: } else {
1349: $xlists[0] = $settings{'internal.crosslistings'};
1350: }
1351: }
1352: if ($env{'form.login'} eq 'krb') {
1353: $newattr{'authtype'} = $env{'form.login'};
1354: $newattr{'authtype'} .= $env{'form.krbver'};
1355: $newattr{'autharg'} = $env{'form.krbarg'};
1356: } elsif ($env{'form.login'} eq 'int') {
1357: $newattr{'authtype'} ='internal';
1358: if ((defined($env{'form.intarg'})) && ($env{'form.intarg'})) {
1359: $newattr{'autharg'} = $env{'form.intarg'};
1360: }
1361: } elsif ($env{'form.login'} eq 'loc') {
1362: $newattr{'authtype'} = 'localauth';
1363: if ((defined($env{'form.locarg'})) && ($env{'form.locarg'})) {
1364: $newattr{'autharg'} = $env{'form.locarg'};
1365: }
1366: }
1367: if ( $newattr{'authtype'}=~ /^krb/) {
1368: if ($newattr{'autharg'} eq '') {
1369: push(@warnings,
1370: &mt('As you did not include the default Kerberos domain'
1371: .' to be used for authentication in this class, the'
1372: .' institutional data used by the automated'
1373: .' enrollment process must include the Kerberos'
1374: .' domain for each new student.'));
1375: }
1376: }
1377:
1378: if ( exists($env{'form.coursecode'}) ) {
1379: $newattr{'coursecode'}=$env{'form.coursecode'};
1380: unless ( $newattr{'coursecode'} eq $currattr{'coursecode'} ) {
1381: $changed{'code'} = 1;
1382: }
1383: }
1384: if ( exists($env{'form.mysqltables'}) ) {
1385: $newattr{'mysqltables'} = $env{'form.mysqltables'};
1386: $newattr{'mysqltables'} =~ s/\D+//g;
1387: }
1388: if (($type ne 'Placement') && (&showcredits($cdom) && exists($env{'form.defaultcredits'}))) {
1389: $newattr{'defaultcredits'}=$env{'form.defaultcredits'};
1390: $newattr{'defaultcredits'} =~ s/[^\d\.]//g;
1391: }
1392: }
1393:
1394: my @newmgrdc = ();
1395: my @newmgrcc = ();
1396: my @currmgrdc = split(/,/,$currattr{'selfenrollmgrdc'});
1397: my @currmgrcc = split(/,/,$currattr{'selfenrollmgrcc'});
1398:
1399: foreach my $item (@{$selfenrollrows}) {
1400: if ($env{'form.selfenrollmgr_'.$item} eq '0') {
1401: push(@newmgrdc,$item);
1402: } elsif ($env{'form.selfenrollmgr_'.$item} eq '1') {
1403: push(@newmgrcc,$item);
1404: }
1405: }
1406:
1407: $newattr{'selfenrollmgrdc'}=join(',',@newmgrdc);
1408: $newattr{'selfenrollmgrcc'}=join(',',@newmgrcc);
1409:
1410: my $cctitle;
1411: if ($type eq 'Community') {
1412: $cctitle = &mt('Community personnel');
1413: } else {
1414: $cctitle = &mt('Course personnel');
1415: }
1416: my $dctitle = &Apache::lonnet::plaintext('dc');
1417:
1418: if ( exists($env{'form.courseowner'}) ) {
1419: $newattr{'courseowner'}=$env{'form.courseowner'};
1420: unless ( $newattr{'courseowner'} eq $currattr{'courseowner'} ) {
1421: $changed{'owner'} = 1;
1422: }
1423: }
1424:
1425: if ($changed{'owner'} || $changed{'code'}) {
1426: my %crsinfo = &Apache::lonnet::courseiddump($cdom,'.',1,'.','.',$cnum,
1427: undef,undef,'.');
1428: if (ref($crsinfo{$env{'form.pickedcourse'}}) eq 'HASH') {
1429: if ($changed{'code'}) {
1430: $crsinfo{$env{'form.pickedcourse'}}{'inst_code'} = $env{'form.coursecode'};
1431: }
1432: if ($changed{'owner'}) {
1433: $crsinfo{$env{'form.pickedcourse'}}{'owner'} = $env{'form.courseowner'};
1434: }
1435: my $chome = &Apache::lonnet::homeserver($cnum,$cdom);
1436: my $putres = &Apache::lonnet::courseidput($cdom,\%crsinfo,$chome,'notime');
1437: if ($putres eq 'ok') {
1438: &update_coowners($cdom,$cnum,$chome,\%settings,\%newattr);
1439: }
1440: }
1441: }
1442: foreach my $param (@modifiable_params) {
1443: if ($currattr{$param} eq $newattr{$param}) {
1444: push(@nochanges,$param);
1445: } else {
1446: $cenv{'internal.'.$param} = $newattr{$param};
1447: push(@changes,$param);
1448: }
1449: }
1450: if (@changes > 0) {
1451: $chgresponse = &mt('The following settings have been changed:').'<br/><ul>';
1452: }
1453: if (@nochanges > 0) {
1454: $nochgresponse = &mt('The following settings remain unchanged:').'<br/><ul>';
1455: }
1456: if (@changes > 0) {
1457: my $putreply = &Apache::lonnet::put('environment',\%cenv,$cdom,$cnum);
1458: if ($putreply !~ /^ok$/) {
1459: $response = '<p class="LC_error">'.
1460: &mt('There was a problem processing your requested changes.').'<br />';
1461: if ($type eq 'Community') {
1462: $response .= &mt('Settings for this community have been left unchanged.');
1463: } else {
1464: $response .= &mt('Settings for this course have been left unchanged.');
1465: }
1466: $response .= '<br/>'.&mt('Error: ').$putreply.'</p>';
1467: } else {
1468: if ($env{'course.'.$cdom.'_'.$cnum.'.description'} ne '') {
1469: my %newenv;
1470: map { $newenv{'course.'.$cdom.'_'.$cnum.'.internal.'.$_} = $newattr{$_}; } @changes;
1471: &Apache::lonnet::appenv(\%newenv);
1472: }
1473: foreach my $attr (@modifiable_params) {
1474: if (grep/^\Q$attr\E$/,@changes) {
1475: my $shown = $newattr{$attr};
1476: if ($attr eq 'selfenrollmgrdc') {
1477: $shown = &selfenroll_config_status(\@newmgrdc,$selfenrolltitles);
1478: } elsif ($attr eq 'selfenrollmgrcc') {
1479: $shown = &selfenroll_config_status(\@newmgrcc,$selfenrolltitles);
1480: } elsif (($attr eq 'defaultcredits') && ($shown eq '')) {
1481: $shown = &mt('None');
1482: } elsif (($attr eq 'mysqltables') && ($shown eq '')) {
1483: $shown = &mt('domain default');
1484: }
1485: $chgresponse .= '<li>'.&mt('[_1] now set to: [_2]',$longtype{$attr},$shown).'</li>';
1486: } else {
1487: my $shown = $currattr{$attr};
1488: if ($attr eq 'selfenrollmgrdc') {
1489: $shown = &selfenroll_config_status(\@currmgrdc,$selfenrolltitles);
1490: } elsif ($attr eq 'selfenrollmgrcc') {
1491: $shown = &selfenroll_config_status(\@currmgrcc,$selfenrolltitles);
1492: } elsif (($attr eq 'defaultcredits') && ($shown eq '')) {
1493: $shown = &mt('None');
1494: } elsif (($attr eq 'mysqltables') && ($shown eq '')) {
1495: $shown = &mt('domain default');
1496: }
1497: $nochgresponse .= '<li>'.&mt('[_1] still set to: [_2]',$longtype{$attr},$shown).'</li>';
1498: }
1499: }
1500: if (($type ne 'Community') && ($type ne 'Placement') && ($changed{'code'} || $changed{'owner'})) {
1501: if ( $newattr{'courseowner'} eq '') {
1502: push(@warnings,&mt('There is no owner associated with this LON-CAPA course.').
1503: '<br />'.&mt('If automated enrollment at your institution requires validation of course owners, automated enrollment will fail.'));
1504: } else {
1505: my %crsenv = &Apache::lonnet::get('environment',['internal.co-owners'],$cdom,$cnum);
1506: my $coowners = $crsenv{'internal.co-owners'};
1507: if (@sections > 0) {
1508: if ($changed{'code'}) {
1509: foreach my $sec (@sections) {
1510: if ($sec =~ m/^(.+):/) {
1511: my $instsec = $1;
1512: my $inst_course_id = $newattr{'coursecode'}.$1;
1513: my $course_check = &Apache::lonnet::auto_validate_courseID($cnum,$cdom,$inst_course_id);
1514: if ($course_check eq 'ok') {
1515: my $outcome = &Apache::lonnet::auto_new_course($cnum,$cdom,$inst_course_id,$newattr{'courseowner'},$coowners);
1516: unless ($outcome eq 'ok') {
1517:
1518: push(@warnings,&mt('If automatic enrollment is enabled for "[_1]", automated enrollment may fail for "[_2]" - section: [_3] for the following reason: "[_4]".',$description,$newattr{'coursecode'},$instsec,$outcome).'<br/>');
1519: }
1520: } else {
1521: push(@warnings,&mt('If automatic enrollment is enabled for "[_1]", automated enrollment may fail for "[_2]" - section: [_3] for the following reason: "[_4]".',$description,$newattr{'coursecode'},$instsec,$course_check));
1522: }
1523: } else {
1524: push(@warnings,&mt('If automatic enrollment is enabled for "[_1]", automated enrollment may fail for "[_2]" - section: [_3], because this is not a valid section entry.',$description,$newattr{'coursecode'},$sec));
1525: }
1526: }
1527: } elsif ($changed{'owner'}) {
1528: foreach my $sec (@sections) {
1529: if ($sec =~ m/^(.+):/) {
1530: my $instsec = $1;
1531: my $inst_course_id = $newattr{'coursecode'}.$instsec;
1532: my $outcome = &Apache::lonnet::auto_new_course($cnum,$cdom,$inst_course_id,$newattr{'courseowner'},$coowners);
1533: unless ($outcome eq 'ok') {
1534: push(@warnings,&mt('If automatic enrollment is enabled for "[_1]", automated enrollment may fail for "[_2]" - section: [_3] for the following reason: "[_4]".',$description,$newattr{'coursecode'},$instsec,$outcome));
1535: }
1536: } else {
1537: push(@warnings,&mt('If automatic enrollment is enabled for "[_1]", automated enrollment may fail for "[_2]" - section: [_3], because this is not a valid section entry.',$description,$newattr{'coursecode'},$sec));
1538: }
1539: }
1540: }
1541: } else {
1542: push(@warnings,&mt('As no section numbers are currently listed for "[_1]", automated enrollment will not occur for any sections of institutional course code: "[_2]".',$description,$newattr{'coursecode'}));
1543: }
1544: if ( (@xlists > 0) && ($changed{'owner'}) ) {
1545: foreach my $xlist (@xlists) {
1546: if ($xlist =~ m/^(.+):/) {
1547: my $instxlist = $1;
1548: my $outcome = &Apache::lonnet::auto_new_course($cnum,$cdom,$instxlist,$newattr{'courseowner'},$coowners);
1549: unless ($outcome eq 'ok') {
1550: push(@warnings,&mt('If automatic enrollment is enabled for "[_1]", automated enrollment may fail for crosslisted class "[_2]" for the following reason: "[_3]".',$description,$instxlist,$outcome));
1551: }
1552: }
1553: }
1554: }
1555: }
1556: }
1557: }
1558: } else {
1559: foreach my $attr (@modifiable_params) {
1560: my $shown = $currattr{$attr};
1561: if ($attr eq 'selfenrollmgrdc') {
1562: $shown = &selfenroll_config_status(\@currmgrdc,$selfenrolltitles);
1563: } elsif ($attr eq 'selfenrollmgrcc') {
1564: $shown = &selfenroll_config_status(\@currmgrcc,$selfenrolltitles);
1565: } elsif (($attr eq 'defaultcredits') && ($shown eq '')) {
1566: $shown = &mt('None');
1567: } elsif (($attr eq 'mysqltables') && ($shown eq '')) {
1568: $shown = &mt('domain default');
1569: }
1570: $nochgresponse .= '<li>'.&mt('[_1] still set to: [_2]',$longtype{$attr},$shown).'</li>';
1571: }
1572: }
1573:
1574: if (@changes > 0) {
1575: $chgresponse .= "</ul><br/><br/>";
1576: }
1577: if (@nochanges > 0) {
1578: $nochgresponse .= "</ul><br/><br/>";
1579: }
1580: my ($warning,$numwarnings);
1581: my $numwarnings = scalar(@warnings);
1582: if ($numwarnings) {
1583: $warning = &mt('The following [quant,_1,warning was,warnings were] generated when applying your changes to automated enrollment:',$numwarnings).'<p><ul>';
1584: foreach my $warn (@warnings) {
1585: $warning .= '<li><span class="LC_warning">'.$warn.'</span></li>';
1586: }
1587: $warning .= '</ul></p>';
1588: }
1589: if ($response) {
1590: $reply = $response;
1591: } else {
1592: $reply = $chgresponse.$nochgresponse.$warning;
1593: }
1594: &print_header($r,$type);
1595: my $mainheader = &modifiable_only_title($type);
1596: $reply = '<h3>'.$mainheader.' <span class="LC_nobreak">'.$cdesc.'</span></h3>'."\n".
1597: '<p>'.$reply.'</p>'."\n".
1598: '<form action="/adm/modifycourse" method="post" name="processparms">'.
1599: &hidden_form_elements();
1600: my @actions =
1601: ('<a href="javascript:changePage(document.processparms,'."'menu'".')">'.
1602: &mt('Pick another action').'</a>');
1603: if ($numwarnings) {
1604: my $newrole = $ccrole.'./'.$cdom.'/'.$cnum;
1605: my $escuri = &HTML::Entities::encode('/adm/roles?selectrole=1&'.$newrole.
1606: '=1&destinationurl=/adm/populate','&<>"');
1607:
1608: push(@actions, '<a href="'.$escuri.'">'.
1609: &mt('Go to Automated Enrollment Manager for course').'</a>');
1610: }
1611: $reply .= &Apache::lonhtmlcommon::actionbox(\@actions).'</form>';
1612: $r->print($reply);
1613: return;
1614: }
1615:
1616: sub selfenroll_config_status {
1617: my ($items,$selfenrolltitles) = @_;
1618: my $shown;
1619: if ((ref($items) eq 'ARRAY') && (ref($selfenrolltitles) eq 'HASH')) {
1620: if (@{$items} > 0) {
1621: $shown = '<ul>';
1622: foreach my $item (@{$items}) {
1623: $shown .= '<li>'.$selfenrolltitles->{$item}.'</li>';
1624: }
1625: $shown .= '</ul>';
1626: } else {
1627: $shown = &mt('None');
1628: }
1629: }
1630: return $shown;
1631: }
1632:
1633: sub update_coowners {
1634: my ($cdom,$cnum,$chome,$settings,$newattr) = @_;
1635: return unless ((ref($settings) eq 'HASH') && (ref($newattr) eq 'HASH'));
1636: my %designhash = &Apache::loncommon::get_domainconf($cdom);
1637: my (%cchash,$autocoowners);
1638: if ($designhash{$cdom.'.autoassign.co-owners'}) {
1639: $autocoowners = 1;
1640: %cchash = &Apache::lonnet::get_my_roles($cnum,$cdom,undef,undef,['cc']);
1641: }
1642: if ($settings->{'internal.courseowner'} ne $newattr->{'courseowner'}) {
1643: my $oldowner_to_coowner;
1644: my @types = ('co-owners');
1645: if (($newattr->{'coursecode'}) && ($autocoowners)) {
1646: my $oldowner = $settings->{'internal.courseowner'};
1647: if ($cchash{$oldowner.':cc'}) {
1648: my ($result,$desc) = &Apache::lonnet::auto_validate_instcode($cnum,$cdom,$newattr->{'coursecode'},$oldowner);
1649: if ($result eq 'valid') {
1650: if ($settings->{'internal.co-owner'}) {
1651: my @current = split(',',$settings->{'internal.co-owners'});
1652: unless (grep(/^\Q$oldowner\E$/,@current)) {
1653: $oldowner_to_coowner = 1;
1654: }
1655: } else {
1656: $oldowner_to_coowner = 1;
1657: }
1658: }
1659: }
1660: } else {
1661: push(@types,'pendingco-owners');
1662: }
1663: foreach my $type (@types) {
1664: if ($settings->{'internal.'.$type}) {
1665: my @current = split(',',$settings->{'internal.'.$type});
1666: my $newowner = $newattr->{'courseowner'};
1667: my @newvalues = ();
1668: if (($newowner ne '') && (grep(/^\Q$newowner\E$/,@current))) {
1669: foreach my $person (@current) {
1670: unless ($person eq $newowner) {
1671: push(@newvalues,$person);
1672: }
1673: }
1674: } else {
1675: @newvalues = @current;
1676: }
1677: if ($oldowner_to_coowner) {
1678: push(@newvalues,$settings->{'internal.courseowner'});
1679: @newvalues = sort(@newvalues);
1680: }
1681: my $newownstr = join(',',@newvalues);
1682: if ($newownstr ne $settings->{'internal.'.$type}) {
1683: if ($type eq 'co-owners') {
1684: my $deleted = '';
1685: unless (@newvalues) {
1686: $deleted = 1;
1687: }
1688: &Apache::lonnet::store_coowners($cdom,$cnum,$chome,
1689: $deleted,@newvalues);
1690: } else {
1691: my $pendingcoowners;
1692: my $cid = $cdom.'_'.$cnum;
1693: if (@newvalues) {
1694: $pendingcoowners = join(',',@newvalues);
1695: my %pendinghash = (
1696: 'internal.pendingco-owners' => $pendingcoowners,
1697: );
1698: my $putresult = &Apache::lonnet::put('environment',\%pendinghash,$cdom,$cnum);
1699: if ($putresult eq 'ok') {
1700: if ($env{'course.'.$cid.'.num'} eq $cnum) {
1701: &Apache::lonnet::appenv({'course.'.$cid.'.internal.pendingco-owners' => $pendingcoowners});
1702: }
1703: }
1704: } else {
1705: my $delresult = &Apache::lonnet::del('environment',['internal.pendingco-owners'],$cdom,$cnum);
1706: if ($delresult eq 'ok') {
1707: if ($env{'course.'.$cid.'.internal.pendingco-owners'}) {
1708: &Apache::lonnet::delenv('course.'.$cid.'.internal.pendingco-owners');
1709: }
1710: }
1711: }
1712: }
1713: } elsif ($oldowner_to_coowner) {
1714: &Apache::lonnet::store_coowners($cdom,$cnum,$chome,'',
1715: $settings->{'internal.courseowner'});
1716:
1717: }
1718: } elsif ($oldowner_to_coowner) {
1719: &Apache::lonnet::store_coowners($cdom,$cnum,$chome,'',
1720: $settings->{'internal.courseowner'});
1721: }
1722: }
1723: }
1724: if ($settings->{'internal.coursecode'} ne $newattr->{'coursecode'}) {
1725: if ($newattr->{'coursecode'} ne '') {
1726: my %designhash = &Apache::loncommon::get_domainconf($cdom);
1727: if ($designhash{$cdom.'.autoassign.co-owners'}) {
1728: my @newcoowners = ();
1729: if ($settings->{'internal.co-owners'}) {
1730: my @currcoown = split(',',$settings->{'internal.co-owners'});
1731: my ($updatecoowners,$delcoowners);
1732: foreach my $person (@currcoown) {
1733: my ($result,$desc) = &Apache::lonnet::auto_validate_instcode($cnum,$cdom,$newattr->{'coursecode'},$person);
1734: if ($result eq 'valid') {
1735: push(@newcoowners,$person);
1736: }
1737: }
1738: foreach my $item (sort(keys(%cchash))) {
1739: my ($uname,$udom,$urole) = split(':',$item);
1740: next if ($uname.':'.$udom eq $newattr->{'courseowner'});
1741: unless (grep(/^\Q$uname\E:\Q$udom\E$/,@newcoowners)) {
1742: my ($result,$desc) = &Apache::lonnet::auto_validate_instcode($cnum,$cdom,$newattr->{'coursecode'},$uname.':'.$udom);
1743: if ($result eq 'valid') {
1744: push(@newcoowners,$uname.':'.$udom);
1745: }
1746: }
1747: }
1748: if (@newcoowners) {
1749: my $coowners = join(',',sort(@newcoowners));
1750: unless ($coowners eq $settings->{'internal.co-owners'}) {
1751: $updatecoowners = 1;
1752: }
1753: } else {
1754: $delcoowners = 1;
1755: }
1756: if ($updatecoowners || $delcoowners) {
1757: &Apache::lonnet::store_coowners($cdom,$cnum,$chome,
1758: $delcoowners,@newcoowners);
1759: }
1760: } else {
1761: foreach my $item (sort(keys(%cchash))) {
1762: my ($uname,$udom,$urole) = split(':',$item);
1763: push(@newcoowners,$uname.':'.$udom);
1764: }
1765: if (@newcoowners) {
1766: &Apache::lonnet::store_coowners($cdom,$cnum,$chome,'',
1767: @newcoowners);
1768: }
1769: }
1770: }
1771: }
1772: }
1773: return;
1774: }
1775:
1776: sub modify_quota {
1777: my ($r,$cdom,$cnum,$cdesc,$domdesc,$type) = @_;
1778: &print_header($r,$type);
1779: my $lctype = lc($type);
1780: my $headline = &mt("Disk space quotas for $lctype: [_1]",
1781: '<span class="LC_nobreak">'.$cdesc.'</span>');
1782: $r->print('<form action="/adm/modifycourse" method="post" name="processquota">'."\n".
1783: '<h3>'.$headline.'</h3>');
1784: my %oldsettings = &Apache::lonnet::get('environment',['internal.coursequota','internal.uploadquota'],$cdom,$cnum);
1785: my %staticdefaults = (
1786: coursequota => 20,
1787: uploadquota => 500,
1788: );
1789: my %default;
1790: $default{'coursequota'} = $staticdefaults{'coursequota'};
1791: my %domdefs = &Apache::lonnet::get_domain_defaults($cdom);
1792: $default{'uploadquota'} = $domdefs{'uploadquota'};
1793: if ($default{'uploadquota'} eq '') {
1794: $default{'uploadquota'} = $staticdefaults{'uploadquota'};
1795: }
1796: my (%cenv,%showresult);
1797: foreach my $item ('coursequota','uploadquota') {
1798: if ($env{'form.'.$item} ne '') {
1799: my $newquota = $env{'form.'.$item};
1800: if ($newquota =~ /^\s*(\d+\.?\d*|\.\d+)\s*$/) {
1801: $newquota = $1;
1802: if ($oldsettings{'internal.'.$item} == $newquota) {
1803: if ($item eq 'coursequota') {
1804: $r->print(&mt('The disk space allocated for group portfolio files remains unchanged as [_1] MB.',$newquota).'<br />');
1805: } else {
1806: $r->print(&mt('The disk space allocated for files uploaded via the Content Editor remains unchanged as [_1] MB.',$newquota).'<br />');
1807: }
1808: } else {
1809: $cenv{'internal.'.$item} = $newquota;
1810: $showresult{$item} = 1;
1811: }
1812: } else {
1813: if ($item eq 'coursequota') {
1814: $r->print(&mt('The proposed group portfolio quota contained invalid characters, so the quota is unchanged.').'<br />');
1815: } else {
1816: $r->print(&mt('The proposed quota for content uploaded via the Content Editor contained invalid characters, so the quota is unchanged.').'<br />');
1817:
1818: }
1819: }
1820: }
1821: }
1822: if (keys(%cenv)) {
1823: my $putreply = &Apache::lonnet::put('environment',\%cenv,$cdom,
1824: $cnum);
1825: foreach my $key (sort(keys(%showresult))) {
1826: if (($oldsettings{'internal.'.$key} eq '') &&
1827: ($env{'form.'.$key} == $default{$key})) {
1828: if ($key eq 'uploadquota') {
1829: if ($type eq 'Community') {
1830: $r->print(&mt('The disk space allocated for files uploaded to this community via the Content Editor is the default quota for this domain: [_1] MB.',
1831: $default{$key}).'<br />');
1832: } else {
1833: $r->print(&mt('The disk space allocated for files uploaded to this course via the Content Editor is the default quota for this domain: [_1] MB.',
1834: $default{$key}).'<br />');
1835: }
1836: } else {
1837: if ($type eq 'Community') {
1838: $r->print(&mt('The disk space allocated for group portfolio files in this community is the default quota for this domain: [_1] MB.',
1839: $default{$key}).'<br />');
1840: } else {
1841: $r->print(&mt('The disk space allocated for group portfolio files in this course is the default quota for this domain: [_1] MB.',
1842: $default{$key}).'<br />');
1843: }
1844: }
1845: delete($showresult{$key});
1846: }
1847: }
1848: if ($putreply eq 'ok') {
1849: my %updatedsettings = &Apache::lonnet::get('environment',['internal.coursequota','internal.uploadquota'],$cdom,$cnum);
1850: if ($showresult{'coursequota'}) {
1851: $r->print(&mt('The disk space allocated for group portfolio files is now: [_1] MB.',
1852: '<b>'.$updatedsettings{'internal.coursequota'}.'</b>').'<br />');
1853: my $usage = &Apache::longroup::sum_quotas($cdom.'_'.$cnum);
1854: if ($usage >= $updatedsettings{'internal.coursequota'}) {
1855: my $newoverquota;
1856: if ($usage < $oldsettings{'internal.coursequota'}) {
1857: $newoverquota = 'now';
1858: }
1859: $r->print('<p>');
1860: if ($type eq 'Community') {
1861: $r->print(&mt("Disk usage $newoverquota exceeds the quota for this community.").' '.
1862: &mt('Upload of new portfolio files and assignment of a non-zero MB quota to new groups in the community will not be possible until some files have been deleted, and total usage is below community quota.'));
1863: } else {
1864: $r->print(&mt("Disk usage $newoverquota exceeds the quota for this course.").' '.
1865: &mt('Upload of new portfolio files and assignment of a non-zero MB quota to new groups in the course will not be possible until some files have been deleted, and total usage is below course quota.'));
1866: }
1867: $r->print('</p>');
1868: }
1869: }
1870: if ($showresult{'uploadquota'}) {
1871: $r->print(&mt('The disk space allocated for content uploaded directly via the Content Editor is now: [_1] MB.',
1872: '<b>'.$updatedsettings{'internal.uploadquota'}.'</b>').'<br />');
1873: }
1874: } else {
1875: $r->print(&mt('An error occurred storing the quota(s) for group portfolio files and/or uploaded content: ').
1876: $putreply);
1877: }
1878: }
1879: $r->print('<p>'.
1880: '<a href="javascript:changePage(document.processquota,'."'menu'".')">'.
1881: &mt('Pick another action').'</a>');
1882: $r->print(&hidden_form_elements().'</form>');
1883: return;
1884: }
1885:
1886: sub modify_anonsurvey_threshold {
1887: my ($r,$cdom,$cnum,$cdesc,$domdesc,$type) = @_;
1888: &print_header($r,$type);
1889: $r->print('<form action="/adm/modifycourse" method="post" name="processthreshold">'."\n".
1890: '<h3>'.&mt('Responder threshold required for display of anonymous survey submissions:').
1891: ' <span class="LC_nobreak">'.$cdesc.'</span></h3><br />');
1892: my %oldsettings = &Apache::lonnet::get('environment',['internal.anonsurvey_threshold'],$cdom,$cnum);
1893: my %domconfig =
1894: &Apache::lonnet::get_dom('configuration',['coursedefaults'],$cdom);
1895: my $defaultthreshold;
1896: if (ref($domconfig{'coursedefaults'}) eq 'HASH') {
1897: $defaultthreshold = $domconfig{'coursedefaults'}{'anonsurvey_threshold'};
1898: if ($defaultthreshold eq '') {
1899: $defaultthreshold = 10;
1900: }
1901: } else {
1902: $defaultthreshold = 10;
1903: }
1904: if ($env{'form.threshold'} eq '') {
1905: $r->print(&mt('The proposed responder threshold for display of anonymous survey submissions was blank, so the threshold is unchanged.'));
1906: } else {
1907: my $newthreshold = $env{'form.threshold'};
1908: if ($newthreshold =~ /^\s*(\d+)\s*$/) {
1909: $newthreshold = $1;
1910: if ($oldsettings{'internal.anonsurvey_threshold'} eq $env{'form.threshold'}) {
1911: $r->print(&mt('Responder threshold for anonymous survey submissions display remains unchanged: [_1].',$env{'form.threshold'}));
1912: } else {
1913: my %cenv = (
1914: 'internal.anonsurvey_threshold' => $env{'form.threshold'},
1915: );
1916: my $putreply = &Apache::lonnet::put('environment',\%cenv,$cdom,
1917: $cnum);
1918: if ($putreply eq 'ok') {
1919: if ($env{'course.'.$cdom.'_'.$cnum.'.description'} ne '') {
1920: &Apache::lonnet::appenv(
1921: {'course.'.$cdom.'_'.$cnum.'.internal.anonsurvey_threshold' => $env{'form.threshold'}});
1922: }
1923: }
1924: if (($oldsettings{'internal.anonsurvey_threshold'} eq '') &&
1925: ($env{'form.threshold'} == $defaultthreshold)) {
1926: $r->print(&mt('The responder threshold for display of anonymous survey submissions is the default for this domain: [_1].',$defaultthreshold));
1927: } else {
1928: if ($putreply eq 'ok') {
1929: my %updatedsettings = &Apache::lonnet::get('environment',['internal.anonsurvey_threshold'],$cdom,$cnum);
1930: $r->print(&mt('The responder threshold for display of anonymous survey submissions is now: [_1].','<b>'.$updatedsettings{'internal.anonsurvey_threshold'}.'</b>'));
1931: } else {
1932: $r->print(&mt('An error occurred storing the responder threshold for anonymous submissions display: ').
1933: $putreply);
1934: }
1935: }
1936: }
1937: } else {
1938: $r->print(&mt('The proposed responder threshold for display of anonymous submissions contained invalid characters, so the threshold is unchanged.'));
1939: }
1940: }
1941: $r->print('<p>'.
1942: '<a href="javascript:changePage(document.processthreshold,'."'menu'".')">'.
1943: &mt('Pick another action').'</a></p>');
1944: $r->print(&hidden_form_elements().'</form>');
1945: return;
1946: }
1947:
1948: sub modify_postsubmit_config {
1949: my ($r,$cdom,$cnum,$cdesc,$domdesc,$type) = @_;
1950: &print_header($r,$type);
1951: my %lt = &Apache::lonlocal::texthash(
1952: subb => 'Submit button behavior after student makes a submission:',
1953: unch => 'Post submission behavior of the Submit button is unchanged.',
1954: erro => 'An error occurred when saving your proposed changes.',
1955: inva => 'An invalid response was recorded.',
1956: pick => 'Pick another action',
1957: );
1958: $r->print('<form action="/adm/modifycourse" method="post" name="processpostsubmit">'."\n".
1959: '<h3>'.$lt{'subb'}.' <span class="LC_nobreak">('.$cdesc.')</span></h3><br />');
1960: my %oldsettings =
1961: &Apache::lonnet::get('environment',['internal.postsubmit','internal.postsubtimeout','internal.coursecode','internal.textbook'],$cdom,$cnum);
1962: my $postsubmit = $env{'form.postsubmit'};
1963: if ($postsubmit eq '1') {
1964: my $postsubtimeout = $env{'form.postsubtimeout'};
1965: $postsubtimeout =~ s/[^\d\.]+//g;
1966: if (($oldsettings{'internal.postsubmit'} eq $postsubmit) && ($oldsettings{'internal.postsubtimeout'} eq $postsubtimeout)) {
1967: $r->print($lt{'unch'});
1968: } else {
1969: my %cenv = (
1970: 'internal.postsubmit' => $postsubmit,
1971: );
1972: if ($postsubtimeout eq '') {
1973: my $putreply = &Apache::lonnet::put('environment',\%cenv,$cdom,$cnum);
1974: if ($putreply eq 'ok') {
1975: my $defaulttimeout = &domain_postsubtimeout($cdom,$type,\%oldsettings);
1976: $r->print(&mt('The proposed duration for disabling the Submit button post-submission was blank, so the domain default of [quant,_1,second] will be used.',$defaulttimeout));
1977: if (exists($oldsettings{'internal.postsubtimeout'})) {
1978: &Apache::lonnet::del('environment',['internal.postsubtimeout'],$cdom,$cnum);
1979: }
1980: } else {
1981: $r->print($lt{'erro'});
1982: }
1983: } else {
1984: $cenv{'internal.postsubtimeout'} = $postsubtimeout;
1985: my $putreply = &Apache::lonnet::put('environment',\%cenv,$cdom,$cnum);
1986: if ($putreply eq 'ok') {
1987: if ($postsubtimeout eq '0') {
1988: $r->print(&mt('Submit button will be disabled after student submission until page is reloaded.'));
1989: } else {
1990: $r->print(&mt('Submit button will be disabled after student submission for [quant,_1,second].',$postsubtimeout));
1991: }
1992: } else {
1993: $r->print($lt{'erro'});
1994: }
1995: }
1996: }
1997: } elsif ($postsubmit eq '0') {
1998: if ($oldsettings{'internal.postsubmit'} eq $postsubmit) {
1999: $r->print($lt{'unch'});
2000: } else {
2001: if (exists($oldsettings{'internal.postsubtimeout'})) {
2002: &Apache::lonnet::del('environment',['internal.postsubtimeout'],$cdom,$cnum);
2003: }
2004: my %cenv = (
2005: 'internal.postsubmit' => $postsubmit,
2006: );
2007: my $putreply = &Apache::lonnet::put('environment',\%cenv,$cdom,$cnum);
2008: if ($putreply eq 'ok') {
2009: $r->print(&mt('Submit button will not be disabled after student submission'));
2010: } else {
2011: $r->print($lt{'erro'});
2012: }
2013: }
2014: } else {
2015: $r->print($lt{'inva'}.' '.$lt{'unch'});
2016: }
2017: $r->print('<p>'.
2018: '<a href="javascript:changePage(document.processpostsubmit,'."'menu'".')">'.
2019: &mt('Pick another action').'</a></p>');
2020: $r->print(&hidden_form_elements().'</form>');
2021: return;
2022: }
2023:
2024: sub modify_catsettings {
2025: my ($r,$cdom,$cnum,$cdesc,$domdesc,$type) = @_;
2026: &print_header($r,$type);
2027: my ($ccrole,%desc);
2028: if ($type eq 'Community') {
2029: $desc{'hidefromcat'} = &mt('Excluded from community catalog');
2030: $desc{'categories'} = &mt('Assigned categories for this community');
2031: $ccrole = 'co';
2032: } else {
2033: $desc{'hidefromcat'} = &mt('Excluded from course catalog');
2034: $desc{'categories'} = &mt('Assigned categories for this course');
2035: $ccrole = 'cc';
2036: }
2037: $r->print('
2038: <form action="/adm/modifycourse" method="post" name="processcat">
2039: <h3>'.&mt('Category settings').'</h3>');
2040: my %domconf = &Apache::lonnet::get_dom('configuration',['coursecategories'],$cdom);
2041: my @cat_params = &catalog_settable($domconf{'coursecategories'},$type);
2042: if (@cat_params > 0) {
2043: my (%cenv,@changes,@nochanges);
2044: my %currsettings =
2045: &Apache::lonnet::get('environment',['hidefromcat','categories'],$cdom,$cnum);
2046: my (@newcategories,%showitem);
2047: if (grep(/^togglecats$/,@cat_params)) {
2048: if ($currsettings{'hidefromcat'} ne $env{'form.hidefromcat'}) {
2049: push(@changes,'hidefromcat');
2050: $cenv{'hidefromcat'} = $env{'form.hidefromcat'};
2051: } else {
2052: push(@nochanges,'hidefromcat');
2053: }
2054: if ($env{'form.hidefromcat'} eq 'yes') {
2055: $showitem{'hidefromcat'} = '"'.&mt('Yes')."'";
2056: } else {
2057: $showitem{'hidefromcat'} = '"'.&mt('No').'"';
2058: }
2059: }
2060: if (grep(/^categorize$/,@cat_params)) {
2061: my (@cats,@trails,%allitems,%idx,@jsarray);
2062: if (ref($domconf{'coursecategories'}) eq 'HASH') {
2063: my $cathash = $domconf{'coursecategories'}{'cats'};
2064: if (ref($cathash) eq 'HASH') {
2065: &Apache::loncommon::extract_categories($cathash,\@cats,\@trails,
2066: \%allitems,\%idx,\@jsarray);
2067: }
2068: }
2069: @newcategories = &Apache::loncommon::get_env_multiple('form.usecategory');
2070: if (@newcategories == 0) {
2071: $showitem{'categories'} = '"'.&mt('None').'"';
2072: } else {
2073: $showitem{'categories'} = '<ul>';
2074: foreach my $item (@newcategories) {
2075: $showitem{'categories'} .= '<li>'.$trails[$allitems{$item}].'</li>';
2076: }
2077: $showitem{'categories'} .= '</ul>';
2078: }
2079: my $catchg = 0;
2080: if ($currsettings{'categories'} ne '') {
2081: my @currcategories = split('&',$currsettings{'categories'});
2082: foreach my $cat (@currcategories) {
2083: if (!grep(/^\Q$cat\E$/,@newcategories)) {
2084: $catchg = 1;
2085: last;
2086: }
2087: }
2088: if (!$catchg) {
2089: foreach my $cat (@newcategories) {
2090: if (!grep(/^\Q$cat\E$/,@currcategories)) {
2091: $catchg = 1;
2092: last;
2093: }
2094: }
2095: }
2096: } else {
2097: if (@newcategories > 0) {
2098: $catchg = 1;
2099: }
2100: }
2101: if ($catchg) {
2102: $cenv{'categories'} = join('&',@newcategories);
2103: push(@changes,'categories');
2104: } else {
2105: push(@nochanges,'categories');
2106: }
2107: if (@changes > 0) {
2108: my $putreply = &Apache::lonnet::put('environment',\%cenv,$cdom,$cnum);
2109: if ($putreply eq 'ok') {
2110: if ($env{'course.'.$cdom.'_'.$cnum.'.description'} ne '') {
2111: my %newenvhash;
2112: foreach my $item (@changes) {
2113: $newenvhash{'course.'.$cdom.'_'.$cnum.'.'.$item} = $cenv{$item};
2114: }
2115: &Apache::lonnet::appenv(\%newenvhash);
2116: }
2117: my %crsinfo = &Apache::lonnet::courseiddump($cdom,'.',1,'.','.',
2118: $cnum,undef,undef,'.');
2119: if (ref($crsinfo{$env{'form.pickedcourse'}}) eq 'HASH') {
2120: if (grep(/^hidefromcat$/,@changes)) {
2121: $crsinfo{$env{'form.pickedcourse'}}{'hidefromcat'} = $env{'form.hidefromcat'};
2122: }
2123: if (grep(/^categories$/,@changes)) {
2124: $crsinfo{$env{'form.pickedcourse'}}{'categories'} = $cenv{'categories'};
2125: }
2126: my $chome = &Apache::lonnet::homeserver($cnum,$cdom);
2127: my $putres = &Apache::lonnet::courseidput($cdom,\%crsinfo,$chome,'notime');
2128: }
2129: $r->print(&mt('The following changes occurred:').'<ul>');
2130: foreach my $item (@changes) {
2131: $r->print('<li>'.&mt('[_1] now set to: [_2]',$desc{$item},$showitem{$item}).'</li>');
2132: }
2133: $r->print('</ul><br />');
2134: }
2135: }
2136: if (@nochanges > 0) {
2137: $r->print(&mt('The following were unchanged:').'<ul>');
2138: foreach my $item (@nochanges) {
2139: $r->print('<li>'.&mt('[_1] still set to: [_2]',$desc{$item},$showitem{$item}).'</li>');
2140: }
2141: $r->print('</ul>');
2142: }
2143: }
2144: } else {
2145: my $newrole = $ccrole.'./'.$cdom.'/'.$cnum;
2146: my $escuri = &HTML::Entities::encode('/adm/roles?selectrole=1&'.$newrole.
2147: '=1&destinationurl=/adm/courseprefs','&<>"');
2148: if ($type eq 'Community') {
2149: $r->print(&mt('Category settings for communities in this domain should be modified in community context (via "[_1]Community Configuration[_2]").','<a href="$escuri">','</a>').'<br />');
2150: } else {
2151: $r->print(&mt('Category settings for courses in this domain should be modified in course context (via "[_1]Course Configuration[_2]").','<a href="$escuri">','</a>').'<br />');
2152: }
2153: }
2154: $r->print('<br />'."\n".
2155: '<a href="javascript:changePage(document.processcat,'."'menu'".')">'.
2156: &mt('Pick another action').'</a>');
2157: $r->print(&hidden_form_elements().'</form>');
2158: return;
2159: }
2160:
2161: sub print_header {
2162: my ($r,$type,$javascript_validations) = @_;
2163: my $phase = "start";
2164: if ( exists($env{'form.phase'}) ) {
2165: $phase = $env{'form.phase'};
2166: }
2167: my $js = qq|
2168:
2169: function changePage(formname,newphase) {
2170: formname.phase.value = newphase;
2171: if (newphase == 'processparms') {
2172: return;
2173: }
2174: formname.submit();
2175: }
2176:
2177: |;
2178: if ($phase eq 'setparms') {
2179: $js .= $javascript_validations;
2180: } elsif ($phase eq 'courselist') {
2181: $js .= <<"ENDJS";
2182: function hide_searching() {
2183: if (document.getElementById('searching')) {
2184: document.getElementById('searching').style.display = 'none';
2185: }
2186: return;
2187: }
2188:
2189: ENDJS
2190: } elsif ($phase eq 'setquota') {
2191: my $invalid = &mt('The quota you entered contained invalid characters.');
2192: my $alert = &mt('You must enter a number');
2193: &js_escape(\$invalid);
2194: &js_escape(\$alert);
2195: my $regexp = '/^\s*(\d+\.?\d*|\.\d+)\s*$/';
2196: $js .= <<"ENDSCRIPT";
2197:
2198: function verify_quota() {
2199: var newquota = document.setquota.coursequota.value;
2200: var num_reg = $regexp;
2201: if (num_reg.test(newquota)) {
2202: changePage(document.setquota,'processquota');
2203: } else {
2204: alert("$invalid\\n$alert");
2205: return false;
2206: }
2207: return true;
2208: }
2209:
2210: ENDSCRIPT
2211: } elsif ($phase eq 'setanon') {
2212: my $invalid = &mt('The responder threshold you entered is invalid.');
2213: my $alert = &mt('You must enter a positive integer.');
2214: &js_escape(\$invalid);
2215: &js_escape(\$alert);
2216: my $regexp = ' /^\s*\d+\s*$/';
2217: $js .= <<"ENDSCRIPT";
2218:
2219: function verify_anon_threshold() {
2220: var newthreshold = document.setanon.threshold.value;
2221: var num_reg = $regexp;
2222: if (num_reg.test(newthreshold)) {
2223: if (newthreshold > 0) {
2224: changePage(document.setanon,'processthreshold');
2225: } else {
2226: alert("$invalid\\n$alert");
2227: return false;
2228: }
2229: } else {
2230: alert("$invalid\\n$alert");
2231: return false;
2232: }
2233: return true;
2234: }
2235:
2236: ENDSCRIPT
2237: } elsif ($phase eq 'setpostsubmit') {
2238: my $invalid = &mt('The choice entered for disabling the submit button is invalid.');
2239: my $invalidtimeout = &mt('The timeout you entered for disabling the submit button is invalid.');
2240: my $alert = &mt('Enter one of: a positive integer, 0 (for no timeout), or leave blank to use domain default');
2241: &js_escape(\$invalid);
2242: &js_escape(\$invalidtimeout);
2243: &js_escape(\$alert);
2244: my $regexp = ' /^\s*\d+\s*$/';
2245:
2246: $js .= <<"ENDSCRIPT";
2247:
2248: function verify_postsubmit() {
2249: var optionsElement = document.setpostsubmit.postsubmit;
2250: var verified = '';
2251: if (optionsElement.length) {
2252: var currval;
2253: for (var i=0; i<optionsElement.length; i++) {
2254: if (optionsElement[i].checked) {
2255: currval = optionsElement[i].value;
2256: }
2257: }
2258: if (currval == 1) {
2259: var newtimeout = document.setpostsubmit.postsubtimeout.value;
2260: if (newtimeout == '') {
2261: verified = 'ok';
2262: } else {
2263: var num_reg = $regexp;
2264: if (num_reg.test(newtimeout)) {
2265: if (newtimeout>= 0) {
2266: verified = 'ok';
2267: } else {
2268: alert("$invalidtimeout\\n$alert");
2269: return false;
2270: }
2271: } else {
2272: alert("$invalid\\n$alert");
2273: return false;
2274: }
2275: }
2276: } else {
2277: if (currval == 0) {
2278: verified = 'ok';
2279: } else {
2280: alert('$invalid');
2281: return false;
2282: }
2283: }
2284: if (verified == 'ok') {
2285: changePage(document.setpostsubmit,'processpostsubmit');
2286: return true;
2287: }
2288: }
2289: return false;
2290: }
2291:
2292: function togglePostsubmit(caller) {
2293: var optionsElement = document.setpostsubmit.postsubmit;
2294: if (document.getElementById(caller)) {
2295: var divitem = document.getElementById(caller);
2296: var optionsElement = document.setpostsubmit.postsubmit;
2297: if (optionsElement.length) {
2298: var currval;
2299: for (var i=0; i<optionsElement.length; i++) {
2300: if (optionsElement[i].checked) {
2301: currval = optionsElement[i].value;
2302: }
2303: }
2304: if (currval == 1) {
2305: divitem.style.display = 'block';
2306: } else {
2307: divitem.style.display = 'none';
2308: }
2309: }
2310: }
2311: return;
2312: }
2313:
2314: ENDSCRIPT
2315:
2316: }
2317: my $starthash;
2318: if ($env{'form.phase'} eq 'adhocrole') {
2319: $starthash = {
2320: add_entries => {'onload' => "javascript:document.adhocrole.submit();"},
2321: };
2322: } elsif ($phase eq 'courselist') {
2323: $starthash = {
2324: add_entries => {'onload' => "hide_searching(); courseSet(document.filterpicker.official, 'load');"},
2325: };
2326: }
2327: $r->print(&Apache::loncommon::start_page('View/Modify Course/Community Settings',
2328: &Apache::lonhtmlcommon::scripttag($js),
2329: $starthash));
2330: my $bread_text = "View/Modify Courses/Communities";
2331: if ($type eq 'Community') {
2332: $bread_text = 'Community Settings';
2333: } elsif ($type eq 'Placement') {
2334: $bread_text = 'Placement Test Settings';
2335: } else {
2336: $bread_text = 'Course Settings';
2337: }
2338: $r->print(&Apache::lonhtmlcommon::breadcrumbs($bread_text));
2339: return;
2340: }
2341:
2342: sub print_footer {
2343: my ($r) = @_;
2344: $r->print('<br />'.&Apache::loncommon::end_page());
2345: return;
2346: }
2347:
2348: sub check_course {
2349: my ($dom,$domdesc) = @_;
2350: my ($ok_course,$description,$instcode);
2351: my %coursehash;
2352: if ($env{'form.pickedcourse'} =~ /^$match_domain\_$match_courseid$/) {
2353: my %args;
2354: unless ($env{'course.'.$env{'form.pickedcourse'}.'.description'}) {
2355: %args = (
2356: 'one_time' => 1,
2357: 'freshen_cache' => 1,
2358: );
2359: }
2360: %coursehash =
2361: &Apache::lonnet::coursedescription($env{'form.pickedcourse'},\%args);
2362: my $cnum = $coursehash{'num'};
2363: my $cdom = $coursehash{'domain'};
2364: $description = $coursehash{'description'};
2365: $instcode = $coursehash{'internal.coursecode'};
2366: if ($instcode) {
2367: $description .= " ($instcode)";
2368: }
2369: if (($cdom eq $dom) && ($cnum =~ /^$match_courseid$/)) {
2370: my %courseIDs = &Apache::lonnet::courseiddump($cdom,'.',1,'.','.',
2371: $cnum,undef,undef,'.');
2372: if ($courseIDs{$cdom.'_'.$cnum}) {
2373: $ok_course = 'ok';
2374: }
2375: }
2376: }
2377: return ($ok_course,$description,\%coursehash);
2378: }
2379:
2380: sub course_settings_descrip {
2381: my ($type) = @_;
2382: my %longtype;
2383: if ($type eq 'Community') {
2384: %longtype = &Apache::lonlocal::texthash(
2385: 'courseowner' => "Username:domain of community owner",
2386: 'co-owners' => "Username:domain of each co-owner",
2387: 'selfenrollmgrdc' => "Community-specific self-enrollment configuration by Domain Coordinator",
2388: 'selfenrollmgrcc' => "Community-specific self-enrollment configuration by Community personnel",
2389: 'mysqltables' => '"Temporary" student performance tables lifetime (seconds)',
2390: );
2391: } else {
2392: %longtype = &Apache::lonlocal::texthash(
2393: 'authtype' => 'Default authentication method',
2394: 'autharg' => 'Default authentication parameter',
2395: 'autoadds' => 'Automated adds',
2396: 'autodrops' => 'Automated drops',
2397: 'autostart' => 'Date of first automated enrollment',
2398: 'autoend' => 'Date of last automated enrollment',
2399: 'default_enrollment_start_date' => 'Date of first student access',
2400: 'default_enrollment_end_date' => 'Date of last student access',
2401: 'coursecode' => 'Official course code',
2402: 'courseowner' => "Username:domain of course owner",
2403: 'co-owners' => "Username:domain of each co-owner",
2404: 'notifylist' => 'Course Coordinators to be notified of enrollment changes',
2405: 'sectionnums' => 'Course section number:LON-CAPA section',
2406: 'crosslistings' => 'Crosslisted class:LON-CAPA section',
2407: 'defaultcredits' => 'Credits',
2408: 'autodropfailsafe' => "Failsafe section enrollment count",
2409: 'selfenrollmgrdc' => "Course-specific self-enrollment configuration by Domain Coordinator",
2410: 'selfenrollmgrcc' => "Course-specific self-enrollment configuration by Course personnel",
2411: 'mysqltables' => '"Temporary" student performance tables lifetime (seconds)',
2412: );
2413: }
2414: return %longtype;
2415: }
2416:
2417: sub hidden_form_elements {
2418: my $hidden_elements =
2419: &Apache::lonhtmlcommon::echo_form_input(['gosearch','updater','coursecode',
2420: 'prevphase','numlocalcc','courseowner','login','coursequota','intarg',
2421: 'locarg','krbarg','krbver','counter','hidefromcat','usecategory',
2422: 'threshold','postsubmit','postsubtimeout','defaultcredits','uploadquota',
2423: 'selfenrollmgrdc','selfenrollmgrcc','action','state','currsec_st',
2424: 'sections','newsec','mysqltables'],['^selfenrollmgr_','^selfenroll_'])."\n".
2425: '<input type="hidden" name="prevphase" value="'.$env{'form.phase'}.'" />';
2426: return $hidden_elements;
2427: }
2428:
2429: sub showcredits {
2430: my ($dom) = @_;
2431: my %domdefaults = &Apache::lonnet::get_domain_defaults($dom);
2432: if ($domdefaults{'officialcredits'} || $domdefaults{'unofficialcredits'} || $domdefaults{'textbookcredits'}) {
2433: return 1;
2434: }
2435: }
2436:
2437: sub get_permission {
2438: my ($dom) = @_;
2439: my ($allowed,%permission);
2440: if (&Apache::lonnet::allowed('ccc',$dom)) {
2441: $allowed = 1;
2442: %permission = (
2443: setquota => 'edit',
2444: processquota => 'edit',
2445: setanon => 'edit',
2446: processthreshold => 'edit',
2447: setpostsubmit => 'edit',
2448: processpostsubmit => 'edit',
2449: viewparms => 'view',
2450: setparms => 'edit',
2451: processparms => 'edit',
2452: catsettings => 'edit',
2453: processcat => 'edit',
2454: selfenroll => 'edit',
2455: adhocrole => 'coord',
2456: );
2457: } elsif (&Apache::lonnet::allowed('rar',$dom)) {
2458: $allowed = 1;
2459: %permission = (
2460: setquota => 'view',
2461: viewparms => 'view',
2462: setanon => 'view',
2463: setpostsubmit => 'view',
2464: setparms => 'view',
2465: catsettings => 'view',
2466: selfenroll => 'view',
2467: adhocrole => 'custom',
2468: );
2469: }
2470: return ($allowed,\%permission);
2471: }
2472:
2473: sub handler {
2474: my $r = shift;
2475: if ($r->header_only) {
2476: &Apache::loncommon::content_type($r,'text/html');
2477: $r->send_http_header;
2478: return OK;
2479: }
2480:
2481: my $dom = $env{'request.role.domain'};
2482: my $domdesc = &Apache::lonnet::domain($dom,'description');
2483: my ($allowed,$permission) = &get_permission($dom);
2484: if ($allowed) {
2485: &Apache::loncommon::content_type($r,'text/html');
2486: $r->send_http_header;
2487:
2488: &Apache::lonhtmlcommon::clear_breadcrumbs();
2489:
2490: my $phase = $env{'form.phase'};
2491: if ($env{'form.updater'}) {
2492: $phase = '';
2493: }
2494: if ($phase eq '') {
2495: &Apache::lonhtmlcommon::add_breadcrumb
2496: ({href=>"/adm/modifycourse",
2497: text=>"Course/Community search"});
2498: &print_course_search_page($r,$dom,$domdesc);
2499: } else {
2500: my $firstform = $phase;
2501: if ($phase eq 'courselist') {
2502: $firstform = 'filterpicker';
2503: }
2504: my $choose_text;
2505: my $type = $env{'form.type'};
2506: if ($type eq '') {
2507: $type = 'Course';
2508: }
2509: if ($type eq 'Community') {
2510: $choose_text = "Choose a community";
2511: } elsif ($type eq 'Placement') {
2512: $choose_text = "Choose a placement test";
2513: } else {
2514: $choose_text = "Choose a course";
2515: }
2516: &Apache::lonhtmlcommon::add_breadcrumb
2517: ({href=>"javascript:changePage(document.$firstform,'')",
2518: text=>"Course/Community search"},
2519: {href=>"javascript:changePage(document.$phase,'courselist')",
2520: text=>$choose_text});
2521: if ($phase eq 'courselist') {
2522: &print_course_selection_page($r,$dom,$domdesc,$permission);
2523: } else {
2524: my ($checked,$cdesc,$coursehash) = &check_course($dom,$domdesc);
2525: if ($checked eq 'ok') {
2526: my $enter_text;
2527: if ($type eq 'Community') {
2528: $enter_text = 'Enter community';
2529: } elsif ($type eq 'Placement') {
2530: $enter_text = 'Enter placement test';
2531: } else {
2532: $enter_text = 'Enter course';
2533: }
2534: if ($phase eq 'menu') {
2535: &Apache::lonhtmlcommon::add_breadcrumb
2536: ({href=>"javascript:changePage(document.$phase,'menu')",
2537: text=>"Pick action"});
2538: &print_modification_menu($r,$cdesc,$domdesc,$dom,$type,
2539: $env{'form.pickedcourse'},$coursehash,
2540: $permission);
2541: } elsif ($phase eq 'adhocrole') {
2542: &Apache::lonhtmlcommon::add_breadcrumb
2543: ({href=>"javascript:changePage(document.$phase,'adhocrole')",
2544: text=>$enter_text});
2545: &print_adhocrole_selected($r,$type,$permission);
2546: } else {
2547: &Apache::lonhtmlcommon::add_breadcrumb
2548: ({href=>"javascript:changePage(document.$phase,'menu')",
2549: text=>"Pick action"});
2550: my ($cdom,$cnum) = split(/_/,$env{'form.pickedcourse'});
2551: my ($readonly,$linktext);
2552: if ($permission->{$phase} eq 'view') {
2553: $readonly = 1;
2554: }
2555: if (($phase eq 'setquota') && ($permission->{'setquota'})) {
2556: if ($permission->{'setquota'} eq 'view') {
2557: $linktext = 'Set quota';
2558: } else {
2559: $linktext = 'Display quota';
2560: }
2561: &Apache::lonhtmlcommon::add_breadcrumb
2562: ({href=>"javascript:changePage(document.$phase,'$phase')",
2563: text=>$linktext});
2564: &print_setquota($r,$cdom,$cnum,$cdesc,$type,$readonly);
2565: } elsif (($phase eq 'processquota') && ($permission->{'processquota'})) {
2566: &Apache::lonhtmlcommon::add_breadcrumb
2567: ({href=>"javascript:changePage(document.$phase,'setquota')",
2568: text=>"Set quota"});
2569: &Apache::lonhtmlcommon::add_breadcrumb
2570: ({href=>"javascript:changePage(document.$phase,'$phase')",
2571: text=>"Result"});
2572: &modify_quota($r,$cdom,$cnum,$cdesc,$domdesc,$type);
2573: } elsif (($phase eq 'setanon') && ($permission->{'setanon'})) {
2574: &Apache::lonhtmlcommon::add_breadcrumb
2575: ({href=>"javascript:changePage(document.$phase,'$phase')",
2576: text=>"Threshold for anonymous submissions display"});
2577: &print_set_anonsurvey_threshold($r,$cdom,$cnum,$cdesc,$type,$readonly);
2578: } elsif (($phase eq 'processthreshold') && ($permission->{'processthreshold'})) {
2579: &Apache::lonhtmlcommon::add_breadcrumb
2580: ({href=>"javascript:changePage(document.$phase,'setanon')",
2581: text=>"Threshold for anonymous submissions display"});
2582: &Apache::lonhtmlcommon::add_breadcrumb
2583: ({href=>"javascript:changePage(document.$phase,'$phase')",
2584: text=>"Result"});
2585: &modify_anonsurvey_threshold($r,$cdom,$cnum,$cdesc,$domdesc,$type);
2586: } elsif (($phase eq 'setpostsubmit') && ($permission->{'setpostsubmit'})) {
2587: if ($permission->{'setpostsubmit'} eq 'view') {
2588: $linktext = 'Submit button behavior post-submission';
2589: } else {
2590: $linktext = 'Configure submit button behavior post-submission';
2591: }
2592: &Apache::lonhtmlcommon::add_breadcrumb
2593: ({href=>"javascript:changePage(document.$phase,'$phase')",
2594: text=>$linktext});
2595: &print_postsubmit_config($r,$cdom,$cnum,$cdesc,$type,$readonly);
2596: } elsif (($phase eq 'processpostsubmit') && ($permission->{'processpostsubmit'})) {
2597: &Apache::lonhtmlcommon::add_breadcrumb
2598: ({href=>"javascript:changePage(document.$phase,'$phase')",
2599: text=>"Result"});
2600: &modify_postsubmit_config($r,$cdom,$cnum,$cdesc,$domdesc,$type);
2601: } elsif (($phase eq 'viewparms') && ($permission->{'viewparms'})) {
2602: &Apache::lonhtmlcommon::add_breadcrumb
2603: ({href=>"javascript:changePage(document.$phase,'viewparms')",
2604: text=>"Display settings"});
2605: &print_settings_display($r,$cdom,$cnum,$cdesc,$type,$permission);
2606: } elsif (($phase eq 'setparms') && ($permission->{'setparms'})) {
2607: if ($permission->{'setparms'} eq 'view') {
2608: $linktext = 'Display settings';
2609: } else {
2610: $linktext = 'Change settings';
2611: }
2612: &Apache::lonhtmlcommon::add_breadcrumb
2613: ({href=>"javascript:changePage(document.$phase,'$phase')",
2614: text=>$linktext});
2615: &print_course_modification_page($r,$cdom,$cnum,$cdesc,$type,$readonly);
2616: } elsif (($phase eq 'processparms') && ($permission->{'processparms'})) {
2617: &Apache::lonhtmlcommon::add_breadcrumb
2618: ({href=>"javascript:changePage(document.$phase,'setparms')",
2619: text=>"Change settings"});
2620: &Apache::lonhtmlcommon::add_breadcrumb
2621: ({href=>"javascript:changePage(document.$phase,'$phase')",
2622: text=>"Result"});
2623: &modify_course($r,$cdom,$cnum,$cdesc,$domdesc,$type);
2624: } elsif (($phase eq 'catsettings') && ($permission->{'catsettings'})) {
2625: &Apache::lonhtmlcommon::add_breadcrumb
2626: ({href=>"javascript:changePage(document.$phase,'$phase')",
2627: text=>"Catalog settings"});
2628: &print_catsettings($r,$cdom,$cnum,$cdesc,$type,$readonly);
2629: } elsif (($phase eq 'processcat') && ($permission->{'processcat'})) {
2630: &Apache::lonhtmlcommon::add_breadcrumb
2631: ({href=>"javascript:changePage(document.$phase,'catsettings')",
2632: text=>"Catalog settings"});
2633: &Apache::lonhtmlcommon::add_breadcrumb
2634: ({href=>"javascript:changePage(document.$phase,'$phase')",
2635: text=>"Result"});
2636: &modify_catsettings($r,$cdom,$cnum,$cdesc,$domdesc,$type);
2637: } elsif (($phase eq 'selfenroll') && ($permission->{'selfenroll'})) {
2638: &Apache::lonhtmlcommon::add_breadcrumb
2639: ({href => "javascript:changePage(document.$phase,'$phase')",
2640: text => "Self-enrollment settings"});
2641: if (!exists($env{'form.state'})) {
2642: &print_selfenrollconfig($r,$type,$cdesc,$coursehash,$readonly);
2643: } elsif ($env{'form.state'} eq 'done') {
2644: &Apache::lonhtmlcommon::add_breadcrumb
2645: ({href=>"javascript:changePage(document.$phase,'$phase')",
2646: text=>"Result"});
2647: &modify_selfenrollconfig($r,$type,$cdesc,$coursehash);
2648: }
2649: }
2650: }
2651: } else {
2652: $r->print('<span class="LC_error">');
2653: if ($type eq 'Community') {
2654: $r->print(&mt('The community you selected is not a valid community in this domain'));
2655: } elsif ($type eq 'Placement') {
2656: $r->print(&mt('The course you selected is not a valid placement test in this domain'));
2657: } else {
2658: $r->print(&mt('The course you selected is not a valid course in this domain'));
2659: }
2660: $r->print(" ($domdesc)</span>");
2661: }
2662: }
2663: }
2664: &print_footer($r);
2665: } else {
2666: $env{'user.error.msg'}=
2667: "/adm/modifycourse:ccc:0:0:Cannot modify course/community settings";
2668: return HTTP_NOT_ACCEPTABLE;
2669: }
2670: return OK;
2671: }
2672:
2673: 1;
2674: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>