Annotation of loncom/interface/lonmodifycourse.pm, revision 1.96
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.96 ! raeburn 4: # $Id: lonmodifycourse.pm,v 1.95 2019/07/25 20:23:52 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.96 ! raeburn 687: my $shown = $enrollvar{$item};
! 688: if ($item eq 'crosslistings') {
! 689: my (@xlists,@lcsecs);
! 690: foreach my $entry (split(/,/,$enrollvar{$item})) {
! 691: my ($xlist,$lc_sec) = split(/:/,$entry);
! 692: push(@xlists,$xlist);
! 693: push(@lcsecs,$lc_sec);
! 694: }
! 695: if (@xlists) {
! 696: my $crskey = $cnum.':'.$enrollvar{'coursecode'};
! 697: my %reformatted =
! 698: &Apache::lonnet::auto_instsec_reformat($cdom,'declutter',
! 699: {$crskey => \@xlists});
! 700: if (ref($reformatted{$crskey}) eq 'ARRAY') {
! 701: my @show;
! 702: my @xlcodes = @{$reformatted{$crskey}};
! 703: for (my $i=0; $i<@xlcodes; $i++) {
! 704: push(@show,$xlcodes[$i].':'.$lcsecs[$i]);
! 705: }
! 706: if (@show) {
! 707: $shown = join(',',@show);
! 708: }
! 709: }
! 710: }
! 711: }
1.28 raeburn 712: $disp_table .= &Apache::loncommon::start_data_table_row()."\n".
1.48 raeburn 713: "<td><b>$longtype{$item}</b></td>\n".
1.96 ! raeburn 714: "<td>$shown</td>\n";
1.48 raeburn 715: if (grep(/^\Q$item\E$/,@modifiable_params)) {
1.50 raeburn 716: $disp_table .= '<td align="right">'.&mt('Yes').'</td>'."\n";
1.28 raeburn 717: } else {
1.48 raeburn 718: $disp_table .= '<td align="right">'.&mt('No').'</td>'."\n";
1.28 raeburn 719: }
720: $disp_table .= &Apache::loncommon::end_data_table_row()."\n";
1.3 raeburn 721: }
1.28 raeburn 722: $disp_table .= &Apache::loncommon::end_data_table()."\n";
1.48 raeburn 723: &print_header($r,$type);
1.86 raeburn 724: my ($enroll_link_start,$enroll_link_end,$setparms_link_start,$setparms_link_end);
725: if (&Apache::lonnet::allowed('ccc',$cdom)) {
726: my $newrole = $ccrole.'./'.$cdom.'/'.$cnum;
727: my $escuri = &HTML::Entities::encode('/adm/roles?selectrole=1&'.$newrole.
728: '=1&destinationurl=/adm/populate','&<>"');
729: $enroll_link_start = '<a href="'.$escuri.'">';
730: $enroll_link_end = '</a>';
731: }
732: if ($permission->{'setparms'}) {
733: $setparms_link_start = '<a href="javascript:changePage(document.viewparms,'."'setparms'".');">';
734: $setparms_link_end = '</a>';
735: }
1.48 raeburn 736: $r->print('<h3>'.&mt('Current automated enrollment settings for:').
737: ' <span class="LC_nobreak">'.$cdesc.'</span></h3>'.
738: '<form action="/adm/modifycourse" method="post" name="viewparms">'."\n".
739: '<p>'.$lt{'cose'}.'<ul>'.
1.86 raeburn 740: '<li>'.&mt('Settings modifiable by a [_1] via the [_2]Automated Enrollment Manager[_3] in a course.',
741: $cctitle,$enroll_link_start,$enroll_link_end).'</li>');
1.60 raeburn 742: if (&showcredits($cdom)) {
1.86 raeburn 743: $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 744: } else {
1.86 raeburn 745: $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 746: }
747: $r->print('</li></ul></p>'.
1.48 raeburn 748: '<p>'.$lt{'cour'}.'</p><p>'.$disp_table.'</p><p>'.
749: '<a href="javascript:changePage(document.viewparms,'."'menu'".')">'.$lt{'back'}.'</a>'."\n".
750: &hidden_form_elements().
751: '</p></form>'
1.86 raeburn 752: );
1.28 raeburn 753: }
1.3 raeburn 754:
1.28 raeburn 755: sub print_setquota {
1.88 raeburn 756: my ($r,$cdom,$cnum,$cdesc,$type,$readonly) = @_;
1.61 raeburn 757: my $lctype = lc($type);
758: my $headline = &mt("Set disk space quotas for $lctype: [_1]",
759: '<span class="LC_nobreak">'.$cdesc.'</span>');
1.28 raeburn 760: my %lt = &Apache::lonlocal::texthash(
1.61 raeburn 761: 'gpqu' => 'Disk space for storage of group portfolio files',
762: 'upqu' => 'Disk space for storage of content directly uploaded to course via Content Editor',
1.42 schafran 763: 'modi' => 'Save',
1.48 raeburn 764: 'back' => 'Pick another action',
1.28 raeburn 765: );
1.61 raeburn 766: my %staticdefaults = (
767: coursequota => 20,
768: uploadquota => 500,
769: );
1.68 raeburn 770: my %settings = &Apache::lonnet::get('environment',['internal.coursequota','internal.uploadquota','internal.coursecode'],
1.61 raeburn 771: $cdom,$cnum);
1.28 raeburn 772: my $coursequota = $settings{'internal.coursequota'};
1.61 raeburn 773: my $uploadquota = $settings{'internal.uploadquota'};
1.28 raeburn 774: if ($coursequota eq '') {
1.61 raeburn 775: $coursequota = $staticdefaults{'coursequota'};
776: }
777: if ($uploadquota eq '') {
778: my %domdefs = &Apache::lonnet::get_domain_defaults($cdom);
1.72 raeburn 779: my $quotatype = &Apache::lonuserutils::get_extended_type($cdom,$cnum,$type,\%settings);
780: $uploadquota = $domdefs{$quotatype.'quota'};
1.61 raeburn 781: if ($uploadquota eq '') {
782: $uploadquota = $staticdefaults{'uploadquota'};
783: }
1.3 raeburn 784: }
1.48 raeburn 785: &print_header($r,$type);
1.28 raeburn 786: my $hidden_elements = &hidden_form_elements();
1.61 raeburn 787: my $porthelpitem = &Apache::loncommon::help_open_topic('Modify_Course_Quota');
788: my $uploadhelpitem = &Apache::loncommon::help_open_topic('Modify_Course_Upload_Quota');
1.88 raeburn 789: my ($disabled,$submit);
790: if ($readonly) {
791: $disabled = ' disabled="disabled"';
792: } else {
793: $submit = '<input type="submit" value="'.$lt{'modi'}.'" />';
794: }
1.28 raeburn 795: $r->print(<<ENDDOCUMENT);
1.57 raeburn 796: <form action="/adm/modifycourse" method="post" name="setquota" onsubmit="return verify_quota();">
1.61 raeburn 797: <h3>$headline</h3>
798: <p><span class="LC_nobreak">
1.88 raeburn 799: $porthelpitem $lt{'gpqu'}: <input type="text" size="4" name="coursequota" value="$coursequota" $disabled /> MB
1.61 raeburn 800: </span>
801: <br />
802: <span class="LC_nobreak">
1.88 raeburn 803: $uploadhelpitem $lt{'upqu'}: <input type="text" size="4" name="uploadquota" value="$uploadquota" $disabled /> MB
1.61 raeburn 804: </span>
805: </p>
1.28 raeburn 806: <p>
1.88 raeburn 807: $submit
1.28 raeburn 808: </p>
809: $hidden_elements
810: <a href="javascript:changePage(document.setquota,'menu')">$lt{'back'}</a>
811: </form>
812: ENDDOCUMENT
813: return;
814: }
1.3 raeburn 815:
1.57 raeburn 816: sub print_set_anonsurvey_threshold {
1.88 raeburn 817: my ($r,$cdom,$cnum,$cdesc,$type,$readonly) = @_;
1.57 raeburn 818: my %lt = &Apache::lonlocal::texthash(
819: 'resp' => 'Responder threshold for anonymous survey submissions display:',
820: 'sufa' => 'Anonymous survey submissions displayed when responders exceeds',
821: 'modi' => 'Save',
822: 'back' => 'Pick another action',
823: );
824: my %settings = &Apache::lonnet::get('environment',['internal.anonsurvey_threshold'],$cdom,$cnum);
825: my $threshold = $settings{'internal.anonsurvey_threshold'};
826: if ($threshold eq '') {
827: my %domconfig =
828: &Apache::lonnet::get_dom('configuration',['coursedefaults'],$cdom);
829: if (ref($domconfig{'coursedefaults'}) eq 'HASH') {
830: $threshold = $domconfig{'coursedefaults'}{'anonsurvey_threshold'};
831: if ($threshold eq '') {
832: $threshold = 10;
833: }
834: } else {
835: $threshold = 10;
836: }
837: }
838: &print_header($r,$type);
839: my $hidden_elements = &hidden_form_elements();
1.88 raeburn 840: my ($disabled,$submit);
841: if ($readonly) {
842: $disabled = ' disabled="disabled"';
843: } else {
844: $submit = '<input type="submit" value="'.$lt{'modi'}.'" />';
845: }
1.57 raeburn 846: my $helpitem = &Apache::loncommon::help_open_topic('Modify_Anonsurvey_Threshold');
847: $r->print(<<ENDDOCUMENT);
848: <form action="/adm/modifycourse" method="post" name="setanon" onsubmit="return verify_anon_threshold();">
849: <h3>$lt{'resp'} <span class="LC_nobreak">$cdesc</span></h3>
850: <p>
1.88 raeburn 851: $helpitem $lt{'sufa'}: <input type="text" size="4" name="threshold" value="$threshold" $disabled />
852: $submit
1.57 raeburn 853: </p>
854: $hidden_elements
855: <a href="javascript:changePage(document.setanon,'menu')">$lt{'back'}</a>
856: </form>
857: ENDDOCUMENT
858: return;
859: }
860:
1.75 raeburn 861: sub print_postsubmit_config {
1.88 raeburn 862: my ($r,$cdom,$cnum,$cdesc,$type,$readonly) = @_;
1.75 raeburn 863: my %lt = &Apache::lonlocal::texthash (
864: 'conf' => 'Configure submit button behavior after student makes a submission',
865: 'disa' => 'Disable submit button/keypress following student submission',
866: 'nums' => 'Number of seconds submit is disabled',
867: 'modi' => 'Save',
868: 'back' => 'Pick another action',
869: 'yes' => 'Yes',
870: 'no' => 'No',
871: );
872: my %settings = &Apache::lonnet::get('environment',['internal.postsubmit','internal.postsubtimeout',
873: 'internal.coursecode','internal.textbook'],$cdom,$cnum);
874: my $postsubmit = $settings{'internal.postsubmit'};
875: if ($postsubmit eq '') {
876: my %domconfig =
877: &Apache::lonnet::get_dom('configuration',['coursedefaults'],$cdom);
878: $postsubmit = 1;
879: if (ref($domconfig{'coursedefaults'}) eq 'HASH') {
880: if (ref($domconfig{'coursedefaults'}{'postsubmit'}) eq 'HASH') {
881: if ($domconfig{'coursedefaults'}{'postsubmit'}{'client'} eq 'off') {
882: $postsubmit = 0;
883: }
884: }
885: }
886: }
887: my ($checkedon,$checkedoff,$display);
888: if ($postsubmit) {
889: $checkedon = 'checked="checked"';
890: $display = 'block';
891: } else {
892: $checkedoff = 'checked="checked"';
893: $display = 'none';
894: }
895: my $postsubtimeout = $settings{'internal.postsubtimeout'};
896: my $default = &domain_postsubtimeout($cdom,$type,\%settings);
897: my $zero = &mt('(Enter 0 to disable until next page reload, or leave blank to use the domain default: [_1])',$default);
898: if ($postsubtimeout eq '') {
899: $postsubtimeout = $default;
900: }
901: &print_header($r,$type);
902: my $hidden_elements = &hidden_form_elements();
1.88 raeburn 903: my ($disabled,$submit);
904: if ($readonly) {
905: $disabled = ' disabled="disabled"';
906: } else {
907: $submit = '<input type="submit" value="'.$lt{'modi'}.'" />';
908: }
1.75 raeburn 909: my $helpitem = &Apache::loncommon::help_open_topic('Modify_Postsubmit_Config');
910: $r->print(<<ENDDOCUMENT);
911: <form action="/adm/modifycourse" method="post" name="setpostsubmit" onsubmit="return verify_postsubmit();">
912: <h3>$lt{'conf'} <span class="LC_nobreak">($cdesc)</span></h3>
913: <p>
914: $helpitem $lt{'disa'}:
1.88 raeburn 915: <label><input type="radio" name="postsubmit" $checkedon onclick="togglePostsubmit('studentsubmission');" value="1" $disabled />
1.75 raeburn 916: $lt{'yes'}</label>
1.89 raeburn 917: <label><input type="radio" name="postsubmit" $checkedoff onclick="togglePostsubmit('studentsubmission');" value="0" $disabled />
1.75 raeburn 918: $lt{'no'}</label>
919: <div id="studentsubmission" style="display: $display">
1.88 raeburn 920: $lt{'nums'} <input type="text" name="postsubtimeout" value="$postsubtimeout" $disabled /><br />
1.75 raeburn 921: $zero</div>
922: <br />
1.88 raeburn 923: $submit
1.75 raeburn 924: </p>
925: $hidden_elements
926: <a href="javascript:changePage(document.setpostsubmit,'menu')">$lt{'back'}</a>
927: </form>
928: ENDDOCUMENT
929: return;
930: }
931:
932: sub domain_postsubtimeout {
933: my ($cdom,$type,$settings) = @_;
934: return unless (ref($settings) eq 'HASH');
935: my $lctype = lc($type);
1.80 raeburn 936: unless (($type eq 'Community') || ($type eq 'Placement')) {
1.75 raeburn 937: $lctype = 'unofficial';
938: if ($settings->{'internal.coursecode'}) {
939: $lctype = 'official';
940: } elsif ($settings->{'internal.textbook'}) {
941: $lctype = 'textbook';
942: }
943: }
944: my %domconfig =
945: &Apache::lonnet::get_dom('configuration',['coursedefaults'],$cdom);
946: my $postsubtimeout = 60;
947: if (ref($domconfig{'coursedefaults'}) eq 'HASH') {
948: if (ref($domconfig{'coursedefaults'}{'postsubmit'}) eq 'HASH') {
949: if (ref($domconfig{'coursedefaults'}{'postsubmit'}{'timeout'}) eq 'HASH') {
950: if ($domconfig{'coursedefaults'}{'postsubmit'}{'timeout'}{$lctype} ne '') {
951: $postsubtimeout = $domconfig{'coursedefaults'}{'postsubmit'}{'timeout'}{$lctype};
952: }
953: }
954: }
955: }
956: return $postsubtimeout;
957: }
958:
1.38 raeburn 959: sub print_catsettings {
1.88 raeburn 960: my ($r,$cdom,$cnum,$cdesc,$type,$readonly) = @_;
1.48 raeburn 961: &print_header($r,$type);
1.38 raeburn 962: my %lt = &Apache::lonlocal::texthash(
1.48 raeburn 963: 'back' => 'Pick another action',
964: 'catset' => 'Catalog Settings for Course',
965: 'visi' => 'Visibility in Course/Community Catalog',
966: 'exclude' => 'Exclude from course catalog:',
967: 'categ' => 'Categorize Course',
968: 'assi' => 'Assign one or more categories and/or subcategories to this course.'
1.38 raeburn 969: );
1.48 raeburn 970: if ($type eq 'Community') {
971: $lt{'catset'} = &mt('Catalog Settings for Community');
972: $lt{'exclude'} = &mt('Exclude from course catalog');
973: $lt{'categ'} = &mt('Categorize Community');
1.49 raeburn 974: $lt{'assi'} = &mt('Assign one or more subcategories to this community.');
1.48 raeburn 975: }
1.38 raeburn 976: $r->print('<form action="/adm/modifycourse" method="post" name="catsettings">'.
1.48 raeburn 977: '<h3>'.$lt{'catset'}.' <span class="LC_nobreak">'.$cdesc.'</span></h3>');
1.38 raeburn 978: my %domconf = &Apache::lonnet::get_dom('configuration',['coursecategories'],$cdom);
1.49 raeburn 979: my @cat_params = &catalog_settable($domconf{'coursecategories'},$type);
1.38 raeburn 980: if (@cat_params > 0) {
1.88 raeburn 981: my $disabled;
982: if ($readonly) {
983: $disabled = ' disabled="disabled"';
984: }
1.38 raeburn 985: my %currsettings =
986: &Apache::lonnet::get('environment',['hidefromcat','categories'],$cdom,$cnum);
987: if (grep(/^togglecats$/,@cat_params)) {
988: my $excludeon = '';
989: my $excludeoff = ' checked="checked" ';
990: if ($currsettings{'hidefromcat'} eq 'yes') {
991: $excludeon = $excludeoff;
992: $excludeoff = '';
993: }
1.48 raeburn 994: $r->print('<br /><h4>'.$lt{'visi'}.'</h4>'.
995: $lt{'exclude'}.
1.88 raeburn 996: ' <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 997: if ($type eq 'Community') {
998: $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 999: } elsif ($type eq 'Placement') {
1000: $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 1001: } else {
1002: $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>'.
1003: '<li>'.&mt('Auto-cataloging is enabled and the course is assigned an institutional code.').'</li>'.
1004: '<li>'.&mt('The course has been categorized using at least one of the course categories defined for the domain.').'</li></ul>');
1005: }
1006: $r->print('</ul></p>');
1.38 raeburn 1007: }
1008: if (grep(/^categorize$/,@cat_params)) {
1.48 raeburn 1009: $r->print('<br /><h4>'.$lt{'categ'}.'</h4>');
1.38 raeburn 1010: if (ref($domconf{'coursecategories'}) eq 'HASH') {
1011: my $cathash = $domconf{'coursecategories'}{'cats'};
1012: if (ref($cathash) eq 'HASH') {
1.48 raeburn 1013: $r->print($lt{'assi'}.'<br /><br />'.
1.38 raeburn 1014: &Apache::loncommon::assign_categories_table($cathash,
1.88 raeburn 1015: $currsettings{'categories'},$type,$disabled));
1.38 raeburn 1016: } else {
1017: $r->print(&mt('No categories defined for this domain'));
1018: }
1019: } else {
1020: $r->print(&mt('No categories defined for this domain'));
1021: }
1.81 raeburn 1022: unless (($type eq 'Community') || ($type eq 'Placement')) {
1.48 raeburn 1023: $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>');
1024: }
1.38 raeburn 1025: }
1.88 raeburn 1026: unless ($readonly) {
1027: $r->print('<p><input type="button" name="chgcatsettings" value="'.
1028: &mt('Save').'" onclick="javascript:changePage(document.catsettings,'."'processcat'".');" /></p>');
1029: }
1.38 raeburn 1030: } else {
1.48 raeburn 1031: $r->print('<span class="LC_warning">');
1032: if ($type eq 'Community') {
1033: $r->print(&mt('Catalog settings in this domain are set in community context via "Community Configuration".'));
1034: } else {
1035: $r->print(&mt('Catalog settings in this domain are set in course context via "Course Configuration".'));
1036: }
1037: $r->print('</span><br /><br />'."\n".
1.38 raeburn 1038: '<a href="javascript:changePage(document.catsettings,'."'menu'".');">'.
1039: $lt{'back'}.'</a>');
1040: }
1041: $r->print(&hidden_form_elements().'</form>'."\n");
1042: return;
1043: }
1044:
1.28 raeburn 1045: sub print_course_modification_page {
1.88 raeburn 1046: my ($r,$cdom,$cnum,$cdesc,$crstype,$readonly) = @_;
1.2 raeburn 1047: my %lt=&Apache::lonlocal::texthash(
1048: 'actv' => "Active",
1049: 'inac' => "Inactive",
1050: 'ownr' => "Owner",
1051: 'name' => "Name",
1.26 raeburn 1052: 'unme' => "Username:Domain",
1.2 raeburn 1053: 'stus' => "Status",
1.48 raeburn 1054: 'nocc' => 'There is currently no owner set for this course.',
1.32 raeburn 1055: 'gobt' => "Save",
1.72 raeburn 1056: 'sett' => 'Setting',
1057: 'domd' => 'Domain default',
1058: 'whom' => 'Who configures',
1.2 raeburn 1059: );
1.88 raeburn 1060: my ($ownertable,$ccrole,$javascript_validations,$authenitems,$ccname,$disabled);
1.48 raeburn 1061: my %enrollvar = &get_enrollment_settings($cdom,$cnum);
1.72 raeburn 1062: my %settings = &Apache::lonnet::get('environment',['internal.coursecode','internal.textbook',
1.85 raeburn 1063: 'internal.selfenrollmgrdc','internal.selfenrollmgrcc',
1.89 raeburn 1064: 'internal.mysqltables'],$cdom,$cnum);
1.72 raeburn 1065: my $type = &Apache::lonuserutils::get_extended_type($cdom,$cnum,$crstype,\%settings);
1066: my @specific_managebydc = split(/,/,$settings{'internal.selfenrollmgrdc'});
1067: my @specific_managebycc = split(/,/,$settings{'internal.selfenrollmgrcc'});
1068: my %domdefaults = &Apache::lonnet::get_domain_defaults($cdom);
1.94 raeburn 1069: my %passwdconf = &Apache::lonnet::get_passwdconf($cdom);
1.72 raeburn 1070: my @default_managebydc = split(/,/,$domdefaults{$type.'selfenrolladmdc'});
1071: if ($crstype eq 'Community') {
1.48 raeburn 1072: $ccrole = 'co';
1073: $lt{'nocc'} = &mt('There is currently no owner set for this community.');
1074: } else {
1075: $ccrole ='cc';
1.88 raeburn 1076: ($javascript_validations,$authenitems) = &gather_authenitems($cdom,\%enrollvar,$readonly);
1.48 raeburn 1077: }
1.72 raeburn 1078: $ccname = &Apache::lonnet::plaintext($ccrole,$crstype);
1.88 raeburn 1079: if ($readonly) {
1080: $disabled = ' disabled="disabled"';
1081: }
1.48 raeburn 1082: my %roleshash = &Apache::lonnet::get_my_roles($cnum,$cdom,'','',[$ccrole]);
1083: my (@local_ccs,%cc_status,%pname);
1084: foreach my $item (keys(%roleshash)) {
1085: my ($uname,$udom) = split(/:/,$item);
1086: if (!grep(/^\Q$uname\E:\Q$udom\E$/,@local_ccs)) {
1087: push(@local_ccs,$uname.':'.$udom);
1088: $pname{$uname.':'.$udom} = &Apache::loncommon::plainname($uname,$udom);
1089: $cc_status{$uname.':'.$udom} = $lt{'actv'};
1.1 raeburn 1090: }
1091: }
1.48 raeburn 1092: if (($enrollvar{'courseowner'} ne '') &&
1093: (!grep(/^$enrollvar{'courseowner'}$/,@local_ccs))) {
1094: push(@local_ccs,$enrollvar{'courseowner'});
1.26 raeburn 1095: my ($owneruname,$ownerdom) = split(/:/,$enrollvar{'courseowner'});
1096: $pname{$enrollvar{'courseowner'}} =
1097: &Apache::loncommon::plainname($owneruname,$ownerdom);
1.48 raeburn 1098: my $active_cc = &Apache::loncommon::check_user_status($ownerdom,$owneruname,
1099: $cdom,$cnum,$ccrole);
1.19 raeburn 1100: if ($active_cc eq 'active') {
1.2 raeburn 1101: $cc_status{$enrollvar{'courseowner'}} = $lt{'actv'};
1.1 raeburn 1102: } else {
1.2 raeburn 1103: $cc_status{$enrollvar{'courseowner'}} = $lt{'inac'};
1.1 raeburn 1104: }
1105: }
1.48 raeburn 1106: @local_ccs = sort(@local_ccs);
1107: if (@local_ccs == 0) {
1108: $ownertable = $lt{'nocc'};
1109: } else {
1110: my $numlocalcc = scalar(@local_ccs);
1111: $ownertable = '<input type="hidden" name="numlocalcc" value="'.$numlocalcc.'" />'.
1112: &Apache::loncommon::start_data_table()."\n".
1113: &Apache::loncommon::start_data_table_header_row()."\n".
1114: '<th>'.$lt{'ownr'}.'</th>'.
1115: '<th>'.$lt{'name'}.'</th>'.
1116: '<th>'.$lt{'unme'}.'</th>'.
1117: '<th>'.$lt{'stus'}.'</th>'.
1118: &Apache::loncommon::end_data_table_header_row()."\n";
1119: foreach my $cc (@local_ccs) {
1120: $ownertable .= &Apache::loncommon::start_data_table_row()."\n";
1121: if ($cc eq $enrollvar{'courseowner'}) {
1.88 raeburn 1122: $ownertable .= '<td><input type="radio" name="courseowner" value="'.$cc.'" checked="checked"'.$disabled.' /></td>'."\n";
1.48 raeburn 1123: } else {
1.88 raeburn 1124: $ownertable .= '<td><input type="radio" name="courseowner" value="'.$cc.'"'.$disabled.' /></td>'."\n";
1.48 raeburn 1125: }
1126: $ownertable .=
1127: '<td>'.$pname{$cc}.'</td>'."\n".
1128: '<td>'.$cc.'</td>'."\n".
1129: '<td>'.$cc_status{$cc}.' '.$ccname.'</td>'."\n".
1130: &Apache::loncommon::end_data_table_row()."\n";
1131: }
1132: $ownertable .= &Apache::loncommon::end_data_table();
1133: }
1.72 raeburn 1134: &print_header($r,$crstype,$javascript_validations);
1.48 raeburn 1135: my $dctitle = &Apache::lonnet::plaintext('dc');
1.72 raeburn 1136: my $mainheader = &modifiable_only_title($crstype);
1.48 raeburn 1137: my $hidden_elements = &hidden_form_elements();
1138: $r->print('<form action="/adm/modifycourse" method="post" name="'.$env{'form.phase'}.'">'."\n".
1139: '<h3>'.$mainheader.' <span class="LC_nobreak">'.$cdesc.'</span></h3><p>'.
1140: &Apache::lonhtmlcommon::start_pick_box());
1.72 raeburn 1141: if ($crstype eq 'Community') {
1.48 raeburn 1142: $r->print(&Apache::lonhtmlcommon::row_title(
1143: &Apache::loncommon::help_open_topic('Modify_Community_Owner').
1.94 raeburn 1144: ' '.&mt('Community Owner'))."\n".
1145: $ownertable."\n".&Apache::lonhtmlcommon::row_closure());
1.48 raeburn 1146: } else {
1147: $r->print(&Apache::lonhtmlcommon::row_title(
1148: &Apache::loncommon::help_open_topic('Modify_Course_Instcode').
1149: ' '.&mt('Course Code'))."\n".
1.91 raeburn 1150: '<input type="text" size="15" name="coursecode" value="'.$enrollvar{'coursecode'}.'"'.$disabled.' />'.
1.60 raeburn 1151: &Apache::lonhtmlcommon::row_closure());
1.83 raeburn 1152: if (($crstype eq 'Course') && (&showcredits($cdom))) {
1.60 raeburn 1153: $r->print(&Apache::lonhtmlcommon::row_title(
1154: &Apache::loncommon::help_open_topic('Modify_Course_Credithours').
1.94 raeburn 1155: ' '.&mt('Credits (students)'))."\n".
1.88 raeburn 1156: '<input type="text" size="3" name="defaultcredits" value="'.$enrollvar{'defaultcredits'}.'"'.$disabled.' />'.
1.60 raeburn 1157: &Apache::lonhtmlcommon::row_closure());
1.83 raeburn 1158: }
1159: $r->print(&Apache::lonhtmlcommon::row_title(
1160: &Apache::loncommon::help_open_topic('Modify_Course_Defaultauth').
1161: ' '.&mt('Default Authentication method'))."\n".
1162: $authenitems."\n".
1163: &Apache::lonhtmlcommon::row_closure().
1164: &Apache::lonhtmlcommon::row_title(
1.94 raeburn 1165: &Apache::loncommon::help_open_topic('Modify_Course_Owner').
1166: ' '.&mt('Course Owner'))."\n".
1167: $ownertable."\n".&Apache::lonhtmlcommon::row_closure());
1168: if (($passwdconf{'crsownerchg'}) && ($type ne 'Placement')) {
1169: my $checked;
1170: if ($enrollvar{'nopasswdchg'}) {
1171: $checked = ' checked="checked"';
1172: }
1173: $r->print(&Apache::lonhtmlcommon::row_title(
1174: &Apache::loncommon::help_open_topic('Modify_Course_Chgpasswd').
1175: ' '.&mt('Changing passwords (internal)'))."\n".
1176: '<label><input type="checkbox" value="1" name="nopasswdchg"'.$checked.$disabled.' />'.
1177: &mt('Disable changing password for users with student role by course owner').'<label>'."\n".
1178: &Apache::lonhtmlcommon::row_closure());
1179: }
1.48 raeburn 1180: }
1.72 raeburn 1181: my ($cctitle,$rolename,$currmanages,$ccchecked,$dcchecked,$defaultchecked);
1182: my ($selfenrollrows,$selfenrolltitles) = &Apache::lonuserutils::get_selfenroll_titles();
1183: if ($type eq 'Community') {
1184: $cctitle = &mt('Community personnel');
1185: } else {
1186: $cctitle = &mt('Course personnel');
1187: }
1188:
1.94 raeburn 1189: $r->print(&Apache::lonhtmlcommon::row_title(
1.72 raeburn 1190: &Apache::loncommon::help_open_topic('Modify_Course_Selfenrolladmin').
1191: ' '.&mt('Self-enrollment configuration')).
1192: &Apache::loncommon::start_data_table()."\n".
1193: &Apache::loncommon::start_data_table_header_row()."\n".
1194: '<th>'.$lt{'sett'}.'</th>'.
1195: '<th>'.$lt{'domd'}.'</th>'.
1196: '<th>'.$lt{'whom'}.'</th>'.
1197: &Apache::loncommon::end_data_table_header_row()."\n");
1198: my %optionname;
1199: $optionname{''} = &mt('Use domain default');
1200: $optionname{'0'} = $dctitle;
1201: $optionname{'1'} = $cctitle;
1202: foreach my $item (@{$selfenrollrows}) {
1203: my %checked;
1204: my $default = $cctitle;
1205: if (grep(/^\Q$item\E$/,@default_managebydc)) {
1206: $default = $dctitle;
1207: }
1208: if (grep(/^\Q$item\E$/,@specific_managebydc)) {
1209: $checked{'0'} = ' checked="checked"';
1210: } elsif (grep(/^\Q$item\E$/,@specific_managebycc)) {
1211: $checked{'1'} = ' checked="checked"';
1212: } else {
1213: $checked{''} = ' checked="checked"';
1214: }
1215: $r->print(&Apache::loncommon::start_data_table_row()."\n".
1216: '<td>'.$selfenrolltitles->{$item}.'</td>'."\n".
1217: '<td>'.&mt('[_1] configures',$default).'</td>'."\n".
1218: '<td>');
1219: foreach my $option ('','0','1') {
1220: $r->print('<span class="LC_nobreak"><label>'.
1221: '<input type="radio" name="selfenrollmgr_'.$item.'" '.
1.88 raeburn 1222: 'value="'.$option.'"'.$checked{$option}.$disabled.' />'.
1.72 raeburn 1223: $optionname{$option}.'</label></span><br />');
1224: }
1225: $r->print('</td>'."\n".
1226: &Apache::loncommon::end_data_table_row()."\n");
1227: }
1228: $r->print(&Apache::loncommon::end_data_table()."\n".
1.85 raeburn 1229: '<br />'.&Apache::lonhtmlcommon::row_closure().
1230: &Apache::lonhtmlcommon::row_title(
1231: &Apache::loncommon::help_open_topic('Modify_Course_Table_Lifetime').
1232: ' '.&mt('"Temporary" Tables Lifetime (s)'))."\n".
1.88 raeburn 1233: '<input type="text" size="10" name="mysqltables" value="'.$settings{'internal.mysqltables'}.'"'.$disabled.' />'.
1.85 raeburn 1234: &Apache::lonhtmlcommon::row_closure(1).
1.88 raeburn 1235: &Apache::lonhtmlcommon::end_pick_box().'</p><p>'.$hidden_elements);
1236: unless ($readonly) {
1237: $r->print('<input type="button" onclick="javascript:changePage(this.form,'."'processparms'".');');
1238: if ($crstype eq 'Community') {
1239: $r->print('this.form.submit();"');
1240: } else {
1241: $r->print('javascript:verify_message(this.form);"');
1242: }
1243: $r->print(' value="'.$lt{'gobt'}.'" />');
1.48 raeburn 1244: }
1.88 raeburn 1245: $r->print('</p></form>');
1.48 raeburn 1246: return;
1247: }
1248:
1.72 raeburn 1249: sub print_selfenrollconfig {
1.88 raeburn 1250: my ($r,$type,$cdesc,$coursehash,$readonly) = @_;
1.72 raeburn 1251: return unless(ref($coursehash) eq 'HASH');
1252: my $cnum = $coursehash->{'num'};
1253: my $cdom = $coursehash->{'domain'};
1254: my %currsettings = &get_selfenroll_settings($coursehash);
1255: &print_header($r,$type);
1256: $r->print('<h3>'.&mt('Self-enrollment with a student role in: [_1]',
1257: '<span class="LC_nobreak">'.$cdesc.'</span>').'</h3>'."\n");
1258: &Apache::loncreateuser::print_selfenroll_menu($r,'domain',$env{'form.pickedcourse'},
1259: $cdom,$cnum,\%currsettings,
1.88 raeburn 1260: &hidden_form_elements(),$readonly);
1.72 raeburn 1261: return;
1262: }
1263:
1264: sub modify_selfenrollconfig {
1265: my ($r,$type,$cdesc,$coursehash) = @_;
1266: return unless(ref($coursehash) eq 'HASH');
1267: my $cnum = $coursehash->{'num'};
1268: my $cdom = $coursehash->{'domain'};
1269: my %currsettings = &get_selfenroll_settings($coursehash);
1270: &print_header($r,$type);
1271: $r->print('<h3>'.&mt('Self-enrollment with a student role in: [_1]',
1272: '<span class="LC_nobreak">'.$cdesc.'</span>').'</h3>'."\n");
1273: $r->print('<form action="/adm/modifycourse" method="post" name="selfenroll">'."\n".
1274: &hidden_form_elements().'<br />');
1275: &Apache::loncreateuser::update_selfenroll_config($r,$env{'form.pickedcourse'},
1.73 raeburn 1276: $cdom,$cnum,'domain',$type,\%currsettings);
1.72 raeburn 1277: $r->print('</form>');
1278: return;
1279: }
1280:
1281: sub get_selfenroll_settings {
1282: my ($coursehash) = @_;
1283: my %currsettings;
1284: if (ref($coursehash) eq 'HASH') {
1285: %currsettings = (
1286: selfenroll_types => $coursehash->{'internal.selfenroll_types'},
1287: selfenroll_registered => $coursehash->{'internal.selfenroll_registered'},
1288: selfenroll_section => $coursehash->{'internal.selfenroll_section'},
1289: selfenroll_notifylist => $coursehash->{'internal.selfenroll_notifylist'},
1290: selfenroll_approval => $coursehash->{'internal.selfenroll_approval'},
1291: selfenroll_limit => $coursehash->{'internal.selfenroll_limit'},
1292: selfenroll_cap => $coursehash->{'internal.selfenroll_cap'},
1293: selfenroll_start_date => $coursehash->{'internal.selfenroll_start_date'},
1294: selfenroll_end_date => $coursehash->{'internal.selfenroll_end_date'},
1295: selfenroll_start_access => $coursehash->{'internal.selfenroll_start_access'},
1296: selfenroll_end_access => $coursehash->{'internal.selfenroll_end_access'},
1297: default_enrollment_start_date => $coursehash->{'default_enrollment_start_date'},
1298: default_enrollment_end_date => $coursehash->{'default_enrollment_end_date'},
1.73 raeburn 1299: uniquecode => $coursehash->{'internal.uniquecode'},
1.72 raeburn 1300: );
1301: }
1302: return %currsettings;
1303: }
1304:
1.48 raeburn 1305: sub modifiable_only_title {
1306: my ($type) = @_;
1307: my $dctitle = &Apache::lonnet::plaintext('dc');
1308: if ($type eq 'Community') {
1309: return &mt('Community settings modifiable only by [_1] for:',$dctitle);
1310: } else {
1311: return &mt('Course settings modifiable only by [_1] for:',$dctitle);
1312: }
1313: }
1.24 albertel 1314:
1.48 raeburn 1315: sub gather_authenitems {
1.88 raeburn 1316: my ($cdom,$enrollvar,$readonly) = @_;
1.28 raeburn 1317: my ($krbdef,$krbdefdom)=&Apache::loncommon::get_kerberos_defaults($cdom);
1.2 raeburn 1318: my $curr_authtype = '';
1319: my $curr_authfield = '';
1.48 raeburn 1320: if (ref($enrollvar) eq 'HASH') {
1321: if ($enrollvar->{'authtype'} =~ /^krb/) {
1322: $curr_authtype = 'krb';
1323: } elsif ($enrollvar->{'authtype'} eq 'internal' ) {
1324: $curr_authtype = 'int';
1325: } elsif ($enrollvar->{'authtype'} eq 'localauth' ) {
1326: $curr_authtype = 'loc';
1.93 raeburn 1327: } elsif ($enrollvar->{'authtype'} eq 'lti' ) {
1328: $curr_authtype = 'lti';
1.48 raeburn 1329: }
1.2 raeburn 1330: }
1331: unless ($curr_authtype eq '') {
1332: $curr_authfield = $curr_authtype.'arg';
1.33 raeburn 1333: }
1.48 raeburn 1334: my $javascript_validations =
1335: &Apache::lonuserutils::javascript_validations('modifycourse',$krbdefdom,
1336: $curr_authtype,$curr_authfield);
1.35 raeburn 1337: my %param = ( formname => 'document.'.$env{'form.phase'},
1.48 raeburn 1338: kerb_def_dom => $krbdefdom,
1339: kerb_def_auth => $krbdef,
1.2 raeburn 1340: mode => 'modifycourse',
1341: curr_authtype => $curr_authtype,
1.88 raeburn 1342: curr_autharg => $enrollvar->{'autharg'},
1343: readonly => $readonly,
1.48 raeburn 1344: );
1.32 raeburn 1345: my (%authform,$authenitems);
1346: $authform{'krb'} = &Apache::loncommon::authform_kerberos(%param);
1347: $authform{'int'} = &Apache::loncommon::authform_internal(%param);
1348: $authform{'loc'} = &Apache::loncommon::authform_local(%param);
1.93 raeburn 1349: $authform{'lti'} = &Apache::loncommon::authform_lti(%param);
1350: foreach my $item ('krb','int','loc','lti') {
1.32 raeburn 1351: if ($authform{$item} ne '') {
1352: $authenitems .= $authform{$item}.'<br />';
1353: }
1.1 raeburn 1354: }
1.48 raeburn 1355: return($javascript_validations,$authenitems);
1.1 raeburn 1356: }
1357:
1358: sub modify_course {
1.30 raeburn 1359: my ($r,$cdom,$cnum,$cdesc,$domdesc,$type) = @_;
1.48 raeburn 1360: my %longtype = &course_settings_descrip($type);
1.50 raeburn 1361: my @items = ('internal.courseowner','description','internal.co-owners',
1.72 raeburn 1362: 'internal.pendingco-owners','internal.selfenrollmgrdc',
1.85 raeburn 1363: 'internal.selfenrollmgrcc','internal.mysqltables');
1.72 raeburn 1364: my ($selfenrollrows,$selfenrolltitles) = &Apache::lonuserutils::get_selfenroll_titles();
1.81 raeburn 1365: unless (($type eq 'Community') || ($type eq 'Placement')) {
1.48 raeburn 1366: push(@items,('internal.coursecode','internal.authtype','internal.autharg',
1367: 'internal.sectionnums','internal.crosslistings'));
1.60 raeburn 1368: if (&showcredits($cdom)) {
1369: push(@items,'internal.defaultcredits');
1370: }
1.94 raeburn 1371: my %passwdconf = &Apache::lonnet::get_passwdconf($cdom);
1372: if ($passwdconf{'crsownerchg'}) {
1373: push(@items,'internal.nopasswdchg');
1374: }
1.1 raeburn 1375: }
1.48 raeburn 1376: my %settings = &Apache::lonnet::get('environment',\@items,$cdom,$cnum);
1377: my $description = $settings{'description'};
1.60 raeburn 1378: my ($ccrole,$response,$chgresponse,$nochgresponse,$reply,%currattr,%newattr,
1379: %cenv,%changed,@changes,@nochanges,@sections,@xlists,@warnings);
1380: my @modifiable_params = &get_dc_settable($type,$cdom);
1.28 raeburn 1381: foreach my $param (@modifiable_params) {
1.48 raeburn 1382: $currattr{$param} = $settings{'internal.'.$param};
1.1 raeburn 1383: }
1.48 raeburn 1384: if ($type eq 'Community') {
1385: %changed = ( owner => 0 );
1386: $ccrole = 'co';
1387: } else {
1388: %changed = ( code => 0,
1389: owner => 0,
1.94 raeburn 1390: passwd => 0,
1.48 raeburn 1391: );
1392: $ccrole = 'cc';
1393: unless ($settings{'internal.sectionnums'} eq '') {
1394: if ($settings{'internal.sectionnums'} =~ m/,/) {
1395: @sections = split/,/,$settings{'internal.sectionnums'};
1396: } else {
1397: $sections[0] = $settings{'internal.sectionnums'};
1398: }
1399: }
1.60 raeburn 1400: unless ($settings{'internal.crosslistings'} eq '') {
1.48 raeburn 1401: if ($settings{'internal.crosslistings'} =~ m/,/) {
1402: @xlists = split/,/,$settings{'internal.crosslistings'};
1403: } else {
1404: $xlists[0] = $settings{'internal.crosslistings'};
1405: }
1406: }
1407: if ($env{'form.login'} eq 'krb') {
1408: $newattr{'authtype'} = $env{'form.login'};
1409: $newattr{'authtype'} .= $env{'form.krbver'};
1410: $newattr{'autharg'} = $env{'form.krbarg'};
1411: } elsif ($env{'form.login'} eq 'int') {
1412: $newattr{'authtype'} ='internal';
1413: if ((defined($env{'form.intarg'})) && ($env{'form.intarg'})) {
1414: $newattr{'autharg'} = $env{'form.intarg'};
1415: }
1416: } elsif ($env{'form.login'} eq 'loc') {
1417: $newattr{'authtype'} = 'localauth';
1418: if ((defined($env{'form.locarg'})) && ($env{'form.locarg'})) {
1419: $newattr{'autharg'} = $env{'form.locarg'};
1420: }
1.93 raeburn 1421: } elsif ($env{'form.login'} eq 'lti') {
1422: $newattr{'authtype'} = 'lti';
1.48 raeburn 1423: }
1424: if ( $newattr{'authtype'}=~ /^krb/) {
1425: if ($newattr{'autharg'} eq '') {
1426: push(@warnings,
1427: &mt('As you did not include the default Kerberos domain'
1.45 bisitz 1428: .' to be used for authentication in this class, the'
1429: .' institutional data used by the automated'
1430: .' enrollment process must include the Kerberos'
1.48 raeburn 1431: .' domain for each new student.'));
1432: }
1433: }
1434:
1435: if ( exists($env{'form.coursecode'}) ) {
1436: $newattr{'coursecode'}=$env{'form.coursecode'};
1437: unless ( $newattr{'coursecode'} eq $currattr{'coursecode'} ) {
1438: $changed{'code'} = 1;
1439: }
1.1 raeburn 1440: }
1.85 raeburn 1441: if ( exists($env{'form.mysqltables'}) ) {
1442: $newattr{'mysqltables'} = $env{'form.mysqltables'};
1443: $newattr{'mysqltables'} =~ s/\D+//g;
1444: }
1.94 raeburn 1445: if ($type ne 'Placement') {
1446: if (&showcredits($cdom) && exists($env{'form.defaultcredits'})) {
1447: $newattr{'defaultcredits'}=$env{'form.defaultcredits'};
1448: $newattr{'defaultcredits'} =~ s/[^\d\.]//g;
1449: }
1450: if (grep(/^nopasswdchg$/,@modifiable_params)) {
1451: if ($env{'form.nopasswdchg'}) {
1452: $newattr{'nopasswdchg'} = 1;
1453: unless ($currattr{'nopasswdchg'}) {
1454: $changed{'passwd'} = 1;
1455: }
1456: } elsif ($currattr{'nopasswdchg'}) {
1457: $changed{'passwd'} = 1;
1458: }
1459: }
1.60 raeburn 1460: }
1.72 raeburn 1461: }
1462:
1463: my @newmgrdc = ();
1464: my @newmgrcc = ();
1465: my @currmgrdc = split(/,/,$currattr{'selfenrollmgrdc'});
1466: my @currmgrcc = split(/,/,$currattr{'selfenrollmgrcc'});
1.60 raeburn 1467:
1.72 raeburn 1468: foreach my $item (@{$selfenrollrows}) {
1469: if ($env{'form.selfenrollmgr_'.$item} eq '0') {
1470: push(@newmgrdc,$item);
1471: } elsif ($env{'form.selfenrollmgr_'.$item} eq '1') {
1472: push(@newmgrcc,$item);
1473: }
1474: }
1475:
1476: $newattr{'selfenrollmgrdc'}=join(',',@newmgrdc);
1477: $newattr{'selfenrollmgrcc'}=join(',',@newmgrcc);
1478:
1479: my $cctitle;
1480: if ($type eq 'Community') {
1481: $cctitle = &mt('Community personnel');
1482: } else {
1483: $cctitle = &mt('Course personnel');
1.1 raeburn 1484: }
1.72 raeburn 1485: my $dctitle = &Apache::lonnet::plaintext('dc');
1.1 raeburn 1486:
1.16 albertel 1487: if ( exists($env{'form.courseowner'}) ) {
1488: $newattr{'courseowner'}=$env{'form.courseowner'};
1.14 raeburn 1489: unless ( $newattr{'courseowner'} eq $currattr{'courseowner'} ) {
1.38 raeburn 1490: $changed{'owner'} = 1;
1.1 raeburn 1491: }
1492: }
1.48 raeburn 1493:
1.94 raeburn 1494: if ($changed{'owner'} || $changed{'code'} || $changed{'passwd'}) {
1.38 raeburn 1495: my %crsinfo = &Apache::lonnet::courseiddump($cdom,'.',1,'.','.',$cnum,
1496: undef,undef,'.');
1497: if (ref($crsinfo{$env{'form.pickedcourse'}}) eq 'HASH') {
1.48 raeburn 1498: if ($changed{'code'}) {
1499: $crsinfo{$env{'form.pickedcourse'}}{'inst_code'} = $env{'form.coursecode'};
1500: }
1501: if ($changed{'owner'}) {
1502: $crsinfo{$env{'form.pickedcourse'}}{'owner'} = $env{'form.courseowner'};
1503: }
1.94 raeburn 1504: if ($changed{'passwd'}) {
1505: if ($env{'form.nopasswdchg'}) {
1506: $crsinfo{$env{'form.pickedcourse'}}{'nopasswdchg'} = 1;
1507: } else {
1508: delete($crsinfo{'nopasswdchg'});
1509: }
1510: }
1.38 raeburn 1511: my $chome = &Apache::lonnet::homeserver($cnum,$cdom);
1512: my $putres = &Apache::lonnet::courseidput($cdom,\%crsinfo,$chome,'notime');
1.94 raeburn 1513: if (($putres eq 'ok') && (($changed{'owner'} || $changed{'code'}))) {
1.50 raeburn 1514: &update_coowners($cdom,$cnum,$chome,\%settings,\%newattr);
1.95 raeburn 1515: if ($changed{'code'}) {
1516: &Apache::lonnet::devalidate_cache_new('instcats',$cdom);
1517: # Update cache of self-cataloging courses on institution's server(s).
1518: if (&Apache::lonnet::shared_institution($cdom)) {
1519: unless ($registered_cleanup) {
1520: my $handlers = $r->get_handlers('PerlCleanupHandler');
1521: $r->set_handlers('PerlCleanupHandler' => [\&devalidate_remote_instcats,@{$handlers}]);
1522: $registered_cleanup=1;
1523: $modified_dom = $cdom;
1524: }
1525: }
1526: }
1.50 raeburn 1527: }
1.38 raeburn 1528: }
1.14 raeburn 1529: }
1.28 raeburn 1530: foreach my $param (@modifiable_params) {
1531: if ($currattr{$param} eq $newattr{$param}) {
1532: push(@nochanges,$param);
1.1 raeburn 1533: } else {
1.48 raeburn 1534: $cenv{'internal.'.$param} = $newattr{$param};
1.28 raeburn 1535: push(@changes,$param);
1.1 raeburn 1536: }
1537: }
1538: if (@changes > 0) {
1.62 bisitz 1539: $chgresponse = &mt('The following settings have been changed:').'<br/><ul>';
1.1 raeburn 1540: }
1.48 raeburn 1541: if (@nochanges > 0) {
1.62 bisitz 1542: $nochgresponse = &mt('The following settings remain unchanged:').'<br/><ul>';
1.1 raeburn 1543: }
1.33 raeburn 1544: if (@changes > 0) {
1.28 raeburn 1545: my $putreply = &Apache::lonnet::put('environment',\%cenv,$cdom,$cnum);
1.1 raeburn 1546: if ($putreply !~ /^ok$/) {
1.48 raeburn 1547: $response = '<p class="LC_error">'.
1548: &mt('There was a problem processing your requested changes.').'<br />';
1549: if ($type eq 'Community') {
1550: $response .= &mt('Settings for this community have been left unchanged.');
1551: } else {
1552: $response .= &mt('Settings for this course have been left unchanged.');
1553: }
1554: $response .= '<br/>'.&mt('Error: ').$putreply.'</p>';
1.1 raeburn 1555: } else {
1.72 raeburn 1556: if ($env{'course.'.$cdom.'_'.$cnum.'.description'} ne '') {
1557: my %newenv;
1558: map { $newenv{'course.'.$cdom.'_'.$cnum.'.internal.'.$_} = $newattr{$_}; } @changes;
1559: &Apache::lonnet::appenv(\%newenv);
1560: }
1.28 raeburn 1561: foreach my $attr (@modifiable_params) {
1.48 raeburn 1562: if (grep/^\Q$attr\E$/,@changes) {
1.72 raeburn 1563: my $shown = $newattr{$attr};
1564: if ($attr eq 'selfenrollmgrdc') {
1565: $shown = &selfenroll_config_status(\@newmgrdc,$selfenrolltitles);
1566: } elsif ($attr eq 'selfenrollmgrcc') {
1567: $shown = &selfenroll_config_status(\@newmgrcc,$selfenrolltitles);
1568: } elsif (($attr eq 'defaultcredits') && ($shown eq '')) {
1569: $shown = &mt('None');
1.85 raeburn 1570: } elsif (($attr eq 'mysqltables') && ($shown eq '')) {
1571: $shown = &mt('domain default');
1.94 raeburn 1572: } elsif ($attr eq 'nopasswdchg') {
1573: if ($shown) {
1574: $shown = &mt('Yes');
1575: } else {
1576: $shown = &mt('No');
1577: }
1.72 raeburn 1578: }
1579: $chgresponse .= '<li>'.&mt('[_1] now set to: [_2]',$longtype{$attr},$shown).'</li>';
1.1 raeburn 1580: } else {
1.72 raeburn 1581: my $shown = $currattr{$attr};
1582: if ($attr eq 'selfenrollmgrdc') {
1583: $shown = &selfenroll_config_status(\@currmgrdc,$selfenrolltitles);
1584: } elsif ($attr eq 'selfenrollmgrcc') {
1585: $shown = &selfenroll_config_status(\@currmgrcc,$selfenrolltitles);
1586: } elsif (($attr eq 'defaultcredits') && ($shown eq '')) {
1587: $shown = &mt('None');
1.85 raeburn 1588: } elsif (($attr eq 'mysqltables') && ($shown eq '')) {
1589: $shown = &mt('domain default');
1.94 raeburn 1590: } elsif ($attr eq 'nopasswdchg') {
1591: if ($shown) {
1592: $shown = &mt('Yes');
1593: } else {
1594: $shown = &mt('No');
1595: }
1.72 raeburn 1596: }
1597: $nochgresponse .= '<li>'.&mt('[_1] still set to: [_2]',$longtype{$attr},$shown).'</li>';
1.1 raeburn 1598: }
1599: }
1.81 raeburn 1600: if (($type ne 'Community') && ($type ne 'Placement') && ($changed{'code'} || $changed{'owner'})) {
1.1 raeburn 1601: if ( $newattr{'courseowner'} eq '') {
1.48 raeburn 1602: push(@warnings,&mt('There is no owner associated with this LON-CAPA course.').
1603: '<br />'.&mt('If automated enrollment at your institution requires validation of course owners, automated enrollment will fail.'));
1.1 raeburn 1604: } else {
1.59 raeburn 1605: my %crsenv = &Apache::lonnet::get('environment',['internal.co-owners'],$cdom,$cnum);
1606: my $coowners = $crsenv{'internal.co-owners'};
1.1 raeburn 1607: if (@sections > 0) {
1.38 raeburn 1608: if ($changed{'code'}) {
1.2 raeburn 1609: foreach my $sec (@sections) {
1610: if ($sec =~ m/^(.+):/) {
1.48 raeburn 1611: my $instsec = $1;
1.8 raeburn 1612: my $inst_course_id = $newattr{'coursecode'}.$1;
1.28 raeburn 1613: my $course_check = &Apache::lonnet::auto_validate_courseID($cnum,$cdom,$inst_course_id);
1.7 raeburn 1614: if ($course_check eq 'ok') {
1.58 raeburn 1615: my $outcome = &Apache::lonnet::auto_new_course($cnum,$cdom,$inst_course_id,$newattr{'courseowner'},$coowners);
1.48 raeburn 1616: unless ($outcome eq 'ok') {
1617:
1.53 raeburn 1618: 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 1619: }
1620: } else {
1.53 raeburn 1621: 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 1622: }
1623: } else {
1.48 raeburn 1624: 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 1625: }
1626: }
1.38 raeburn 1627: } elsif ($changed{'owner'}) {
1.4 raeburn 1628: foreach my $sec (@sections) {
1629: if ($sec =~ m/^(.+):/) {
1.48 raeburn 1630: my $instsec = $1;
1631: my $inst_course_id = $newattr{'coursecode'}.$instsec;
1.58 raeburn 1632: my $outcome = &Apache::lonnet::auto_new_course($cnum,$cdom,$inst_course_id,$newattr{'courseowner'},$coowners);
1.4 raeburn 1633: unless ($outcome eq 'ok') {
1.53 raeburn 1634: 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 1635: }
1636: } else {
1.53 raeburn 1637: 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 1638: }
1639: }
1640: }
1.1 raeburn 1641: } else {
1.53 raeburn 1642: 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 1643: }
1.38 raeburn 1644: if ( (@xlists > 0) && ($changed{'owner'}) ) {
1.1 raeburn 1645: foreach my $xlist (@xlists) {
1646: if ($xlist =~ m/^(.+):/) {
1.48 raeburn 1647: my $instxlist = $1;
1.58 raeburn 1648: my $outcome = &Apache::lonnet::auto_new_course($cnum,$cdom,$instxlist,$newattr{'courseowner'},$coowners);
1.1 raeburn 1649: unless ($outcome eq 'ok') {
1.48 raeburn 1650: 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 1651: }
1.28 raeburn 1652: }
1.1 raeburn 1653: }
1654: }
1655: }
1656: }
1657: }
1.2 raeburn 1658: } else {
1.28 raeburn 1659: foreach my $attr (@modifiable_params) {
1.72 raeburn 1660: my $shown = $currattr{$attr};
1661: if ($attr eq 'selfenrollmgrdc') {
1662: $shown = &selfenroll_config_status(\@currmgrdc,$selfenrolltitles);
1663: } elsif ($attr eq 'selfenrollmgrcc') {
1664: $shown = &selfenroll_config_status(\@currmgrcc,$selfenrolltitles);
1665: } elsif (($attr eq 'defaultcredits') && ($shown eq '')) {
1666: $shown = &mt('None');
1.85 raeburn 1667: } elsif (($attr eq 'mysqltables') && ($shown eq '')) {
1668: $shown = &mt('domain default');
1.72 raeburn 1669: }
1670: $nochgresponse .= '<li>'.&mt('[_1] still set to: [_2]',$longtype{$attr},$shown).'</li>';
1.2 raeburn 1671: }
1.1 raeburn 1672: }
1673:
1674: if (@changes > 0) {
1675: $chgresponse .= "</ul><br/><br/>";
1676: }
1677: if (@nochanges > 0) {
1678: $nochgresponse .= "</ul><br/><br/>";
1679: }
1.48 raeburn 1680: my ($warning,$numwarnings);
1681: my $numwarnings = scalar(@warnings);
1682: if ($numwarnings) {
1683: $warning = &mt('The following [quant,_1,warning was,warnings were] generated when applying your changes to automated enrollment:',$numwarnings).'<p><ul>';
1684: foreach my $warn (@warnings) {
1685: $warning .= '<li><span class="LC_warning">'.$warn.'</span></li>';
1686: }
1687: $warning .= '</ul></p>';
1.1 raeburn 1688: }
1.48 raeburn 1689: if ($response) {
1690: $reply = $response;
1691: } else {
1.1 raeburn 1692: $reply = $chgresponse.$nochgresponse.$warning;
1693: }
1.48 raeburn 1694: &print_header($r,$type);
1695: my $mainheader = &modifiable_only_title($type);
1696: $reply = '<h3>'.$mainheader.' <span class="LC_nobreak">'.$cdesc.'</span></h3>'."\n".
1697: '<p>'.$reply.'</p>'."\n".
1.28 raeburn 1698: '<form action="/adm/modifycourse" method="post" name="processparms">'.
1.66 bisitz 1699: &hidden_form_elements();
1700: my @actions =
1701: ('<a href="javascript:changePage(document.processparms,'."'menu'".')">'.
1702: &mt('Pick another action').'</a>');
1.48 raeburn 1703: if ($numwarnings) {
1704: my $newrole = $ccrole.'./'.$cdom.'/'.$cnum;
1705: my $escuri = &HTML::Entities::encode('/adm/roles?selectrole=1&'.$newrole.
1706: '=1&destinationurl=/adm/populate','&<>"');
1707:
1.66 bisitz 1708: push(@actions, '<a href="'.$escuri.'">'.
1709: &mt('Go to Automated Enrollment Manager for course').'</a>');
1.48 raeburn 1710: }
1.66 bisitz 1711: $reply .= &Apache::lonhtmlcommon::actionbox(\@actions).'</form>';
1.3 raeburn 1712: $r->print($reply);
1.28 raeburn 1713: return;
1714: }
1715:
1.72 raeburn 1716: sub selfenroll_config_status {
1717: my ($items,$selfenrolltitles) = @_;
1718: my $shown;
1719: if ((ref($items) eq 'ARRAY') && (ref($selfenrolltitles) eq 'HASH')) {
1720: if (@{$items} > 0) {
1721: $shown = '<ul>';
1722: foreach my $item (@{$items}) {
1723: $shown .= '<li>'.$selfenrolltitles->{$item}.'</li>';
1724: }
1725: $shown .= '</ul>';
1726: } else {
1727: $shown = &mt('None');
1728: }
1729: }
1730: return $shown;
1731: }
1732:
1.50 raeburn 1733: sub update_coowners {
1734: my ($cdom,$cnum,$chome,$settings,$newattr) = @_;
1735: return unless ((ref($settings) eq 'HASH') && (ref($newattr) eq 'HASH'));
1736: my %designhash = &Apache::loncommon::get_domainconf($cdom);
1737: my (%cchash,$autocoowners);
1738: if ($designhash{$cdom.'.autoassign.co-owners'}) {
1739: $autocoowners = 1;
1740: %cchash = &Apache::lonnet::get_my_roles($cnum,$cdom,undef,undef,['cc']);
1741: }
1742: if ($settings->{'internal.courseowner'} ne $newattr->{'courseowner'}) {
1743: my $oldowner_to_coowner;
1.51 raeburn 1744: my @types = ('co-owners');
1.50 raeburn 1745: if (($newattr->{'coursecode'}) && ($autocoowners)) {
1746: my $oldowner = $settings->{'internal.courseowner'};
1747: if ($cchash{$oldowner.':cc'}) {
1.51 raeburn 1748: my ($result,$desc) = &Apache::lonnet::auto_validate_instcode($cnum,$cdom,$newattr->{'coursecode'},$oldowner);
1749: if ($result eq 'valid') {
1750: if ($settings->{'internal.co-owner'}) {
1751: my @current = split(',',$settings->{'internal.co-owners'});
1752: unless (grep(/^\Q$oldowner\E$/,@current)) {
1753: $oldowner_to_coowner = 1;
1754: }
1755: } else {
1.50 raeburn 1756: $oldowner_to_coowner = 1;
1757: }
1758: }
1759: }
1.51 raeburn 1760: } else {
1761: push(@types,'pendingco-owners');
1.50 raeburn 1762: }
1.51 raeburn 1763: foreach my $type (@types) {
1.50 raeburn 1764: if ($settings->{'internal.'.$type}) {
1765: my @current = split(',',$settings->{'internal.'.$type});
1766: my $newowner = $newattr->{'courseowner'};
1767: my @newvalues = ();
1768: if (($newowner ne '') && (grep(/^\Q$newowner\E$/,@current))) {
1769: foreach my $person (@current) {
1770: unless ($person eq $newowner) {
1771: push(@newvalues,$person);
1772: }
1773: }
1774: } else {
1775: @newvalues = @current;
1776: }
1777: if ($oldowner_to_coowner) {
1778: push(@newvalues,$settings->{'internal.courseowner'});
1779: @newvalues = sort(@newvalues);
1780: }
1781: my $newownstr = join(',',@newvalues);
1782: if ($newownstr ne $settings->{'internal.'.$type}) {
1783: if ($type eq 'co-owners') {
1784: my $deleted = '';
1785: unless (@newvalues) {
1786: $deleted = 1;
1787: }
1788: &Apache::lonnet::store_coowners($cdom,$cnum,$chome,
1789: $deleted,@newvalues);
1790: } else {
1791: my $pendingcoowners;
1792: my $cid = $cdom.'_'.$cnum;
1793: if (@newvalues) {
1794: $pendingcoowners = join(',',@newvalues);
1795: my %pendinghash = (
1796: 'internal.pendingco-owners' => $pendingcoowners,
1797: );
1.52 raeburn 1798: my $putresult = &Apache::lonnet::put('environment',\%pendinghash,$cdom,$cnum);
1.50 raeburn 1799: if ($putresult eq 'ok') {
1800: if ($env{'course.'.$cid.'.num'} eq $cnum) {
1.52 raeburn 1801: &Apache::lonnet::appenv({'course.'.$cid.'.internal.pendingco-owners' => $pendingcoowners});
1.50 raeburn 1802: }
1803: }
1804: } else {
1805: my $delresult = &Apache::lonnet::del('environment',['internal.pendingco-owners'],$cdom,$cnum);
1806: if ($delresult eq 'ok') {
1807: if ($env{'course.'.$cid.'.internal.pendingco-owners'}) {
1808: &Apache::lonnet::delenv('course.'.$cid.'.internal.pendingco-owners');
1809: }
1810: }
1811: }
1812: }
1813: } elsif ($oldowner_to_coowner) {
1814: &Apache::lonnet::store_coowners($cdom,$cnum,$chome,'',
1815: $settings->{'internal.courseowner'});
1816:
1817: }
1818: } elsif ($oldowner_to_coowner) {
1819: &Apache::lonnet::store_coowners($cdom,$cnum,$chome,'',
1820: $settings->{'internal.courseowner'});
1821: }
1822: }
1823: }
1824: if ($settings->{'internal.coursecode'} ne $newattr->{'coursecode'}) {
1825: if ($newattr->{'coursecode'} ne '') {
1826: my %designhash = &Apache::loncommon::get_domainconf($cdom);
1827: if ($designhash{$cdom.'.autoassign.co-owners'}) {
1828: my @newcoowners = ();
1829: if ($settings->{'internal.co-owners'}) {
1.58 raeburn 1830: my @currcoown = split(',',$settings->{'internal.co-owners'});
1.50 raeburn 1831: my ($updatecoowners,$delcoowners);
1832: foreach my $person (@currcoown) {
1.51 raeburn 1833: my ($result,$desc) = &Apache::lonnet::auto_validate_instcode($cnum,$cdom,$newattr->{'coursecode'},$person);
1.50 raeburn 1834: if ($result eq 'valid') {
1835: push(@newcoowners,$person);
1836: }
1837: }
1838: foreach my $item (sort(keys(%cchash))) {
1839: my ($uname,$udom,$urole) = split(':',$item);
1.51 raeburn 1840: next if ($uname.':'.$udom eq $newattr->{'courseowner'});
1.50 raeburn 1841: unless (grep(/^\Q$uname\E:\Q$udom\E$/,@newcoowners)) {
1.51 raeburn 1842: my ($result,$desc) = &Apache::lonnet::auto_validate_instcode($cnum,$cdom,$newattr->{'coursecode'},$uname.':'.$udom);
1843: if ($result eq 'valid') {
1844: push(@newcoowners,$uname.':'.$udom);
1845: }
1.50 raeburn 1846: }
1847: }
1848: if (@newcoowners) {
1849: my $coowners = join(',',sort(@newcoowners));
1850: unless ($coowners eq $settings->{'internal.co-owners'}) {
1851: $updatecoowners = 1;
1852: }
1853: } else {
1854: $delcoowners = 1;
1855: }
1856: if ($updatecoowners || $delcoowners) {
1857: &Apache::lonnet::store_coowners($cdom,$cnum,$chome,
1858: $delcoowners,@newcoowners);
1859: }
1860: } else {
1861: foreach my $item (sort(keys(%cchash))) {
1862: my ($uname,$udom,$urole) = split(':',$item);
1863: push(@newcoowners,$uname.':'.$udom);
1864: }
1865: if (@newcoowners) {
1866: &Apache::lonnet::store_coowners($cdom,$cnum,$chome,'',
1867: @newcoowners);
1868: }
1869: }
1870: }
1871: }
1872: }
1873: return;
1874: }
1875:
1.28 raeburn 1876: sub modify_quota {
1.48 raeburn 1877: my ($r,$cdom,$cnum,$cdesc,$domdesc,$type) = @_;
1878: &print_header($r,$type);
1.61 raeburn 1879: my $lctype = lc($type);
1880: my $headline = &mt("Disk space quotas for $lctype: [_1]",
1881: '<span class="LC_nobreak">'.$cdesc.'</span>');
1.48 raeburn 1882: $r->print('<form action="/adm/modifycourse" method="post" name="processquota">'."\n".
1.61 raeburn 1883: '<h3>'.$headline.'</h3>');
1884: my %oldsettings = &Apache::lonnet::get('environment',['internal.coursequota','internal.uploadquota'],$cdom,$cnum);
1885: my %staticdefaults = (
1886: coursequota => 20,
1887: uploadquota => 500,
1888: );
1889: my %default;
1890: $default{'coursequota'} = $staticdefaults{'coursequota'};
1891: my %domdefs = &Apache::lonnet::get_domain_defaults($cdom);
1892: $default{'uploadquota'} = $domdefs{'uploadquota'};
1893: if ($default{'uploadquota'} eq '') {
1894: $default{'uploadquota'} = $staticdefaults{'uploadquota'};
1895: }
1896: my (%cenv,%showresult);
1897: foreach my $item ('coursequota','uploadquota') {
1898: if ($env{'form.'.$item} ne '') {
1899: my $newquota = $env{'form.'.$item};
1900: if ($newquota =~ /^\s*(\d+\.?\d*|\.\d+)\s*$/) {
1901: $newquota = $1;
1902: if ($oldsettings{'internal.'.$item} == $newquota) {
1903: if ($item eq 'coursequota') {
1904: $r->print(&mt('The disk space allocated for group portfolio files remains unchanged as [_1] MB.',$newquota).'<br />');
1905: } else {
1906: $r->print(&mt('The disk space allocated for files uploaded via the Content Editor remains unchanged as [_1] MB.',$newquota).'<br />');
1907: }
1908: } else {
1909: $cenv{'internal.'.$item} = $newquota;
1910: $showresult{$item} = 1;
1911: }
1.28 raeburn 1912: } else {
1.61 raeburn 1913: if ($item eq 'coursequota') {
1914: $r->print(&mt('The proposed group portfolio quota contained invalid characters, so the quota is unchanged.').'<br />');
1915: } else {
1916: $r->print(&mt('The proposed quota for content uploaded via the Content Editor contained invalid characters, so the quota is unchanged.').'<br />');
1917:
1918: }
1919: }
1920: }
1921: }
1922: if (keys(%cenv)) {
1923: my $putreply = &Apache::lonnet::put('environment',\%cenv,$cdom,
1924: $cnum);
1925: foreach my $key (sort(keys(%showresult))) {
1926: if (($oldsettings{'internal.'.$key} eq '') &&
1927: ($env{'form.'.$key} == $default{$key})) {
1928: if ($key eq 'uploadquota') {
1929: if ($type eq 'Community') {
1930: $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.',
1931: $default{$key}).'<br />');
1932: } else {
1933: $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.',
1934: $default{$key}).'<br />');
1935: }
1936: } else {
1.48 raeburn 1937: if ($type eq 'Community') {
1.61 raeburn 1938: $r->print(&mt('The disk space allocated for group portfolio files in this community is the default quota for this domain: [_1] MB.',
1939: $default{$key}).'<br />');
1.48 raeburn 1940: } else {
1.61 raeburn 1941: $r->print(&mt('The disk space allocated for group portfolio files in this course is the default quota for this domain: [_1] MB.',
1942: $default{$key}).'<br />');
1.48 raeburn 1943: }
1.61 raeburn 1944: }
1945: delete($showresult{$key});
1946: }
1947: }
1948: if ($putreply eq 'ok') {
1949: my %updatedsettings = &Apache::lonnet::get('environment',['internal.coursequota','internal.uploadquota'],$cdom,$cnum);
1950: if ($showresult{'coursequota'}) {
1951: $r->print(&mt('The disk space allocated for group portfolio files is now: [_1] MB.',
1952: '<b>'.$updatedsettings{'internal.coursequota'}.'</b>').'<br />');
1953: my $usage = &Apache::longroup::sum_quotas($cdom.'_'.$cnum);
1954: if ($usage >= $updatedsettings{'internal.coursequota'}) {
1955: my $newoverquota;
1956: if ($usage < $oldsettings{'internal.coursequota'}) {
1957: $newoverquota = 'now';
1958: }
1959: $r->print('<p>');
1960: if ($type eq 'Community') {
1.67 bisitz 1961: $r->print(&mt("Disk usage $newoverquota exceeds the quota for this community.").' '.
1.61 raeburn 1962: &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 1963: } else {
1.67 bisitz 1964: $r->print(&mt("Disk usage $newoverquota exceeds the quota for this course.").' '.
1.61 raeburn 1965: &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 1966: }
1.61 raeburn 1967: $r->print('</p>');
1.28 raeburn 1968: }
1969: }
1.61 raeburn 1970: if ($showresult{'uploadquota'}) {
1971: $r->print(&mt('The disk space allocated for content uploaded directly via the Content Editor is now: [_1] MB.',
1972: '<b>'.$updatedsettings{'internal.uploadquota'}.'</b>').'<br />');
1973: }
1.28 raeburn 1974: } else {
1.63 raeburn 1975: $r->print(&mt('An error occurred storing the quota(s) for group portfolio files and/or uploaded content: ').
1.61 raeburn 1976: $putreply);
1.28 raeburn 1977: }
1978: }
1.48 raeburn 1979: $r->print('<p>'.
1980: '<a href="javascript:changePage(document.processquota,'."'menu'".')">'.
1981: &mt('Pick another action').'</a>');
1.28 raeburn 1982: $r->print(&hidden_form_elements().'</form>');
1983: return;
1.1 raeburn 1984: }
1985:
1.57 raeburn 1986: sub modify_anonsurvey_threshold {
1987: my ($r,$cdom,$cnum,$cdesc,$domdesc,$type) = @_;
1988: &print_header($r,$type);
1989: $r->print('<form action="/adm/modifycourse" method="post" name="processthreshold">'."\n".
1990: '<h3>'.&mt('Responder threshold required for display of anonymous survey submissions:').
1991: ' <span class="LC_nobreak">'.$cdesc.'</span></h3><br />');
1992: my %oldsettings = &Apache::lonnet::get('environment',['internal.anonsurvey_threshold'],$cdom,$cnum);
1993: my %domconfig =
1994: &Apache::lonnet::get_dom('configuration',['coursedefaults'],$cdom);
1995: my $defaultthreshold;
1996: if (ref($domconfig{'coursedefaults'}) eq 'HASH') {
1997: $defaultthreshold = $domconfig{'coursedefaults'}{'anonsurvey_threshold'};
1998: if ($defaultthreshold eq '') {
1999: $defaultthreshold = 10;
2000: }
2001: } else {
2002: $defaultthreshold = 10;
2003: }
2004: if ($env{'form.threshold'} eq '') {
2005: $r->print(&mt('The proposed responder threshold for display of anonymous survey submissions was blank, so the threshold is unchanged.'));
2006: } else {
2007: my $newthreshold = $env{'form.threshold'};
2008: if ($newthreshold =~ /^\s*(\d+)\s*$/) {
2009: $newthreshold = $1;
2010: if ($oldsettings{'internal.anonsurvey_threshold'} eq $env{'form.threshold'}) {
2011: $r->print(&mt('Responder threshold for anonymous survey submissions display remains unchanged: [_1].',$env{'form.threshold'}));
2012: } else {
2013: my %cenv = (
2014: 'internal.anonsurvey_threshold' => $env{'form.threshold'},
2015: );
2016: my $putreply = &Apache::lonnet::put('environment',\%cenv,$cdom,
2017: $cnum);
1.72 raeburn 2018: if ($putreply eq 'ok') {
2019: if ($env{'course.'.$cdom.'_'.$cnum.'.description'} ne '') {
2020: &Apache::lonnet::appenv(
2021: {'course.'.$cdom.'_'.$cnum.'.internal.anonsurvey_threshold' => $env{'form.threshold'}});
2022: }
2023: }
1.57 raeburn 2024: if (($oldsettings{'internal.anonsurvey_threshold'} eq '') &&
2025: ($env{'form.threshold'} == $defaultthreshold)) {
2026: $r->print(&mt('The responder threshold for display of anonymous survey submissions is the default for this domain: [_1].',$defaultthreshold));
2027: } else {
2028: if ($putreply eq 'ok') {
2029: my %updatedsettings = &Apache::lonnet::get('environment',['internal.anonsurvey_threshold'],$cdom,$cnum);
2030: $r->print(&mt('The responder threshold for display of anonymous survey submissions is now: [_1].','<b>'.$updatedsettings{'internal.anonsurvey_threshold'}.'</b>'));
2031: } else {
2032: $r->print(&mt('An error occurred storing the responder threshold for anonymous submissions display: ').
2033: $putreply);
2034: }
2035: }
2036: }
2037: } else {
2038: $r->print(&mt('The proposed responder threshold for display of anonymous submissions contained invalid characters, so the threshold is unchanged.'));
2039: }
2040: }
2041: $r->print('<p>'.
2042: '<a href="javascript:changePage(document.processthreshold,'."'menu'".')">'.
1.75 raeburn 2043: &mt('Pick another action').'</a></p>');
2044: $r->print(&hidden_form_elements().'</form>');
2045: return;
2046: }
2047:
2048: sub modify_postsubmit_config {
2049: my ($r,$cdom,$cnum,$cdesc,$domdesc,$type) = @_;
2050: &print_header($r,$type);
2051: my %lt = &Apache::lonlocal::texthash(
2052: subb => 'Submit button behavior after student makes a submission:',
2053: unch => 'Post submission behavior of the Submit button is unchanged.',
2054: erro => 'An error occurred when saving your proposed changes.',
2055: inva => 'An invalid response was recorded.',
2056: pick => 'Pick another action',
2057: );
2058: $r->print('<form action="/adm/modifycourse" method="post" name="processpostsubmit">'."\n".
2059: '<h3>'.$lt{'subb'}.' <span class="LC_nobreak">('.$cdesc.')</span></h3><br />');
2060: my %oldsettings =
2061: &Apache::lonnet::get('environment',['internal.postsubmit','internal.postsubtimeout','internal.coursecode','internal.textbook'],$cdom,$cnum);
2062: my $postsubmit = $env{'form.postsubmit'};
2063: if ($postsubmit eq '1') {
2064: my $postsubtimeout = $env{'form.postsubtimeout'};
2065: $postsubtimeout =~ s/[^\d\.]+//g;
2066: if (($oldsettings{'internal.postsubmit'} eq $postsubmit) && ($oldsettings{'internal.postsubtimeout'} eq $postsubtimeout)) {
2067: $r->print($lt{'unch'});
2068: } else {
2069: my %cenv = (
2070: 'internal.postsubmit' => $postsubmit,
2071: );
2072: if ($postsubtimeout eq '') {
2073: my $putreply = &Apache::lonnet::put('environment',\%cenv,$cdom,$cnum);
2074: if ($putreply eq 'ok') {
2075: my $defaulttimeout = &domain_postsubtimeout($cdom,$type,\%oldsettings);
2076: $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));
2077: if (exists($oldsettings{'internal.postsubtimeout'})) {
2078: &Apache::lonnet::del('environment',['internal.postsubtimeout'],$cdom,$cnum);
2079: }
2080: } else {
2081: $r->print($lt{'erro'});
2082: }
2083: } else {
2084: $cenv{'internal.postsubtimeout'} = $postsubtimeout;
2085: my $putreply = &Apache::lonnet::put('environment',\%cenv,$cdom,$cnum);
2086: if ($putreply eq 'ok') {
2087: if ($postsubtimeout eq '0') {
2088: $r->print(&mt('Submit button will be disabled after student submission until page is reloaded.'));
2089: } else {
2090: $r->print(&mt('Submit button will be disabled after student submission for [quant,_1,second].',$postsubtimeout));
2091: }
2092: } else {
2093: $r->print($lt{'erro'});
2094: }
2095: }
2096: }
2097: } elsif ($postsubmit eq '0') {
2098: if ($oldsettings{'internal.postsubmit'} eq $postsubmit) {
2099: $r->print($lt{'unch'});
2100: } else {
2101: if (exists($oldsettings{'internal.postsubtimeout'})) {
2102: &Apache::lonnet::del('environment',['internal.postsubtimeout'],$cdom,$cnum);
2103: }
2104: my %cenv = (
2105: 'internal.postsubmit' => $postsubmit,
2106: );
2107: my $putreply = &Apache::lonnet::put('environment',\%cenv,$cdom,$cnum);
2108: if ($putreply eq 'ok') {
1.76 droeschl 2109: $r->print(&mt('Submit button will not be disabled after student submission'));
1.75 raeburn 2110: } else {
2111: $r->print($lt{'erro'});
2112: }
2113: }
2114: } else {
2115: $r->print($lt{'inva'}.' '.$lt{'unch'});
2116: }
2117: $r->print('<p>'.
2118: '<a href="javascript:changePage(document.processpostsubmit,'."'menu'".')">'.
2119: &mt('Pick another action').'</a></p>');
1.57 raeburn 2120: $r->print(&hidden_form_elements().'</form>');
2121: return;
2122: }
2123:
1.38 raeburn 2124: sub modify_catsettings {
1.48 raeburn 2125: my ($r,$cdom,$cnum,$cdesc,$domdesc,$type) = @_;
2126: &print_header($r,$type);
2127: my ($ccrole,%desc);
2128: if ($type eq 'Community') {
2129: $desc{'hidefromcat'} = &mt('Excluded from community catalog');
2130: $desc{'categories'} = &mt('Assigned categories for this community');
2131: $ccrole = 'co';
2132: } else {
2133: $desc{'hidefromcat'} = &mt('Excluded from course catalog');
2134: $desc{'categories'} = &mt('Assigned categories for this course');
2135: $ccrole = 'cc';
2136: }
1.38 raeburn 2137: $r->print('
2138: <form action="/adm/modifycourse" method="post" name="processcat">
2139: <h3>'.&mt('Category settings').'</h3>');
2140: my %domconf = &Apache::lonnet::get_dom('configuration',['coursecategories'],$cdom);
1.49 raeburn 2141: my @cat_params = &catalog_settable($domconf{'coursecategories'},$type);
1.38 raeburn 2142: if (@cat_params > 0) {
2143: my (%cenv,@changes,@nochanges);
2144: my %currsettings =
2145: &Apache::lonnet::get('environment',['hidefromcat','categories'],$cdom,$cnum);
2146: my (@newcategories,%showitem);
2147: if (grep(/^togglecats$/,@cat_params)) {
2148: if ($currsettings{'hidefromcat'} ne $env{'form.hidefromcat'}) {
2149: push(@changes,'hidefromcat');
2150: $cenv{'hidefromcat'} = $env{'form.hidefromcat'};
2151: } else {
2152: push(@nochanges,'hidefromcat');
2153: }
2154: if ($env{'form.hidefromcat'} eq 'yes') {
2155: $showitem{'hidefromcat'} = '"'.&mt('Yes')."'";
2156: } else {
2157: $showitem{'hidefromcat'} = '"'.&mt('No').'"';
2158: }
2159: }
2160: if (grep(/^categorize$/,@cat_params)) {
2161: my (@cats,@trails,%allitems,%idx,@jsarray);
2162: if (ref($domconf{'coursecategories'}) eq 'HASH') {
2163: my $cathash = $domconf{'coursecategories'}{'cats'};
2164: if (ref($cathash) eq 'HASH') {
2165: &Apache::loncommon::extract_categories($cathash,\@cats,\@trails,
2166: \%allitems,\%idx,\@jsarray);
2167: }
2168: }
2169: @newcategories = &Apache::loncommon::get_env_multiple('form.usecategory');
2170: if (@newcategories == 0) {
2171: $showitem{'categories'} = '"'.&mt('None').'"';
2172: } else {
2173: $showitem{'categories'} = '<ul>';
2174: foreach my $item (@newcategories) {
2175: $showitem{'categories'} .= '<li>'.$trails[$allitems{$item}].'</li>';
2176: }
2177: $showitem{'categories'} .= '</ul>';
2178: }
2179: my $catchg = 0;
2180: if ($currsettings{'categories'} ne '') {
2181: my @currcategories = split('&',$currsettings{'categories'});
2182: foreach my $cat (@currcategories) {
2183: if (!grep(/^\Q$cat\E$/,@newcategories)) {
2184: $catchg = 1;
2185: last;
2186: }
2187: }
2188: if (!$catchg) {
2189: foreach my $cat (@newcategories) {
2190: if (!grep(/^\Q$cat\E$/,@currcategories)) {
2191: $catchg = 1;
2192: last;
2193: }
2194: }
2195: }
2196: } else {
2197: if (@newcategories > 0) {
2198: $catchg = 1;
2199: }
2200: }
2201: if ($catchg) {
2202: $cenv{'categories'} = join('&',@newcategories);
2203: push(@changes,'categories');
2204: } else {
2205: push(@nochanges,'categories');
2206: }
2207: if (@changes > 0) {
2208: my $putreply = &Apache::lonnet::put('environment',\%cenv,$cdom,$cnum);
2209: if ($putreply eq 'ok') {
1.72 raeburn 2210: if ($env{'course.'.$cdom.'_'.$cnum.'.description'} ne '') {
2211: my %newenvhash;
2212: foreach my $item (@changes) {
2213: $newenvhash{'course.'.$cdom.'_'.$cnum.'.'.$item} = $cenv{$item};
2214: }
2215: &Apache::lonnet::appenv(\%newenvhash);
2216: }
1.38 raeburn 2217: my %crsinfo = &Apache::lonnet::courseiddump($cdom,'.',1,'.','.',
2218: $cnum,undef,undef,'.');
2219: if (ref($crsinfo{$env{'form.pickedcourse'}}) eq 'HASH') {
2220: if (grep(/^hidefromcat$/,@changes)) {
2221: $crsinfo{$env{'form.pickedcourse'}}{'hidefromcat'} = $env{'form.hidefromcat'};
2222: }
2223: if (grep(/^categories$/,@changes)) {
2224: $crsinfo{$env{'form.pickedcourse'}}{'categories'} = $cenv{'categories'};
2225: }
2226: my $chome = &Apache::lonnet::homeserver($cnum,$cdom);
2227: my $putres = &Apache::lonnet::courseidput($cdom,\%crsinfo,$chome,'notime');
2228: }
1.48 raeburn 2229: $r->print(&mt('The following changes occurred:').'<ul>');
1.38 raeburn 2230: foreach my $item (@changes) {
1.48 raeburn 2231: $r->print('<li>'.&mt('[_1] now set to: [_2]',$desc{$item},$showitem{$item}).'</li>');
1.38 raeburn 2232: }
2233: $r->print('</ul><br />');
2234: }
2235: }
2236: if (@nochanges > 0) {
1.48 raeburn 2237: $r->print(&mt('The following were unchanged:').'<ul>');
1.38 raeburn 2238: foreach my $item (@nochanges) {
1.48 raeburn 2239: $r->print('<li>'.&mt('[_1] still set to: [_2]',$desc{$item},$showitem{$item}).'</li>');
1.38 raeburn 2240: }
2241: $r->print('</ul>');
2242: }
2243: }
2244: } else {
1.48 raeburn 2245: my $newrole = $ccrole.'./'.$cdom.'/'.$cnum;
2246: my $escuri = &HTML::Entities::encode('/adm/roles?selectrole=1&'.$newrole.
2247: '=1&destinationurl=/adm/courseprefs','&<>"');
2248: if ($type eq 'Community') {
2249: $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 />');
2250: } else {
2251: $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 />');
2252: }
1.38 raeburn 2253: }
2254: $r->print('<br />'."\n".
2255: '<a href="javascript:changePage(document.processcat,'."'menu'".')">'.
1.48 raeburn 2256: &mt('Pick another action').'</a>');
1.38 raeburn 2257: $r->print(&hidden_form_elements().'</form>');
2258: return;
2259: }
2260:
1.1 raeburn 2261: sub print_header {
1.48 raeburn 2262: my ($r,$type,$javascript_validations) = @_;
1.28 raeburn 2263: my $phase = "start";
2264: if ( exists($env{'form.phase'}) ) {
2265: $phase = $env{'form.phase'};
2266: }
2267: my $js = qq|
1.60 raeburn 2268:
1.28 raeburn 2269: function changePage(formname,newphase) {
2270: formname.phase.value = newphase;
2271: if (newphase == 'processparms') {
2272: return;
1.1 raeburn 2273: }
1.28 raeburn 2274: formname.submit();
2275: }
1.60 raeburn 2276:
1.28 raeburn 2277: |;
2278: if ($phase eq 'setparms') {
1.60 raeburn 2279: $js .= $javascript_validations;
1.28 raeburn 2280: } elsif ($phase eq 'courselist') {
1.90 raeburn 2281: $js .= <<"ENDJS";
1.60 raeburn 2282: function hide_searching() {
2283: if (document.getElementById('searching')) {
2284: document.getElementById('searching').style.display = 'none';
2285: }
2286: return;
2287: }
2288:
1.90 raeburn 2289: ENDJS
1.28 raeburn 2290: } elsif ($phase eq 'setquota') {
1.57 raeburn 2291: my $invalid = &mt('The quota you entered contained invalid characters.');
2292: my $alert = &mt('You must enter a number');
1.78 damieng 2293: &js_escape(\$invalid);
2294: &js_escape(\$alert);
1.57 raeburn 2295: my $regexp = '/^\s*(\d+\.?\d*|\.\d+)\s*$/';
2296: $js .= <<"ENDSCRIPT";
1.60 raeburn 2297:
1.57 raeburn 2298: function verify_quota() {
2299: var newquota = document.setquota.coursequota.value;
2300: var num_reg = $regexp;
1.28 raeburn 2301: if (num_reg.test(newquota)) {
1.57 raeburn 2302: changePage(document.setquota,'processquota');
1.1 raeburn 2303: } else {
1.57 raeburn 2304: alert("$invalid\\n$alert");
2305: return false;
1.1 raeburn 2306: }
1.57 raeburn 2307: return true;
2308: }
1.60 raeburn 2309:
1.57 raeburn 2310: ENDSCRIPT
2311: } elsif ($phase eq 'setanon') {
2312: my $invalid = &mt('The responder threshold you entered is invalid.');
2313: my $alert = &mt('You must enter a positive integer.');
1.78 damieng 2314: &js_escape(\$invalid);
2315: &js_escape(\$alert);
1.57 raeburn 2316: my $regexp = ' /^\s*\d+\s*$/';
2317: $js .= <<"ENDSCRIPT";
1.60 raeburn 2318:
1.57 raeburn 2319: function verify_anon_threshold() {
2320: var newthreshold = document.setanon.threshold.value;
2321: var num_reg = $regexp;
2322: if (num_reg.test(newthreshold)) {
2323: if (newthreshold > 0) {
2324: changePage(document.setanon,'processthreshold');
2325: } else {
2326: alert("$invalid\\n$alert");
2327: return false;
2328: }
2329: } else {
2330: alert("$invalid\\n$alert");
2331: return false;
2332: }
2333: return true;
1.28 raeburn 2334: }
1.60 raeburn 2335:
1.28 raeburn 2336: ENDSCRIPT
1.75 raeburn 2337: } elsif ($phase eq 'setpostsubmit') {
2338: my $invalid = &mt('The choice entered for disabling the submit button is invalid.');
2339: my $invalidtimeout = &mt('The timeout you entered for disabling the submit button is invalid.');
2340: my $alert = &mt('Enter one of: a positive integer, 0 (for no timeout), or leave blank to use domain default');
1.78 damieng 2341: &js_escape(\$invalid);
2342: &js_escape(\$invalidtimeout);
2343: &js_escape(\$alert);
1.75 raeburn 2344: my $regexp = ' /^\s*\d+\s*$/';
2345:
2346: $js .= <<"ENDSCRIPT";
2347:
2348: function verify_postsubmit() {
2349: var optionsElement = document.setpostsubmit.postsubmit;
2350: var verified = '';
2351: if (optionsElement.length) {
2352: var currval;
2353: for (var i=0; i<optionsElement.length; i++) {
2354: if (optionsElement[i].checked) {
2355: currval = optionsElement[i].value;
2356: }
2357: }
2358: if (currval == 1) {
2359: var newtimeout = document.setpostsubmit.postsubtimeout.value;
2360: if (newtimeout == '') {
2361: verified = 'ok';
2362: } else {
2363: var num_reg = $regexp;
2364: if (num_reg.test(newtimeout)) {
2365: if (newtimeout>= 0) {
2366: verified = 'ok';
2367: } else {
2368: alert("$invalidtimeout\\n$alert");
2369: return false;
2370: }
2371: } else {
2372: alert("$invalid\\n$alert");
2373: return false;
2374: }
2375: }
2376: } else {
2377: if (currval == 0) {
2378: verified = 'ok';
2379: } else {
2380: alert('$invalid');
2381: return false;
2382: }
2383: }
2384: if (verified == 'ok') {
2385: changePage(document.setpostsubmit,'processpostsubmit');
2386: return true;
2387: }
2388: }
2389: return false;
2390: }
2391:
2392: function togglePostsubmit(caller) {
2393: var optionsElement = document.setpostsubmit.postsubmit;
2394: if (document.getElementById(caller)) {
2395: var divitem = document.getElementById(caller);
2396: var optionsElement = document.setpostsubmit.postsubmit;
2397: if (optionsElement.length) {
2398: var currval;
2399: for (var i=0; i<optionsElement.length; i++) {
2400: if (optionsElement[i].checked) {
2401: currval = optionsElement[i].value;
2402: }
2403: }
2404: if (currval == 1) {
2405: divitem.style.display = 'block';
2406: } else {
2407: divitem.style.display = 'none';
2408: }
2409: }
1.1 raeburn 2410: }
1.75 raeburn 2411: return;
2412: }
1.60 raeburn 2413:
1.75 raeburn 2414: ENDSCRIPT
2415:
2416: }
1.37 raeburn 2417: my $starthash;
1.86 raeburn 2418: if ($env{'form.phase'} eq 'adhocrole') {
1.37 raeburn 2419: $starthash = {
1.86 raeburn 2420: add_entries => {'onload' => "javascript:document.adhocrole.submit();"},
1.37 raeburn 2421: };
1.60 raeburn 2422: } elsif ($phase eq 'courselist') {
2423: $starthash = {
1.74 musolffc 2424: add_entries => {'onload' => "hide_searching(); courseSet(document.filterpicker.official, 'load');"},
1.60 raeburn 2425: };
1.37 raeburn 2426: }
1.48 raeburn 2427: $r->print(&Apache::loncommon::start_page('View/Modify Course/Community Settings',
1.60 raeburn 2428: &Apache::lonhtmlcommon::scripttag($js),
2429: $starthash));
1.48 raeburn 2430: my $bread_text = "View/Modify Courses/Communities";
2431: if ($type eq 'Community') {
2432: $bread_text = 'Community Settings';
1.81 raeburn 2433: } elsif ($type eq 'Placement') {
2434: $bread_text = 'Placement Test Settings';
1.41 raeburn 2435: } else {
1.48 raeburn 2436: $bread_text = 'Course Settings';
1.41 raeburn 2437: }
1.48 raeburn 2438: $r->print(&Apache::lonhtmlcommon::breadcrumbs($bread_text));
1.5 raeburn 2439: return;
1.1 raeburn 2440: }
2441:
2442: sub print_footer {
1.23 albertel 2443: my ($r) = @_;
2444: $r->print('<br />'.&Apache::loncommon::end_page());
1.5 raeburn 2445: return;
1.3 raeburn 2446: }
2447:
2448: sub check_course {
1.71 raeburn 2449: my ($dom,$domdesc) = @_;
2450: my ($ok_course,$description,$instcode);
2451: my %coursehash;
2452: if ($env{'form.pickedcourse'} =~ /^$match_domain\_$match_courseid$/) {
2453: my %args;
2454: unless ($env{'course.'.$env{'form.pickedcourse'}.'.description'}) {
2455: %args = (
2456: 'one_time' => 1,
2457: 'freshen_cache' => 1,
2458: );
2459: }
2460: %coursehash =
2461: &Apache::lonnet::coursedescription($env{'form.pickedcourse'},\%args);
2462: my $cnum = $coursehash{'num'};
2463: my $cdom = $coursehash{'domain'};
2464: $description = $coursehash{'description'};
2465: $instcode = $coursehash{'internal.coursecode'};
2466: if ($instcode) {
2467: $description .= " ($instcode)";
2468: }
2469: if (($cdom eq $dom) && ($cnum =~ /^$match_courseid$/)) {
2470: my %courseIDs = &Apache::lonnet::courseiddump($cdom,'.',1,'.','.',
2471: $cnum,undef,undef,'.');
2472: if ($courseIDs{$cdom.'_'.$cnum}) {
2473: $ok_course = 'ok';
1.5 raeburn 2474: }
1.3 raeburn 2475: }
2476: }
1.71 raeburn 2477: return ($ok_course,$description,\%coursehash);
1.1 raeburn 2478: }
2479:
1.28 raeburn 2480: sub course_settings_descrip {
1.48 raeburn 2481: my ($type) = @_;
2482: my %longtype;
2483: if ($type eq 'Community') {
2484: %longtype = &Apache::lonlocal::texthash(
1.72 raeburn 2485: 'courseowner' => "Username:domain of community owner",
2486: 'co-owners' => "Username:domain of each co-owner",
2487: 'selfenrollmgrdc' => "Community-specific self-enrollment configuration by Domain Coordinator",
2488: 'selfenrollmgrcc' => "Community-specific self-enrollment configuration by Community personnel",
1.85 raeburn 2489: 'mysqltables' => '"Temporary" student performance tables lifetime (seconds)',
1.48 raeburn 2490: );
2491: } else {
2492: %longtype = &Apache::lonlocal::texthash(
1.28 raeburn 2493: 'authtype' => 'Default authentication method',
2494: 'autharg' => 'Default authentication parameter',
2495: 'autoadds' => 'Automated adds',
2496: 'autodrops' => 'Automated drops',
2497: 'autostart' => 'Date of first automated enrollment',
2498: 'autoend' => 'Date of last automated enrollment',
2499: 'default_enrollment_start_date' => 'Date of first student access',
2500: 'default_enrollment_end_date' => 'Date of last student access',
2501: 'coursecode' => 'Official course code',
2502: 'courseowner' => "Username:domain of course owner",
1.50 raeburn 2503: 'co-owners' => "Username:domain of each co-owner",
1.28 raeburn 2504: 'notifylist' => 'Course Coordinators to be notified of enrollment changes',
1.48 raeburn 2505: 'sectionnums' => 'Course section number:LON-CAPA section',
2506: 'crosslistings' => 'Crosslisted class:LON-CAPA section',
1.72 raeburn 2507: 'defaultcredits' => 'Credits',
1.84 raeburn 2508: 'autodropfailsafe' => "Failsafe section enrollment count",
1.72 raeburn 2509: 'selfenrollmgrdc' => "Course-specific self-enrollment configuration by Domain Coordinator",
2510: 'selfenrollmgrcc' => "Course-specific self-enrollment configuration by Course personnel",
1.85 raeburn 2511: 'mysqltables' => '"Temporary" student performance tables lifetime (seconds)',
1.94 raeburn 2512: 'nopasswdchg' => 'Disable changing password for users with student role by course owner',
1.48 raeburn 2513: );
2514: }
1.28 raeburn 2515: return %longtype;
2516: }
2517:
2518: sub hidden_form_elements {
2519: my $hidden_elements =
1.46 raeburn 2520: &Apache::lonhtmlcommon::echo_form_input(['gosearch','updater','coursecode',
1.37 raeburn 2521: 'prevphase','numlocalcc','courseowner','login','coursequota','intarg',
1.57 raeburn 2522: 'locarg','krbarg','krbver','counter','hidefromcat','usecategory',
1.75 raeburn 2523: 'threshold','postsubmit','postsubtimeout','defaultcredits','uploadquota',
2524: 'selfenrollmgrdc','selfenrollmgrcc','action','state','currsec_st',
1.94 raeburn 2525: 'sections','newsec','mysqltables','nopasswdchg'],
2526: ['^selfenrollmgr_','^selfenroll_'])."\n".
1.37 raeburn 2527: '<input type="hidden" name="prevphase" value="'.$env{'form.phase'}.'" />';
1.28 raeburn 2528: return $hidden_elements;
2529: }
1.1 raeburn 2530:
1.60 raeburn 2531: sub showcredits {
2532: my ($dom) = @_;
2533: my %domdefaults = &Apache::lonnet::get_domain_defaults($dom);
1.79 raeburn 2534: if ($domdefaults{'officialcredits'} || $domdefaults{'unofficialcredits'} || $domdefaults{'textbookcredits'}) {
1.60 raeburn 2535: return 1;
2536: }
2537: }
2538:
1.86 raeburn 2539: sub get_permission {
2540: my ($dom) = @_;
2541: my ($allowed,%permission);
1.94 raeburn 2542: my %passwdconf = &Apache::lonnet::get_passwdconf($dom);
1.86 raeburn 2543: if (&Apache::lonnet::allowed('ccc',$dom)) {
2544: $allowed = 1;
2545: %permission = (
1.88 raeburn 2546: setquota => 'edit',
2547: processquota => 'edit',
2548: setanon => 'edit',
2549: processthreshold => 'edit',
2550: setpostsubmit => 'edit',
2551: processpostsubmit => 'edit',
2552: viewparms => 'view',
2553: setparms => 'edit',
2554: processparms => 'edit',
2555: catsettings => 'edit',
2556: processcat => 'edit',
2557: selfenroll => 'edit',
1.90 raeburn 2558: adhocrole => 'coord',
1.86 raeburn 2559: );
1.94 raeburn 2560: if ($passwdconf{'crsownerchg'}) {
2561: $permission{passwdchg} = 'edit';
2562: }
1.86 raeburn 2563: } elsif (&Apache::lonnet::allowed('rar',$dom)) {
2564: $allowed = 1;
2565: %permission = (
1.88 raeburn 2566: setquota => 'view',
2567: viewparms => 'view',
2568: setanon => 'view',
2569: setpostsubmit => 'view',
2570: setparms => 'view',
2571: catsettings => 'view',
2572: selfenroll => 'view',
1.90 raeburn 2573: adhocrole => 'custom',
1.86 raeburn 2574: );
1.94 raeburn 2575: if ($passwdconf{'crsownerchg'}) {
2576: $permission{passwdchg} = 'view';
2577: }
1.86 raeburn 2578: }
2579: return ($allowed,\%permission);
2580: }
2581:
1.95 raeburn 2582: sub devalidate_remote_instcats {
2583: if ($modified_dom ne '') {
2584: my %servers = &Apache::lonnet::internet_dom_servers($modified_dom);
2585: my %thismachine;
2586: map { $thismachine{$_} = 1; } &Apache::lonnet::current_machine_ids();
2587: if (keys(%servers)) {
2588: foreach my $server (keys(%servers)) {
2589: next if ($thismachine{$server});
2590: &Apache::lonnet::remote_devalidate_cache($server,['instcats:'.$modified_dom]);
2591: }
2592: }
2593: $modified_dom = '';
2594: }
2595: return;
2596: }
2597:
1.1 raeburn 2598: sub handler {
2599: my $r = shift;
2600: if ($r->header_only) {
2601: &Apache::loncommon::content_type($r,'text/html');
2602: $r->send_http_header;
2603: return OK;
2604: }
1.72 raeburn 2605:
1.95 raeburn 2606: $registered_cleanup=0;
2607: $modified_dom = '';
2608:
1.28 raeburn 2609: my $dom = $env{'request.role.domain'};
1.31 albertel 2610: my $domdesc = &Apache::lonnet::domain($dom,'description');
1.86 raeburn 2611: my ($allowed,$permission) = &get_permission($dom);
2612: if ($allowed) {
1.1 raeburn 2613: &Apache::loncommon::content_type($r,'text/html');
2614: $r->send_http_header;
2615:
1.28 raeburn 2616: &Apache::lonhtmlcommon::clear_breadcrumbs();
2617:
2618: my $phase = $env{'form.phase'};
1.46 raeburn 2619: if ($env{'form.updater'}) {
2620: $phase = '';
2621: }
1.37 raeburn 2622: if ($phase eq '') {
2623: &Apache::lonhtmlcommon::add_breadcrumb
1.28 raeburn 2624: ({href=>"/adm/modifycourse",
1.48 raeburn 2625: text=>"Course/Community search"});
1.28 raeburn 2626: &print_course_search_page($r,$dom,$domdesc);
1.1 raeburn 2627: } else {
1.37 raeburn 2628: my $firstform = $phase;
2629: if ($phase eq 'courselist') {
2630: $firstform = 'filterpicker';
1.48 raeburn 2631: }
2632: my $choose_text;
2633: my $type = $env{'form.type'};
2634: if ($type eq '') {
2635: $type = 'Course';
2636: }
2637: if ($type eq 'Community') {
2638: $choose_text = "Choose a community";
1.81 raeburn 2639: } elsif ($type eq 'Placement') {
2640: $choose_text = "Choose a placement test";
1.48 raeburn 2641: } else {
2642: $choose_text = "Choose a course";
1.37 raeburn 2643: }
1.28 raeburn 2644: &Apache::lonhtmlcommon::add_breadcrumb
1.37 raeburn 2645: ({href=>"javascript:changePage(document.$firstform,'')",
1.48 raeburn 2646: text=>"Course/Community search"},
1.37 raeburn 2647: {href=>"javascript:changePage(document.$phase,'courselist')",
1.48 raeburn 2648: text=>$choose_text});
1.28 raeburn 2649: if ($phase eq 'courselist') {
1.90 raeburn 2650: &print_course_selection_page($r,$dom,$domdesc,$permission);
1.28 raeburn 2651: } else {
1.71 raeburn 2652: my ($checked,$cdesc,$coursehash) = &check_course($dom,$domdesc);
1.28 raeburn 2653: if ($checked eq 'ok') {
1.48 raeburn 2654: my $enter_text;
2655: if ($type eq 'Community') {
2656: $enter_text = 'Enter community';
1.81 raeburn 2657: } elsif ($type eq 'Placement') {
2658: $enter_text = 'Enter placement test';
1.48 raeburn 2659: } else {
2660: $enter_text = 'Enter course';
2661: }
1.28 raeburn 2662: if ($phase eq 'menu') {
1.37 raeburn 2663: &Apache::lonhtmlcommon::add_breadcrumb
2664: ({href=>"javascript:changePage(document.$phase,'menu')",
2665: text=>"Pick action"});
1.71 raeburn 2666: &print_modification_menu($r,$cdesc,$domdesc,$dom,$type,
1.86 raeburn 2667: $env{'form.pickedcourse'},$coursehash,
2668: $permission);
2669: } elsif ($phase eq 'adhocrole') {
1.37 raeburn 2670: &Apache::lonhtmlcommon::add_breadcrumb
1.86 raeburn 2671: ({href=>"javascript:changePage(document.$phase,'adhocrole')",
1.48 raeburn 2672: text=>$enter_text});
1.90 raeburn 2673: &print_adhocrole_selected($r,$type,$permission);
1.28 raeburn 2674: } else {
1.37 raeburn 2675: &Apache::lonhtmlcommon::add_breadcrumb
2676: ({href=>"javascript:changePage(document.$phase,'menu')",
2677: text=>"Pick action"});
1.28 raeburn 2678: my ($cdom,$cnum) = split(/_/,$env{'form.pickedcourse'});
1.88 raeburn 2679: my ($readonly,$linktext);
2680: if ($permission->{$phase} eq 'view') {
2681: $readonly = 1;
2682: }
1.86 raeburn 2683: if (($phase eq 'setquota') && ($permission->{'setquota'})) {
1.88 raeburn 2684: if ($permission->{'setquota'} eq 'view') {
2685: $linktext = 'Set quota';
2686: } else {
2687: $linktext = 'Display quota';
2688: }
1.28 raeburn 2689: &Apache::lonhtmlcommon::add_breadcrumb
2690: ({href=>"javascript:changePage(document.$phase,'$phase')",
1.89 raeburn 2691: text=>$linktext});
1.88 raeburn 2692: &print_setquota($r,$cdom,$cnum,$cdesc,$type,$readonly);
1.86 raeburn 2693: } elsif (($phase eq 'processquota') && ($permission->{'processquota'})) {
1.28 raeburn 2694: &Apache::lonhtmlcommon::add_breadcrumb
2695: ({href=>"javascript:changePage(document.$phase,'setquota')",
2696: text=>"Set quota"});
2697: &Apache::lonhtmlcommon::add_breadcrumb
2698: ({href=>"javascript:changePage(document.$phase,'$phase')",
2699: text=>"Result"});
1.48 raeburn 2700: &modify_quota($r,$cdom,$cnum,$cdesc,$domdesc,$type);
1.86 raeburn 2701: } elsif (($phase eq 'setanon') && ($permission->{'setanon'})) {
1.57 raeburn 2702: &Apache::lonhtmlcommon::add_breadcrumb
2703: ({href=>"javascript:changePage(document.$phase,'$phase')",
2704: text=>"Threshold for anonymous submissions display"});
1.88 raeburn 2705: &print_set_anonsurvey_threshold($r,$cdom,$cnum,$cdesc,$type,$readonly);
1.86 raeburn 2706: } elsif (($phase eq 'processthreshold') && ($permission->{'processthreshold'})) {
1.57 raeburn 2707: &Apache::lonhtmlcommon::add_breadcrumb
2708: ({href=>"javascript:changePage(document.$phase,'setanon')",
2709: text=>"Threshold for anonymous submissions display"});
2710: &Apache::lonhtmlcommon::add_breadcrumb
2711: ({href=>"javascript:changePage(document.$phase,'$phase')",
2712: text=>"Result"});
2713: &modify_anonsurvey_threshold($r,$cdom,$cnum,$cdesc,$domdesc,$type);
1.86 raeburn 2714: } elsif (($phase eq 'setpostsubmit') && ($permission->{'setpostsubmit'})) {
1.88 raeburn 2715: if ($permission->{'setpostsubmit'} eq 'view') {
2716: $linktext = 'Submit button behavior post-submission';
2717: } else {
2718: $linktext = 'Configure submit button behavior post-submission';
2719: }
1.75 raeburn 2720: &Apache::lonhtmlcommon::add_breadcrumb
2721: ({href=>"javascript:changePage(document.$phase,'$phase')",
1.89 raeburn 2722: text=>$linktext});
1.88 raeburn 2723: &print_postsubmit_config($r,$cdom,$cnum,$cdesc,$type,$readonly);
1.86 raeburn 2724: } elsif (($phase eq 'processpostsubmit') && ($permission->{'processpostsubmit'})) {
1.75 raeburn 2725: &Apache::lonhtmlcommon::add_breadcrumb
2726: ({href=>"javascript:changePage(document.$phase,'$phase')",
2727: text=>"Result"});
2728: &modify_postsubmit_config($r,$cdom,$cnum,$cdesc,$domdesc,$type);
1.86 raeburn 2729: } elsif (($phase eq 'viewparms') && ($permission->{'viewparms'})) {
1.28 raeburn 2730: &Apache::lonhtmlcommon::add_breadcrumb
2731: ({href=>"javascript:changePage(document.$phase,'viewparms')",
2732: text=>"Display settings"});
1.86 raeburn 2733: &print_settings_display($r,$cdom,$cnum,$cdesc,$type,$permission);
2734: } elsif (($phase eq 'setparms') && ($permission->{'setparms'})) {
1.88 raeburn 2735: if ($permission->{'setparms'} eq 'view') {
2736: $linktext = 'Display settings';
2737: } else {
2738: $linktext = 'Change settings';
2739: }
1.28 raeburn 2740: &Apache::lonhtmlcommon::add_breadcrumb
2741: ({href=>"javascript:changePage(document.$phase,'$phase')",
1.89 raeburn 2742: text=>$linktext});
1.88 raeburn 2743: &print_course_modification_page($r,$cdom,$cnum,$cdesc,$type,$readonly);
1.86 raeburn 2744: } elsif (($phase eq 'processparms') && ($permission->{'processparms'})) {
1.28 raeburn 2745: &Apache::lonhtmlcommon::add_breadcrumb
2746: ({href=>"javascript:changePage(document.$phase,'setparms')",
2747: text=>"Change settings"});
2748: &Apache::lonhtmlcommon::add_breadcrumb
2749: ({href=>"javascript:changePage(document.$phase,'$phase')",
2750: text=>"Result"});
1.30 raeburn 2751: &modify_course($r,$cdom,$cnum,$cdesc,$domdesc,$type);
1.86 raeburn 2752: } elsif (($phase eq 'catsettings') && ($permission->{'catsettings'})) {
1.38 raeburn 2753: &Apache::lonhtmlcommon::add_breadcrumb
2754: ({href=>"javascript:changePage(document.$phase,'$phase')",
2755: text=>"Catalog settings"});
1.88 raeburn 2756: &print_catsettings($r,$cdom,$cnum,$cdesc,$type,$readonly);
1.86 raeburn 2757: } elsif (($phase eq 'processcat') && ($permission->{'processcat'})) {
1.38 raeburn 2758: &Apache::lonhtmlcommon::add_breadcrumb
2759: ({href=>"javascript:changePage(document.$phase,'catsettings')",
2760: text=>"Catalog settings"});
2761: &Apache::lonhtmlcommon::add_breadcrumb
2762: ({href=>"javascript:changePage(document.$phase,'$phase')",
2763: text=>"Result"});
1.48 raeburn 2764: &modify_catsettings($r,$cdom,$cnum,$cdesc,$domdesc,$type);
1.86 raeburn 2765: } elsif (($phase eq 'selfenroll') && ($permission->{'selfenroll'})) {
1.72 raeburn 2766: &Apache::lonhtmlcommon::add_breadcrumb
2767: ({href => "javascript:changePage(document.$phase,'$phase')",
2768: text => "Self-enrollment settings"});
2769: if (!exists($env{'form.state'})) {
1.88 raeburn 2770: &print_selfenrollconfig($r,$type,$cdesc,$coursehash,$readonly);
1.72 raeburn 2771: } elsif ($env{'form.state'} eq 'done') {
2772: &Apache::lonhtmlcommon::add_breadcrumb
2773: ({href=>"javascript:changePage(document.$phase,'$phase')",
2774: text=>"Result"});
2775: &modify_selfenrollconfig($r,$type,$cdesc,$coursehash);
2776: }
1.28 raeburn 2777: }
2778: }
2779: } else {
1.48 raeburn 2780: $r->print('<span class="LC_error">');
2781: if ($type eq 'Community') {
1.72 raeburn 2782: $r->print(&mt('The community you selected is not a valid community in this domain'));
1.81 raeburn 2783: } elsif ($type eq 'Placement') {
2784: $r->print(&mt('The course you selected is not a valid placement test in this domain'));
1.72 raeburn 2785: } else {
1.48 raeburn 2786: $r->print(&mt('The course you selected is not a valid course in this domain'));
2787: }
2788: $r->print(" ($domdesc)</span>");
1.28 raeburn 2789: }
2790: }
1.1 raeburn 2791: }
1.28 raeburn 2792: &print_footer($r);
1.1 raeburn 2793: } else {
1.16 albertel 2794: $env{'user.error.msg'}=
1.48 raeburn 2795: "/adm/modifycourse:ccc:0:0:Cannot modify course/community settings";
1.1 raeburn 2796: return HTTP_NOT_ACCEPTABLE;
2797: }
2798: return OK;
2799: }
2800:
2801: 1;
2802: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>