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