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