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