Annotation of loncom/interface/lonmodifycourse.pm, revision 1.79.2.8
1.20 albertel 1: # The LearningOnline Network with CAPA
1.28 raeburn 2: # handler for DC-only modifiable course settings
1.20 albertel 3: #
1.79.2.8! raeburn 4: # $Id: lonmodifycourse.pm,v 1.79.2.7 2019/07/26 17:43:54 raeburn Exp $
1.20 albertel 5: #
1.3 raeburn 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: #
1.1 raeburn 28: package Apache::lonmodifycourse;
29:
30: use strict;
31: use Apache::Constants qw(:common :http);
32: use Apache::lonnet;
33: use Apache::loncommon;
1.28 raeburn 34: use Apache::lonhtmlcommon;
1.1 raeburn 35: use Apache::lonlocal;
1.36 raeburn 36: use Apache::lonuserutils;
1.72 raeburn 37: use Apache::loncreateuser;
1.28 raeburn 38: use Apache::lonpickcourse;
1.1 raeburn 39: use lib '/home/httpd/lib/perl';
1.72 raeburn 40: use LONCAPA qw(:DEFAULT :match);
1.1 raeburn 41:
1.79.2.7 raeburn 42: my $registered_cleanup;
43: my $modified_dom;
44:
1.28 raeburn 45: sub get_dc_settable {
1.60 raeburn 46: my ($type,$cdom) = @_;
1.48 raeburn 47: if ($type eq 'Community') {
1.72 raeburn 48: return ('courseowner','selfenrollmgrdc','selfenrollmgrcc');
1.48 raeburn 49: } else {
1.79.2.2 raeburn 50: my @items = ('courseowner','coursecode','authtype','autharg','selfenrollmgrdc',
51: 'selfenrollmgrcc','mysqltables');
1.60 raeburn 52: if (&showcredits($cdom)) {
53: push(@items,'defaultcredits');
54: }
1.79.2.8! raeburn 55: my %passwdconf = &Apache::lonnet::get_passwdconf($cdom);
! 56: if (($passwdconf{'crsownerchg'}) && ($type ne 'Placement')) {
! 57: push(@items,'nopasswdchg');
! 58: }
1.60 raeburn 59: return @items;
1.48 raeburn 60: }
61: }
62:
63: sub autoenroll_keys {
1.60 raeburn 64: my $internals = ['coursecode','courseowner','authtype','autharg','defaultcredits',
65: 'autoadds','autodrops','autostart','autoend','sectionnums',
1.79.2.1 raeburn 66: 'crosslistings','co-owners','autodropfailsafe'];
1.48 raeburn 67: my $accessdates = ['default_enrollment_start_date','default_enrollment_end_date'];
68: return ($internals,$accessdates);
1.28 raeburn 69: }
70:
1.38 raeburn 71: sub catalog_settable {
1.49 raeburn 72: my ($confhash,$type) = @_;
1.38 raeburn 73: my @settable;
74: if (ref($confhash) eq 'HASH') {
1.49 raeburn 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: }
1.38 raeburn 89: }
90: } else {
91: push(@settable,('togglecats','categorize'));
92: }
93: return @settable;
94: }
95:
1.28 raeburn 96: sub get_enrollment_settings {
97: my ($cdom,$cnum) = @_;
1.48 raeburn 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: }
1.79.2.8! raeburn 104: push(@items,'internal.nopasswdchg');
1.48 raeburn 105: my %settings = &Apache::lonnet::get('environment',\@items,$cdom,$cnum);
1.28 raeburn 106: my %enrollvar;
107: $enrollvar{'autharg'} = '';
108: $enrollvar{'authtype'} = '';
1.48 raeburn 109: foreach my $item (keys(%settings)) {
1.28 raeburn 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";
1.10 raeburn 117: }
1.28 raeburn 118: } elsif ( ($type eq "autostart") || ($type eq "autoend") ) {
119: if ( ($type eq "autoend") && ($settings{$item} == 0) ) {
1.48 raeburn 120: $enrollvar{$type} = &mt('No end date');
1.28 raeburn 121: } else {
1.48 raeburn 122: $enrollvar{$type} = &Apache::lonlocal::locallocaltime($settings{$item});
1.14 raeburn 123: }
1.50 raeburn 124: } elsif (($type eq 'sectionnums') || ($type eq 'co-owners')) {
1.28 raeburn 125: $enrollvar{$type} = $settings{$item};
126: $enrollvar{$type} =~ s/,/, /g;
127: } elsif ($type eq "authtype"
128: || $type eq "autharg" || $type eq "coursecode"
1.79.2.1 raeburn 129: || $type eq "crosslistings" || $type eq "selfenrollmgr"
1.79.2.8! raeburn 130: || $type eq "autodropfailsafe" || $type eq 'nopasswdchg') {
1.28 raeburn 131: $enrollvar{$type} = $settings{$item};
1.60 raeburn 132: } elsif ($type eq 'defaultcredits') {
133: if (&showcredits($cdom)) {
134: $enrollvar{$type} = $settings{$item};
135: }
1.28 raeburn 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;
1.26 raeburn 142: }
1.1 raeburn 143: }
1.28 raeburn 144: }
145: } elsif ($item =~ m/^default_enrollment_(start|end)_date$/) {
146: my $type = $1;
147: if ( ($type eq 'end') && ($settings{$item} == 0) ) {
1.48 raeburn 148: $enrollvar{$item} = &mt('No end date');
1.28 raeburn 149: } elsif ( ($type eq 'start') && ($settings{$item} eq '') ) {
150: $enrollvar{$item} = 'When enrolled';
151: } else {
1.48 raeburn 152: $enrollvar{$item} = &Apache::lonlocal::locallocaltime($settings{$item});
1.1 raeburn 153: }
154: }
155: }
1.28 raeburn 156: return %enrollvar;
157: }
158:
159: sub print_course_search_page {
160: my ($r,$dom,$domdesc) = @_;
1.48 raeburn 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);
1.70 raeburn 167: my ($filterlist,$filter) = &get_filters($dom);
1.56 raeburn 168: my ($numtitles,$cctitle,$dctitle,@codetitles);
1.48 raeburn 169: my $ccrole = 'cc';
170: if ($type eq 'Community') {
171: $ccrole = 'co';
1.46 raeburn 172: }
1.48 raeburn 173: $cctitle = &Apache::lonnet::plaintext($ccrole,$type);
1.46 raeburn 174: $dctitle = &Apache::lonnet::plaintext('dc');
1.70 raeburn 175: $r->print(&Apache::loncommon::js_changer());
1.48 raeburn 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>');
1.69 raeburn 180: }
181: $r->print(&Apache::loncommon::build_filters($filterlist,$type,undef,undef,$filter,$action,
182: \$numtitles,'modifycourse',undef,undef,undef,
1.70 raeburn 183: \@codetitles,$dom));
1.79.2.3 raeburn 184:
185: my ($actiontext,$roleoption,$settingsoption);
1.48 raeburn 186: if ($type eq 'Community') {
1.79.2.3 raeburn 187: $actiontext = &mt('Actions available after searching for a community:');
188: } else {
189: $actiontext = &mt('Actions available after searching for a course:');
1.48 raeburn 190: }
1.79.2.3 raeburn 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)) {
1.79.2.5 raeburn 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) {
1.79.2.3 raeburn 203: if ($type eq 'Community') {
1.79.2.5 raeburn 204: $roleoption = &mt('Enter the community with one of the available ad hoc roles');
1.79.2.3 raeburn 205: } else {
1.79.2.5 raeburn 206: $roleoption = &mt('Enter the course with one of the available ad hoc roles.');
1.79.2.3 raeburn 207: }
208: } else {
1.79.2.5 raeburn 209: my $rolename = $description->{$roles_by_num->[0]};
1.79.2.3 raeburn 210: if ($type eq 'Community') {
1.79.2.5 raeburn 211: $roleoption = &mt('Enter the community with the ad hoc role of: [_1]',$rolename);
1.79.2.3 raeburn 212: } else {
1.79.2.5 raeburn 213: $roleoption = &mt('Enter the course with the ad hoc role of: [_1]',$rolename);
1.79.2.3 raeburn 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>');
1.69 raeburn 228: return;
1.28 raeburn 229: }
230:
231: sub print_course_selection_page {
1.79.2.5 raeburn 232: my ($r,$dom,$domdesc,$permission) = @_;
1.48 raeburn 233: my $type = $env{'form.type'};
234: if (!defined($type)) {
235: $type = 'Course';
236: }
237: &print_header($r,$type);
1.28 raeburn 238:
1.79.2.5 raeburn 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 = '';
1.79.2.6 raeburn 280: \$("#LC_choose_adhoc").empty();
1.79.2.5 raeburn 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: }
1.79.2.6 raeburn 285: \$( "#LC_adhocrole_chooser" ).toggle( true );
1.79.2.5 raeburn 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:
1.79.2.6 raeburn 331: <div id="LC_adhocrole_chooser" title="$lt{'title'}" style="display:none">
1.79.2.5 raeburn 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
1.69 raeburn 359: my ($filterlist,$filter) = &get_filters();
1.28 raeburn 360: my $action = '/adm/modifycourse';
361: my $dctitle = &Apache::lonnet::plaintext('dc');
1.56 raeburn 362: my ($numtitles,@codetitles);
1.70 raeburn 363: $r->print(&Apache::loncommon::js_changer());
1.48 raeburn 364: $r->print(&mt('Revise your search criteria for this domain').' ('.$domdesc.').<br />');
1.69 raeburn 365: $r->print(&Apache::loncommon::build_filters($filterlist,$type,undef,undef,$filter,$action,
366: \$numtitles,'modifycourse',undef,undef,undef,
1.70 raeburn 367: \@codetitles,$dom,$env{'form.form'}));
368: my %courses = &Apache::loncommon::search_courses($dom,$type,$filter,$numtitles,
369: undef,undef,undef,\@codetitles);
1.46 raeburn 370: &Apache::lonpickcourse::display_matched_courses($r,$type,0,$action,undef,undef,undef,
1.79.2.3 raeburn 371: $dom,undef,%courses);
1.1 raeburn 372: return;
373: }
374:
1.69 raeburn 375: sub get_filters {
1.70 raeburn 376: my ($dom) = @_;
1.69 raeburn 377: my @filterlist = ('descriptfilter','instcodefilter','ownerfilter',
378: 'ownerdomfilter','coursefilter','sincefilter');
379: # created filter
1.70 raeburn 380: my $loncaparev = &Apache::lonnet::get_server_loncaparev($dom);
1.69 raeburn 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:
1.28 raeburn 391: sub print_modification_menu {
1.79.2.3 raeburn 392: my ($r,$cdesc,$domdesc,$dom,$type,$cid,$coursehash,$permission) = @_;
1.48 raeburn 393: &print_header($r,$type);
1.79.2.4 raeburn 394: my ($ccrole,$categorytitle,$setquota_text,$setuploadquota_text,$cdom,$cnum);
1.71 raeburn 395: if (ref($coursehash) eq 'HASH') {
396: $cdom = $coursehash->{'domain'};
397: $cnum = $coursehash->{'num'};
398: } else {
399: ($cdom,$cnum) = split(/_/,$cid);
400: }
1.48 raeburn 401: if ($type eq 'Community') {
402: $ccrole = 'co';
403: } else {
404: $ccrole = 'cc';
1.61 raeburn 405: }
1.79.2.4 raeburn 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: }
1.48 raeburn 422: if ($type eq 'Community') {
1.79.2.4 raeburn 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: }
1.48 raeburn 432: $setquota_text = &mt('Total disk space allocated for storage of portfolio files in all groups in a community.');
1.79.2.4 raeburn 433: $setuploadquota_text = &mt('Disk space allocated for storage of content uploaded directly to a community via Content Editor.');
1.48 raeburn 434: } else {
1.79.2.4 raeburn 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: }
1.60 raeburn 443: } else {
1.79.2.4 raeburn 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: }
1.60 raeburn 451: }
1.79.2.4 raeburn 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.');
1.48 raeburn 454: }
1.75 raeburn 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.');
1.79.2.3 raeburn 457: my $mysqltables_text = &mt('Override default for lifetime of "temporary" MySQL tables containing student performance data.');
1.79.2.4 raeburn 458: $linktext{'viewparms'} = 'Display current settings for automated enrollment';
1.54 bisitz 459:
1.38 raeburn 460: my %domconf = &Apache::lonnet::get_dom('configuration',['coursecategories'],$dom);
1.49 raeburn 461: my @additional_params = &catalog_settable($domconf{'coursecategories'},$type);
1.54 bisitz 462:
1.72 raeburn 463: sub manage_selfenrollment {
1.79.2.3 raeburn 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: }
1.72 raeburn 472: }
473: return 0;
474: }
475:
1.54 bisitz 476: sub phaseurl {
477: my $phase = shift;
478: return "javascript:changePage(document.menu,'$phase')"
1.38 raeburn 479: }
1.54 bisitz 480: my @menu =
481: ({ categorytitle => $categorytitle,
482: items => [
483: {
1.79.2.4 raeburn 484: linktext => $linktext{'setparms'},
1.54 bisitz 485: url => &phaseurl('setparms'),
1.79.2.3 raeburn 486: permission => $permission->{'setparms'},
1.54 bisitz 487: #help => '',
1.55 bisitz 488: icon => 'crsconf.png',
1.54 bisitz 489: linktitle => ''
490: },
491: {
1.79.2.4 raeburn 492: linktext => $linktext{'setquota'},
1.54 bisitz 493: url => &phaseurl('setquota'),
1.79.2.3 raeburn 494: permission => $permission->{'setquota'},
1.54 bisitz 495: #help => '',
1.55 bisitz 496: icon => 'groupportfolioquota.png',
1.54 bisitz 497: linktitle => ''
498: },
499: {
1.79.2.4 raeburn 500: linktext => $linktext{'setanon'},
1.57 raeburn 501: url => &phaseurl('setanon'),
1.79.2.3 raeburn 502: permission => $permission->{'setanon'},
1.57 raeburn 503: #help => '',
504: icon => 'anonsurveythreshold.png',
505: linktitle => ''
506: },
507: {
1.79.2.4 raeburn 508: linktext => $linktext{'catsettings'},
1.54 bisitz 509: url => &phaseurl('catsettings'),
1.79.2.3 raeburn 510: permission => (($permission->{'catsettings'}) && (@additional_params > 0)),
1.54 bisitz 511: #help => '',
1.55 bisitz 512: icon => 'ccatconf.png',
1.54 bisitz 513: linktitle => ''
514: },
515: {
1.79.2.4 raeburn 516: linktext => $linktext{'viewparms'},
1.54 bisitz 517: url => &phaseurl('viewparms'),
1.79.2.3 raeburn 518: permission => ($permission->{'viewparms'} && ($type ne 'Community')),
1.54 bisitz 519: #help => '',
1.55 bisitz 520: icon => 'roles.png',
1.54 bisitz 521: linktitle => ''
522: },
1.72 raeburn 523: {
1.79.2.4 raeburn 524: linktext => $linktext{'selfenroll'},
1.72 raeburn 525: icon => 'self_enroll.png',
526: #help => 'Course_Self_Enrollment',
527: url => &phaseurl('selfenroll'),
1.79.2.3 raeburn 528: permission => &manage_selfenrollment($cdom,$cnum,$type,$coursehash,$permission),
1.72 raeburn 529: linktitle => 'Configure user self-enrollment.',
530: },
1.75 raeburn 531: {
1.79.2.4 raeburn 532: linktext => $linktext{'setpostsubmit'},
1.75 raeburn 533: icon => 'emblem-readonly.png',
534: #help => '',
535: url => &phaseurl('setpostsubmit'),
1.79.2.3 raeburn 536: permission => $permission->{'setpostsubmit'},
1.75 raeburn 537: linktitle => '',
538: },
1.54 bisitz 539: ]
540: },
1.48 raeburn 541: );
1.54 bisitz 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>';
1.48 raeburn 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: }
1.54 bisitz 553: $menu_html .= '</p>'."\n".'<ul>';
1.48 raeburn 554: if ($type eq 'Community') {
1.72 raeburn 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";
1.48 raeburn 557: } else {
1.72 raeburn 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";
1.60 raeburn 560: if (&showcredits($dom)) {
1.72 raeburn 561: $menu_html .= '<li>'.&mt('Default credits earned by student on course completion.').'</li>'."\n";
1.60 raeburn 562: }
1.72 raeburn 563: $menu_html .= ' <li>'.&mt('Override defaults for who configures self-enrollment for this specific course.').'</li>'."\n";
1.48 raeburn 564: }
1.79.2.2 raeburn 565: $menu_html .= '<li>'.$mysqltables_text.'</li>'."\n".
566: '<li>'.$setquota_text.'</li>'."\n".
1.72 raeburn 567: '<li>'.$setuploadquota_text.'</li>'."\n".
1.75 raeburn 568: '<li>'.$anon_text.'</li>'."\n".
569: '<li>'.$postsubmit_text.'</li>'."\n";
1.79.2.3 raeburn 570: my ($categories_link_start,$categories_link_end);
1.79.2.4 raeburn 571: if ($permission->{'catsettings'} eq 'edit') {
1.79.2.3 raeburn 572: $categories_link_start = '<a href="/adm/domainprefs?actions=coursecategories&phase=display">';
573: $categories_link_end = '</a>';
574: }
1.38 raeburn 575: foreach my $item (@additional_params) {
1.48 raeburn 576: if ($type eq 'Community') {
577: if ($item eq 'togglecats') {
1.79.2.3 raeburn 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";
1.48 raeburn 579: } elsif ($item eq 'categorize') {
1.79.2.3 raeburn 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";
1.48 raeburn 581: }
582: } else {
583: if ($item eq 'togglecats') {
1.79.2.3 raeburn 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";
1.48 raeburn 585: } elsif ($item eq 'categorize') {
1.79.2.3 raeburn 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";
1.48 raeburn 587: }
1.38 raeburn 588: }
589: }
1.54 bisitz 590: $menu_html .=
591: ' </ul>'
592: .'<form name="menu" method="post" action="/adm/modifycourse">'
593: ."\n"
594: .&hidden_form_elements();
1.28 raeburn 595:
596: $r->print($menu_html);
1.54 bisitz 597: $r->print(&Apache::lonhtmlcommon::generate_menu(@menu));
598: $r->print('</form>');
1.28 raeburn 599: return;
600: }
601:
1.79.2.3 raeburn 602: sub print_adhocrole_selected {
1.79.2.5 raeburn 603: my ($r,$type,$permission) = @_;
1.48 raeburn 604: &print_header($r,$type);
1.37 raeburn 605: my ($cdom,$cnum) = split(/_/,$env{'form.pickedcourse'});
1.79.2.3 raeburn 606: my ($newrole,$selectrole);
1.79.2.5 raeburn 607: if ($permission->{'adhocrole'} eq 'coord') {
1.79.2.3 raeburn 608: if ($type eq 'Community') {
609: $newrole = "co./$cdom/$cnum";
610: } else {
611: $newrole = "cc./$cdom/$cnum";
612: }
613: $selectrole = 1;
1.79.2.5 raeburn 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') {
1.79.2.3 raeburn 617: my $possrole = $env{'form.adhocrole'};
1.79.2.5 raeburn 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;
1.79.2.3 raeburn 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.'" />
1.37 raeburn 629: </form>');
1.79.2.3 raeburn 630: } else {
631: $r->print('<form name="ccrole" method="post" action="/adm/modifycourse">'.
632: '</form>');
633: }
634: return;
1.37 raeburn 635: }
636:
1.28 raeburn 637: sub print_settings_display {
1.79.2.3 raeburn 638: my ($r,$cdom,$cnum,$cdesc,$type,$permission) = @_;
1.28 raeburn 639: my %enrollvar = &get_enrollment_settings($cdom,$cnum);
1.48 raeburn 640: my %longtype = &course_settings_descrip($type);
1.28 raeburn 641: my %lt = &Apache::lonlocal::texthash(
1.48 raeburn 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',
1.28 raeburn 647: );
1.48 raeburn 648: my $ccrole = 'cc';
649: if ($type eq 'Community') {
650: $ccrole = 'co';
651: }
652: my $cctitle = &Apache::lonnet::plaintext($ccrole,$type);
1.28 raeburn 653: my $dctitle = &Apache::lonnet::plaintext('dc');
1.60 raeburn 654: my @modifiable_params = &get_dc_settable($type,$cdom);
1.48 raeburn 655: my ($internals,$accessdates) = &autoenroll_keys();
656: my @items;
657: if ((ref($internals) eq 'ARRAY') && (ref($accessdates) eq 'ARRAY')) {
658: @items = (@{$internals},@{$accessdates});
659: }
1.28 raeburn 660: my $disp_table = &Apache::loncommon::start_data_table()."\n".
661: &Apache::loncommon::start_data_table_header_row()."\n".
1.48 raeburn 662: "<th> </th>\n".
1.28 raeburn 663: "<th>$lt{'valu'}</th>\n".
664: "<th>$lt{'dcon'}</th>\n".
665: &Apache::loncommon::end_data_table_header_row()."\n";
1.48 raeburn 666: foreach my $item (@items) {
1.28 raeburn 667: $disp_table .= &Apache::loncommon::start_data_table_row()."\n".
1.48 raeburn 668: "<td><b>$longtype{$item}</b></td>\n".
669: "<td>$enrollvar{$item}</td>\n";
670: if (grep(/^\Q$item\E$/,@modifiable_params)) {
1.50 raeburn 671: $disp_table .= '<td align="right">'.&mt('Yes').'</td>'."\n";
1.28 raeburn 672: } else {
1.48 raeburn 673: $disp_table .= '<td align="right">'.&mt('No').'</td>'."\n";
1.28 raeburn 674: }
675: $disp_table .= &Apache::loncommon::end_data_table_row()."\n";
1.3 raeburn 676: }
1.28 raeburn 677: $disp_table .= &Apache::loncommon::end_data_table()."\n";
1.48 raeburn 678: &print_header($r,$type);
1.79.2.3 raeburn 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: }
1.48 raeburn 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>'.
1.79.2.3 raeburn 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>');
1.60 raeburn 697: if (&showcredits($cdom)) {
1.79.2.3 raeburn 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");
1.60 raeburn 699: } else {
1.79.2.3 raeburn 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");
1.60 raeburn 701: }
702: $r->print('</li></ul></p>'.
1.48 raeburn 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>'
1.79.2.3 raeburn 707: );
1.28 raeburn 708: }
1.3 raeburn 709:
1.28 raeburn 710: sub print_setquota {
1.79.2.4 raeburn 711: my ($r,$cdom,$cnum,$cdesc,$type,$readonly) = @_;
1.61 raeburn 712: my $lctype = lc($type);
713: my $headline = &mt("Set disk space quotas for $lctype: [_1]",
714: '<span class="LC_nobreak">'.$cdesc.'</span>');
1.28 raeburn 715: my %lt = &Apache::lonlocal::texthash(
1.61 raeburn 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',
1.42 schafran 718: 'modi' => 'Save',
1.48 raeburn 719: 'back' => 'Pick another action',
1.28 raeburn 720: );
1.61 raeburn 721: my %staticdefaults = (
722: coursequota => 20,
723: uploadquota => 500,
724: );
1.68 raeburn 725: my %settings = &Apache::lonnet::get('environment',['internal.coursequota','internal.uploadquota','internal.coursecode'],
1.61 raeburn 726: $cdom,$cnum);
1.28 raeburn 727: my $coursequota = $settings{'internal.coursequota'};
1.61 raeburn 728: my $uploadquota = $settings{'internal.uploadquota'};
1.28 raeburn 729: if ($coursequota eq '') {
1.61 raeburn 730: $coursequota = $staticdefaults{'coursequota'};
731: }
732: if ($uploadquota eq '') {
733: my %domdefs = &Apache::lonnet::get_domain_defaults($cdom);
1.72 raeburn 734: my $quotatype = &Apache::lonuserutils::get_extended_type($cdom,$cnum,$type,\%settings);
735: $uploadquota = $domdefs{$quotatype.'quota'};
1.61 raeburn 736: if ($uploadquota eq '') {
737: $uploadquota = $staticdefaults{'uploadquota'};
738: }
1.3 raeburn 739: }
1.48 raeburn 740: &print_header($r,$type);
1.28 raeburn 741: my $hidden_elements = &hidden_form_elements();
1.61 raeburn 742: my $porthelpitem = &Apache::loncommon::help_open_topic('Modify_Course_Quota');
743: my $uploadhelpitem = &Apache::loncommon::help_open_topic('Modify_Course_Upload_Quota');
1.79.2.4 raeburn 744: my ($disabled,$submit);
745: if ($readonly) {
746: $disabled = ' disabled="disabled"';
747: } else {
748: $submit = '<input type="submit" value="'.$lt{'modi'}.'" />';
749: }
1.28 raeburn 750: $r->print(<<ENDDOCUMENT);
1.57 raeburn 751: <form action="/adm/modifycourse" method="post" name="setquota" onsubmit="return verify_quota();">
1.61 raeburn 752: <h3>$headline</h3>
753: <p><span class="LC_nobreak">
1.79.2.4 raeburn 754: $porthelpitem $lt{'gpqu'}: <input type="text" size="4" name="coursequota" value="$coursequota" $disabled /> MB
1.61 raeburn 755: </span>
756: <br />
757: <span class="LC_nobreak">
1.79.2.4 raeburn 758: $uploadhelpitem $lt{'upqu'}: <input type="text" size="4" name="uploadquota" value="$uploadquota" $disabled /> MB
1.61 raeburn 759: </span>
760: </p>
1.28 raeburn 761: <p>
1.79.2.4 raeburn 762: $submit
1.28 raeburn 763: </p>
764: $hidden_elements
765: <a href="javascript:changePage(document.setquota,'menu')">$lt{'back'}</a>
766: </form>
767: ENDDOCUMENT
768: return;
769: }
1.3 raeburn 770:
1.57 raeburn 771: sub print_set_anonsurvey_threshold {
1.79.2.4 raeburn 772: my ($r,$cdom,$cnum,$cdesc,$type,$readonly) = @_;
1.57 raeburn 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();
1.79.2.4 raeburn 795: my ($disabled,$submit);
796: if ($readonly) {
797: $disabled = ' disabled="disabled"';
798: } else {
799: $submit = '<input type="submit" value="'.$lt{'modi'}.'" />';
800: }
1.57 raeburn 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>
1.79.2.4 raeburn 806: $helpitem $lt{'sufa'}: <input type="text" size="4" name="threshold" value="$threshold" $disabled />
807: $submit
1.57 raeburn 808: </p>
809: $hidden_elements
810: <a href="javascript:changePage(document.setanon,'menu')">$lt{'back'}</a>
811: </form>
812: ENDDOCUMENT
813: return;
814: }
815:
1.75 raeburn 816: sub print_postsubmit_config {
1.79.2.4 raeburn 817: my ($r,$cdom,$cnum,$cdesc,$type,$readonly) = @_;
1.75 raeburn 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();
1.79.2.4 raeburn 858: my ($disabled,$submit);
859: if ($readonly) {
860: $disabled = ' disabled="disabled"';
861: } else {
862: $submit = '<input type="submit" value="'.$lt{'modi'}.'" />';
863: }
1.75 raeburn 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'}:
1.79.2.4 raeburn 870: <label><input type="radio" name="postsubmit" $checkedon onclick="togglePostsubmit('studentsubmission');" value="1" $disabled />
1.75 raeburn 871: $lt{'yes'}</label>
1.79.2.4 raeburn 872: <label><input type="radio" name="postsubmit" $checkedoff onclick="togglePostsubmit('studentsubmission');" value="0" $disabled />
1.75 raeburn 873: $lt{'no'}</label>
874: <div id="studentsubmission" style="display: $display">
1.79.2.4 raeburn 875: $lt{'nums'} <input type="text" name="postsubtimeout" value="$postsubtimeout" $disabled /><br />
1.75 raeburn 876: $zero</div>
877: <br />
1.79.2.4 raeburn 878: $submit
1.75 raeburn 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:
1.38 raeburn 914: sub print_catsettings {
1.79.2.4 raeburn 915: my ($r,$cdom,$cnum,$cdesc,$type,$readonly) = @_;
1.48 raeburn 916: &print_header($r,$type);
1.38 raeburn 917: my %lt = &Apache::lonlocal::texthash(
1.48 raeburn 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.'
1.38 raeburn 924: );
1.48 raeburn 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');
1.49 raeburn 929: $lt{'assi'} = &mt('Assign one or more subcategories to this community.');
1.48 raeburn 930: }
1.38 raeburn 931: $r->print('<form action="/adm/modifycourse" method="post" name="catsettings">'.
1.48 raeburn 932: '<h3>'.$lt{'catset'}.' <span class="LC_nobreak">'.$cdesc.'</span></h3>');
1.38 raeburn 933: my %domconf = &Apache::lonnet::get_dom('configuration',['coursecategories'],$cdom);
1.49 raeburn 934: my @cat_params = &catalog_settable($domconf{'coursecategories'},$type);
1.38 raeburn 935: if (@cat_params > 0) {
1.79.2.4 raeburn 936: my $disabled;
937: if ($readonly) {
938: $disabled = ' disabled="disabled"';
939: }
1.38 raeburn 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: }
1.48 raeburn 949: $r->print('<br /><h4>'.$lt{'visi'}.'</h4>'.
950: $lt{'exclude'}.
1.79.2.4 raeburn 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>');
1.48 raeburn 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>');
1.38 raeburn 960: }
961: if (grep(/^categorize$/,@cat_params)) {
1.48 raeburn 962: $r->print('<br /><h4>'.$lt{'categ'}.'</h4>');
1.38 raeburn 963: if (ref($domconf{'coursecategories'}) eq 'HASH') {
964: my $cathash = $domconf{'coursecategories'}{'cats'};
965: if (ref($cathash) eq 'HASH') {
1.48 raeburn 966: $r->print($lt{'assi'}.'<br /><br />'.
1.38 raeburn 967: &Apache::loncommon::assign_categories_table($cathash,
1.79.2.4 raeburn 968: $currsettings{'categories'},$type,$disabled));
1.38 raeburn 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: }
1.48 raeburn 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: }
1.38 raeburn 978: }
1.79.2.4 raeburn 979: unless ($readonly) {
980: $r->print('<p><input type="button" name="chgcatsettings" value="'.
981: &mt('Save').'" onclick="javascript:changePage(document.catsettings,'."'processcat'".');" /></p>');
982: }
1.38 raeburn 983: } else {
1.48 raeburn 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".
1.38 raeburn 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:
1.28 raeburn 998: sub print_course_modification_page {
1.79.2.4 raeburn 999: my ($r,$cdom,$cnum,$cdesc,$crstype,$readonly) = @_;
1.2 raeburn 1000: my %lt=&Apache::lonlocal::texthash(
1001: 'actv' => "Active",
1002: 'inac' => "Inactive",
1003: 'ownr' => "Owner",
1004: 'name' => "Name",
1.26 raeburn 1005: 'unme' => "Username:Domain",
1.2 raeburn 1006: 'stus' => "Status",
1.48 raeburn 1007: 'nocc' => 'There is currently no owner set for this course.',
1.32 raeburn 1008: 'gobt' => "Save",
1.72 raeburn 1009: 'sett' => 'Setting',
1010: 'domd' => 'Domain default',
1011: 'whom' => 'Who configures',
1.2 raeburn 1012: );
1.79.2.4 raeburn 1013: my ($ownertable,$ccrole,$javascript_validations,$authenitems,$ccname,$disabled);
1.48 raeburn 1014: my %enrollvar = &get_enrollment_settings($cdom,$cnum);
1.72 raeburn 1015: my %settings = &Apache::lonnet::get('environment',['internal.coursecode','internal.textbook',
1.79.2.2 raeburn 1016: 'internal.selfenrollmgrdc','internal.selfenrollmgrcc',
1017: 'internal.mysqltables'],$cdom,$cnum);
1.72 raeburn 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);
1.79.2.8! raeburn 1022: my %passwdconf = &Apache::lonnet::get_passwdconf($cdom);
1.72 raeburn 1023: my @default_managebydc = split(/,/,$domdefaults{$type.'selfenrolladmdc'});
1024: if ($crstype eq 'Community') {
1.48 raeburn 1025: $ccrole = 'co';
1026: $lt{'nocc'} = &mt('There is currently no owner set for this community.');
1027: } else {
1028: $ccrole ='cc';
1.79.2.4 raeburn 1029: ($javascript_validations,$authenitems) = &gather_authenitems($cdom,\%enrollvar,$readonly);
1.48 raeburn 1030: }
1.72 raeburn 1031: $ccname = &Apache::lonnet::plaintext($ccrole,$crstype);
1.79.2.4 raeburn 1032: if ($readonly) {
1033: $disabled = ' disabled="disabled"';
1034: }
1.48 raeburn 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'};
1.1 raeburn 1043: }
1044: }
1.48 raeburn 1045: if (($enrollvar{'courseowner'} ne '') &&
1046: (!grep(/^$enrollvar{'courseowner'}$/,@local_ccs))) {
1047: push(@local_ccs,$enrollvar{'courseowner'});
1.26 raeburn 1048: my ($owneruname,$ownerdom) = split(/:/,$enrollvar{'courseowner'});
1049: $pname{$enrollvar{'courseowner'}} =
1050: &Apache::loncommon::plainname($owneruname,$ownerdom);
1.48 raeburn 1051: my $active_cc = &Apache::loncommon::check_user_status($ownerdom,$owneruname,
1052: $cdom,$cnum,$ccrole);
1.19 raeburn 1053: if ($active_cc eq 'active') {
1.2 raeburn 1054: $cc_status{$enrollvar{'courseowner'}} = $lt{'actv'};
1.1 raeburn 1055: } else {
1.2 raeburn 1056: $cc_status{$enrollvar{'courseowner'}} = $lt{'inac'};
1.1 raeburn 1057: }
1058: }
1.48 raeburn 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'}) {
1.79.2.4 raeburn 1075: $ownertable .= '<td><input type="radio" name="courseowner" value="'.$cc.'" checked="checked"'.$disabled.' /></td>'."\n";
1.48 raeburn 1076: } else {
1.79.2.4 raeburn 1077: $ownertable .= '<td><input type="radio" name="courseowner" value="'.$cc.'"'.$disabled.' /></td>'."\n";
1.48 raeburn 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: }
1.72 raeburn 1087: &print_header($r,$crstype,$javascript_validations);
1.48 raeburn 1088: my $dctitle = &Apache::lonnet::plaintext('dc');
1.72 raeburn 1089: my $mainheader = &modifiable_only_title($crstype);
1.48 raeburn 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());
1.72 raeburn 1094: if ($crstype eq 'Community') {
1.48 raeburn 1095: $r->print(&Apache::lonhtmlcommon::row_title(
1096: &Apache::loncommon::help_open_topic('Modify_Community_Owner').
1.79.2.8! raeburn 1097: ' '.&mt('Community Owner'))."\n".
! 1098: $ownertable."\n".&Apache::lonhtmlcommon::row_closure());
1.48 raeburn 1099: } else {
1100: $r->print(&Apache::lonhtmlcommon::row_title(
1101: &Apache::loncommon::help_open_topic('Modify_Course_Instcode').
1102: ' '.&mt('Course Code'))."\n".
1.79.2.4 raeburn 1103: '<input type="text" size="15" name="coursecode" value="'.$enrollvar{'coursecode'}.'"'.$disabled.' />'.
1.60 raeburn 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').
1.79.2.8! raeburn 1108: ' '.&mt('Credits (students)'))."\n".
1.79.2.4 raeburn 1109: '<input type="text" size="3" name="defaultcredits" value="'.$enrollvar{'defaultcredits'}.'"'.$disabled.' />'.
1.60 raeburn 1110: &Apache::lonhtmlcommon::row_closure());
1.79.2.3 raeburn 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(
1.79.2.8! raeburn 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: }
1.48 raeburn 1133: }
1.72 raeburn 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:
1.79.2.8! raeburn 1142: $r->print(&Apache::lonhtmlcommon::row_title(
1.72 raeburn 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.'" '.
1.79.2.4 raeburn 1175: 'value="'.$option.'"'.$checked{$option}.$disabled.' />'.
1.72 raeburn 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".
1.79.2.2 raeburn 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".
1.79.2.4 raeburn 1186: '<input type="text" size="10" name="mysqltables" value="'.$settings{'internal.mysqltables'}.'"'.$disabled.' />'.
1.79.2.2 raeburn 1187: &Apache::lonhtmlcommon::row_closure(1).
1.79.2.4 raeburn 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'}.'" />');
1.48 raeburn 1197: }
1.79.2.4 raeburn 1198: $r->print('</p></form>');
1.48 raeburn 1199: return;
1200: }
1201:
1.72 raeburn 1202: sub print_selfenrollconfig {
1.79.2.4 raeburn 1203: my ($r,$type,$cdesc,$coursehash,$readonly) = @_;
1.72 raeburn 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,
1.79.2.4 raeburn 1213: &hidden_form_elements(),$readonly);
1.72 raeburn 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'},
1.73 raeburn 1229: $cdom,$cnum,'domain',$type,\%currsettings);
1.72 raeburn 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'},
1.73 raeburn 1252: uniquecode => $coursehash->{'internal.uniquecode'},
1.72 raeburn 1253: );
1254: }
1255: return %currsettings;
1256: }
1257:
1.48 raeburn 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: }
1.24 albertel 1267:
1.48 raeburn 1268: sub gather_authenitems {
1.79.2.4 raeburn 1269: my ($cdom,$enrollvar,$readonly) = @_;
1.28 raeburn 1270: my ($krbdef,$krbdefdom)=&Apache::loncommon::get_kerberos_defaults($cdom);
1.2 raeburn 1271: my $curr_authtype = '';
1272: my $curr_authfield = '';
1.48 raeburn 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: }
1.2 raeburn 1281: }
1282: unless ($curr_authtype eq '') {
1283: $curr_authfield = $curr_authtype.'arg';
1.33 raeburn 1284: }
1.48 raeburn 1285: my $javascript_validations =
1286: &Apache::lonuserutils::javascript_validations('modifycourse',$krbdefdom,
1287: $curr_authtype,$curr_authfield);
1.35 raeburn 1288: my %param = ( formname => 'document.'.$env{'form.phase'},
1.48 raeburn 1289: kerb_def_dom => $krbdefdom,
1290: kerb_def_auth => $krbdef,
1.2 raeburn 1291: mode => 'modifycourse',
1292: curr_authtype => $curr_authtype,
1.79.2.4 raeburn 1293: curr_autharg => $enrollvar->{'autharg'},
1294: readonly => $readonly,
1.48 raeburn 1295: );
1.32 raeburn 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: }
1.1 raeburn 1304: }
1.48 raeburn 1305: return($javascript_validations,$authenitems);
1.1 raeburn 1306: }
1307:
1308: sub modify_course {
1.30 raeburn 1309: my ($r,$cdom,$cnum,$cdesc,$domdesc,$type) = @_;
1.48 raeburn 1310: my %longtype = &course_settings_descrip($type);
1.50 raeburn 1311: my @items = ('internal.courseowner','description','internal.co-owners',
1.72 raeburn 1312: 'internal.pendingco-owners','internal.selfenrollmgrdc',
1.79.2.2 raeburn 1313: 'internal.selfenrollmgrcc','internal.mysqltables');
1.72 raeburn 1314: my ($selfenrollrows,$selfenrolltitles) = &Apache::lonuserutils::get_selfenroll_titles();
1.48 raeburn 1315: unless ($type eq 'Community') {
1316: push(@items,('internal.coursecode','internal.authtype','internal.autharg',
1317: 'internal.sectionnums','internal.crosslistings'));
1.60 raeburn 1318: if (&showcredits($cdom)) {
1319: push(@items,'internal.defaultcredits');
1320: }
1.79.2.8! raeburn 1321: my %passwdconf = &Apache::lonnet::get_passwdconf($cdom);
! 1322: if ($passwdconf{'crsownerchg'}) {
! 1323: push(@items,'internal.nopasswdchg');
! 1324: }
1.1 raeburn 1325: }
1.48 raeburn 1326: my %settings = &Apache::lonnet::get('environment',\@items,$cdom,$cnum);
1327: my $description = $settings{'description'};
1.60 raeburn 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);
1.28 raeburn 1331: foreach my $param (@modifiable_params) {
1.48 raeburn 1332: $currattr{$param} = $settings{'internal.'.$param};
1.1 raeburn 1333: }
1.48 raeburn 1334: if ($type eq 'Community') {
1335: %changed = ( owner => 0 );
1336: $ccrole = 'co';
1337: } else {
1338: %changed = ( code => 0,
1339: owner => 0,
1.79.2.8! raeburn 1340: passwd => 0,
1.48 raeburn 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: }
1.60 raeburn 1350: unless ($settings{'internal.crosslistings'} eq '') {
1.48 raeburn 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'
1.45 bisitz 1376: .' to be used for authentication in this class, the'
1377: .' institutional data used by the automated'
1378: .' enrollment process must include the Kerberos'
1.48 raeburn 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: }
1.1 raeburn 1388: }
1.79.2.2 raeburn 1389: if ( exists($env{'form.mysqltables'}) ) {
1390: $newattr{'mysqltables'} = $env{'form.mysqltables'};
1391: $newattr{'mysqltables'} =~ s/\D+//g;
1392: }
1.79.2.8! raeburn 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: }
1.60 raeburn 1408: }
1.72 raeburn 1409: }
1410:
1411: my @newmgrdc = ();
1412: my @newmgrcc = ();
1413: my @currmgrdc = split(/,/,$currattr{'selfenrollmgrdc'});
1414: my @currmgrcc = split(/,/,$currattr{'selfenrollmgrcc'});
1.60 raeburn 1415:
1.72 raeburn 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');
1.1 raeburn 1432: }
1.72 raeburn 1433: my $dctitle = &Apache::lonnet::plaintext('dc');
1.1 raeburn 1434:
1.16 albertel 1435: if ( exists($env{'form.courseowner'}) ) {
1436: $newattr{'courseowner'}=$env{'form.courseowner'};
1.14 raeburn 1437: unless ( $newattr{'courseowner'} eq $currattr{'courseowner'} ) {
1.38 raeburn 1438: $changed{'owner'} = 1;
1.1 raeburn 1439: }
1440: }
1.48 raeburn 1441:
1.79.2.8! raeburn 1442: if ($changed{'owner'} || $changed{'code'} || $changed{'passwd'}) {
1.38 raeburn 1443: my %crsinfo = &Apache::lonnet::courseiddump($cdom,'.',1,'.','.',$cnum,
1444: undef,undef,'.');
1445: if (ref($crsinfo{$env{'form.pickedcourse'}}) eq 'HASH') {
1.48 raeburn 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: }
1.79.2.8! raeburn 1452: if ($changed{'passwd'}) {
! 1453: if ($env{'form.nopasswdchg'}) {
! 1454: $crsinfo{$env{'form.pickedcourse'}}{'nopasswdchg'} = 1;
! 1455: } else {
! 1456: delete($crsinfo{'nopasswdchg'});
! 1457: }
! 1458: }
1.38 raeburn 1459: my $chome = &Apache::lonnet::homeserver($cnum,$cdom);
1460: my $putres = &Apache::lonnet::courseidput($cdom,\%crsinfo,$chome,'notime');
1.79.2.8! raeburn 1461: if (($putres eq 'ok') && (($changed{'owner'} || $changed{'code'}))) {
1.50 raeburn 1462: &update_coowners($cdom,$cnum,$chome,\%settings,\%newattr);
1.79.2.7 raeburn 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: }
1.50 raeburn 1475: }
1.38 raeburn 1476: }
1.14 raeburn 1477: }
1.28 raeburn 1478: foreach my $param (@modifiable_params) {
1479: if ($currattr{$param} eq $newattr{$param}) {
1480: push(@nochanges,$param);
1.1 raeburn 1481: } else {
1.48 raeburn 1482: $cenv{'internal.'.$param} = $newattr{$param};
1.28 raeburn 1483: push(@changes,$param);
1.1 raeburn 1484: }
1485: }
1486: if (@changes > 0) {
1.62 bisitz 1487: $chgresponse = &mt('The following settings have been changed:').'<br/><ul>';
1.1 raeburn 1488: }
1.48 raeburn 1489: if (@nochanges > 0) {
1.62 bisitz 1490: $nochgresponse = &mt('The following settings remain unchanged:').'<br/><ul>';
1.1 raeburn 1491: }
1.33 raeburn 1492: if (@changes > 0) {
1.28 raeburn 1493: my $putreply = &Apache::lonnet::put('environment',\%cenv,$cdom,$cnum);
1.1 raeburn 1494: if ($putreply !~ /^ok$/) {
1.48 raeburn 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>';
1.1 raeburn 1503: } else {
1.72 raeburn 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: }
1.28 raeburn 1509: foreach my $attr (@modifiable_params) {
1.48 raeburn 1510: if (grep/^\Q$attr\E$/,@changes) {
1.72 raeburn 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');
1.79.2.2 raeburn 1518: } elsif (($attr eq 'mysqltables') && ($shown eq '')) {
1519: $shown = &mt('domain default');
1.79.2.8! raeburn 1520: } elsif ($attr eq 'nopasswdchg') {
! 1521: if ($shown) {
! 1522: $shown = &mt('Yes');
! 1523: } else {
! 1524: $shown = &mt('No');
! 1525: }
1.72 raeburn 1526: }
1527: $chgresponse .= '<li>'.&mt('[_1] now set to: [_2]',$longtype{$attr},$shown).'</li>';
1.1 raeburn 1528: } else {
1.72 raeburn 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');
1.79.2.2 raeburn 1536: } elsif (($attr eq 'mysqltables') && ($shown eq '')) {
1537: $shown = &mt('domain default');
1.79.2.8! raeburn 1538: } elsif ($attr eq 'nopasswdchg') {
! 1539: if ($shown) {
! 1540: $shown = &mt('Yes');
! 1541: } else {
! 1542: $shown = &mt('No');
! 1543: }
1.72 raeburn 1544: }
1545: $nochgresponse .= '<li>'.&mt('[_1] still set to: [_2]',$longtype{$attr},$shown).'</li>';
1.1 raeburn 1546: }
1547: }
1.48 raeburn 1548: if (($type ne 'Community') && ($changed{'code'} || $changed{'owner'})) {
1.1 raeburn 1549: if ( $newattr{'courseowner'} eq '') {
1.48 raeburn 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.'));
1.1 raeburn 1552: } else {
1.59 raeburn 1553: my %crsenv = &Apache::lonnet::get('environment',['internal.co-owners'],$cdom,$cnum);
1554: my $coowners = $crsenv{'internal.co-owners'};
1.1 raeburn 1555: if (@sections > 0) {
1.38 raeburn 1556: if ($changed{'code'}) {
1.2 raeburn 1557: foreach my $sec (@sections) {
1558: if ($sec =~ m/^(.+):/) {
1.48 raeburn 1559: my $instsec = $1;
1.8 raeburn 1560: my $inst_course_id = $newattr{'coursecode'}.$1;
1.28 raeburn 1561: my $course_check = &Apache::lonnet::auto_validate_courseID($cnum,$cdom,$inst_course_id);
1.7 raeburn 1562: if ($course_check eq 'ok') {
1.58 raeburn 1563: my $outcome = &Apache::lonnet::auto_new_course($cnum,$cdom,$inst_course_id,$newattr{'courseowner'},$coowners);
1.48 raeburn 1564: unless ($outcome eq 'ok') {
1565:
1.53 raeburn 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/>');
1.1 raeburn 1567: }
1568: } else {
1.53 raeburn 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));
1.1 raeburn 1570: }
1571: } else {
1.48 raeburn 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));
1.1 raeburn 1573: }
1574: }
1.38 raeburn 1575: } elsif ($changed{'owner'}) {
1.4 raeburn 1576: foreach my $sec (@sections) {
1577: if ($sec =~ m/^(.+):/) {
1.48 raeburn 1578: my $instsec = $1;
1579: my $inst_course_id = $newattr{'coursecode'}.$instsec;
1.58 raeburn 1580: my $outcome = &Apache::lonnet::auto_new_course($cnum,$cdom,$inst_course_id,$newattr{'courseowner'},$coowners);
1.4 raeburn 1581: unless ($outcome eq 'ok') {
1.53 raeburn 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));
1.4 raeburn 1583: }
1584: } else {
1.53 raeburn 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));
1.4 raeburn 1586: }
1587: }
1588: }
1.1 raeburn 1589: } else {
1.53 raeburn 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'}));
1.1 raeburn 1591: }
1.38 raeburn 1592: if ( (@xlists > 0) && ($changed{'owner'}) ) {
1.1 raeburn 1593: foreach my $xlist (@xlists) {
1594: if ($xlist =~ m/^(.+):/) {
1.48 raeburn 1595: my $instxlist = $1;
1.58 raeburn 1596: my $outcome = &Apache::lonnet::auto_new_course($cnum,$cdom,$instxlist,$newattr{'courseowner'},$coowners);
1.1 raeburn 1597: unless ($outcome eq 'ok') {
1.48 raeburn 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));
1.1 raeburn 1599: }
1.28 raeburn 1600: }
1.1 raeburn 1601: }
1602: }
1603: }
1604: }
1605: }
1.2 raeburn 1606: } else {
1.28 raeburn 1607: foreach my $attr (@modifiable_params) {
1.72 raeburn 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');
1.79.2.3 raeburn 1615: } elsif (($attr eq 'mysqltables') && ($shown eq '')) {
1.79.2.2 raeburn 1616: $shown = &mt('domain default');
1.72 raeburn 1617: }
1618: $nochgresponse .= '<li>'.&mt('[_1] still set to: [_2]',$longtype{$attr},$shown).'</li>';
1.2 raeburn 1619: }
1.1 raeburn 1620: }
1621:
1622: if (@changes > 0) {
1623: $chgresponse .= "</ul><br/><br/>";
1624: }
1625: if (@nochanges > 0) {
1626: $nochgresponse .= "</ul><br/><br/>";
1627: }
1.48 raeburn 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>';
1.1 raeburn 1636: }
1.48 raeburn 1637: if ($response) {
1638: $reply = $response;
1639: } else {
1.1 raeburn 1640: $reply = $chgresponse.$nochgresponse.$warning;
1641: }
1.48 raeburn 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".
1.28 raeburn 1646: '<form action="/adm/modifycourse" method="post" name="processparms">'.
1.66 bisitz 1647: &hidden_form_elements();
1648: my @actions =
1649: ('<a href="javascript:changePage(document.processparms,'."'menu'".')">'.
1650: &mt('Pick another action').'</a>');
1.48 raeburn 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:
1.66 bisitz 1656: push(@actions, '<a href="'.$escuri.'">'.
1657: &mt('Go to Automated Enrollment Manager for course').'</a>');
1.48 raeburn 1658: }
1.66 bisitz 1659: $reply .= &Apache::lonhtmlcommon::actionbox(\@actions).'</form>';
1.3 raeburn 1660: $r->print($reply);
1.28 raeburn 1661: return;
1662: }
1663:
1.72 raeburn 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:
1.50 raeburn 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;
1.51 raeburn 1692: my @types = ('co-owners');
1.50 raeburn 1693: if (($newattr->{'coursecode'}) && ($autocoowners)) {
1694: my $oldowner = $settings->{'internal.courseowner'};
1695: if ($cchash{$oldowner.':cc'}) {
1.51 raeburn 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 {
1.50 raeburn 1704: $oldowner_to_coowner = 1;
1705: }
1706: }
1707: }
1.51 raeburn 1708: } else {
1709: push(@types,'pendingco-owners');
1.50 raeburn 1710: }
1.51 raeburn 1711: foreach my $type (@types) {
1.50 raeburn 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: );
1.52 raeburn 1746: my $putresult = &Apache::lonnet::put('environment',\%pendinghash,$cdom,$cnum);
1.50 raeburn 1747: if ($putresult eq 'ok') {
1748: if ($env{'course.'.$cid.'.num'} eq $cnum) {
1.52 raeburn 1749: &Apache::lonnet::appenv({'course.'.$cid.'.internal.pendingco-owners' => $pendingcoowners});
1.50 raeburn 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'}) {
1.58 raeburn 1778: my @currcoown = split(',',$settings->{'internal.co-owners'});
1.50 raeburn 1779: my ($updatecoowners,$delcoowners);
1780: foreach my $person (@currcoown) {
1.51 raeburn 1781: my ($result,$desc) = &Apache::lonnet::auto_validate_instcode($cnum,$cdom,$newattr->{'coursecode'},$person);
1.50 raeburn 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);
1.51 raeburn 1788: next if ($uname.':'.$udom eq $newattr->{'courseowner'});
1.50 raeburn 1789: unless (grep(/^\Q$uname\E:\Q$udom\E$/,@newcoowners)) {
1.51 raeburn 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: }
1.50 raeburn 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:
1.28 raeburn 1824: sub modify_quota {
1.48 raeburn 1825: my ($r,$cdom,$cnum,$cdesc,$domdesc,$type) = @_;
1826: &print_header($r,$type);
1.61 raeburn 1827: my $lctype = lc($type);
1828: my $headline = &mt("Disk space quotas for $lctype: [_1]",
1829: '<span class="LC_nobreak">'.$cdesc.'</span>');
1.48 raeburn 1830: $r->print('<form action="/adm/modifycourse" method="post" name="processquota">'."\n".
1.61 raeburn 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: }
1.28 raeburn 1860: } else {
1.61 raeburn 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 {
1.48 raeburn 1885: if ($type eq 'Community') {
1.61 raeburn 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 />');
1.48 raeburn 1888: } else {
1.61 raeburn 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 />');
1.48 raeburn 1891: }
1.61 raeburn 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') {
1.67 bisitz 1909: $r->print(&mt("Disk usage $newoverquota exceeds the quota for this community.").' '.
1.61 raeburn 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.'));
1.28 raeburn 1911: } else {
1.67 bisitz 1912: $r->print(&mt("Disk usage $newoverquota exceeds the quota for this course.").' '.
1.61 raeburn 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.'));
1.28 raeburn 1914: }
1.61 raeburn 1915: $r->print('</p>');
1.28 raeburn 1916: }
1917: }
1.61 raeburn 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: }
1.28 raeburn 1922: } else {
1.63 raeburn 1923: $r->print(&mt('An error occurred storing the quota(s) for group portfolio files and/or uploaded content: ').
1.61 raeburn 1924: $putreply);
1.28 raeburn 1925: }
1926: }
1.48 raeburn 1927: $r->print('<p>'.
1928: '<a href="javascript:changePage(document.processquota,'."'menu'".')">'.
1929: &mt('Pick another action').'</a>');
1.28 raeburn 1930: $r->print(&hidden_form_elements().'</form>');
1931: return;
1.1 raeburn 1932: }
1933:
1.57 raeburn 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);
1.72 raeburn 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: }
1.57 raeburn 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'".')">'.
1.75 raeburn 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') {
1.76 droeschl 2057: $r->print(&mt('Submit button will not be disabled after student submission'));
1.75 raeburn 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>');
1.57 raeburn 2068: $r->print(&hidden_form_elements().'</form>');
2069: return;
2070: }
2071:
1.38 raeburn 2072: sub modify_catsettings {
1.48 raeburn 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: }
1.38 raeburn 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);
1.49 raeburn 2089: my @cat_params = &catalog_settable($domconf{'coursecategories'},$type);
1.38 raeburn 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') {
1.72 raeburn 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: }
1.38 raeburn 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: }
1.48 raeburn 2177: $r->print(&mt('The following changes occurred:').'<ul>');
1.38 raeburn 2178: foreach my $item (@changes) {
1.48 raeburn 2179: $r->print('<li>'.&mt('[_1] now set to: [_2]',$desc{$item},$showitem{$item}).'</li>');
1.38 raeburn 2180: }
2181: $r->print('</ul><br />');
2182: }
2183: }
2184: if (@nochanges > 0) {
1.48 raeburn 2185: $r->print(&mt('The following were unchanged:').'<ul>');
1.38 raeburn 2186: foreach my $item (@nochanges) {
1.48 raeburn 2187: $r->print('<li>'.&mt('[_1] still set to: [_2]',$desc{$item},$showitem{$item}).'</li>');
1.38 raeburn 2188: }
2189: $r->print('</ul>');
2190: }
2191: }
2192: } else {
1.48 raeburn 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: }
1.38 raeburn 2201: }
2202: $r->print('<br />'."\n".
2203: '<a href="javascript:changePage(document.processcat,'."'menu'".')">'.
1.48 raeburn 2204: &mt('Pick another action').'</a>');
1.38 raeburn 2205: $r->print(&hidden_form_elements().'</form>');
2206: return;
2207: }
2208:
1.1 raeburn 2209: sub print_header {
1.48 raeburn 2210: my ($r,$type,$javascript_validations) = @_;
1.28 raeburn 2211: my $phase = "start";
2212: if ( exists($env{'form.phase'}) ) {
2213: $phase = $env{'form.phase'};
2214: }
2215: my $js = qq|
1.60 raeburn 2216:
1.28 raeburn 2217: function changePage(formname,newphase) {
2218: formname.phase.value = newphase;
2219: if (newphase == 'processparms') {
2220: return;
1.1 raeburn 2221: }
1.28 raeburn 2222: formname.submit();
2223: }
1.60 raeburn 2224:
1.28 raeburn 2225: |;
2226: if ($phase eq 'setparms') {
1.60 raeburn 2227: $js .= $javascript_validations;
1.28 raeburn 2228: } elsif ($phase eq 'courselist') {
1.79.2.5 raeburn 2229: $js .= <<"ENDJS";
1.60 raeburn 2230: function hide_searching() {
2231: if (document.getElementById('searching')) {
2232: document.getElementById('searching').style.display = 'none';
2233: }
2234: return;
2235: }
2236:
1.79.2.5 raeburn 2237: ENDJS
1.28 raeburn 2238: } elsif ($phase eq 'setquota') {
1.57 raeburn 2239: my $invalid = &mt('The quota you entered contained invalid characters.');
2240: my $alert = &mt('You must enter a number');
1.78 damieng 2241: &js_escape(\$invalid);
2242: &js_escape(\$alert);
1.57 raeburn 2243: my $regexp = '/^\s*(\d+\.?\d*|\.\d+)\s*$/';
2244: $js .= <<"ENDSCRIPT";
1.60 raeburn 2245:
1.57 raeburn 2246: function verify_quota() {
2247: var newquota = document.setquota.coursequota.value;
2248: var num_reg = $regexp;
1.28 raeburn 2249: if (num_reg.test(newquota)) {
1.57 raeburn 2250: changePage(document.setquota,'processquota');
1.1 raeburn 2251: } else {
1.57 raeburn 2252: alert("$invalid\\n$alert");
2253: return false;
1.1 raeburn 2254: }
1.57 raeburn 2255: return true;
2256: }
1.60 raeburn 2257:
1.57 raeburn 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.');
1.78 damieng 2262: &js_escape(\$invalid);
2263: &js_escape(\$alert);
1.57 raeburn 2264: my $regexp = ' /^\s*\d+\s*$/';
2265: $js .= <<"ENDSCRIPT";
1.60 raeburn 2266:
1.57 raeburn 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;
1.28 raeburn 2282: }
1.60 raeburn 2283:
1.28 raeburn 2284: ENDSCRIPT
1.75 raeburn 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');
1.78 damieng 2289: &js_escape(\$invalid);
2290: &js_escape(\$invalidtimeout);
2291: &js_escape(\$alert);
1.75 raeburn 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: }
1.1 raeburn 2358: }
1.75 raeburn 2359: return;
2360: }
1.60 raeburn 2361:
1.75 raeburn 2362: ENDSCRIPT
2363:
2364: }
1.37 raeburn 2365: my $starthash;
1.79.2.3 raeburn 2366: if ($env{'form.phase'} eq 'adhocrole') {
1.37 raeburn 2367: $starthash = {
1.79.2.3 raeburn 2368: add_entries => {'onload' => "javascript:document.adhocrole.submit();"},
1.37 raeburn 2369: };
1.60 raeburn 2370: } elsif ($phase eq 'courselist') {
2371: $starthash = {
1.74 musolffc 2372: add_entries => {'onload' => "hide_searching(); courseSet(document.filterpicker.official, 'load');"},
1.60 raeburn 2373: };
1.37 raeburn 2374: }
1.48 raeburn 2375: $r->print(&Apache::loncommon::start_page('View/Modify Course/Community Settings',
1.60 raeburn 2376: &Apache::lonhtmlcommon::scripttag($js),
2377: $starthash));
1.48 raeburn 2378: my $bread_text = "View/Modify Courses/Communities";
2379: if ($type eq 'Community') {
2380: $bread_text = 'Community Settings';
1.41 raeburn 2381: } else {
1.48 raeburn 2382: $bread_text = 'Course Settings';
1.41 raeburn 2383: }
1.48 raeburn 2384: $r->print(&Apache::lonhtmlcommon::breadcrumbs($bread_text));
1.5 raeburn 2385: return;
1.1 raeburn 2386: }
2387:
2388: sub print_footer {
1.23 albertel 2389: my ($r) = @_;
2390: $r->print('<br />'.&Apache::loncommon::end_page());
1.5 raeburn 2391: return;
1.3 raeburn 2392: }
2393:
2394: sub check_course {
1.71 raeburn 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';
1.5 raeburn 2420: }
1.3 raeburn 2421: }
2422: }
1.71 raeburn 2423: return ($ok_course,$description,\%coursehash);
1.1 raeburn 2424: }
2425:
1.28 raeburn 2426: sub course_settings_descrip {
1.48 raeburn 2427: my ($type) = @_;
2428: my %longtype;
2429: if ($type eq 'Community') {
2430: %longtype = &Apache::lonlocal::texthash(
1.72 raeburn 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",
1.79.2.3 raeburn 2435: 'mysqltables' => '"Temporary" student performance tables lifetime (seconds)',
1.48 raeburn 2436: );
2437: } else {
2438: %longtype = &Apache::lonlocal::texthash(
1.28 raeburn 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",
1.50 raeburn 2449: 'co-owners' => "Username:domain of each co-owner",
1.28 raeburn 2450: 'notifylist' => 'Course Coordinators to be notified of enrollment changes',
1.48 raeburn 2451: 'sectionnums' => 'Course section number:LON-CAPA section',
2452: 'crosslistings' => 'Crosslisted class:LON-CAPA section',
1.72 raeburn 2453: 'defaultcredits' => 'Credits',
1.79.2.1 raeburn 2454: 'autodropfailsafe' => "Failsafe section enrollment count",
1.72 raeburn 2455: 'selfenrollmgrdc' => "Course-specific self-enrollment configuration by Domain Coordinator",
2456: 'selfenrollmgrcc' => "Course-specific self-enrollment configuration by Course personnel",
1.79.2.2 raeburn 2457: 'mysqltables' => '"Temporary" student performance tables lifetime (seconds)',
1.79.2.8! raeburn 2458: 'nopasswdchg' => 'Disable changing password for users with student role by course owner',
1.48 raeburn 2459: );
2460: }
1.28 raeburn 2461: return %longtype;
2462: }
2463:
2464: sub hidden_form_elements {
2465: my $hidden_elements =
1.46 raeburn 2466: &Apache::lonhtmlcommon::echo_form_input(['gosearch','updater','coursecode',
1.37 raeburn 2467: 'prevphase','numlocalcc','courseowner','login','coursequota','intarg',
1.57 raeburn 2468: 'locarg','krbarg','krbver','counter','hidefromcat','usecategory',
1.75 raeburn 2469: 'threshold','postsubmit','postsubtimeout','defaultcredits','uploadquota',
2470: 'selfenrollmgrdc','selfenrollmgrcc','action','state','currsec_st',
1.79.2.8! raeburn 2471: 'sections','newsec','mysqltables','nopasswdchg'],
! 2472: ['^selfenrollmgr_','^selfenroll_'])."\n".
1.37 raeburn 2473: '<input type="hidden" name="prevphase" value="'.$env{'form.phase'}.'" />';
1.28 raeburn 2474: return $hidden_elements;
2475: }
1.1 raeburn 2476:
1.60 raeburn 2477: sub showcredits {
2478: my ($dom) = @_;
2479: my %domdefaults = &Apache::lonnet::get_domain_defaults($dom);
1.79 raeburn 2480: if ($domdefaults{'officialcredits'} || $domdefaults{'unofficialcredits'} || $domdefaults{'textbookcredits'}) {
1.60 raeburn 2481: return 1;
2482: }
2483: }
2484:
1.79.2.3 raeburn 2485: sub get_permission {
2486: my ($dom) = @_;
2487: my ($allowed,%permission);
1.79.2.8! raeburn 2488: my %passwdconf = &Apache::lonnet::get_passwdconf($dom);
1.79.2.3 raeburn 2489: if (&Apache::lonnet::allowed('ccc',$dom)) {
2490: $allowed = 1;
2491: %permission = (
1.79.2.4 raeburn 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',
1.79.2.5 raeburn 2504: adhocrole => 'coord',
1.79.2.3 raeburn 2505: );
1.79.2.8! raeburn 2506: if ($passwdconf{'crsownerchg'}) {
! 2507: $permission{passwdchg} = 'edit';
! 2508: }
1.79.2.3 raeburn 2509: } elsif (&Apache::lonnet::allowed('rar',$dom)) {
2510: $allowed = 1;
2511: %permission = (
1.79.2.4 raeburn 2512: setquota => 'view',
2513: viewparms => 'view',
2514: setanon => 'view',
2515: setpostsubmit => 'view',
2516: setparms => 'view',
2517: catsettings => 'view',
2518: selfenroll => 'view',
1.79.2.5 raeburn 2519: adhocrole => 'custom',
1.79.2.3 raeburn 2520: );
1.79.2.8! raeburn 2521: if ($passwdconf{'crsownerchg'}) {
! 2522: $permission{passwdchg} = 'view';
! 2523: }
1.79.2.3 raeburn 2524: }
2525: return ($allowed,\%permission);
2526: }
2527:
1.79.2.7 raeburn 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:
1.1 raeburn 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: }
1.72 raeburn 2551:
1.79.2.7 raeburn 2552: $registered_cleanup=0;
2553: $modified_dom = '';
2554:
1.28 raeburn 2555: my $dom = $env{'request.role.domain'};
1.31 albertel 2556: my $domdesc = &Apache::lonnet::domain($dom,'description');
1.79.2.3 raeburn 2557: my ($allowed,$permission) = &get_permission($dom);
2558: if ($allowed) {
1.1 raeburn 2559: &Apache::loncommon::content_type($r,'text/html');
2560: $r->send_http_header;
2561:
1.28 raeburn 2562: &Apache::lonhtmlcommon::clear_breadcrumbs();
2563:
2564: my $phase = $env{'form.phase'};
1.46 raeburn 2565: if ($env{'form.updater'}) {
2566: $phase = '';
2567: }
1.37 raeburn 2568: if ($phase eq '') {
2569: &Apache::lonhtmlcommon::add_breadcrumb
1.28 raeburn 2570: ({href=>"/adm/modifycourse",
1.48 raeburn 2571: text=>"Course/Community search"});
1.28 raeburn 2572: &print_course_search_page($r,$dom,$domdesc);
1.1 raeburn 2573: } else {
1.37 raeburn 2574: my $firstform = $phase;
2575: if ($phase eq 'courselist') {
2576: $firstform = 'filterpicker';
1.48 raeburn 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";
1.37 raeburn 2587: }
1.28 raeburn 2588: &Apache::lonhtmlcommon::add_breadcrumb
1.37 raeburn 2589: ({href=>"javascript:changePage(document.$firstform,'')",
1.48 raeburn 2590: text=>"Course/Community search"},
1.37 raeburn 2591: {href=>"javascript:changePage(document.$phase,'courselist')",
1.48 raeburn 2592: text=>$choose_text});
1.28 raeburn 2593: if ($phase eq 'courselist') {
1.79.2.5 raeburn 2594: &print_course_selection_page($r,$dom,$domdesc,$permission);
1.28 raeburn 2595: } else {
1.71 raeburn 2596: my ($checked,$cdesc,$coursehash) = &check_course($dom,$domdesc);
1.28 raeburn 2597: if ($checked eq 'ok') {
1.48 raeburn 2598: my $enter_text;
2599: if ($type eq 'Community') {
2600: $enter_text = 'Enter community';
2601: } else {
2602: $enter_text = 'Enter course';
2603: }
1.28 raeburn 2604: if ($phase eq 'menu') {
1.37 raeburn 2605: &Apache::lonhtmlcommon::add_breadcrumb
2606: ({href=>"javascript:changePage(document.$phase,'menu')",
2607: text=>"Pick action"});
1.71 raeburn 2608: &print_modification_menu($r,$cdesc,$domdesc,$dom,$type,
1.79.2.3 raeburn 2609: $env{'form.pickedcourse'},$coursehash,
2610: $permission);
2611: } elsif ($phase eq 'adhocrole') {
1.37 raeburn 2612: &Apache::lonhtmlcommon::add_breadcrumb
1.79.2.3 raeburn 2613: ({href=>"javascript:changePage(document.$phase,'adhocrole')",
1.48 raeburn 2614: text=>$enter_text});
1.79.2.5 raeburn 2615: &print_adhocrole_selected($r,$type,$permission);
1.28 raeburn 2616: } else {
1.37 raeburn 2617: &Apache::lonhtmlcommon::add_breadcrumb
2618: ({href=>"javascript:changePage(document.$phase,'menu')",
2619: text=>"Pick action"});
1.28 raeburn 2620: my ($cdom,$cnum) = split(/_/,$env{'form.pickedcourse'});
1.79.2.4 raeburn 2621: my ($readonly,$linktext);
2622: if ($permission->{$phase} eq 'view') {
2623: $readonly = 1;
2624: }
1.79.2.3 raeburn 2625: if (($phase eq 'setquota') && ($permission->{'setquota'})) {
1.79.2.4 raeburn 2626: if ($permission->{'setquota'} eq 'view') {
2627: $linktext = 'Set quota';
2628: } else {
2629: $linktext = 'Display quota';
2630: }
1.28 raeburn 2631: &Apache::lonhtmlcommon::add_breadcrumb
2632: ({href=>"javascript:changePage(document.$phase,'$phase')",
1.79.2.4 raeburn 2633: text=>$linktext});
2634: &print_setquota($r,$cdom,$cnum,$cdesc,$type,$readonly);
1.79.2.3 raeburn 2635: } elsif (($phase eq 'processquota') && ($permission->{'processquota'})) {
1.28 raeburn 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"});
1.48 raeburn 2642: &modify_quota($r,$cdom,$cnum,$cdesc,$domdesc,$type);
1.79.2.3 raeburn 2643: } elsif (($phase eq 'setanon') && ($permission->{'setanon'})) {
1.57 raeburn 2644: &Apache::lonhtmlcommon::add_breadcrumb
2645: ({href=>"javascript:changePage(document.$phase,'$phase')",
2646: text=>"Threshold for anonymous submissions display"});
1.79.2.4 raeburn 2647: &print_set_anonsurvey_threshold($r,$cdom,$cnum,$cdesc,$type,$readonly);
1.79.2.3 raeburn 2648: } elsif (($phase eq 'processthreshold') && ($permission->{'processthreshold'})) {
1.57 raeburn 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);
1.79.2.3 raeburn 2656: } elsif (($phase eq 'setpostsubmit') && ($permission->{'setpostsubmit'})) {
1.79.2.4 raeburn 2657: if ($permission->{'setpostsubmit'} eq 'view') {
2658: $linktext = 'Submit button behavior post-submission';
2659: } else {
2660: $linktext = 'Configure submit button behavior post-submission';
2661: }
1.75 raeburn 2662: &Apache::lonhtmlcommon::add_breadcrumb
2663: ({href=>"javascript:changePage(document.$phase,'$phase')",
1.79.2.4 raeburn 2664: text=>$linktext});
2665: &print_postsubmit_config($r,$cdom,$cnum,$cdesc,$type,$readonly);
1.79.2.3 raeburn 2666: } elsif (($phase eq 'processpostsubmit') && ($permission->{'processpostsubmit'})) {
1.75 raeburn 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);
1.79.2.3 raeburn 2671: } elsif (($phase eq 'viewparms') && ($permission->{'viewparms'})) {
1.28 raeburn 2672: &Apache::lonhtmlcommon::add_breadcrumb
2673: ({href=>"javascript:changePage(document.$phase,'viewparms')",
2674: text=>"Display settings"});
1.79.2.3 raeburn 2675: &print_settings_display($r,$cdom,$cnum,$cdesc,$type,$permission);
2676: } elsif (($phase eq 'setparms') && ($permission->{'setparms'})) {
1.79.2.4 raeburn 2677: if ($permission->{'setparms'} eq 'view') {
2678: $linktext = 'Display settings';
2679: } else {
2680: $linktext = 'Change settings';
2681: }
1.28 raeburn 2682: &Apache::lonhtmlcommon::add_breadcrumb
2683: ({href=>"javascript:changePage(document.$phase,'$phase')",
1.79.2.4 raeburn 2684: text=>$linktext});
2685: &print_course_modification_page($r,$cdom,$cnum,$cdesc,$type,$readonly);
1.79.2.3 raeburn 2686: } elsif (($phase eq 'processparms') && ($permission->{'processparms'})) {
1.28 raeburn 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"});
1.30 raeburn 2693: &modify_course($r,$cdom,$cnum,$cdesc,$domdesc,$type);
1.79.2.3 raeburn 2694: } elsif (($phase eq 'catsettings') && ($permission->{'catsettings'})) {
1.38 raeburn 2695: &Apache::lonhtmlcommon::add_breadcrumb
2696: ({href=>"javascript:changePage(document.$phase,'$phase')",
2697: text=>"Catalog settings"});
1.79.2.4 raeburn 2698: &print_catsettings($r,$cdom,$cnum,$cdesc,$type,$readonly);
1.79.2.3 raeburn 2699: } elsif (($phase eq 'processcat') && ($permission->{'processcat'})) {
1.38 raeburn 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"});
1.48 raeburn 2706: &modify_catsettings($r,$cdom,$cnum,$cdesc,$domdesc,$type);
1.79.2.3 raeburn 2707: } elsif (($phase eq 'selfenroll') && ($permission->{'selfenroll'})) {
1.72 raeburn 2708: &Apache::lonhtmlcommon::add_breadcrumb
2709: ({href => "javascript:changePage(document.$phase,'$phase')",
2710: text => "Self-enrollment settings"});
2711: if (!exists($env{'form.state'})) {
1.79.2.4 raeburn 2712: &print_selfenrollconfig($r,$type,$cdesc,$coursehash,$readonly);
1.72 raeburn 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: }
1.28 raeburn 2719: }
2720: }
2721: } else {
1.48 raeburn 2722: $r->print('<span class="LC_error">');
2723: if ($type eq 'Community') {
1.72 raeburn 2724: $r->print(&mt('The community you selected is not a valid community in this domain'));
2725: } else {
1.48 raeburn 2726: $r->print(&mt('The course you selected is not a valid course in this domain'));
2727: }
2728: $r->print(" ($domdesc)</span>");
1.28 raeburn 2729: }
2730: }
1.1 raeburn 2731: }
1.28 raeburn 2732: &print_footer($r);
1.1 raeburn 2733: } else {
1.16 albertel 2734: $env{'user.error.msg'}=
1.48 raeburn 2735: "/adm/modifycourse:ccc:0:0:Cannot modify course/community settings";
1.1 raeburn 2736: return HTTP_NOT_ACCEPTABLE;
2737: }
2738: return OK;
2739: }
2740:
2741: 1;
2742: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>