Annotation of loncom/interface/lonmodifycourse.pm, revision 1.104
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.104 ! raeburn 4: # $Id: lonmodifycourse.pm,v 1.103 2023/09/05 03:42:31 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;
1.103 raeburn 107: if ((ref($internals) eq 'ARRAY') && (ref($accessdates) eq 'ARRAY')) {
1.48 raeburn 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.102 raeburn 414: my ($ccrole,$categorytitle,$setquota_text,$setuploadquota_text,$cdom,$cnum,
415: $extendedtype);
1.71 raeburn 416: if (ref($coursehash) eq 'HASH') {
417: $cdom = $coursehash->{'domain'};
418: $cnum = $coursehash->{'num'};
419: } else {
420: ($cdom,$cnum) = split(/_/,$cid);
421: }
1.48 raeburn 422: if ($type eq 'Community') {
423: $ccrole = 'co';
424: } else {
425: $ccrole = 'cc';
1.61 raeburn 426: }
1.88 raeburn 427: my %linktext;
428: if ($permission->{'setparms'} eq 'edit') {
429: %linktext = (
430: 'setquota' => 'View/Modify quotas for group portfolio files, and for uploaded content',
431: 'setanon' => 'View/Modify responders threshold for anonymous survey submissions display',
432: 'selfenroll' => 'View/Modify Self-Enrollment configuration',
433: 'setpostsubmit' => 'View/Modify submit button behavior, post-submission',
1.97 raeburn 434: 'setltiauth' => 'View/Modify re-authentication requirement for LTI launch of deep-linked item',
1.99 raeburn 435: 'setexttool' => 'View/Modify External Tools permissions',
1.104 ! raeburn 436: 'setcrsauthor' => 'View/Modify In-course Authoring permissions',
1.88 raeburn 437: );
438: } else {
439: %linktext = (
440: 'setquota' => 'View quotas for group portfolio files, and for uploaded content',
441: 'setanon' => 'View responders threshold for anonymous survey submissions display',
442: 'selfenroll' => 'View Self-Enrollment configuration',
443: 'setpostsubmit' => 'View submit button behavior, post-submission',
1.97 raeburn 444: 'setltiauth' => 'View re-authentication requirement for LTI launch of deep-linked item',
1.99 raeburn 445: 'setexttool' => 'View External Tools permissions',
1.104 ! raeburn 446: 'setcrsauthor' => 'View In-course Authoring permissions',
1.88 raeburn 447: );
448: }
1.48 raeburn 449: if ($type eq 'Community') {
1.103 raeburn 450: if ($permission->{'setparms'} eq 'edit') {
1.88 raeburn 451: $categorytitle = 'View/Modify Community Settings';
1.102 raeburn 452: $linktext{'setparms'} = 'View/Modify community owner, self-enrollment and table lifetime';
1.88 raeburn 453: $linktext{'catsettings'} = 'View/Modify catalog settings for community';
454: } else {
455: $categorytitle = 'View Community Settings';
1.102 raeburn 456: $linktext{'setparms'} = 'View community owner, self-enrollment and table lifetime';
1.88 raeburn 457: $linktext{'catsettings'} = 'View catalog settings for community';
458: }
1.48 raeburn 459: $setquota_text = &mt('Total disk space allocated for storage of portfolio files in all groups in a community.');
1.103 raeburn 460: $setuploadquota_text = &mt('Disk space allocated for storage of content uploaded directly to a community via Content Editor.');
1.48 raeburn 461: } else {
1.88 raeburn 462: if ($permission->{'setparms'} eq 'edit') {
463: $categorytitle = 'View/Modify Course Settings';
464: $linktext{'catsettings'} = 'View/Modify catalog settings for course';
465: if (($type ne 'Placement') && (&showcredits($dom))) {
466: $linktext{'setparms'} = 'View/Modify course owner, institutional code, default authentication, credits, self-enrollment and table lifetime';
467: } else {
468: $linktext{'setparms'} = 'View/Modify course owner, institutional code, default authentication, self-enrollment and table lifetime';
469: }
470: } else {
471: $categorytitle = 'View Course Settings';
472: $linktext{'catsettings'} = 'View catalog settings for course';
473: if (($type ne 'Placement') && (&showcredits($dom))) {
474: $linktext{'setparms'} = 'View course owner, institutional code, default authentication, credits, self-enrollment and table lifetime';
475: } else {
476: $linktext{'setparms'} = 'View course owner, institutional code, default authentication, self-enrollment and table lifetime';
477: }
478: }
1.48 raeburn 479: $setquota_text = &mt('Total disk space allocated for storage of portfolio files in all groups in a course.');
1.61 raeburn 480: $setuploadquota_text = &mt('Disk space allocated for storage of content uploaded directly to a course via Content Editor.');
1.102 raeburn 481: my %settings = &Apache::lonnet::get('environment',['internal.coursecode','internal.textbook'],
482: $cdom,$cnum);
483: $extendedtype = ucfirst(&Apache::lonuserutils::get_extended_type($cdom,$cnum,$type,\%settings));
1.48 raeburn 484: }
1.75 raeburn 485: my $anon_text = &mt('Responder threshold required to display anonymous survey submissions.');
1.103 raeburn 486: my $postsubmit_text = &mt('Override defaults for submit button behavior post-submission for this specific course.');
1.85 raeburn 487: my $mysqltables_text = &mt('Override default for lifetime of "temporary" MySQL tables containing student performance data.');
1.99 raeburn 488: my $ltiauth_text = &mt('Override default for requirement for re-authentication for LTI-limited launch of deep-linked item.');
489: my $exttool_text = &mt('Override default permissions for external tools use for this specific course.');
1.88 raeburn 490: $linktext{'viewparms'} = 'Display current settings for automated enrollment';
1.54 bisitz 491:
1.38 raeburn 492: my %domconf = &Apache::lonnet::get_dom('configuration',['coursecategories'],$dom);
1.49 raeburn 493: my @additional_params = &catalog_settable($domconf{'coursecategories'},$type);
1.54 bisitz 494:
1.72 raeburn 495: sub manage_selfenrollment {
1.86 raeburn 496: my ($cdom,$cnum,$type,$coursehash,$permission) = @_;
497: if ($permission->{'selfenroll'}) {
498: my ($managed_by_cc,$managed_by_dc) = &Apache::lonuserutils::selfenrollment_administration($cdom,$cnum,$type,$coursehash);
499: if (ref($managed_by_dc) eq 'ARRAY') {
500: if (@{$managed_by_dc}) {
501: return 1;
1.87 raeburn 502: }
1.86 raeburn 503: }
1.72 raeburn 504: }
505: return 0;
506: }
507:
1.54 bisitz 508: sub phaseurl {
509: my $phase = shift;
510: return "javascript:changePage(document.menu,'$phase')"
1.38 raeburn 511: }
1.54 bisitz 512: my @menu =
513: ({ categorytitle => $categorytitle,
514: items => [
515: {
1.88 raeburn 516: linktext => $linktext{'setparms'},
1.54 bisitz 517: url => &phaseurl('setparms'),
1.86 raeburn 518: permission => $permission->{'setparms'},
1.54 bisitz 519: #help => '',
1.55 bisitz 520: icon => 'crsconf.png',
1.54 bisitz 521: linktitle => ''
522: },
523: {
1.88 raeburn 524: linktext => $linktext{'setquota'},
1.54 bisitz 525: url => &phaseurl('setquota'),
1.86 raeburn 526: permission => $permission->{'setquota'},
1.54 bisitz 527: #help => '',
1.55 bisitz 528: icon => 'groupportfolioquota.png',
1.54 bisitz 529: linktitle => ''
530: },
531: {
1.88 raeburn 532: linktext => $linktext{'setanon'},
1.57 raeburn 533: url => &phaseurl('setanon'),
1.86 raeburn 534: permission => $permission->{'setanon'},
1.57 raeburn 535: #help => '',
536: icon => 'anonsurveythreshold.png',
537: linktitle => ''
538: },
539: {
1.88 raeburn 540: linktext => $linktext{'catsettings'},
1.54 bisitz 541: url => &phaseurl('catsettings'),
1.86 raeburn 542: permission => (($permission->{'catsettings'}) && (@additional_params > 0)),
1.54 bisitz 543: #help => '',
1.55 bisitz 544: icon => 'ccatconf.png',
1.54 bisitz 545: linktitle => ''
546: },
547: {
1.88 raeburn 548: linktext => $linktext{'viewparms'},
1.54 bisitz 549: url => &phaseurl('viewparms'),
1.86 raeburn 550: permission => ($permission->{'viewparms'} && ($type ne 'Community') && ($type ne 'Placement')),
1.54 bisitz 551: #help => '',
1.55 bisitz 552: icon => 'roles.png',
1.54 bisitz 553: linktitle => ''
554: },
1.72 raeburn 555: {
1.89 raeburn 556: linktext => $linktext{'selfenroll'},
1.72 raeburn 557: icon => 'self_enroll.png',
558: #help => 'Course_Self_Enrollment',
559: url => &phaseurl('selfenroll'),
1.86 raeburn 560: permission => &manage_selfenrollment($cdom,$cnum,$type,$coursehash,$permission),
1.72 raeburn 561: linktitle => 'Configure user self-enrollment.',
562: },
1.75 raeburn 563: {
1.88 raeburn 564: linktext => $linktext{'setpostsubmit'},
1.75 raeburn 565: icon => 'emblem-readonly.png',
566: #help => '',
567: url => &phaseurl('setpostsubmit'),
1.86 raeburn 568: permission => $permission->{'setpostsubmit'},
1.75 raeburn 569: linktitle => '',
570: },
1.97 raeburn 571: {
572: linktext => $linktext{'setltiauth'},
573: icon => 'system-lock-screen.png',
574: #help => '',
575: url => &phaseurl('setltiauth'),
576: permission => $permission->{'setltiauth'},
577: linktitle => '',
578: },
1.99 raeburn 579: {
580: linktext => $linktext{'setexttool'},
581: icon => 'exttool.png',
582: #help => '',
583: url => &phaseurl('setexttool'),
584: permission => $permission->{'setexttool'},
585: linktitle => '',
586: },
1.104 ! raeburn 587: {
! 588: linktext => $linktext{'setcrsauthor'},
! 589: icon => 'crsauthor.png',
! 590: #help => '',
! 591: url => &phaseurl('setcrsauthor'),
! 592: permission => $permission->{'setcrsauthor'},
! 593: linktitle => '',
! 594: },
1.54 bisitz 595: ]
596: },
1.48 raeburn 597: );
1.54 bisitz 598:
1.102 raeburn 599: $r->print(
1.54 bisitz 600: '<h3>'
1.102 raeburn 601: .&mt($type).': <span class="LC_nobreak">'.$cdesc.'</span>'
602: .'</h3>'."\n");
603: if ($extendedtype) {
604: $r->print('<h4>'.&mt('Type').': '.&mt("$extendedtype $type").'</h4>');
1.48 raeburn 605: }
1.102 raeburn 606: $r->print(
607: '<form name="menu" method="post" action="/adm/modifycourse">'
1.54 bisitz 608: ."\n"
1.102 raeburn 609: .&hidden_form_elements()
610: .&Apache::lonhtmlcommon::generate_menu(@menu)
611: .'</form>');
1.28 raeburn 612: return;
613: }
614:
1.86 raeburn 615: sub print_adhocrole_selected {
1.90 raeburn 616: my ($r,$type,$permission) = @_;
1.48 raeburn 617: &print_header($r,$type);
1.37 raeburn 618: my ($cdom,$cnum) = split(/_/,$env{'form.pickedcourse'});
1.86 raeburn 619: my ($newrole,$selectrole);
1.90 raeburn 620: if ($permission->{'adhocrole'} eq 'coord') {
1.86 raeburn 621: if ($type eq 'Community') {
622: $newrole = "co./$cdom/$cnum";
623: } else {
624: $newrole = "cc./$cdom/$cnum";
625: }
626: $selectrole = 1;
1.90 raeburn 627: } elsif ($permission->{'adhocrole'} eq 'custom') {
1.103 raeburn 628: my ($okroles,$description) = &Apache::lonnet::get_my_adhocroles($env{'form.pickedcourse'},1);
1.90 raeburn 629: if (ref($okroles) eq 'ARRAY') {
1.103 raeburn 630: my $possrole = $env{'form.adhocrole'};
1.90 raeburn 631: if (($possrole ne '') && (grep(/^\Q$possrole\E$/,@{$okroles}))) {
632: my $confname = &Apache::lonnet::get_domainconfiguser($cdom);
633: $newrole = "cr/$cdom/$confname/$possrole./$cdom/$cnum";
634: $selectrole = 1;
1.86 raeburn 635: }
636: }
637: }
638: if ($selectrole) {
639: $r->print('<form name="adhocrole" method="post" action="/adm/roles">
640: <input type="hidden" name="selectrole" value="'.$selectrole.'" />
641: <input type="hidden" name="newrole" value="'.$newrole.'" />
1.37 raeburn 642: </form>');
1.86 raeburn 643: } else {
644: $r->print('<form name="ccrole" method="post" action="/adm/modifycourse">'.
645: '</form>');
646: }
647: return;
1.37 raeburn 648: }
649:
1.28 raeburn 650: sub print_settings_display {
1.86 raeburn 651: my ($r,$cdom,$cnum,$cdesc,$type,$permission) = @_;
1.28 raeburn 652: my %enrollvar = &get_enrollment_settings($cdom,$cnum);
1.48 raeburn 653: my %longtype = &course_settings_descrip($type);
1.28 raeburn 654: my %lt = &Apache::lonlocal::texthash(
1.48 raeburn 655: 'valu' => 'Current value',
656: 'cour' => 'Current settings are:',
657: 'cose' => "Settings which control auto-enrollment using classlists from your institution's student information system fall into two groups:",
658: 'dcon' => 'Modifiable only by Domain Coordinator',
659: 'back' => 'Pick another action',
1.28 raeburn 660: );
1.48 raeburn 661: my $ccrole = 'cc';
662: if ($type eq 'Community') {
663: $ccrole = 'co';
664: }
665: my $cctitle = &Apache::lonnet::plaintext($ccrole,$type);
1.28 raeburn 666: my $dctitle = &Apache::lonnet::plaintext('dc');
1.60 raeburn 667: my @modifiable_params = &get_dc_settable($type,$cdom);
1.48 raeburn 668: my ($internals,$accessdates) = &autoenroll_keys();
669: my @items;
670: if ((ref($internals) eq 'ARRAY') && (ref($accessdates) eq 'ARRAY')) {
671: @items = (@{$internals},@{$accessdates});
672: }
1.28 raeburn 673: my $disp_table = &Apache::loncommon::start_data_table()."\n".
674: &Apache::loncommon::start_data_table_header_row()."\n".
1.48 raeburn 675: "<th> </th>\n".
1.28 raeburn 676: "<th>$lt{'valu'}</th>\n".
677: "<th>$lt{'dcon'}</th>\n".
678: &Apache::loncommon::end_data_table_header_row()."\n";
1.48 raeburn 679: foreach my $item (@items) {
1.96 raeburn 680: my $shown = $enrollvar{$item};
681: if ($item eq 'crosslistings') {
682: my (@xlists,@lcsecs);
683: foreach my $entry (split(/,/,$enrollvar{$item})) {
684: my ($xlist,$lc_sec) = split(/:/,$entry);
685: push(@xlists,$xlist);
686: push(@lcsecs,$lc_sec);
687: }
688: if (@xlists) {
689: my $crskey = $cnum.':'.$enrollvar{'coursecode'};
690: my %reformatted =
691: &Apache::lonnet::auto_instsec_reformat($cdom,'declutter',
692: {$crskey => \@xlists});
693: if (ref($reformatted{$crskey}) eq 'ARRAY') {
694: my @show;
695: my @xlcodes = @{$reformatted{$crskey}};
696: for (my $i=0; $i<@xlcodes; $i++) {
697: push(@show,$xlcodes[$i].':'.$lcsecs[$i]);
698: }
699: if (@show) {
700: $shown = join(',',@show);
701: }
702: }
703: }
704: }
1.28 raeburn 705: $disp_table .= &Apache::loncommon::start_data_table_row()."\n".
1.48 raeburn 706: "<td><b>$longtype{$item}</b></td>\n".
1.96 raeburn 707: "<td>$shown</td>\n";
1.48 raeburn 708: if (grep(/^\Q$item\E$/,@modifiable_params)) {
1.50 raeburn 709: $disp_table .= '<td align="right">'.&mt('Yes').'</td>'."\n";
1.28 raeburn 710: } else {
1.48 raeburn 711: $disp_table .= '<td align="right">'.&mt('No').'</td>'."\n";
1.28 raeburn 712: }
713: $disp_table .= &Apache::loncommon::end_data_table_row()."\n";
1.3 raeburn 714: }
1.28 raeburn 715: $disp_table .= &Apache::loncommon::end_data_table()."\n";
1.48 raeburn 716: &print_header($r,$type);
1.86 raeburn 717: my ($enroll_link_start,$enroll_link_end,$setparms_link_start,$setparms_link_end);
718: if (&Apache::lonnet::allowed('ccc',$cdom)) {
719: my $newrole = $ccrole.'./'.$cdom.'/'.$cnum;
720: my $escuri = &HTML::Entities::encode('/adm/roles?selectrole=1&'.$newrole.
721: '=1&destinationurl=/adm/populate','&<>"');
722: $enroll_link_start = '<a href="'.$escuri.'">';
723: $enroll_link_end = '</a>';
724: }
725: if ($permission->{'setparms'}) {
726: $setparms_link_start = '<a href="javascript:changePage(document.viewparms,'."'setparms'".');">';
727: $setparms_link_end = '</a>';
728: }
1.102 raeburn 729: $r->print('<h3>'.&mt('Current automated enrollment settings').'</h3>'."\n".
730: '<h4><span class="LC_nobreak">'.&mt($type).': '.$cdesc.'</span></h4>'."\n".
1.48 raeburn 731: '<form action="/adm/modifycourse" method="post" name="viewparms">'."\n".
1.102 raeburn 732: '<p>'.$lt{'cose'}.'</p><ul>'.
1.86 raeburn 733: '<li>'.&mt('Settings modifiable by a [_1] via the [_2]Automated Enrollment Manager[_3] in a course.',
734: $cctitle,$enroll_link_start,$enroll_link_end).'</li>');
1.60 raeburn 735: if (&showcredits($cdom)) {
1.102 raeburn 736: $r->print('<li>'.&mt('Settings modifiable by a [_1] via [_2]View/Modify course owner, institutional code, default authentication, credits, self-enrollment and table lifetime[_3].',$dctitle,$setparms_link_start,$setparms_link_end)."\n");
1.60 raeburn 737: } else {
1.102 raeburn 738: $r->print('<li>'.&mt('Settings modifiable by a [_1] via [_2]View/Modify course owner, institutional code, default authentication, self-enrollment and table lifetime[_3].',$dctitle,$setparms_link_start,$setparms_link_end)."\n");
1.60 raeburn 739: }
1.102 raeburn 740: $r->print('</li></ul><p>'.
741: $lt{'cour'}.'</p>'.$disp_table.'<p>'."\n".
742: &hidden_form_elements().'</p>'.
743: '</form>'."\n");
744: my @actions =
745: ('<a href="javascript:changePage(document.viewparms,'."'menu'".')">'.
746: $lt{'back'}.'</a>');
747: $r->print('<br />'.&Apache::lonhtmlcommon::actionbox(\@actions));
1.28 raeburn 748: }
1.3 raeburn 749:
1.28 raeburn 750: sub print_setquota {
1.88 raeburn 751: my ($r,$cdom,$cnum,$cdesc,$type,$readonly) = @_;
1.61 raeburn 752: my $lctype = lc($type);
1.102 raeburn 753: my $headline = '<h3>'.&mt("Set disk space quotas for $lctype").'</h3>'."\n".
754: '<h4><span class="LC_nobreak">'.&mt($type).': '.$cdesc.'</span></h4>'."\n";
1.28 raeburn 755: my %lt = &Apache::lonlocal::texthash(
1.61 raeburn 756: 'gpqu' => 'Disk space for storage of group portfolio files',
757: 'upqu' => 'Disk space for storage of content directly uploaded to course via Content Editor',
1.42 schafran 758: 'modi' => 'Save',
1.48 raeburn 759: 'back' => 'Pick another action',
1.28 raeburn 760: );
1.61 raeburn 761: my %staticdefaults = (
762: coursequota => 20,
763: uploadquota => 500,
764: );
1.68 raeburn 765: my %settings = &Apache::lonnet::get('environment',['internal.coursequota','internal.uploadquota','internal.coursecode'],
1.61 raeburn 766: $cdom,$cnum);
1.28 raeburn 767: my $coursequota = $settings{'internal.coursequota'};
1.61 raeburn 768: my $uploadquota = $settings{'internal.uploadquota'};
1.101 raeburn 769: if (($uploadquota eq '') || ($coursequota eq '')) {
1.61 raeburn 770: my %domdefs = &Apache::lonnet::get_domain_defaults($cdom);
1.72 raeburn 771: my $quotatype = &Apache::lonuserutils::get_extended_type($cdom,$cnum,$type,\%settings);
1.61 raeburn 772: if ($uploadquota eq '') {
1.101 raeburn 773: $uploadquota = $domdefs{$quotatype.'quota'};
774: if ($uploadquota eq '') {
775: $uploadquota = $staticdefaults{'uploadquota'};
776: }
777: }
778: if ($coursequota eq '') {
779: $coursequota = $domdefs{$quotatype.'coursequota'};
780: if ($coursequota eq '') {
781: $coursequota = $staticdefaults{'coursequota'};
782: }
1.61 raeburn 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.102 raeburn 796: $headline
1.57 raeburn 797: <form action="/adm/modifycourse" method="post" name="setquota" onsubmit="return verify_quota();">
1.61 raeburn 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: </form>
811: ENDDOCUMENT
1.102 raeburn 812: my @actions =
813: ('<a href="javascript:changePage(document.setquota,'."'menu'".')">'.
814: $lt{'back'}.'</a>');
815: $r->print('<br />'.&Apache::lonhtmlcommon::actionbox(\@actions));
1.28 raeburn 816: return;
817: }
1.3 raeburn 818:
1.57 raeburn 819: sub print_set_anonsurvey_threshold {
1.88 raeburn 820: my ($r,$cdom,$cnum,$cdesc,$type,$readonly) = @_;
1.57 raeburn 821: my %lt = &Apache::lonlocal::texthash(
822: 'resp' => 'Responder threshold for anonymous survey submissions display:',
823: 'sufa' => 'Anonymous survey submissions displayed when responders exceeds',
824: 'modi' => 'Save',
825: 'back' => 'Pick another action',
826: );
827: my %settings = &Apache::lonnet::get('environment',['internal.anonsurvey_threshold'],$cdom,$cnum);
828: my $threshold = $settings{'internal.anonsurvey_threshold'};
829: if ($threshold eq '') {
1.103 raeburn 830: my %domconfig =
1.57 raeburn 831: &Apache::lonnet::get_dom('configuration',['coursedefaults'],$cdom);
832: if (ref($domconfig{'coursedefaults'}) eq 'HASH') {
833: $threshold = $domconfig{'coursedefaults'}{'anonsurvey_threshold'};
834: if ($threshold eq '') {
835: $threshold = 10;
836: }
837: } else {
838: $threshold = 10;
839: }
840: }
841: &print_header($r,$type);
842: my $hidden_elements = &hidden_form_elements();
1.88 raeburn 843: my ($disabled,$submit);
844: if ($readonly) {
1.103 raeburn 845: $disabled = ' disabled="disabled"';
1.88 raeburn 846: } else {
847: $submit = '<input type="submit" value="'.$lt{'modi'}.'" />';
848: }
1.57 raeburn 849: my $helpitem = &Apache::loncommon::help_open_topic('Modify_Anonsurvey_Threshold');
1.102 raeburn 850: my $showtype = &mt($type);
1.57 raeburn 851: $r->print(<<ENDDOCUMENT);
1.102 raeburn 852: <h3>$lt{'resp'}</h3>
853: <h4><span class="LC_nobreak">$showtype: $cdesc</span></h4>
1.57 raeburn 854: <form action="/adm/modifycourse" method="post" name="setanon" onsubmit="return verify_anon_threshold();">
855: <p>
1.102 raeburn 856: $helpitem $lt{'sufa'}: <input type="text" size="4" name="threshold" value="$threshold" $disabled /> </p>
1.88 raeburn 857: $submit
1.57 raeburn 858: $hidden_elements
859: </form>
860: ENDDOCUMENT
1.102 raeburn 861: my @actions =
862: ('<a href="javascript:changePage(document.setanon,'."'menu'".')">'.
863: $lt{'back'}.'</a>');
864: $r->print('<br /><br />'.&Apache::lonhtmlcommon::actionbox(\@actions));
1.57 raeburn 865: return;
866: }
867:
1.75 raeburn 868: sub print_postsubmit_config {
1.88 raeburn 869: my ($r,$cdom,$cnum,$cdesc,$type,$readonly) = @_;
1.75 raeburn 870: my %lt = &Apache::lonlocal::texthash (
871: 'conf' => 'Configure submit button behavior after student makes a submission',
872: 'disa' => 'Disable submit button/keypress following student submission',
873: 'nums' => 'Number of seconds submit is disabled',
874: 'modi' => 'Save',
875: 'back' => 'Pick another action',
876: 'yes' => 'Yes',
877: 'no' => 'No',
878: );
879: my %settings = &Apache::lonnet::get('environment',['internal.postsubmit','internal.postsubtimeout',
880: 'internal.coursecode','internal.textbook'],$cdom,$cnum);
881: my $postsubmit = $settings{'internal.postsubmit'};
882: if ($postsubmit eq '') {
883: my %domconfig =
884: &Apache::lonnet::get_dom('configuration',['coursedefaults'],$cdom);
1.103 raeburn 885: $postsubmit = 1;
1.75 raeburn 886: if (ref($domconfig{'coursedefaults'}) eq 'HASH') {
887: if (ref($domconfig{'coursedefaults'}{'postsubmit'}) eq 'HASH') {
888: if ($domconfig{'coursedefaults'}{'postsubmit'}{'client'} eq 'off') {
1.103 raeburn 889: $postsubmit = 0;
1.75 raeburn 890: }
891: }
892: }
893: }
894: my ($checkedon,$checkedoff,$display);
895: if ($postsubmit) {
896: $checkedon = 'checked="checked"';
897: $display = 'block';
898: } else {
899: $checkedoff = 'checked="checked"';
900: $display = 'none';
901: }
902: my $postsubtimeout = $settings{'internal.postsubtimeout'};
903: my $default = &domain_postsubtimeout($cdom,$type,\%settings);
904: my $zero = &mt('(Enter 0 to disable until next page reload, or leave blank to use the domain default: [_1])',$default);
905: if ($postsubtimeout eq '') {
906: $postsubtimeout = $default;
907: }
908: &print_header($r,$type);
909: my $hidden_elements = &hidden_form_elements();
1.88 raeburn 910: my ($disabled,$submit);
911: if ($readonly) {
912: $disabled = ' disabled="disabled"';
913: } else {
914: $submit = '<input type="submit" value="'.$lt{'modi'}.'" />';
915: }
1.75 raeburn 916: my $helpitem = &Apache::loncommon::help_open_topic('Modify_Postsubmit_Config');
1.102 raeburn 917: my $showtype = &mt($type);
1.75 raeburn 918: $r->print(<<ENDDOCUMENT);
1.102 raeburn 919: <h3>$lt{'conf'}</h3>
920: <h4><span class="LC_nobreak">$showtype: $cdesc</span></h4>
1.75 raeburn 921: <form action="/adm/modifycourse" method="post" name="setpostsubmit" onsubmit="return verify_postsubmit();">
922: <p>
1.103 raeburn 923: $helpitem $lt{'disa'}:
1.88 raeburn 924: <label><input type="radio" name="postsubmit" $checkedon onclick="togglePostsubmit('studentsubmission');" value="1" $disabled />
1.75 raeburn 925: $lt{'yes'}</label>
1.89 raeburn 926: <label><input type="radio" name="postsubmit" $checkedoff onclick="togglePostsubmit('studentsubmission');" value="0" $disabled />
1.102 raeburn 927: $lt{'no'}</label></p>
1.75 raeburn 928: <div id="studentsubmission" style="display: $display">
1.88 raeburn 929: $lt{'nums'} <input type="text" name="postsubtimeout" value="$postsubtimeout" $disabled /><br />
1.75 raeburn 930: $zero</div>
1.102 raeburn 931: <p>
1.88 raeburn 932: $submit
1.75 raeburn 933: </p>
934: $hidden_elements
935: </form>
936: ENDDOCUMENT
1.102 raeburn 937: my @actions =
938: ('<a href="javascript:changePage(document.setpostsubmit,'."'menu'".')">'.
939: $lt{'back'}.'</a>');
940: $r->print('<br />'.&Apache::lonhtmlcommon::actionbox(\@actions));
1.75 raeburn 941: return;
942: }
943:
944: sub domain_postsubtimeout {
945: my ($cdom,$type,$settings) = @_;
1.103 raeburn 946: return unless (ref($settings) eq 'HASH');
1.99 raeburn 947: my $lctype = &get_lctype($type,$settings);
1.75 raeburn 948: my %domconfig =
949: &Apache::lonnet::get_dom('configuration',['coursedefaults'],$cdom);
950: my $postsubtimeout = 60;
951: if (ref($domconfig{'coursedefaults'}) eq 'HASH') {
952: if (ref($domconfig{'coursedefaults'}{'postsubmit'}) eq 'HASH') {
953: if (ref($domconfig{'coursedefaults'}{'postsubmit'}{'timeout'}) eq 'HASH') {
954: if ($domconfig{'coursedefaults'}{'postsubmit'}{'timeout'}{$lctype} ne '') {
955: $postsubtimeout = $domconfig{'coursedefaults'}{'postsubmit'}{'timeout'}{$lctype};
956: }
957: }
958: }
959: }
960: return $postsubtimeout;
961: }
962:
1.99 raeburn 963: sub get_lctype {
964: my ($type,$settings) = @_;
965: my $lctype = lc($type);
966: unless (($type eq 'Community') || ($type eq 'Placement')) {
967: $lctype = 'unofficial';
968: if (ref($settings) eq 'HASH') {
969: if ($settings->{'internal.coursecode'}) {
970: $lctype = 'official';
971: } elsif ($settings->{'internal.textbook'}) {
972: $lctype = 'textbook';
973: }
974: }
975: }
976: return $lctype;
977: }
978:
1.38 raeburn 979: sub print_catsettings {
1.88 raeburn 980: my ($r,$cdom,$cnum,$cdesc,$type,$readonly) = @_;
1.48 raeburn 981: &print_header($r,$type);
1.38 raeburn 982: my %lt = &Apache::lonlocal::texthash(
1.48 raeburn 983: 'back' => 'Pick another action',
984: 'catset' => 'Catalog Settings for Course',
985: 'visi' => 'Visibility in Course/Community Catalog',
986: 'exclude' => 'Exclude from course catalog:',
987: 'categ' => 'Categorize Course',
988: 'assi' => 'Assign one or more categories and/or subcategories to this course.'
1.38 raeburn 989: );
1.48 raeburn 990: if ($type eq 'Community') {
991: $lt{'catset'} = &mt('Catalog Settings for Community');
992: $lt{'exclude'} = &mt('Exclude from course catalog');
993: $lt{'categ'} = &mt('Categorize Community');
1.49 raeburn 994: $lt{'assi'} = &mt('Assign one or more subcategories to this community.');
1.48 raeburn 995: }
1.102 raeburn 996: $r->print('<h3>'.$lt{'catset'}.'</h3>'."\n".
997: '<h4><span class="LC_nobreak">'.&mt($type).': '.$cdesc.'</span></h4>'."\n".
998: '<form action="/adm/modifycourse" method="post" name="catsettings">'."\n");
1.38 raeburn 999: my %domconf = &Apache::lonnet::get_dom('configuration',['coursecategories'],$cdom);
1.49 raeburn 1000: my @cat_params = &catalog_settable($domconf{'coursecategories'},$type);
1.38 raeburn 1001: if (@cat_params > 0) {
1.88 raeburn 1002: my $disabled;
1003: if ($readonly) {
1004: $disabled = ' disabled="disabled"';
1005: }
1.103 raeburn 1006: my %currsettings =
1.38 raeburn 1007: &Apache::lonnet::get('environment',['hidefromcat','categories'],$cdom,$cnum);
1008: if (grep(/^togglecats$/,@cat_params)) {
1009: my $excludeon = '';
1010: my $excludeoff = ' checked="checked" ';
1011: if ($currsettings{'hidefromcat'} eq 'yes') {
1012: $excludeon = $excludeoff;
1.103 raeburn 1013: $excludeoff = '';
1.38 raeburn 1014: }
1.48 raeburn 1015: $r->print('<br /><h4>'.$lt{'visi'}.'</h4>'.
1.102 raeburn 1016: '<p>'.
1.48 raeburn 1017: $lt{'exclude'}.
1.102 raeburn 1018: ' <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></p><p>');
1.48 raeburn 1019: if ($type eq 'Community') {
1.102 raeburn 1020: $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.").'</p>');
1.81 raeburn 1021: } elsif ($type eq 'Placement') {
1.102 raeburn 1022: $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.").'</p>');
1.48 raeburn 1023: } else {
1.102 raeburn 1024: $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").':</p><ul>'.
1.48 raeburn 1025: '<li>'.&mt('Auto-cataloging is enabled and the course is assigned an institutional code.').'</li>'.
1026: '<li>'.&mt('The course has been categorized using at least one of the course categories defined for the domain.').'</li></ul>');
1027: }
1.38 raeburn 1028: }
1.102 raeburn 1029: my $savebutton;
1030: unless ($readonly) {
1031: $savebutton = '<p><br /><input type="button" name="chgcatsettings" value="'.
1032: &mt('Save').'" onclick="javascript:changePage(document.catsettings,'.
1033: "'processcat'".');" /></p>';
1034: }
1035: my $shownsave;
1.38 raeburn 1036: if (grep(/^categorize$/,@cat_params)) {
1.102 raeburn 1037: my $categheader = '<br /><h4>'.$lt{'categ'}.'</h4>';
1.38 raeburn 1038: if (ref($domconf{'coursecategories'}) eq 'HASH') {
1039: my $cathash = $domconf{'coursecategories'}{'cats'};
1040: if (ref($cathash) eq 'HASH') {
1.102 raeburn 1041: $r->print($categheader.
1042: '<p>'.$lt{'assi'}.'</p>'.
1.38 raeburn 1043: &Apache::loncommon::assign_categories_table($cathash,
1.88 raeburn 1044: $currsettings{'categories'},$type,$disabled));
1.38 raeburn 1045: } else {
1.102 raeburn 1046: $r->print($savebutton.$categheader.
1047: '<p>'.&mt('No categories defined for this domain.'));
1048: $shownsave = 1;
1.38 raeburn 1049: }
1050: } else {
1.102 raeburn 1051: $r->print($savebutton.$categheader.
1052: '<p>'.&mt('No categories defined for this domain.'));
1053: $shownsave = 1;
1.38 raeburn 1054: }
1.102 raeburn 1055: if (($type eq 'Community') || ($type eq 'Placement')) {
1056: $r->print('</p>');
1057: } elsif ($shownsave) {
1058: $r->print('<br />'.&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.').'</p>');
1059: } else {
1060: $r->print('</p><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>');
1.48 raeburn 1061: }
1.38 raeburn 1062: }
1.102 raeburn 1063: unless ($readonly || $shownsave) {
1064: $r->print($savebutton);
1.88 raeburn 1065: }
1.38 raeburn 1066: } else {
1.48 raeburn 1067: $r->print('<span class="LC_warning">');
1068: if ($type eq 'Community') {
1069: $r->print(&mt('Catalog settings in this domain are set in community context via "Community Configuration".'));
1070: } else {
1071: $r->print(&mt('Catalog settings in this domain are set in course context via "Course Configuration".'));
1072: }
1.102 raeburn 1073: $r->print('</span>'."\n");
1.38 raeburn 1074: }
1075: $r->print(&hidden_form_elements().'</form>'."\n");
1.102 raeburn 1076: my @actions =
1077: ('<a href="javascript:changePage(document.catsettings,'."'menu'".')">'.
1078: $lt{'back'}.'</a>');
1079: $r->print('<br />'.&Apache::lonhtmlcommon::actionbox(\@actions));
1.38 raeburn 1080: return;
1081: }
1082:
1.28 raeburn 1083: sub print_course_modification_page {
1.88 raeburn 1084: my ($r,$cdom,$cnum,$cdesc,$crstype,$readonly) = @_;
1.2 raeburn 1085: my %lt=&Apache::lonlocal::texthash(
1086: 'actv' => "Active",
1087: 'inac' => "Inactive",
1088: 'ownr' => "Owner",
1089: 'name' => "Name",
1.26 raeburn 1090: 'unme' => "Username:Domain",
1.2 raeburn 1091: 'stus' => "Status",
1.48 raeburn 1092: 'nocc' => 'There is currently no owner set for this course.',
1.32 raeburn 1093: 'gobt' => "Save",
1.72 raeburn 1094: 'sett' => 'Setting',
1095: 'domd' => 'Domain default',
1.103 raeburn 1096: 'whom' => 'Who configures',
1.2 raeburn 1097: );
1.88 raeburn 1098: my ($ownertable,$ccrole,$javascript_validations,$authenitems,$ccname,$disabled);
1.48 raeburn 1099: my %enrollvar = &get_enrollment_settings($cdom,$cnum);
1.72 raeburn 1100: my %settings = &Apache::lonnet::get('environment',['internal.coursecode','internal.textbook',
1.85 raeburn 1101: 'internal.selfenrollmgrdc','internal.selfenrollmgrcc',
1.89 raeburn 1102: 'internal.mysqltables'],$cdom,$cnum);
1.72 raeburn 1103: my $type = &Apache::lonuserutils::get_extended_type($cdom,$cnum,$crstype,\%settings);
1104: my @specific_managebydc = split(/,/,$settings{'internal.selfenrollmgrdc'});
1105: my @specific_managebycc = split(/,/,$settings{'internal.selfenrollmgrcc'});
1106: my %domdefaults = &Apache::lonnet::get_domain_defaults($cdom);
1.94 raeburn 1107: my %passwdconf = &Apache::lonnet::get_passwdconf($cdom);
1.72 raeburn 1108: my @default_managebydc = split(/,/,$domdefaults{$type.'selfenrolladmdc'});
1109: if ($crstype eq 'Community') {
1.48 raeburn 1110: $ccrole = 'co';
1111: $lt{'nocc'} = &mt('There is currently no owner set for this community.');
1112: } else {
1113: $ccrole ='cc';
1.88 raeburn 1114: ($javascript_validations,$authenitems) = &gather_authenitems($cdom,\%enrollvar,$readonly);
1.48 raeburn 1115: }
1.72 raeburn 1116: $ccname = &Apache::lonnet::plaintext($ccrole,$crstype);
1.88 raeburn 1117: if ($readonly) {
1118: $disabled = ' disabled="disabled"';
1119: }
1.48 raeburn 1120: my %roleshash = &Apache::lonnet::get_my_roles($cnum,$cdom,'','',[$ccrole]);
1121: my (@local_ccs,%cc_status,%pname);
1122: foreach my $item (keys(%roleshash)) {
1123: my ($uname,$udom) = split(/:/,$item);
1124: if (!grep(/^\Q$uname\E:\Q$udom\E$/,@local_ccs)) {
1125: push(@local_ccs,$uname.':'.$udom);
1126: $pname{$uname.':'.$udom} = &Apache::loncommon::plainname($uname,$udom);
1127: $cc_status{$uname.':'.$udom} = $lt{'actv'};
1.1 raeburn 1128: }
1129: }
1.103 raeburn 1130: if (($enrollvar{'courseowner'} ne '') &&
1.48 raeburn 1131: (!grep(/^$enrollvar{'courseowner'}$/,@local_ccs))) {
1132: push(@local_ccs,$enrollvar{'courseowner'});
1.26 raeburn 1133: my ($owneruname,$ownerdom) = split(/:/,$enrollvar{'courseowner'});
1.103 raeburn 1134: $pname{$enrollvar{'courseowner'}} =
1.26 raeburn 1135: &Apache::loncommon::plainname($owneruname,$ownerdom);
1.48 raeburn 1136: my $active_cc = &Apache::loncommon::check_user_status($ownerdom,$owneruname,
1137: $cdom,$cnum,$ccrole);
1.19 raeburn 1138: if ($active_cc eq 'active') {
1.2 raeburn 1139: $cc_status{$enrollvar{'courseowner'}} = $lt{'actv'};
1.1 raeburn 1140: } else {
1.2 raeburn 1141: $cc_status{$enrollvar{'courseowner'}} = $lt{'inac'};
1.1 raeburn 1142: }
1143: }
1.48 raeburn 1144: @local_ccs = sort(@local_ccs);
1145: if (@local_ccs == 0) {
1146: $ownertable = $lt{'nocc'};
1147: } else {
1148: my $numlocalcc = scalar(@local_ccs);
1149: $ownertable = '<input type="hidden" name="numlocalcc" value="'.$numlocalcc.'" />'.
1150: &Apache::loncommon::start_data_table()."\n".
1151: &Apache::loncommon::start_data_table_header_row()."\n".
1152: '<th>'.$lt{'ownr'}.'</th>'.
1153: '<th>'.$lt{'name'}.'</th>'.
1154: '<th>'.$lt{'unme'}.'</th>'.
1155: '<th>'.$lt{'stus'}.'</th>'.
1156: &Apache::loncommon::end_data_table_header_row()."\n";
1157: foreach my $cc (@local_ccs) {
1158: $ownertable .= &Apache::loncommon::start_data_table_row()."\n";
1159: if ($cc eq $enrollvar{'courseowner'}) {
1.88 raeburn 1160: $ownertable .= '<td><input type="radio" name="courseowner" value="'.$cc.'" checked="checked"'.$disabled.' /></td>'."\n";
1.48 raeburn 1161: } else {
1.88 raeburn 1162: $ownertable .= '<td><input type="radio" name="courseowner" value="'.$cc.'"'.$disabled.' /></td>'."\n";
1.48 raeburn 1163: }
1.103 raeburn 1164: $ownertable .=
1.48 raeburn 1165: '<td>'.$pname{$cc}.'</td>'."\n".
1166: '<td>'.$cc.'</td>'."\n".
1167: '<td>'.$cc_status{$cc}.' '.$ccname.'</td>'."\n".
1168: &Apache::loncommon::end_data_table_row()."\n";
1169: }
1170: $ownertable .= &Apache::loncommon::end_data_table();
1171: }
1.72 raeburn 1172: &print_header($r,$crstype,$javascript_validations);
1.48 raeburn 1173: my $dctitle = &Apache::lonnet::plaintext('dc');
1174: my $hidden_elements = &hidden_form_elements();
1.102 raeburn 1175: my $showtype;
1176: if (($type eq 'official') || ($type eq 'unofficial') || ($type eq 'textbook')) {
1177: $showtype = ' ('.&mt($type).')';
1178: }
1179: $r->print('<h3>'.&modifiable_only_title($crstype).'</h3>'."\n".
1180: '<h4><span class="LC_nobreak">'.&mt($crstype).': '.$cdesc.$showtype.'</span></h4><br />'."\n".
1181: '<form action="/adm/modifycourse" method="post" name="'.$env{'form.phase'}.'">'."\n".
1.48 raeburn 1182: &Apache::lonhtmlcommon::start_pick_box());
1.72 raeburn 1183: if ($crstype eq 'Community') {
1.48 raeburn 1184: $r->print(&Apache::lonhtmlcommon::row_title(
1185: &Apache::loncommon::help_open_topic('Modify_Community_Owner').
1.94 raeburn 1186: ' '.&mt('Community Owner'))."\n".
1187: $ownertable."\n".&Apache::lonhtmlcommon::row_closure());
1.48 raeburn 1188: } else {
1189: $r->print(&Apache::lonhtmlcommon::row_title(
1190: &Apache::loncommon::help_open_topic('Modify_Course_Instcode').
1191: ' '.&mt('Course Code'))."\n".
1.91 raeburn 1192: '<input type="text" size="15" name="coursecode" value="'.$enrollvar{'coursecode'}.'"'.$disabled.' />'.
1.60 raeburn 1193: &Apache::lonhtmlcommon::row_closure());
1.83 raeburn 1194: if (($crstype eq 'Course') && (&showcredits($cdom))) {
1.60 raeburn 1195: $r->print(&Apache::lonhtmlcommon::row_title(
1196: &Apache::loncommon::help_open_topic('Modify_Course_Credithours').
1.94 raeburn 1197: ' '.&mt('Credits (students)'))."\n".
1.88 raeburn 1198: '<input type="text" size="3" name="defaultcredits" value="'.$enrollvar{'defaultcredits'}.'"'.$disabled.' />'.
1.60 raeburn 1199: &Apache::lonhtmlcommon::row_closure());
1.83 raeburn 1200: }
1201: $r->print(&Apache::lonhtmlcommon::row_title(
1202: &Apache::loncommon::help_open_topic('Modify_Course_Defaultauth').
1203: ' '.&mt('Default Authentication method'))."\n".
1204: $authenitems."\n".
1205: &Apache::lonhtmlcommon::row_closure().
1206: &Apache::lonhtmlcommon::row_title(
1.94 raeburn 1207: &Apache::loncommon::help_open_topic('Modify_Course_Owner').
1208: ' '.&mt('Course Owner'))."\n".
1209: $ownertable."\n".&Apache::lonhtmlcommon::row_closure());
1210: if (($passwdconf{'crsownerchg'}) && ($type ne 'Placement')) {
1211: my $checked;
1212: if ($enrollvar{'nopasswdchg'}) {
1213: $checked = ' checked="checked"';
1214: }
1215: $r->print(&Apache::lonhtmlcommon::row_title(
1216: &Apache::loncommon::help_open_topic('Modify_Course_Chgpasswd').
1217: ' '.&mt('Changing passwords (internal)'))."\n".
1218: '<label><input type="checkbox" value="1" name="nopasswdchg"'.$checked.$disabled.' />'.
1.102 raeburn 1219: &mt('Disable changing password for users with student role by course owner').'</label>'."\n".
1.94 raeburn 1220: &Apache::lonhtmlcommon::row_closure());
1221: }
1.48 raeburn 1222: }
1.72 raeburn 1223: my ($cctitle,$rolename,$currmanages,$ccchecked,$dcchecked,$defaultchecked);
1224: my ($selfenrollrows,$selfenrolltitles) = &Apache::lonuserutils::get_selfenroll_titles();
1225: if ($type eq 'Community') {
1226: $cctitle = &mt('Community personnel');
1227: } else {
1228: $cctitle = &mt('Course personnel');
1229: }
1230:
1.94 raeburn 1231: $r->print(&Apache::lonhtmlcommon::row_title(
1.72 raeburn 1232: &Apache::loncommon::help_open_topic('Modify_Course_Selfenrolladmin').
1233: ' '.&mt('Self-enrollment configuration')).
1234: &Apache::loncommon::start_data_table()."\n".
1235: &Apache::loncommon::start_data_table_header_row()."\n".
1236: '<th>'.$lt{'sett'}.'</th>'.
1237: '<th>'.$lt{'domd'}.'</th>'.
1238: '<th>'.$lt{'whom'}.'</th>'.
1239: &Apache::loncommon::end_data_table_header_row()."\n");
1240: my %optionname;
1.103 raeburn 1241: $optionname{''} = &mt('Use domain default');
1.72 raeburn 1242: $optionname{'0'} = $dctitle;
1243: $optionname{'1'} = $cctitle;
1244: foreach my $item (@{$selfenrollrows}) {
1245: my %checked;
1246: my $default = $cctitle;
1247: if (grep(/^\Q$item\E$/,@default_managebydc)) {
1248: $default = $dctitle;
1249: }
1250: if (grep(/^\Q$item\E$/,@specific_managebydc)) {
1251: $checked{'0'} = ' checked="checked"';
1252: } elsif (grep(/^\Q$item\E$/,@specific_managebycc)) {
1253: $checked{'1'} = ' checked="checked"';
1254: } else {
1255: $checked{''} = ' checked="checked"';
1.103 raeburn 1256: }
1.72 raeburn 1257: $r->print(&Apache::loncommon::start_data_table_row()."\n".
1258: '<td>'.$selfenrolltitles->{$item}.'</td>'."\n".
1259: '<td>'.&mt('[_1] configures',$default).'</td>'."\n".
1260: '<td>');
1.103 raeburn 1261: foreach my $option ('','0','1') {
1.72 raeburn 1262: $r->print('<span class="LC_nobreak"><label>'.
1263: '<input type="radio" name="selfenrollmgr_'.$item.'" '.
1.88 raeburn 1264: 'value="'.$option.'"'.$checked{$option}.$disabled.' />'.
1.72 raeburn 1265: $optionname{$option}.'</label></span><br />');
1266: }
1267: $r->print('</td>'."\n".
1268: &Apache::loncommon::end_data_table_row()."\n");
1269: }
1270: $r->print(&Apache::loncommon::end_data_table()."\n".
1.85 raeburn 1271: '<br />'.&Apache::lonhtmlcommon::row_closure().
1272: &Apache::lonhtmlcommon::row_title(
1273: &Apache::loncommon::help_open_topic('Modify_Course_Table_Lifetime').
1274: ' '.&mt('"Temporary" Tables Lifetime (s)'))."\n".
1.88 raeburn 1275: '<input type="text" size="10" name="mysqltables" value="'.$settings{'internal.mysqltables'}.'"'.$disabled.' />'.
1.85 raeburn 1276: &Apache::lonhtmlcommon::row_closure(1).
1.102 raeburn 1277: &Apache::lonhtmlcommon::end_pick_box().'<br />'.$hidden_elements);
1.88 raeburn 1278: unless ($readonly) {
1279: $r->print('<input type="button" onclick="javascript:changePage(this.form,'."'processparms'".');');
1280: if ($crstype eq 'Community') {
1281: $r->print('this.form.submit();"');
1282: } else {
1283: $r->print('javascript:verify_message(this.form);"');
1284: }
1285: $r->print(' value="'.$lt{'gobt'}.'" />');
1.48 raeburn 1286: }
1.102 raeburn 1287: $r->print('</form>');
1288: my @actions =
1289: ('<a href="javascript:changePage(document.'.$env{'form.phase'}.','."'menu'".')">'.
1290: &mt('Pick another action').'</a>');
1291: $r->print('<br /><br />'.&Apache::lonhtmlcommon::actionbox(\@actions));
1.48 raeburn 1292: return;
1293: }
1294:
1.72 raeburn 1295: sub print_selfenrollconfig {
1.88 raeburn 1296: my ($r,$type,$cdesc,$coursehash,$readonly) = @_;
1.72 raeburn 1297: return unless(ref($coursehash) eq 'HASH');
1298: my $cnum = $coursehash->{'num'};
1299: my $cdom = $coursehash->{'domain'};
1300: my %currsettings = &get_selfenroll_settings($coursehash);
1301: &print_header($r,$type);
1.102 raeburn 1302: $r->print('<h3>'.&mt('Self-enrollment with a student role').'</h3>'."\n".
1303: '<h4><span class="LC_nobreak">'.&mt($type).': '.$cdesc.'</span></h4>'."\n");
1.72 raeburn 1304: &Apache::loncreateuser::print_selfenroll_menu($r,'domain',$env{'form.pickedcourse'},
1305: $cdom,$cnum,\%currsettings,
1.88 raeburn 1306: &hidden_form_elements(),$readonly);
1.102 raeburn 1307: my @actions =
1308: ('<a href="javascript:changePage(document.selfenroll,'."'menu'".')">'.
1309: &mt('Pick another action').'</a>');
1310: $r->print('<br /><br />'.&Apache::lonhtmlcommon::actionbox(\@actions));
1.72 raeburn 1311: return;
1312: }
1313:
1.104 ! raeburn 1314: sub print_default_overrides {
! 1315: my ($r,$cdom,$cnum,$cdesc,$type,$readonly,$item) = @_;
! 1316: my (%titles,$checkeddom,$checkedcrs,$divsty,$currcrsval,$crsdefault,%crschecked,
! 1317: $helpfile,$title,$crselements);
! 1318: %titles = &default_overrides_titles($type);
! 1319: my ($title,$domdefdisplay,$settings,$optiontext,$options) =
! 1320: &default_overrides_common($item,$cdom,$cnum,$type,\%titles);
1.99 raeburn 1321: $checkeddom = ' checked="checked"';
1.97 raeburn 1322: $divsty = 'display:none';
1.104 ! raeburn 1323: if ($item eq 'ltiauth') {
! 1324: $helpfile = 'Modify_Course_LTI_Authen';
! 1325: $crsdefault = 0;
! 1326: } else {
! 1327: if ($item eq 'exttool') {
! 1328: $helpfile = 'Modify_Course_External_Tool';
! 1329: $crsdefault = 'both';
! 1330: } elsif ($item eq 'crsauthor') {
! 1331: $helpfile = 'Modify_Course_Crsauthor';
! 1332: $crsdefault = 1;
! 1333: }
1.97 raeburn 1334: }
1.104 ! raeburn 1335: $currcrsval = $settings->{'internal.'.$item};
! 1336: if ($currcrsval ne '') {
1.97 raeburn 1337: $checkedcrs = $checkeddom;
1338: $checkeddom = '';
1339: $divsty = 'display:inline-block';
1.104 ! raeburn 1340: foreach my $option (@{$options}) {
! 1341: if ($currcrsval eq $option) {
! 1342: $crschecked{$option} = ' checked="checked"';
! 1343: } else {
! 1344: $crschecked{$option} = '';
! 1345: }
1.97 raeburn 1346: }
1347: } else {
1.104 ! raeburn 1348: foreach my $option (@{$options}) {
! 1349: if ($crsdefault eq $option) {
1.103 raeburn 1350: $crschecked{$option} = ' checked="checked"';
1.99 raeburn 1351: } else {
1352: $crschecked{$option} = '';
1353: }
1354: }
1355: }
1356: my ($disabled,$submit);
1357: if ($readonly) {
1358: $disabled = ' disabled="disabled"';
1359: } else {
1.104 ! raeburn 1360: $submit = '<input type="button" onclick="javascript:changePage(this.form,'."'process${item}'".');" value="'.$titles{'modi'}.'" />';
! 1361: }
! 1362: foreach my $option (@{$options}) {
! 1363: $crselements .= '<span class="LC_nobreak">'.
! 1364: '<label><input type="radio" name="'.$item.'" value="'.$option.'"'.
! 1365: $crschecked{$option}.$disabled.' />'.$optiontext->{$option}.'</label>'.
! 1366: '</span><br />'."\n";
1.99 raeburn 1367: }
1.104 ! raeburn 1368: &print_header($r,$type);
! 1369: my $hidden_elements = &hidden_form_elements();
! 1370: my $helpitem = &Apache::loncommon::help_open_topic($helpfile);
1.102 raeburn 1371: my $showtype = &mt($type);
1.99 raeburn 1372: $r->print(<<ENDDOCUMENT);
1.104 ! raeburn 1373: <h3>$helpitem $title</h3>
1.102 raeburn 1374: <h4><span class="LC_nobreak">$showtype: $cdesc</span></h4>
1.104 ! raeburn 1375: <form action="/adm/modifycourse" method="post" name="set$item">
1.102 raeburn 1376: <p><span class="LC_nobreak">$titles{'curd'}: <span style="font-style:italic">$domdefdisplay</span></span></p>
1.99 raeburn 1377: <p><span class="LC_nobreak">
1.104 ! raeburn 1378: <label><input type="radio" name="${item}set" value="dom" onclick="toggleOptions(this.form,'set$item');"$checkeddom$disabled />$titles{'used'}</label></span><br />
1.99 raeburn 1379: <span class="LC_nobreak">
1.104 ! raeburn 1380: <label><input type="radio" name="${item}set" value="course" onclick="toggleOptions(this.form,'set$item');"$checkedcrs$disabled />$titles{'cour'}</label></span></p>
! 1381: <fieldset id="crs$item" style="$divsty">
1.99 raeburn 1382: <legend>$titles{'valu'}</legend>
1.104 ! raeburn 1383: $crselements
1.102 raeburn 1384: </fieldset><p>
1.99 raeburn 1385: $submit
1.102 raeburn 1386: $hidden_elements
1.99 raeburn 1387: </p>
1388: </form>
1389: ENDDOCUMENT
1.102 raeburn 1390: my @actions =
1.104 ! raeburn 1391: ('<a href="javascript:changePage(document.set'.$item.','."'menu'".')">'.
1.102 raeburn 1392: $titles{'back'}.'</a>');
1393: $r->print('<br />'.&Apache::lonhtmlcommon::actionbox(\@actions));
1.99 raeburn 1394: return;
1395: }
1396:
1.104 ! raeburn 1397: sub default_overrides_titles {
1.99 raeburn 1398: my ($type) = @_;
1399: my %titles = &Apache::lonlocal::texthash(
1.104 ! raeburn 1400: 'requ' => 'Requirement for re-authentication for student LTI-limited launch of deep-linked item',
! 1401: 'link' => 'Link protection can be set to accept username for an enrolled student (if sent by Consumer)',
! 1402: 'logi' => 'Login needed, regardless of user information sent by LTI Consumer in (signed) parameters',
1.99 raeburn 1403: 'extt' => 'External Tool permissions',
1404: 'none' => 'Use of external tools not permitted',
1405: 'crs' => 'Only external tools defined in course may be used',
1406: 'dom' => 'Only external tools defined in domain may be used',
1407: 'both' => 'External tools defined/configured in either domain or course may be used',
1.104 ! raeburn 1408: 'stan' => "'In-course' authoring of standard LON-CAPA problems",
! 1409: 'on' => 'In-course authoring available',
! 1410: 'off' => 'In-course authoring unavailable',
1.99 raeburn 1411: 'used' => 'Use domain default',
1412: 'cour' => 'Use course-specific setting',
1413: 'curd' => 'Current domain default is',
1414: 'valu' => 'Value for this course',
1415: 'modi' => 'Save',
1416: 'back' => 'Pick another action',
1417: );
1418: if ($type eq 'Community') {
1419: $titles{'crs'} = &mt('Only external tools defined in community may be used');
1420: $titles{'both'} = &mt('External tools defined/configured in either domain or community may be used');
1421: $titles{'cour'} = &mt('Use community-specific setting');
1422: $titles{'valu'} = &mt('Value for this community');
1423: }
1424: return %titles;
1425: }
1426:
1.104 ! raeburn 1427: sub default_overrides_common {
! 1428: my ($item,$cdom,$cnum,$type,$titles) = @_;
! 1429: my ($title,$domdef,$domdefdom,$domdefdisplay,%settings,%optiontext,@options);
! 1430: if ($item eq 'ltiauth') {
! 1431: %settings = &Apache::lonnet::get('environment',['internal.'.$item],$cdom,$cnum);
! 1432: $title = $titles->{'requ'};
! 1433: $domdef = 0;
! 1434: @options = ('0','1');
! 1435: %optiontext = (
! 1436: 0 => $titles->{'logi'},
! 1437: 1 => $titles->{'link'},
! 1438: );
! 1439: } else {
! 1440: %settings =
! 1441: &Apache::lonnet::get('environment',['internal.'.$item,'internal.coursecode',
! 1442: 'internal.textbook'],$cdom,$cnum);
! 1443: if ($item eq 'exttool') {
! 1444: $title = $titles->{'extt'};
! 1445: $domdefdom = 1;
! 1446: $domdef = 0;
! 1447: @options = ('both','dom','crs','none');
! 1448: map { $optiontext{$_} = $titles->{$_}; } @options;
! 1449: } elsif ($item eq 'crsauthor') {
! 1450: $title = $titles->{'stan'};
! 1451: $domdef = 1;
! 1452: @options = ('1','0');
! 1453: %optiontext = (
! 1454: 1 => $titles->{'on'},
! 1455: 0 => $titles->{'off'},
! 1456: );
! 1457: }
! 1458: }
! 1459: my %domconfig =
! 1460: &Apache::lonnet::get_dom('configuration',['coursedefaults'],$cdom);
! 1461: if (ref($domconfig{'coursedefaults'}) eq 'HASH') {
! 1462: if ($item eq 'ltiauth') {
! 1463: $domdef = $domconfig{'coursedefaults'}{$item};
! 1464: } else {
! 1465: my $lctype = &get_lctype($type,\%settings);
! 1466: if (ref($domconfig{'coursedefaults'}{$item}) eq 'HASH') {
! 1467: if (exists($domconfig{'coursedefaults'}{$item}{$lctype})) {
! 1468: $domdef = $domconfig{'coursedefaults'}{$item}{$lctype};
! 1469: }
! 1470: }
! 1471: if ($item eq 'exttool') {
! 1472: if (ref($domconfig{'coursedefaults'}{'domexttool'}) eq 'HASH') {
! 1473: if (exists($domconfig{'coursedefaults'}{'domexttool'}{$lctype})) {
! 1474: $domdefdom = $domconfig{'coursedefaults'}{'domexttool'}{$lctype};
! 1475: }
! 1476: }
! 1477: }
! 1478: }
! 1479: }
! 1480: if ($item eq 'ltiauth') {
! 1481: if ($domdef) {
! 1482: $domdefdisplay = $titles->{'link'};
! 1483: } else {
! 1484: $domdefdisplay = $titles->{'logi'};
! 1485: }
! 1486: } elsif ($item eq 'exttool') {
! 1487: if ($domdef && $domdefdom) {
! 1488: $domdefdisplay = $titles->{'both'};
! 1489: } elsif ($domdef) {
! 1490: $domdefdisplay = $titles->{'crs'};
! 1491: } elsif ($domdefdom) {
! 1492: $domdefdisplay = $titles->{'dom'};
! 1493: } else {
! 1494: $domdefdisplay = $titles->{'none'};
! 1495: }
! 1496: } elsif ($item eq 'crsauthor') {
! 1497: if ($domdef) {
! 1498: $domdefdisplay = $titles->{'on'};
! 1499: } else {
! 1500: $domdefdisplay = $titles->{'off'};
! 1501: }
! 1502: }
! 1503: return ($title,$domdefdisplay,\%settings,\%optiontext,\@options);
! 1504: }
! 1505:
1.72 raeburn 1506: sub modify_selfenrollconfig {
1507: my ($r,$type,$cdesc,$coursehash) = @_;
1508: return unless(ref($coursehash) eq 'HASH');
1509: my $cnum = $coursehash->{'num'};
1510: my $cdom = $coursehash->{'domain'};
1511: my %currsettings = &get_selfenroll_settings($coursehash);
1512: &print_header($r,$type);
1.102 raeburn 1513: $r->print('<h3>'.&mt('Self-enrollment with a student role').'</h3>'.
1514: '<h4><span class="LC_nobreak">'.&mt($type).': '.$cdesc.'</span></h4>'."\n".
1515: '<form action="/adm/modifycourse" method="post" name="selfenrollchg">'."\n".
1.72 raeburn 1516: &hidden_form_elements().'<br />');
1517: &Apache::loncreateuser::update_selfenroll_config($r,$env{'form.pickedcourse'},
1.73 raeburn 1518: $cdom,$cnum,'domain',$type,\%currsettings);
1.72 raeburn 1519: $r->print('</form>');
1.102 raeburn 1520: my @actions =
1521: ('<a href="javascript:changePage(document.selfenrollchg,'."'menu'".')">'.
1522: &mt('Pick another action').'</a>');
1523: $r->print('<br /><br />'.&Apache::lonhtmlcommon::actionbox(\@actions));
1.72 raeburn 1524: return;
1525: }
1526:
1527: sub get_selfenroll_settings {
1528: my ($coursehash) = @_;
1529: my %currsettings;
1530: if (ref($coursehash) eq 'HASH') {
1531: %currsettings = (
1532: selfenroll_types => $coursehash->{'internal.selfenroll_types'},
1533: selfenroll_registered => $coursehash->{'internal.selfenroll_registered'},
1534: selfenroll_section => $coursehash->{'internal.selfenroll_section'},
1535: selfenroll_notifylist => $coursehash->{'internal.selfenroll_notifylist'},
1536: selfenroll_approval => $coursehash->{'internal.selfenroll_approval'},
1537: selfenroll_limit => $coursehash->{'internal.selfenroll_limit'},
1538: selfenroll_cap => $coursehash->{'internal.selfenroll_cap'},
1539: selfenroll_start_date => $coursehash->{'internal.selfenroll_start_date'},
1540: selfenroll_end_date => $coursehash->{'internal.selfenroll_end_date'},
1541: selfenroll_start_access => $coursehash->{'internal.selfenroll_start_access'},
1542: selfenroll_end_access => $coursehash->{'internal.selfenroll_end_access'},
1543: default_enrollment_start_date => $coursehash->{'default_enrollment_start_date'},
1544: default_enrollment_end_date => $coursehash->{'default_enrollment_end_date'},
1.73 raeburn 1545: uniquecode => $coursehash->{'internal.uniquecode'},
1.72 raeburn 1546: );
1547: }
1548: return %currsettings;
1549: }
1550:
1.48 raeburn 1551: sub modifiable_only_title {
1552: my ($type) = @_;
1553: my $dctitle = &Apache::lonnet::plaintext('dc');
1554: if ($type eq 'Community') {
1.102 raeburn 1555: return &mt('Community settings modifiable only by [_1]',$dctitle);
1.48 raeburn 1556: } else {
1.102 raeburn 1557: return &mt('Course settings modifiable only by [_1]',$dctitle);
1.48 raeburn 1558: }
1559: }
1.24 albertel 1560:
1.48 raeburn 1561: sub gather_authenitems {
1.88 raeburn 1562: my ($cdom,$enrollvar,$readonly) = @_;
1.28 raeburn 1563: my ($krbdef,$krbdefdom)=&Apache::loncommon::get_kerberos_defaults($cdom);
1.2 raeburn 1564: my $curr_authtype = '';
1565: my $curr_authfield = '';
1.48 raeburn 1566: if (ref($enrollvar) eq 'HASH') {
1567: if ($enrollvar->{'authtype'} =~ /^krb/) {
1568: $curr_authtype = 'krb';
1569: } elsif ($enrollvar->{'authtype'} eq 'internal' ) {
1570: $curr_authtype = 'int';
1571: } elsif ($enrollvar->{'authtype'} eq 'localauth' ) {
1572: $curr_authtype = 'loc';
1.93 raeburn 1573: } elsif ($enrollvar->{'authtype'} eq 'lti' ) {
1574: $curr_authtype = 'lti';
1.48 raeburn 1575: }
1.2 raeburn 1576: }
1577: unless ($curr_authtype eq '') {
1578: $curr_authfield = $curr_authtype.'arg';
1.33 raeburn 1579: }
1.103 raeburn 1580: my $javascript_validations =
1.48 raeburn 1581: &Apache::lonuserutils::javascript_validations('modifycourse',$krbdefdom,
1582: $curr_authtype,$curr_authfield);
1.35 raeburn 1583: my %param = ( formname => 'document.'.$env{'form.phase'},
1.48 raeburn 1584: kerb_def_dom => $krbdefdom,
1585: kerb_def_auth => $krbdef,
1.2 raeburn 1586: mode => 'modifycourse',
1587: curr_authtype => $curr_authtype,
1.88 raeburn 1588: curr_autharg => $enrollvar->{'autharg'},
1589: readonly => $readonly,
1.48 raeburn 1590: );
1.32 raeburn 1591: my (%authform,$authenitems);
1592: $authform{'krb'} = &Apache::loncommon::authform_kerberos(%param);
1593: $authform{'int'} = &Apache::loncommon::authform_internal(%param);
1594: $authform{'loc'} = &Apache::loncommon::authform_local(%param);
1.93 raeburn 1595: $authform{'lti'} = &Apache::loncommon::authform_lti(%param);
1596: foreach my $item ('krb','int','loc','lti') {
1.32 raeburn 1597: if ($authform{$item} ne '') {
1598: $authenitems .= $authform{$item}.'<br />';
1599: }
1.1 raeburn 1600: }
1.48 raeburn 1601: return($javascript_validations,$authenitems);
1.1 raeburn 1602: }
1603:
1604: sub modify_course {
1.30 raeburn 1605: my ($r,$cdom,$cnum,$cdesc,$domdesc,$type) = @_;
1.48 raeburn 1606: my %longtype = &course_settings_descrip($type);
1.50 raeburn 1607: my @items = ('internal.courseowner','description','internal.co-owners',
1.72 raeburn 1608: 'internal.pendingco-owners','internal.selfenrollmgrdc',
1.85 raeburn 1609: 'internal.selfenrollmgrcc','internal.mysqltables');
1.72 raeburn 1610: my ($selfenrollrows,$selfenrolltitles) = &Apache::lonuserutils::get_selfenroll_titles();
1.81 raeburn 1611: unless (($type eq 'Community') || ($type eq 'Placement')) {
1.48 raeburn 1612: push(@items,('internal.coursecode','internal.authtype','internal.autharg',
1613: 'internal.sectionnums','internal.crosslistings'));
1.103 raeburn 1614: if (&showcredits($cdom)) {
1.60 raeburn 1615: push(@items,'internal.defaultcredits');
1616: }
1.94 raeburn 1617: my %passwdconf = &Apache::lonnet::get_passwdconf($cdom);
1618: if ($passwdconf{'crsownerchg'}) {
1619: push(@items,'internal.nopasswdchg');
1620: }
1.1 raeburn 1621: }
1.48 raeburn 1622: my %settings = &Apache::lonnet::get('environment',\@items,$cdom,$cnum);
1623: my $description = $settings{'description'};
1.60 raeburn 1624: my ($ccrole,$response,$chgresponse,$nochgresponse,$reply,%currattr,%newattr,
1625: %cenv,%changed,@changes,@nochanges,@sections,@xlists,@warnings);
1626: my @modifiable_params = &get_dc_settable($type,$cdom);
1.28 raeburn 1627: foreach my $param (@modifiable_params) {
1.48 raeburn 1628: $currattr{$param} = $settings{'internal.'.$param};
1.1 raeburn 1629: }
1.48 raeburn 1630: if ($type eq 'Community') {
1631: %changed = ( owner => 0 );
1632: $ccrole = 'co';
1633: } else {
1634: %changed = ( code => 0,
1635: owner => 0,
1.94 raeburn 1636: passwd => 0,
1.48 raeburn 1637: );
1638: $ccrole = 'cc';
1639: unless ($settings{'internal.sectionnums'} eq '') {
1640: if ($settings{'internal.sectionnums'} =~ m/,/) {
1641: @sections = split/,/,$settings{'internal.sectionnums'};
1642: } else {
1643: $sections[0] = $settings{'internal.sectionnums'};
1644: }
1645: }
1.60 raeburn 1646: unless ($settings{'internal.crosslistings'} eq '') {
1.48 raeburn 1647: if ($settings{'internal.crosslistings'} =~ m/,/) {
1648: @xlists = split/,/,$settings{'internal.crosslistings'};
1649: } else {
1650: $xlists[0] = $settings{'internal.crosslistings'};
1651: }
1652: }
1653: if ($env{'form.login'} eq 'krb') {
1654: $newattr{'authtype'} = $env{'form.login'};
1655: $newattr{'authtype'} .= $env{'form.krbver'};
1656: $newattr{'autharg'} = $env{'form.krbarg'};
1657: } elsif ($env{'form.login'} eq 'int') {
1658: $newattr{'authtype'} ='internal';
1659: if ((defined($env{'form.intarg'})) && ($env{'form.intarg'})) {
1660: $newattr{'autharg'} = $env{'form.intarg'};
1661: }
1662: } elsif ($env{'form.login'} eq 'loc') {
1663: $newattr{'authtype'} = 'localauth';
1664: if ((defined($env{'form.locarg'})) && ($env{'form.locarg'})) {
1665: $newattr{'autharg'} = $env{'form.locarg'};
1666: }
1.93 raeburn 1667: } elsif ($env{'form.login'} eq 'lti') {
1668: $newattr{'authtype'} = 'lti';
1.48 raeburn 1669: }
1670: if ( $newattr{'authtype'}=~ /^krb/) {
1671: if ($newattr{'autharg'} eq '') {
1672: push(@warnings,
1673: &mt('As you did not include the default Kerberos domain'
1.45 bisitz 1674: .' to be used for authentication in this class, the'
1675: .' institutional data used by the automated'
1676: .' enrollment process must include the Kerberos'
1.48 raeburn 1677: .' domain for each new student.'));
1678: }
1679: }
1680:
1681: if ( exists($env{'form.coursecode'}) ) {
1682: $newattr{'coursecode'}=$env{'form.coursecode'};
1683: unless ( $newattr{'coursecode'} eq $currattr{'coursecode'} ) {
1684: $changed{'code'} = 1;
1685: }
1.1 raeburn 1686: }
1.85 raeburn 1687: if ( exists($env{'form.mysqltables'}) ) {
1688: $newattr{'mysqltables'} = $env{'form.mysqltables'};
1689: $newattr{'mysqltables'} =~ s/\D+//g;
1690: }
1.94 raeburn 1691: if ($type ne 'Placement') {
1692: if (&showcredits($cdom) && exists($env{'form.defaultcredits'})) {
1693: $newattr{'defaultcredits'}=$env{'form.defaultcredits'};
1694: $newattr{'defaultcredits'} =~ s/[^\d\.]//g;
1695: }
1696: if (grep(/^nopasswdchg$/,@modifiable_params)) {
1697: if ($env{'form.nopasswdchg'}) {
1698: $newattr{'nopasswdchg'} = 1;
1699: unless ($currattr{'nopasswdchg'}) {
1700: $changed{'passwd'} = 1;
1701: }
1702: } elsif ($currattr{'nopasswdchg'}) {
1703: $changed{'passwd'} = 1;
1704: }
1705: }
1.60 raeburn 1706: }
1.72 raeburn 1707: }
1708:
1709: my @newmgrdc = ();
1710: my @newmgrcc = ();
1711: my @currmgrdc = split(/,/,$currattr{'selfenrollmgrdc'});
1712: my @currmgrcc = split(/,/,$currattr{'selfenrollmgrcc'});
1.60 raeburn 1713:
1.72 raeburn 1714: foreach my $item (@{$selfenrollrows}) {
1715: if ($env{'form.selfenrollmgr_'.$item} eq '0') {
1716: push(@newmgrdc,$item);
1717: } elsif ($env{'form.selfenrollmgr_'.$item} eq '1') {
1718: push(@newmgrcc,$item);
1719: }
1720: }
1721:
1722: $newattr{'selfenrollmgrdc'}=join(',',@newmgrdc);
1723: $newattr{'selfenrollmgrcc'}=join(',',@newmgrcc);
1724:
1725: my $cctitle;
1726: if ($type eq 'Community') {
1727: $cctitle = &mt('Community personnel');
1728: } else {
1729: $cctitle = &mt('Course personnel');
1.1 raeburn 1730: }
1.72 raeburn 1731: my $dctitle = &Apache::lonnet::plaintext('dc');
1.1 raeburn 1732:
1.16 albertel 1733: if ( exists($env{'form.courseowner'}) ) {
1734: $newattr{'courseowner'}=$env{'form.courseowner'};
1.14 raeburn 1735: unless ( $newattr{'courseowner'} eq $currattr{'courseowner'} ) {
1.38 raeburn 1736: $changed{'owner'} = 1;
1.103 raeburn 1737: }
1.1 raeburn 1738: }
1.48 raeburn 1739:
1.94 raeburn 1740: if ($changed{'owner'} || $changed{'code'} || $changed{'passwd'}) {
1.38 raeburn 1741: my %crsinfo = &Apache::lonnet::courseiddump($cdom,'.',1,'.','.',$cnum,
1742: undef,undef,'.');
1743: if (ref($crsinfo{$env{'form.pickedcourse'}}) eq 'HASH') {
1.48 raeburn 1744: if ($changed{'code'}) {
1745: $crsinfo{$env{'form.pickedcourse'}}{'inst_code'} = $env{'form.coursecode'};
1746: }
1747: if ($changed{'owner'}) {
1748: $crsinfo{$env{'form.pickedcourse'}}{'owner'} = $env{'form.courseowner'};
1749: }
1.94 raeburn 1750: if ($changed{'passwd'}) {
1751: if ($env{'form.nopasswdchg'}) {
1752: $crsinfo{$env{'form.pickedcourse'}}{'nopasswdchg'} = 1;
1753: } else {
1754: delete($crsinfo{'nopasswdchg'});
1755: }
1756: }
1.38 raeburn 1757: my $chome = &Apache::lonnet::homeserver($cnum,$cdom);
1758: my $putres = &Apache::lonnet::courseidput($cdom,\%crsinfo,$chome,'notime');
1.94 raeburn 1759: if (($putres eq 'ok') && (($changed{'owner'} || $changed{'code'}))) {
1.50 raeburn 1760: &update_coowners($cdom,$cnum,$chome,\%settings,\%newattr);
1.95 raeburn 1761: if ($changed{'code'}) {
1762: &Apache::lonnet::devalidate_cache_new('instcats',$cdom);
1763: # Update cache of self-cataloging courses on institution's server(s).
1764: if (&Apache::lonnet::shared_institution($cdom)) {
1765: unless ($registered_cleanup) {
1766: my $handlers = $r->get_handlers('PerlCleanupHandler');
1767: $r->set_handlers('PerlCleanupHandler' => [\&devalidate_remote_instcats,@{$handlers}]);
1768: $registered_cleanup=1;
1769: $modified_dom = $cdom;
1770: }
1771: }
1772: }
1.50 raeburn 1773: }
1.38 raeburn 1774: }
1.14 raeburn 1775: }
1.28 raeburn 1776: foreach my $param (@modifiable_params) {
1777: if ($currattr{$param} eq $newattr{$param}) {
1778: push(@nochanges,$param);
1.1 raeburn 1779: } else {
1.48 raeburn 1780: $cenv{'internal.'.$param} = $newattr{$param};
1.28 raeburn 1781: push(@changes,$param);
1.1 raeburn 1782: }
1783: }
1784: if (@changes > 0) {
1.62 bisitz 1785: $chgresponse = &mt('The following settings have been changed:').'<br/><ul>';
1.1 raeburn 1786: }
1.48 raeburn 1787: if (@nochanges > 0) {
1.62 bisitz 1788: $nochgresponse = &mt('The following settings remain unchanged:').'<br/><ul>';
1.1 raeburn 1789: }
1.33 raeburn 1790: if (@changes > 0) {
1.28 raeburn 1791: my $putreply = &Apache::lonnet::put('environment',\%cenv,$cdom,$cnum);
1.1 raeburn 1792: if ($putreply !~ /^ok$/) {
1.48 raeburn 1793: $response = '<p class="LC_error">'.
1794: &mt('There was a problem processing your requested changes.').'<br />';
1795: if ($type eq 'Community') {
1796: $response .= &mt('Settings for this community have been left unchanged.');
1797: } else {
1798: $response .= &mt('Settings for this course have been left unchanged.');
1799: }
1800: $response .= '<br/>'.&mt('Error: ').$putreply.'</p>';
1.1 raeburn 1801: } else {
1.72 raeburn 1802: if ($env{'course.'.$cdom.'_'.$cnum.'.description'} ne '') {
1803: my %newenv;
1.103 raeburn 1804: map { $newenv{'course.'.$cdom.'_'.$cnum.'.internal.'.$_} = $newattr{$_}; } @changes;
1.72 raeburn 1805: &Apache::lonnet::appenv(\%newenv);
1806: }
1.28 raeburn 1807: foreach my $attr (@modifiable_params) {
1.48 raeburn 1808: if (grep/^\Q$attr\E$/,@changes) {
1.72 raeburn 1809: my $shown = $newattr{$attr};
1810: if ($attr eq 'selfenrollmgrdc') {
1811: $shown = &selfenroll_config_status(\@newmgrdc,$selfenrolltitles);
1812: } elsif ($attr eq 'selfenrollmgrcc') {
1813: $shown = &selfenroll_config_status(\@newmgrcc,$selfenrolltitles);
1814: } elsif (($attr eq 'defaultcredits') && ($shown eq '')) {
1815: $shown = &mt('None');
1.85 raeburn 1816: } elsif (($attr eq 'mysqltables') && ($shown eq '')) {
1817: $shown = &mt('domain default');
1.94 raeburn 1818: } elsif ($attr eq 'nopasswdchg') {
1819: if ($shown) {
1820: $shown = &mt('Yes');
1821: } else {
1822: $shown = &mt('No');
1823: }
1.72 raeburn 1824: }
1825: $chgresponse .= '<li>'.&mt('[_1] now set to: [_2]',$longtype{$attr},$shown).'</li>';
1.1 raeburn 1826: } else {
1.72 raeburn 1827: my $shown = $currattr{$attr};
1828: if ($attr eq 'selfenrollmgrdc') {
1829: $shown = &selfenroll_config_status(\@currmgrdc,$selfenrolltitles);
1830: } elsif ($attr eq 'selfenrollmgrcc') {
1831: $shown = &selfenroll_config_status(\@currmgrcc,$selfenrolltitles);
1832: } elsif (($attr eq 'defaultcredits') && ($shown eq '')) {
1833: $shown = &mt('None');
1.85 raeburn 1834: } elsif (($attr eq 'mysqltables') && ($shown eq '')) {
1835: $shown = &mt('domain default');
1.94 raeburn 1836: } elsif ($attr eq 'nopasswdchg') {
1837: if ($shown) {
1838: $shown = &mt('Yes');
1839: } else {
1840: $shown = &mt('No');
1841: }
1.72 raeburn 1842: }
1843: $nochgresponse .= '<li>'.&mt('[_1] still set to: [_2]',$longtype{$attr},$shown).'</li>';
1.1 raeburn 1844: }
1845: }
1.81 raeburn 1846: if (($type ne 'Community') && ($type ne 'Placement') && ($changed{'code'} || $changed{'owner'})) {
1.1 raeburn 1847: if ( $newattr{'courseowner'} eq '') {
1.48 raeburn 1848: push(@warnings,&mt('There is no owner associated with this LON-CAPA course.').
1849: '<br />'.&mt('If automated enrollment at your institution requires validation of course owners, automated enrollment will fail.'));
1.1 raeburn 1850: } else {
1.59 raeburn 1851: my %crsenv = &Apache::lonnet::get('environment',['internal.co-owners'],$cdom,$cnum);
1852: my $coowners = $crsenv{'internal.co-owners'};
1.1 raeburn 1853: if (@sections > 0) {
1.38 raeburn 1854: if ($changed{'code'}) {
1.2 raeburn 1855: foreach my $sec (@sections) {
1856: if ($sec =~ m/^(.+):/) {
1.48 raeburn 1857: my $instsec = $1;
1.8 raeburn 1858: my $inst_course_id = $newattr{'coursecode'}.$1;
1.28 raeburn 1859: my $course_check = &Apache::lonnet::auto_validate_courseID($cnum,$cdom,$inst_course_id);
1.7 raeburn 1860: if ($course_check eq 'ok') {
1.58 raeburn 1861: my $outcome = &Apache::lonnet::auto_new_course($cnum,$cdom,$inst_course_id,$newattr{'courseowner'},$coowners);
1.48 raeburn 1862: unless ($outcome eq 'ok') {
1.53 raeburn 1863: 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 1864: }
1865: } else {
1.53 raeburn 1866: 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 1867: }
1868: } else {
1.48 raeburn 1869: 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 1870: }
1871: }
1.38 raeburn 1872: } elsif ($changed{'owner'}) {
1.4 raeburn 1873: foreach my $sec (@sections) {
1874: if ($sec =~ m/^(.+):/) {
1.48 raeburn 1875: my $instsec = $1;
1876: my $inst_course_id = $newattr{'coursecode'}.$instsec;
1.58 raeburn 1877: my $outcome = &Apache::lonnet::auto_new_course($cnum,$cdom,$inst_course_id,$newattr{'courseowner'},$coowners);
1.4 raeburn 1878: unless ($outcome eq 'ok') {
1.53 raeburn 1879: 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 1880: }
1881: } else {
1.53 raeburn 1882: 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 1883: }
1884: }
1885: }
1.1 raeburn 1886: } else {
1.53 raeburn 1887: 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 1888: }
1.38 raeburn 1889: if ( (@xlists > 0) && ($changed{'owner'}) ) {
1.1 raeburn 1890: foreach my $xlist (@xlists) {
1891: if ($xlist =~ m/^(.+):/) {
1.48 raeburn 1892: my $instxlist = $1;
1.58 raeburn 1893: my $outcome = &Apache::lonnet::auto_new_course($cnum,$cdom,$instxlist,$newattr{'courseowner'},$coowners);
1.1 raeburn 1894: unless ($outcome eq 'ok') {
1.48 raeburn 1895: 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 1896: }
1.28 raeburn 1897: }
1.1 raeburn 1898: }
1899: }
1900: }
1901: }
1902: }
1.2 raeburn 1903: } else {
1.28 raeburn 1904: foreach my $attr (@modifiable_params) {
1.72 raeburn 1905: my $shown = $currattr{$attr};
1906: if ($attr eq 'selfenrollmgrdc') {
1907: $shown = &selfenroll_config_status(\@currmgrdc,$selfenrolltitles);
1908: } elsif ($attr eq 'selfenrollmgrcc') {
1909: $shown = &selfenroll_config_status(\@currmgrcc,$selfenrolltitles);
1910: } elsif (($attr eq 'defaultcredits') && ($shown eq '')) {
1911: $shown = &mt('None');
1.85 raeburn 1912: } elsif (($attr eq 'mysqltables') && ($shown eq '')) {
1913: $shown = &mt('domain default');
1.72 raeburn 1914: }
1915: $nochgresponse .= '<li>'.&mt('[_1] still set to: [_2]',$longtype{$attr},$shown).'</li>';
1.2 raeburn 1916: }
1.1 raeburn 1917: }
1918:
1919: if (@changes > 0) {
1920: $chgresponse .= "</ul><br/><br/>";
1921: }
1922: if (@nochanges > 0) {
1923: $nochgresponse .= "</ul><br/><br/>";
1924: }
1.48 raeburn 1925: my ($warning,$numwarnings);
1.103 raeburn 1926: my $numwarnings = scalar(@warnings);
1.48 raeburn 1927: if ($numwarnings) {
1928: $warning = &mt('The following [quant,_1,warning was,warnings were] generated when applying your changes to automated enrollment:',$numwarnings).'<p><ul>';
1929: foreach my $warn (@warnings) {
1930: $warning .= '<li><span class="LC_warning">'.$warn.'</span></li>';
1931: }
1932: $warning .= '</ul></p>';
1.1 raeburn 1933: }
1.48 raeburn 1934: if ($response) {
1935: $reply = $response;
1936: } else {
1.1 raeburn 1937: $reply = $chgresponse.$nochgresponse.$warning;
1938: }
1.48 raeburn 1939: &print_header($r,$type);
1.102 raeburn 1940: $reply = '<h3>'.&modifiable_only_title($type).'</h3>'."\n".
1941: '<h4><span class="LC_nobreak">'.&mt($type).': '.$cdesc.'</span></h4>'."\n".
1.48 raeburn 1942: '<p>'.$reply.'</p>'."\n".
1.28 raeburn 1943: '<form action="/adm/modifycourse" method="post" name="processparms">'.
1.66 bisitz 1944: &hidden_form_elements();
1945: my @actions =
1946: ('<a href="javascript:changePage(document.processparms,'."'menu'".')">'.
1947: &mt('Pick another action').'</a>');
1.48 raeburn 1948: if ($numwarnings) {
1949: my $newrole = $ccrole.'./'.$cdom.'/'.$cnum;
1950: my $escuri = &HTML::Entities::encode('/adm/roles?selectrole=1&'.$newrole.
1951: '=1&destinationurl=/adm/populate','&<>"');
1952:
1.66 bisitz 1953: push(@actions, '<a href="'.$escuri.'">'.
1954: &mt('Go to Automated Enrollment Manager for course').'</a>');
1.48 raeburn 1955: }
1.102 raeburn 1956: $reply .= '</form>'.
1957: '<br />'.&Apache::lonhtmlcommon::actionbox(\@actions);
1.3 raeburn 1958: $r->print($reply);
1.28 raeburn 1959: return;
1960: }
1961:
1.72 raeburn 1962: sub selfenroll_config_status {
1963: my ($items,$selfenrolltitles) = @_;
1964: my $shown;
1965: if ((ref($items) eq 'ARRAY') && (ref($selfenrolltitles) eq 'HASH')) {
1966: if (@{$items} > 0) {
1967: $shown = '<ul>';
1968: foreach my $item (@{$items}) {
1969: $shown .= '<li>'.$selfenrolltitles->{$item}.'</li>';
1970: }
1971: $shown .= '</ul>';
1972: } else {
1973: $shown = &mt('None');
1974: }
1975: }
1976: return $shown;
1977: }
1978:
1.50 raeburn 1979: sub update_coowners {
1980: my ($cdom,$cnum,$chome,$settings,$newattr) = @_;
1981: return unless ((ref($settings) eq 'HASH') && (ref($newattr) eq 'HASH'));
1982: my %designhash = &Apache::loncommon::get_domainconf($cdom);
1983: my (%cchash,$autocoowners);
1984: if ($designhash{$cdom.'.autoassign.co-owners'}) {
1985: $autocoowners = 1;
1986: %cchash = &Apache::lonnet::get_my_roles($cnum,$cdom,undef,undef,['cc']);
1987: }
1988: if ($settings->{'internal.courseowner'} ne $newattr->{'courseowner'}) {
1989: my $oldowner_to_coowner;
1.51 raeburn 1990: my @types = ('co-owners');
1.50 raeburn 1991: if (($newattr->{'coursecode'}) && ($autocoowners)) {
1992: my $oldowner = $settings->{'internal.courseowner'};
1993: if ($cchash{$oldowner.':cc'}) {
1.51 raeburn 1994: my ($result,$desc) = &Apache::lonnet::auto_validate_instcode($cnum,$cdom,$newattr->{'coursecode'},$oldowner);
1995: if ($result eq 'valid') {
1996: if ($settings->{'internal.co-owner'}) {
1997: my @current = split(',',$settings->{'internal.co-owners'});
1998: unless (grep(/^\Q$oldowner\E$/,@current)) {
1999: $oldowner_to_coowner = 1;
2000: }
2001: } else {
1.50 raeburn 2002: $oldowner_to_coowner = 1;
2003: }
2004: }
2005: }
1.51 raeburn 2006: } else {
2007: push(@types,'pendingco-owners');
1.50 raeburn 2008: }
1.51 raeburn 2009: foreach my $type (@types) {
1.50 raeburn 2010: if ($settings->{'internal.'.$type}) {
2011: my @current = split(',',$settings->{'internal.'.$type});
2012: my $newowner = $newattr->{'courseowner'};
2013: my @newvalues = ();
2014: if (($newowner ne '') && (grep(/^\Q$newowner\E$/,@current))) {
2015: foreach my $person (@current) {
2016: unless ($person eq $newowner) {
2017: push(@newvalues,$person);
2018: }
2019: }
2020: } else {
2021: @newvalues = @current;
2022: }
2023: if ($oldowner_to_coowner) {
2024: push(@newvalues,$settings->{'internal.courseowner'});
2025: @newvalues = sort(@newvalues);
2026: }
2027: my $newownstr = join(',',@newvalues);
2028: if ($newownstr ne $settings->{'internal.'.$type}) {
2029: if ($type eq 'co-owners') {
2030: my $deleted = '';
2031: unless (@newvalues) {
2032: $deleted = 1;
2033: }
2034: &Apache::lonnet::store_coowners($cdom,$cnum,$chome,
2035: $deleted,@newvalues);
2036: } else {
2037: my $pendingcoowners;
2038: my $cid = $cdom.'_'.$cnum;
2039: if (@newvalues) {
2040: $pendingcoowners = join(',',@newvalues);
2041: my %pendinghash = (
2042: 'internal.pendingco-owners' => $pendingcoowners,
2043: );
1.52 raeburn 2044: my $putresult = &Apache::lonnet::put('environment',\%pendinghash,$cdom,$cnum);
1.50 raeburn 2045: if ($putresult eq 'ok') {
2046: if ($env{'course.'.$cid.'.num'} eq $cnum) {
1.52 raeburn 2047: &Apache::lonnet::appenv({'course.'.$cid.'.internal.pendingco-owners' => $pendingcoowners});
1.50 raeburn 2048: }
2049: }
2050: } else {
2051: my $delresult = &Apache::lonnet::del('environment',['internal.pendingco-owners'],$cdom,$cnum);
2052: if ($delresult eq 'ok') {
2053: if ($env{'course.'.$cid.'.internal.pendingco-owners'}) {
2054: &Apache::lonnet::delenv('course.'.$cid.'.internal.pendingco-owners');
2055: }
2056: }
2057: }
2058: }
2059: } elsif ($oldowner_to_coowner) {
2060: &Apache::lonnet::store_coowners($cdom,$cnum,$chome,'',
2061: $settings->{'internal.courseowner'});
2062:
2063: }
2064: } elsif ($oldowner_to_coowner) {
2065: &Apache::lonnet::store_coowners($cdom,$cnum,$chome,'',
2066: $settings->{'internal.courseowner'});
2067: }
2068: }
2069: }
2070: if ($settings->{'internal.coursecode'} ne $newattr->{'coursecode'}) {
2071: if ($newattr->{'coursecode'} ne '') {
2072: my %designhash = &Apache::loncommon::get_domainconf($cdom);
2073: if ($designhash{$cdom.'.autoassign.co-owners'}) {
2074: my @newcoowners = ();
2075: if ($settings->{'internal.co-owners'}) {
1.58 raeburn 2076: my @currcoown = split(',',$settings->{'internal.co-owners'});
1.50 raeburn 2077: my ($updatecoowners,$delcoowners);
2078: foreach my $person (@currcoown) {
1.51 raeburn 2079: my ($result,$desc) = &Apache::lonnet::auto_validate_instcode($cnum,$cdom,$newattr->{'coursecode'},$person);
1.50 raeburn 2080: if ($result eq 'valid') {
2081: push(@newcoowners,$person);
2082: }
2083: }
2084: foreach my $item (sort(keys(%cchash))) {
2085: my ($uname,$udom,$urole) = split(':',$item);
1.51 raeburn 2086: next if ($uname.':'.$udom eq $newattr->{'courseowner'});
1.50 raeburn 2087: unless (grep(/^\Q$uname\E:\Q$udom\E$/,@newcoowners)) {
1.51 raeburn 2088: my ($result,$desc) = &Apache::lonnet::auto_validate_instcode($cnum,$cdom,$newattr->{'coursecode'},$uname.':'.$udom);
2089: if ($result eq 'valid') {
2090: push(@newcoowners,$uname.':'.$udom);
2091: }
1.50 raeburn 2092: }
2093: }
2094: if (@newcoowners) {
2095: my $coowners = join(',',sort(@newcoowners));
2096: unless ($coowners eq $settings->{'internal.co-owners'}) {
2097: $updatecoowners = 1;
2098: }
2099: } else {
2100: $delcoowners = 1;
2101: }
2102: if ($updatecoowners || $delcoowners) {
2103: &Apache::lonnet::store_coowners($cdom,$cnum,$chome,
2104: $delcoowners,@newcoowners);
2105: }
2106: } else {
2107: foreach my $item (sort(keys(%cchash))) {
2108: my ($uname,$udom,$urole) = split(':',$item);
2109: push(@newcoowners,$uname.':'.$udom);
2110: }
2111: if (@newcoowners) {
2112: &Apache::lonnet::store_coowners($cdom,$cnum,$chome,'',
2113: @newcoowners);
2114: }
2115: }
2116: }
2117: }
2118: }
2119: return;
2120: }
2121:
1.28 raeburn 2122: sub modify_quota {
1.48 raeburn 2123: my ($r,$cdom,$cnum,$cdesc,$domdesc,$type) = @_;
2124: &print_header($r,$type);
1.61 raeburn 2125: my $lctype = lc($type);
1.102 raeburn 2126: $r->print('<h3>'.&mt("Disk space quotas for $lctype")."</h3>\n".
2127: '<h4><span class="LC_nobreak">'.&mt($type).' :'.$cdesc.'</span></h4>'."\n".
2128: '<form action="/adm/modifycourse" method="post" name="processquota">'."\n");
1.61 raeburn 2129: my %oldsettings = &Apache::lonnet::get('environment',['internal.coursequota','internal.uploadquota'],$cdom,$cnum);
2130: my %staticdefaults = (
2131: coursequota => 20,
2132: uploadquota => 500,
2133: );
2134: my %default;
2135: $default{'coursequota'} = $staticdefaults{'coursequota'};
2136: my %domdefs = &Apache::lonnet::get_domain_defaults($cdom);
2137: $default{'uploadquota'} = $domdefs{'uploadquota'};
2138: if ($default{'uploadquota'} eq '') {
2139: $default{'uploadquota'} = $staticdefaults{'uploadquota'};
2140: }
2141: my (%cenv,%showresult);
2142: foreach my $item ('coursequota','uploadquota') {
2143: if ($env{'form.'.$item} ne '') {
2144: my $newquota = $env{'form.'.$item};
2145: if ($newquota =~ /^\s*(\d+\.?\d*|\.\d+)\s*$/) {
2146: $newquota = $1;
2147: if ($oldsettings{'internal.'.$item} == $newquota) {
2148: if ($item eq 'coursequota') {
2149: $r->print(&mt('The disk space allocated for group portfolio files remains unchanged as [_1] MB.',$newquota).'<br />');
2150: } else {
2151: $r->print(&mt('The disk space allocated for files uploaded via the Content Editor remains unchanged as [_1] MB.',$newquota).'<br />');
2152: }
2153: } else {
2154: $cenv{'internal.'.$item} = $newquota;
2155: $showresult{$item} = 1;
2156: }
1.28 raeburn 2157: } else {
1.103 raeburn 2158: if ($item eq 'coursequota') {
1.61 raeburn 2159: $r->print(&mt('The proposed group portfolio quota contained invalid characters, so the quota is unchanged.').'<br />');
2160: } else {
2161: $r->print(&mt('The proposed quota for content uploaded via the Content Editor contained invalid characters, so the quota is unchanged.').'<br />');
2162:
2163: }
2164: }
2165: }
2166: }
2167: if (keys(%cenv)) {
2168: my $putreply = &Apache::lonnet::put('environment',\%cenv,$cdom,
2169: $cnum);
2170: foreach my $key (sort(keys(%showresult))) {
1.103 raeburn 2171: if (($oldsettings{'internal.'.$key} eq '') &&
1.61 raeburn 2172: ($env{'form.'.$key} == $default{$key})) {
2173: if ($key eq 'uploadquota') {
2174: if ($type eq 'Community') {
2175: $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.',
2176: $default{$key}).'<br />');
2177: } else {
2178: $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.',
2179: $default{$key}).'<br />');
2180: }
1.103 raeburn 2181: } else {
1.48 raeburn 2182: if ($type eq 'Community') {
1.61 raeburn 2183: $r->print(&mt('The disk space allocated for group portfolio files in this community is the default quota for this domain: [_1] MB.',
2184: $default{$key}).'<br />');
1.48 raeburn 2185: } else {
1.61 raeburn 2186: $r->print(&mt('The disk space allocated for group portfolio files in this course is the default quota for this domain: [_1] MB.',
2187: $default{$key}).'<br />');
1.48 raeburn 2188: }
1.61 raeburn 2189: }
2190: delete($showresult{$key});
2191: }
2192: }
2193: if ($putreply eq 'ok') {
2194: my %updatedsettings = &Apache::lonnet::get('environment',['internal.coursequota','internal.uploadquota'],$cdom,$cnum);
2195: if ($showresult{'coursequota'}) {
2196: $r->print(&mt('The disk space allocated for group portfolio files is now: [_1] MB.',
2197: '<b>'.$updatedsettings{'internal.coursequota'}.'</b>').'<br />');
2198: my $usage = &Apache::longroup::sum_quotas($cdom.'_'.$cnum);
2199: if ($usage >= $updatedsettings{'internal.coursequota'}) {
2200: my $newoverquota;
2201: if ($usage < $oldsettings{'internal.coursequota'}) {
2202: $newoverquota = 'now';
2203: }
2204: $r->print('<p>');
2205: if ($type eq 'Community') {
1.67 bisitz 2206: $r->print(&mt("Disk usage $newoverquota exceeds the quota for this community.").' '.
1.61 raeburn 2207: &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 2208: } else {
1.67 bisitz 2209: $r->print(&mt("Disk usage $newoverquota exceeds the quota for this course.").' '.
1.61 raeburn 2210: &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 2211: }
1.61 raeburn 2212: $r->print('</p>');
1.28 raeburn 2213: }
2214: }
1.61 raeburn 2215: if ($showresult{'uploadquota'}) {
2216: $r->print(&mt('The disk space allocated for content uploaded directly via the Content Editor is now: [_1] MB.',
2217: '<b>'.$updatedsettings{'internal.uploadquota'}.'</b>').'<br />');
2218: }
1.28 raeburn 2219: } else {
1.63 raeburn 2220: $r->print(&mt('An error occurred storing the quota(s) for group portfolio files and/or uploaded content: ').
1.61 raeburn 2221: $putreply);
1.28 raeburn 2222: }
2223: }
2224: $r->print(&hidden_form_elements().'</form>');
1.102 raeburn 2225: my @actions =
2226: ('<a href="javascript:changePage(document.processparms,'."'menu'".')">'.
2227: &mt('Pick another action').'</a>');
2228: $r->print('<br />'.&Apache::lonhtmlcommon::actionbox(\@actions));
1.28 raeburn 2229: return;
1.1 raeburn 2230: }
2231:
1.57 raeburn 2232: sub modify_anonsurvey_threshold {
2233: my ($r,$cdom,$cnum,$cdesc,$domdesc,$type) = @_;
2234: &print_header($r,$type);
1.102 raeburn 2235: $r->print('<h3>'.&mt('Responder threshold required for display of anonymous survey submissions').'</h3>'."\n".
2236: '<h4><span class="LC_nobreak">'.&mt($type).': '.$cdesc.'</span></h4>'."\n".
2237: '<form action="/adm/modifycourse" method="post" name="processthreshold">'."\n");
1.57 raeburn 2238: my %oldsettings = &Apache::lonnet::get('environment',['internal.anonsurvey_threshold'],$cdom,$cnum);
2239: my %domconfig =
2240: &Apache::lonnet::get_dom('configuration',['coursedefaults'],$cdom);
1.103 raeburn 2241: my $defaultthreshold;
1.57 raeburn 2242: if (ref($domconfig{'coursedefaults'}) eq 'HASH') {
2243: $defaultthreshold = $domconfig{'coursedefaults'}{'anonsurvey_threshold'};
2244: if ($defaultthreshold eq '') {
2245: $defaultthreshold = 10;
2246: }
2247: } else {
2248: $defaultthreshold = 10;
2249: }
2250: if ($env{'form.threshold'} eq '') {
2251: $r->print(&mt('The proposed responder threshold for display of anonymous survey submissions was blank, so the threshold is unchanged.'));
2252: } else {
2253: my $newthreshold = $env{'form.threshold'};
2254: if ($newthreshold =~ /^\s*(\d+)\s*$/) {
2255: $newthreshold = $1;
2256: if ($oldsettings{'internal.anonsurvey_threshold'} eq $env{'form.threshold'}) {
2257: $r->print(&mt('Responder threshold for anonymous survey submissions display remains unchanged: [_1].',$env{'form.threshold'}));
2258: } else {
2259: my %cenv = (
2260: 'internal.anonsurvey_threshold' => $env{'form.threshold'},
2261: );
2262: my $putreply = &Apache::lonnet::put('environment',\%cenv,$cdom,
2263: $cnum);
1.72 raeburn 2264: if ($putreply eq 'ok') {
2265: if ($env{'course.'.$cdom.'_'.$cnum.'.description'} ne '') {
2266: &Apache::lonnet::appenv(
2267: {'course.'.$cdom.'_'.$cnum.'.internal.anonsurvey_threshold' => $env{'form.threshold'}});
2268: }
2269: }
1.57 raeburn 2270: if (($oldsettings{'internal.anonsurvey_threshold'} eq '') &&
2271: ($env{'form.threshold'} == $defaultthreshold)) {
2272: $r->print(&mt('The responder threshold for display of anonymous survey submissions is the default for this domain: [_1].',$defaultthreshold));
2273: } else {
2274: if ($putreply eq 'ok') {
2275: my %updatedsettings = &Apache::lonnet::get('environment',['internal.anonsurvey_threshold'],$cdom,$cnum);
2276: $r->print(&mt('The responder threshold for display of anonymous survey submissions is now: [_1].','<b>'.$updatedsettings{'internal.anonsurvey_threshold'}.'</b>'));
2277: } else {
2278: $r->print(&mt('An error occurred storing the responder threshold for anonymous submissions display: ').
2279: $putreply);
2280: }
2281: }
2282: }
2283: } else {
2284: $r->print(&mt('The proposed responder threshold for display of anonymous submissions contained invalid characters, so the threshold is unchanged.'));
2285: }
2286: }
1.75 raeburn 2287: $r->print(&hidden_form_elements().'</form>');
1.102 raeburn 2288: my @actions =
2289: ('<a href="javascript:changePage(document.processthreshold,'."'menu'".')">'.
2290: &mt('Pick another action').'</a>');
2291: $r->print('<br />'.&Apache::lonhtmlcommon::actionbox(\@actions));
1.75 raeburn 2292: return;
2293: }
2294:
2295: sub modify_postsubmit_config {
2296: my ($r,$cdom,$cnum,$cdesc,$domdesc,$type) = @_;
2297: &print_header($r,$type);
2298: my %lt = &Apache::lonlocal::texthash(
2299: subb => 'Submit button behavior after student makes a submission:',
2300: unch => 'Post submission behavior of the Submit button is unchanged.',
2301: erro => 'An error occurred when saving your proposed changes.',
2302: inva => 'An invalid response was recorded.',
1.102 raeburn 2303: back => 'Pick another action',
1.75 raeburn 2304: );
1.102 raeburn 2305: $r->print('<h3>'.$lt{'subb'}.'</h3>'."\n".
2306: '<h4><span class="LC_nobreak">'.&mt($type).': '.$cdesc.'</span></h4>'."\n".
2307: '<form action="/adm/modifycourse" method="post" name="processpostsubmit"><p>'."\n");
1.103 raeburn 2308: my %oldsettings =
1.75 raeburn 2309: &Apache::lonnet::get('environment',['internal.postsubmit','internal.postsubtimeout','internal.coursecode','internal.textbook'],$cdom,$cnum);
2310: my $postsubmit = $env{'form.postsubmit'};
2311: if ($postsubmit eq '1') {
2312: my $postsubtimeout = $env{'form.postsubtimeout'};
2313: $postsubtimeout =~ s/[^\d\.]+//g;
2314: if (($oldsettings{'internal.postsubmit'} eq $postsubmit) && ($oldsettings{'internal.postsubtimeout'} eq $postsubtimeout)) {
1.103 raeburn 2315: $r->print($lt{'unch'});
1.75 raeburn 2316: } else {
2317: my %cenv = (
2318: 'internal.postsubmit' => $postsubmit,
2319: );
2320: if ($postsubtimeout eq '') {
2321: my $putreply = &Apache::lonnet::put('environment',\%cenv,$cdom,$cnum);
2322: if ($putreply eq 'ok') {
2323: my $defaulttimeout = &domain_postsubtimeout($cdom,$type,\%oldsettings);
2324: $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));
2325: if (exists($oldsettings{'internal.postsubtimeout'})) {
2326: &Apache::lonnet::del('environment',['internal.postsubtimeout'],$cdom,$cnum);
2327: }
2328: } else {
2329: $r->print($lt{'erro'});
2330: }
1.103 raeburn 2331: } else {
1.75 raeburn 2332: $cenv{'internal.postsubtimeout'} = $postsubtimeout;
2333: my $putreply = &Apache::lonnet::put('environment',\%cenv,$cdom,$cnum);
2334: if ($putreply eq 'ok') {
2335: if ($postsubtimeout eq '0') {
1.103 raeburn 2336: $r->print(&mt('Submit button will be disabled after student submission until page is reloaded.'));
1.75 raeburn 2337: } else {
2338: $r->print(&mt('Submit button will be disabled after student submission for [quant,_1,second].',$postsubtimeout));
2339: }
2340: } else {
2341: $r->print($lt{'erro'});
2342: }
2343: }
2344: }
2345: } elsif ($postsubmit eq '0') {
2346: if ($oldsettings{'internal.postsubmit'} eq $postsubmit) {
2347: $r->print($lt{'unch'});
2348: } else {
2349: if (exists($oldsettings{'internal.postsubtimeout'})) {
1.103 raeburn 2350: &Apache::lonnet::del('environment',['internal.postsubtimeout'],$cdom,$cnum);
1.75 raeburn 2351: }
2352: my %cenv = (
2353: 'internal.postsubmit' => $postsubmit,
2354: );
2355: my $putreply = &Apache::lonnet::put('environment',\%cenv,$cdom,$cnum);
2356: if ($putreply eq 'ok') {
1.76 droeschl 2357: $r->print(&mt('Submit button will not be disabled after student submission'));
1.75 raeburn 2358: } else {
2359: $r->print($lt{'erro'});
2360: }
2361: }
2362: } else {
2363: $r->print($lt{'inva'}.' '.$lt{'unch'});
2364: }
1.102 raeburn 2365: $r->print('</p>'.&hidden_form_elements().'</form>');
2366: my @actions =
2367: ('<a href="javascript:changePage(document.processpostsubmit,'."'menu'".')">'.
2368: $lt{'back'}.'</a>');
2369: $r->print('<br />'.&Apache::lonhtmlcommon::actionbox(\@actions));
1.57 raeburn 2370: return;
2371: }
2372:
1.38 raeburn 2373: sub modify_catsettings {
1.48 raeburn 2374: my ($r,$cdom,$cnum,$cdesc,$domdesc,$type) = @_;
2375: &print_header($r,$type);
2376: my ($ccrole,%desc);
2377: if ($type eq 'Community') {
2378: $desc{'hidefromcat'} = &mt('Excluded from community catalog');
2379: $desc{'categories'} = &mt('Assigned categories for this community');
2380: $ccrole = 'co';
2381: } else {
2382: $desc{'hidefromcat'} = &mt('Excluded from course catalog');
2383: $desc{'categories'} = &mt('Assigned categories for this course');
2384: $ccrole = 'cc';
2385: }
1.102 raeburn 2386: $r->print('<h3>'.&mt('Category settings').'</h3>'."\n".
2387: '<h4><span class="LC_nobreak">'.&mt($type).': '.$cdesc.'</span></h4>'."\n".
2388: '<form action="/adm/modifycourse" method="post" name="processcat"><br />'."\n");
1.38 raeburn 2389: my %domconf = &Apache::lonnet::get_dom('configuration',['coursecategories'],$cdom);
1.49 raeburn 2390: my @cat_params = &catalog_settable($domconf{'coursecategories'},$type);
1.38 raeburn 2391: if (@cat_params > 0) {
2392: my (%cenv,@changes,@nochanges);
2393: my %currsettings =
2394: &Apache::lonnet::get('environment',['hidefromcat','categories'],$cdom,$cnum);
1.103 raeburn 2395: my (@newcategories,%showitem);
1.38 raeburn 2396: if (grep(/^togglecats$/,@cat_params)) {
2397: if ($currsettings{'hidefromcat'} ne $env{'form.hidefromcat'}) {
2398: push(@changes,'hidefromcat');
2399: $cenv{'hidefromcat'} = $env{'form.hidefromcat'};
2400: } else {
2401: push(@nochanges,'hidefromcat');
2402: }
2403: if ($env{'form.hidefromcat'} eq 'yes') {
2404: $showitem{'hidefromcat'} = '"'.&mt('Yes')."'";
2405: } else {
2406: $showitem{'hidefromcat'} = '"'.&mt('No').'"';
2407: }
2408: }
2409: if (grep(/^categorize$/,@cat_params)) {
2410: my (@cats,@trails,%allitems,%idx,@jsarray);
2411: if (ref($domconf{'coursecategories'}) eq 'HASH') {
2412: my $cathash = $domconf{'coursecategories'}{'cats'};
2413: if (ref($cathash) eq 'HASH') {
2414: &Apache::loncommon::extract_categories($cathash,\@cats,\@trails,
2415: \%allitems,\%idx,\@jsarray);
2416: }
2417: }
2418: @newcategories = &Apache::loncommon::get_env_multiple('form.usecategory');
2419: if (@newcategories == 0) {
2420: $showitem{'categories'} = '"'.&mt('None').'"';
2421: } else {
2422: $showitem{'categories'} = '<ul>';
2423: foreach my $item (@newcategories) {
2424: $showitem{'categories'} .= '<li>'.$trails[$allitems{$item}].'</li>';
2425: }
2426: $showitem{'categories'} .= '</ul>';
2427: }
2428: my $catchg = 0;
2429: if ($currsettings{'categories'} ne '') {
2430: my @currcategories = split('&',$currsettings{'categories'});
2431: foreach my $cat (@currcategories) {
2432: if (!grep(/^\Q$cat\E$/,@newcategories)) {
2433: $catchg = 1;
2434: last;
2435: }
2436: }
2437: if (!$catchg) {
2438: foreach my $cat (@newcategories) {
2439: if (!grep(/^\Q$cat\E$/,@currcategories)) {
2440: $catchg = 1;
1.103 raeburn 2441: last;
2442: }
2443: }
1.38 raeburn 2444: }
2445: } else {
2446: if (@newcategories > 0) {
2447: $catchg = 1;
2448: }
2449: }
2450: if ($catchg) {
2451: $cenv{'categories'} = join('&',@newcategories);
2452: push(@changes,'categories');
2453: } else {
2454: push(@nochanges,'categories');
2455: }
2456: if (@changes > 0) {
2457: my $putreply = &Apache::lonnet::put('environment',\%cenv,$cdom,$cnum);
2458: if ($putreply eq 'ok') {
1.72 raeburn 2459: if ($env{'course.'.$cdom.'_'.$cnum.'.description'} ne '') {
2460: my %newenvhash;
2461: foreach my $item (@changes) {
2462: $newenvhash{'course.'.$cdom.'_'.$cnum.'.'.$item} = $cenv{$item};
2463: }
2464: &Apache::lonnet::appenv(\%newenvhash);
2465: }
1.38 raeburn 2466: my %crsinfo = &Apache::lonnet::courseiddump($cdom,'.',1,'.','.',
2467: $cnum,undef,undef,'.');
2468: if (ref($crsinfo{$env{'form.pickedcourse'}}) eq 'HASH') {
2469: if (grep(/^hidefromcat$/,@changes)) {
2470: $crsinfo{$env{'form.pickedcourse'}}{'hidefromcat'} = $env{'form.hidefromcat'};
2471: }
2472: if (grep(/^categories$/,@changes)) {
2473: $crsinfo{$env{'form.pickedcourse'}}{'categories'} = $cenv{'categories'};
2474: }
2475: my $chome = &Apache::lonnet::homeserver($cnum,$cdom);
2476: my $putres = &Apache::lonnet::courseidput($cdom,\%crsinfo,$chome,'notime');
2477: }
1.48 raeburn 2478: $r->print(&mt('The following changes occurred:').'<ul>');
1.38 raeburn 2479: foreach my $item (@changes) {
1.48 raeburn 2480: $r->print('<li>'.&mt('[_1] now set to: [_2]',$desc{$item},$showitem{$item}).'</li>');
1.38 raeburn 2481: }
2482: $r->print('</ul><br />');
2483: }
2484: }
2485: if (@nochanges > 0) {
1.48 raeburn 2486: $r->print(&mt('The following were unchanged:').'<ul>');
1.38 raeburn 2487: foreach my $item (@nochanges) {
1.48 raeburn 2488: $r->print('<li>'.&mt('[_1] still set to: [_2]',$desc{$item},$showitem{$item}).'</li>');
1.38 raeburn 2489: }
2490: $r->print('</ul>');
2491: }
2492: }
2493: } else {
1.48 raeburn 2494: my $newrole = $ccrole.'./'.$cdom.'/'.$cnum;
2495: my $escuri = &HTML::Entities::encode('/adm/roles?selectrole=1&'.$newrole.
2496: '=1&destinationurl=/adm/courseprefs','&<>"');
2497: if ($type eq 'Community') {
2498: $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 />');
2499: } else {
2500: $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 />');
2501: }
1.38 raeburn 2502: }
1.102 raeburn 2503: $r->print('<br />'.&hidden_form_elements().'</form>');
2504: my @actions =
2505: ('<a href="javascript:changePage(document.processcat,'."'menu'".')">'.
2506: &mt('Pick another action').'</a>');
2507: $r->print('<br />'.&Apache::lonhtmlcommon::actionbox(\@actions));
1.38 raeburn 2508: return;
2509: }
2510:
1.104 ! raeburn 2511: sub modify_default_overrides {
! 2512: my ($r,$cdom,$cnum,$cdesc,$domdesc,$type,$item) = @_;
! 2513: my (%titles,$oldcrsval,$newcrsval,%resulttext,$itemvalue,$nochange,$change,$status,$error);
! 2514: %titles = &default_overrides_titles($type);
! 2515: my ($title,$domdefdisplay,$oldsettings,$optiontext,$options) =
! 2516: &default_overrides_common($item,$cdom,$cnum,$type,\%titles);
! 2517: $oldcrsval = $oldsettings->{'internal.'.$item};
! 2518: if ($item eq 'ltiauth') {
! 2519: %resulttext =
! 2520: &Apache::lonlocal::texthash(
! 2521: chg => 'Re-authentication requirement for LTI launch of deep-linked changed',
! 2522: nochg => 'Re-authentication requirement for LTI launch of deep-linked item is unchanged',
! 2523: );
! 2524: } elsif ($item eq 'exttool') {
! 2525: %resulttext =
! 2526: &Apache::lonlocal::texthash(
! 2527: chg => 'External Tool permissions changed',
! 2528: nochg => 'External Tool permissions unchanged',
! 2529: );
! 2530: } elsif ($item eq 'crsauthor') {
! 2531: %resulttext =
! 2532: &Apache::lonlocal::texthash(
! 2533: chg => 'In-course authoring permissions changed',
! 2534: nochg => 'In-course authoring permissions unchanged',
! 2535: );
! 2536: }
1.97 raeburn 2537: &print_header($r,$type);
1.104 ! raeburn 2538: $r->print('<h3>'.$title.'</h3>'."\n".
1.102 raeburn 2539: '<h4><span class="LC_nobreak">'.&mt($type).': '.$cdesc.'</span></h4>'."\n".
1.104 ! raeburn 2540: '<form action="/adm/modifycourse" method="post" name="process'.$item.'">'."\n");
! 2541: if ($env{'form.'.$item.'set'} eq 'dom') {
! 2542: if ($oldcrsval eq '') {
1.97 raeburn 2543: $nochange = 1;
2544: } else {
2545: $change = 1;
2546: }
1.104 ! raeburn 2547: } elsif ($env{'form.'.$item.'set'} eq 'course') {
! 2548: my $posscrsval = $env{'form.'.$item};
! 2549: if (grep(/^\Q$posscrsval\E$/,@{$options})) {
! 2550: $newcrsval = $posscrsval;
1.97 raeburn 2551: }
1.104 ! raeburn 2552: if ($oldcrsval eq $newcrsval) {
1.97 raeburn 2553: $nochange = 1;
2554: } else {
2555: $change = 1;
2556: }
2557: }
2558: if ($change) {
1.104 ! raeburn 2559: if ($newcrsval ne '') {
1.97 raeburn 2560: my %cenv = (
1.104 ! raeburn 2561: 'internal.'.$item => $newcrsval,
1.97 raeburn 2562: );
2563: if (&Apache::lonnet::put('environment',\%cenv,$cdom,$cnum) eq 'ok') {
2564: if ($env{'course.'.$cdom.'_'.$cnum.'.description'} ne '') {
2565: &Apache::lonnet::appenv(
1.104 ! raeburn 2566: {'course.'.$cdom.'_'.$cnum.'.internal.'.$item => $newcrsval});
1.97 raeburn 2567: }
2568: } else {
2569: $error = 1;
2570: }
2571: } else {
1.104 ! raeburn 2572: if (&Apache::lonnet::del('environment',['internal.'.$item],$cdom,$cnum) eq 'ok') {
! 2573: if (exists($env{'course.'.$cdom.'_'.$cnum.'.internal.'.$item})) {
! 2574: &Apache::lonnet::delenv('course.'.$cdom.'_'.$cnum.'.internal.'.$item);
1.97 raeburn 2575: }
2576: } else {
2577: $error = 1;
2578: }
2579: }
2580: }
2581: if ($error) {
2582: $nochange = 1;
2583: }
2584: if ($nochange) {
1.104 ! raeburn 2585: $itemvalue = $oldcrsval;
1.97 raeburn 2586: } else {
1.104 ! raeburn 2587: $itemvalue = $newcrsval;
1.97 raeburn 2588: }
1.104 ! raeburn 2589: if ($itemvalue eq '') {
! 2590: $status = $titles{'used'}.': '.
! 2591: '<span style="font-style:italic">'.$domdefdisplay.'</span>';
1.97 raeburn 2592: } else {
1.104 ! raeburn 2593: $status = $titles{'cour'}.': '.
! 2594: '<span style="font-style:italic">'.$optiontext->{$itemvalue}.'</span>';
1.97 raeburn 2595: }
2596: if ($error) {
2597: $r->print('<p class="LC_warning">'.&mt('An error occurred when saving your changes').'</p>');
2598: }
2599: $r->print('<p>');
2600: if ($nochange) {
1.104 ! raeburn 2601: $r->print($resulttext{'nochg'});
1.97 raeburn 2602: } elsif ($change) {
1.104 ! raeburn 2603: $r->print($resulttext{'chg'});
1.97 raeburn 2604: }
1.102 raeburn 2605: $r->print('<br />'.$status.'</p>'.
2606: &hidden_form_elements().'</form>');
2607: my @actions =
1.104 ! raeburn 2608: ('<a href="javascript:changePage(document.process'.$item.','."'menu'".')">'.
1.102 raeburn 2609: $titles{'back'}.'</a>');
2610: $r->print('<br />'.&Apache::lonhtmlcommon::actionbox(\@actions));
1.97 raeburn 2611: return;
2612: }
2613:
1.1 raeburn 2614: sub print_header {
1.48 raeburn 2615: my ($r,$type,$javascript_validations) = @_;
1.28 raeburn 2616: my $phase = "start";
2617: if ( exists($env{'form.phase'}) ) {
2618: $phase = $env{'form.phase'};
2619: }
2620: my $js = qq|
1.60 raeburn 2621:
1.28 raeburn 2622: function changePage(formname,newphase) {
2623: formname.phase.value = newphase;
2624: if (newphase == 'processparms') {
2625: return;
1.1 raeburn 2626: }
1.28 raeburn 2627: formname.submit();
2628: }
1.60 raeburn 2629:
1.28 raeburn 2630: |;
2631: if ($phase eq 'setparms') {
1.60 raeburn 2632: $js .= $javascript_validations;
1.28 raeburn 2633: } elsif ($phase eq 'courselist') {
1.90 raeburn 2634: $js .= <<"ENDJS";
1.60 raeburn 2635: function hide_searching() {
2636: if (document.getElementById('searching')) {
2637: document.getElementById('searching').style.display = 'none';
2638: }
2639: return;
2640: }
2641:
1.90 raeburn 2642: ENDJS
1.28 raeburn 2643: } elsif ($phase eq 'setquota') {
1.57 raeburn 2644: my $invalid = &mt('The quota you entered contained invalid characters.');
2645: my $alert = &mt('You must enter a number');
1.78 damieng 2646: &js_escape(\$invalid);
2647: &js_escape(\$alert);
1.57 raeburn 2648: my $regexp = '/^\s*(\d+\.?\d*|\.\d+)\s*$/';
2649: $js .= <<"ENDSCRIPT";
1.60 raeburn 2650:
1.57 raeburn 2651: function verify_quota() {
1.101 raeburn 2652: var newcoursequota = document.setquota.coursequota.value;
2653: var newuploadquota = document.setquota.uploadquota.value;
1.57 raeburn 2654: var num_reg = $regexp;
1.101 raeburn 2655: if ((num_reg.test(newcoursequota)) && (num_reg.test(newuploadquota))) {
1.57 raeburn 2656: changePage(document.setquota,'processquota');
1.1 raeburn 2657: } else {
1.57 raeburn 2658: alert("$invalid\\n$alert");
2659: return false;
1.1 raeburn 2660: }
1.57 raeburn 2661: return true;
2662: }
1.60 raeburn 2663:
1.57 raeburn 2664: ENDSCRIPT
2665: } elsif ($phase eq 'setanon') {
2666: my $invalid = &mt('The responder threshold you entered is invalid.');
2667: my $alert = &mt('You must enter a positive integer.');
1.78 damieng 2668: &js_escape(\$invalid);
2669: &js_escape(\$alert);
1.57 raeburn 2670: my $regexp = ' /^\s*\d+\s*$/';
2671: $js .= <<"ENDSCRIPT";
1.60 raeburn 2672:
1.57 raeburn 2673: function verify_anon_threshold() {
2674: var newthreshold = document.setanon.threshold.value;
2675: var num_reg = $regexp;
2676: if (num_reg.test(newthreshold)) {
2677: if (newthreshold > 0) {
2678: changePage(document.setanon,'processthreshold');
2679: } else {
2680: alert("$invalid\\n$alert");
2681: return false;
2682: }
2683: } else {
2684: alert("$invalid\\n$alert");
2685: return false;
2686: }
2687: return true;
1.28 raeburn 2688: }
1.60 raeburn 2689:
1.28 raeburn 2690: ENDSCRIPT
1.75 raeburn 2691: } elsif ($phase eq 'setpostsubmit') {
2692: my $invalid = &mt('The choice entered for disabling the submit button is invalid.');
2693: my $invalidtimeout = &mt('The timeout you entered for disabling the submit button is invalid.');
2694: my $alert = &mt('Enter one of: a positive integer, 0 (for no timeout), or leave blank to use domain default');
1.78 damieng 2695: &js_escape(\$invalid);
2696: &js_escape(\$invalidtimeout);
2697: &js_escape(\$alert);
1.75 raeburn 2698: my $regexp = ' /^\s*\d+\s*$/';
2699:
1.103 raeburn 2700: $js .= <<"ENDSCRIPT";
1.75 raeburn 2701:
2702: function verify_postsubmit() {
2703: var optionsElement = document.setpostsubmit.postsubmit;
2704: var verified = '';
2705: if (optionsElement.length) {
2706: var currval;
2707: for (var i=0; i<optionsElement.length; i++) {
2708: if (optionsElement[i].checked) {
2709: currval = optionsElement[i].value;
2710: }
2711: }
2712: if (currval == 1) {
2713: var newtimeout = document.setpostsubmit.postsubtimeout.value;
2714: if (newtimeout == '') {
2715: verified = 'ok';
2716: } else {
2717: var num_reg = $regexp;
2718: if (num_reg.test(newtimeout)) {
2719: if (newtimeout>= 0) {
2720: verified = 'ok';
2721: } else {
2722: alert("$invalidtimeout\\n$alert");
2723: return false;
2724: }
2725: } else {
2726: alert("$invalid\\n$alert");
2727: return false;
2728: }
2729: }
2730: } else {
2731: if (currval == 0) {
1.103 raeburn 2732: verified = 'ok';
1.75 raeburn 2733: } else {
2734: alert('$invalid');
2735: return false;
2736: }
2737: }
2738: if (verified == 'ok') {
2739: changePage(document.setpostsubmit,'processpostsubmit');
2740: return true;
2741: }
2742: }
2743: return false;
2744: }
2745:
2746: function togglePostsubmit(caller) {
2747: var optionsElement = document.setpostsubmit.postsubmit;
2748: if (document.getElementById(caller)) {
2749: var divitem = document.getElementById(caller);
1.103 raeburn 2750: var optionsElement = document.setpostsubmit.postsubmit;
1.75 raeburn 2751: if (optionsElement.length) {
2752: var currval;
2753: for (var i=0; i<optionsElement.length; i++) {
2754: if (optionsElement[i].checked) {
2755: currval = optionsElement[i].value;
2756: }
2757: }
2758: if (currval == 1) {
2759: divitem.style.display = 'block';
2760: } else {
2761: divitem.style.display = 'none';
2762: }
2763: }
1.1 raeburn 2764: }
1.75 raeburn 2765: return;
2766: }
1.60 raeburn 2767:
1.75 raeburn 2768: ENDSCRIPT
2769:
1.104 ! raeburn 2770: } elsif (($phase eq 'setltiauth') || ($phase eq 'setexttool') || ($phase eq 'setcrsauthor')) {
1.97 raeburn 2771: $js .= <<"ENDJS";
1.104 ! raeburn 2772: function toggleOptions(form,phase) {
! 2773: var radioname;
! 2774: var divid;
! 2775: if (phase == 'setltiauth') {
! 2776: radioname = 'ltiauthset';
! 2777: divid = 'crsltiauth';
! 2778: } else if (phase == 'setexttool') {
! 2779: radioname = 'exttoolset';
! 2780: divid = 'crsexttool';
! 2781: } else if (phase == 'setcrsauthor') {
! 2782: radioname = 'crsauthorset';
! 2783: divid = 'crscrsauthor';
1.97 raeburn 2784: }
1.99 raeburn 2785: var num = form.elements[radioname].length;
2786: if (num) {
2787: var setvis = '';
2788: for (var i=0; i<num; i++) {
2789: if (form.elements[radioname][i].checked) {
2790: if (form.elements[radioname][i].value == 'course') {
2791: if (document.getElementById(divid)) {
2792: document.getElementById(divid).style.display = 'inline-block';
2793: }
2794: setvis = 1;
2795: }
2796: break;
2797: }
2798: }
2799: if (!setvis) {
2800: if (document.getElementById(divid)) {
2801: document.getElementById(divid).style.display = 'none';
2802: }
2803: }
2804: }
2805: return;
2806: }
2807:
2808: ENDJS
1.75 raeburn 2809: }
1.37 raeburn 2810: my $starthash;
1.86 raeburn 2811: if ($env{'form.phase'} eq 'adhocrole') {
1.37 raeburn 2812: $starthash = {
1.86 raeburn 2813: add_entries => {'onload' => "javascript:document.adhocrole.submit();"},
1.37 raeburn 2814: };
1.60 raeburn 2815: } elsif ($phase eq 'courselist') {
2816: $starthash = {
1.74 musolffc 2817: add_entries => {'onload' => "hide_searching(); courseSet(document.filterpicker.official, 'load');"},
1.60 raeburn 2818: };
1.104 ! raeburn 2819: } elsif ($env{'form.phase'} =~ /^set(ltiauth|exttool|crsauthor)$/) {
1.97 raeburn 2820: $starthash = {
1.104 ! raeburn 2821: add_entries => {'onload' => "toggleOptions(document.$env{'form.phase'},'$env{'form.phase'}');"},
1.99 raeburn 2822: };
1.37 raeburn 2823: }
1.48 raeburn 2824: $r->print(&Apache::loncommon::start_page('View/Modify Course/Community Settings',
1.60 raeburn 2825: &Apache::lonhtmlcommon::scripttag($js),
2826: $starthash));
1.48 raeburn 2827: my $bread_text = "View/Modify Courses/Communities";
2828: if ($type eq 'Community') {
2829: $bread_text = 'Community Settings';
1.81 raeburn 2830: } elsif ($type eq 'Placement') {
2831: $bread_text = 'Placement Test Settings';
1.41 raeburn 2832: } else {
1.48 raeburn 2833: $bread_text = 'Course Settings';
1.41 raeburn 2834: }
1.102 raeburn 2835: my $helpcomponent;
2836: if ($env{'form.phase'} eq 'menu') {
2837: if ($type eq 'Community') {
2838: $helpcomponent = 'Domain_Modify_Community';
2839: } else {
2840: $helpcomponent = 'Domain_Modify_Course';
2841: }
2842: }
2843: $r->print(&Apache::lonhtmlcommon::breadcrumbs($bread_text,$helpcomponent));
1.5 raeburn 2844: return;
1.1 raeburn 2845: }
2846:
2847: sub print_footer {
1.23 albertel 2848: my ($r) = @_;
2849: $r->print('<br />'.&Apache::loncommon::end_page());
1.5 raeburn 2850: return;
1.3 raeburn 2851: }
2852:
2853: sub check_course {
1.71 raeburn 2854: my ($dom,$domdesc) = @_;
2855: my ($ok_course,$description,$instcode);
2856: my %coursehash;
2857: if ($env{'form.pickedcourse'} =~ /^$match_domain\_$match_courseid$/) {
2858: my %args;
2859: unless ($env{'course.'.$env{'form.pickedcourse'}.'.description'}) {
2860: %args = (
2861: 'one_time' => 1,
2862: 'freshen_cache' => 1,
2863: );
2864: }
2865: %coursehash =
2866: &Apache::lonnet::coursedescription($env{'form.pickedcourse'},\%args);
2867: my $cnum = $coursehash{'num'};
2868: my $cdom = $coursehash{'domain'};
2869: $description = $coursehash{'description'};
2870: $instcode = $coursehash{'internal.coursecode'};
2871: if ($instcode) {
2872: $description .= " ($instcode)";
2873: }
2874: if (($cdom eq $dom) && ($cnum =~ /^$match_courseid$/)) {
2875: my %courseIDs = &Apache::lonnet::courseiddump($cdom,'.',1,'.','.',
2876: $cnum,undef,undef,'.');
2877: if ($courseIDs{$cdom.'_'.$cnum}) {
2878: $ok_course = 'ok';
1.5 raeburn 2879: }
1.3 raeburn 2880: }
2881: }
1.71 raeburn 2882: return ($ok_course,$description,\%coursehash);
1.1 raeburn 2883: }
2884:
1.28 raeburn 2885: sub course_settings_descrip {
1.48 raeburn 2886: my ($type) = @_;
2887: my %longtype;
2888: if ($type eq 'Community') {
2889: %longtype = &Apache::lonlocal::texthash(
1.72 raeburn 2890: 'courseowner' => "Username:domain of community owner",
2891: 'co-owners' => "Username:domain of each co-owner",
2892: 'selfenrollmgrdc' => "Community-specific self-enrollment configuration by Domain Coordinator",
2893: 'selfenrollmgrcc' => "Community-specific self-enrollment configuration by Community personnel",
1.85 raeburn 2894: 'mysqltables' => '"Temporary" student performance tables lifetime (seconds)',
1.48 raeburn 2895: );
2896: } else {
2897: %longtype = &Apache::lonlocal::texthash(
1.28 raeburn 2898: 'authtype' => 'Default authentication method',
2899: 'autharg' => 'Default authentication parameter',
2900: 'autoadds' => 'Automated adds',
2901: 'autodrops' => 'Automated drops',
2902: 'autostart' => 'Date of first automated enrollment',
2903: 'autoend' => 'Date of last automated enrollment',
2904: 'default_enrollment_start_date' => 'Date of first student access',
2905: 'default_enrollment_end_date' => 'Date of last student access',
2906: 'coursecode' => 'Official course code',
2907: 'courseowner' => "Username:domain of course owner",
1.50 raeburn 2908: 'co-owners' => "Username:domain of each co-owner",
1.28 raeburn 2909: 'notifylist' => 'Course Coordinators to be notified of enrollment changes',
1.48 raeburn 2910: 'sectionnums' => 'Course section number:LON-CAPA section',
2911: 'crosslistings' => 'Crosslisted class:LON-CAPA section',
1.72 raeburn 2912: 'defaultcredits' => 'Credits',
1.84 raeburn 2913: 'autodropfailsafe' => "Failsafe section enrollment count",
1.72 raeburn 2914: 'selfenrollmgrdc' => "Course-specific self-enrollment configuration by Domain Coordinator",
2915: 'selfenrollmgrcc' => "Course-specific self-enrollment configuration by Course personnel",
1.85 raeburn 2916: 'mysqltables' => '"Temporary" student performance tables lifetime (seconds)',
1.94 raeburn 2917: 'nopasswdchg' => 'Disable changing password for users with student role by course owner',
1.48 raeburn 2918: );
2919: }
1.28 raeburn 2920: return %longtype;
2921: }
2922:
2923: sub hidden_form_elements {
1.103 raeburn 2924: my $hidden_elements =
1.46 raeburn 2925: &Apache::lonhtmlcommon::echo_form_input(['gosearch','updater','coursecode',
1.37 raeburn 2926: 'prevphase','numlocalcc','courseowner','login','coursequota','intarg',
1.57 raeburn 2927: 'locarg','krbarg','krbver','counter','hidefromcat','usecategory',
1.75 raeburn 2928: 'threshold','postsubmit','postsubtimeout','defaultcredits','uploadquota',
2929: 'selfenrollmgrdc','selfenrollmgrcc','action','state','currsec_st',
1.99 raeburn 2930: 'sections','newsec','mysqltables','nopasswdchg','ltiauth','ltiauthset',
1.104 ! raeburn 2931: 'exttoolset','exttool','crsauthorset','crsauthor'],
! 2932: ['^selfenrollmgr_','^selfenroll_'])."\n".
1.37 raeburn 2933: '<input type="hidden" name="prevphase" value="'.$env{'form.phase'}.'" />';
1.28 raeburn 2934: return $hidden_elements;
2935: }
1.1 raeburn 2936:
1.60 raeburn 2937: sub showcredits {
2938: my ($dom) = @_;
2939: my %domdefaults = &Apache::lonnet::get_domain_defaults($dom);
1.79 raeburn 2940: if ($domdefaults{'officialcredits'} || $domdefaults{'unofficialcredits'} || $domdefaults{'textbookcredits'}) {
1.60 raeburn 2941: return 1;
2942: }
2943: }
2944:
1.86 raeburn 2945: sub get_permission {
2946: my ($dom) = @_;
2947: my ($allowed,%permission);
1.94 raeburn 2948: my %passwdconf = &Apache::lonnet::get_passwdconf($dom);
1.86 raeburn 2949: if (&Apache::lonnet::allowed('ccc',$dom)) {
2950: $allowed = 1;
2951: %permission = (
1.88 raeburn 2952: setquota => 'edit',
2953: processquota => 'edit',
2954: setanon => 'edit',
2955: processthreshold => 'edit',
2956: setpostsubmit => 'edit',
2957: processpostsubmit => 'edit',
2958: viewparms => 'view',
2959: setparms => 'edit',
2960: processparms => 'edit',
2961: catsettings => 'edit',
2962: processcat => 'edit',
2963: selfenroll => 'edit',
1.90 raeburn 2964: adhocrole => 'coord',
1.97 raeburn 2965: setltiauth => 'edit',
2966: processltiauth => 'edit',
1.99 raeburn 2967: setexttool => 'edit',
2968: processexttool => 'edit',
1.104 ! raeburn 2969: setcrsauthor => 'edit',
! 2970: processcrsauthor => 'edit',
1.86 raeburn 2971: );
1.94 raeburn 2972: if ($passwdconf{'crsownerchg'}) {
2973: $permission{passwdchg} = 'edit';
2974: }
1.86 raeburn 2975: } elsif (&Apache::lonnet::allowed('rar',$dom)) {
2976: $allowed = 1;
2977: %permission = (
1.88 raeburn 2978: setquota => 'view',
2979: viewparms => 'view',
2980: setanon => 'view',
2981: setpostsubmit => 'view',
2982: setparms => 'view',
2983: catsettings => 'view',
2984: selfenroll => 'view',
1.90 raeburn 2985: adhocrole => 'custom',
1.97 raeburn 2986: setltiauth => 'view',
1.99 raeburn 2987: setexttool => 'view',
1.104 ! raeburn 2988: setcrsauthor => 'view',
1.86 raeburn 2989: );
1.94 raeburn 2990: if ($passwdconf{'crsownerchg'}) {
2991: $permission{passwdchg} = 'view';
2992: }
1.86 raeburn 2993: }
2994: return ($allowed,\%permission);
2995: }
2996:
1.95 raeburn 2997: sub devalidate_remote_instcats {
2998: if ($modified_dom ne '') {
2999: my %servers = &Apache::lonnet::internet_dom_servers($modified_dom);
3000: my %thismachine;
3001: map { $thismachine{$_} = 1; } &Apache::lonnet::current_machine_ids();
3002: if (keys(%servers)) {
3003: foreach my $server (keys(%servers)) {
3004: next if ($thismachine{$server});
3005: &Apache::lonnet::remote_devalidate_cache($server,['instcats:'.$modified_dom]);
3006: }
3007: }
3008: $modified_dom = '';
3009: }
3010: return;
3011: }
3012:
1.1 raeburn 3013: sub handler {
3014: my $r = shift;
3015: if ($r->header_only) {
3016: &Apache::loncommon::content_type($r,'text/html');
3017: $r->send_http_header;
3018: return OK;
3019: }
1.72 raeburn 3020:
1.95 raeburn 3021: $registered_cleanup=0;
3022: $modified_dom = '';
3023:
1.28 raeburn 3024: my $dom = $env{'request.role.domain'};
1.31 albertel 3025: my $domdesc = &Apache::lonnet::domain($dom,'description');
1.86 raeburn 3026: my ($allowed,$permission) = &get_permission($dom);
3027: if ($allowed) {
1.1 raeburn 3028: &Apache::loncommon::content_type($r,'text/html');
3029: $r->send_http_header;
3030:
1.28 raeburn 3031: &Apache::lonhtmlcommon::clear_breadcrumbs();
3032:
3033: my $phase = $env{'form.phase'};
1.46 raeburn 3034: if ($env{'form.updater'}) {
3035: $phase = '';
3036: }
1.37 raeburn 3037: if ($phase eq '') {
3038: &Apache::lonhtmlcommon::add_breadcrumb
1.28 raeburn 3039: ({href=>"/adm/modifycourse",
1.48 raeburn 3040: text=>"Course/Community search"});
1.28 raeburn 3041: &print_course_search_page($r,$dom,$domdesc);
1.1 raeburn 3042: } else {
1.37 raeburn 3043: my $firstform = $phase;
3044: if ($phase eq 'courselist') {
3045: $firstform = 'filterpicker';
1.48 raeburn 3046: }
3047: my $choose_text;
3048: my $type = $env{'form.type'};
3049: if ($type eq '') {
3050: $type = 'Course';
3051: }
3052: if ($type eq 'Community') {
3053: $choose_text = "Choose a community";
1.81 raeburn 3054: } elsif ($type eq 'Placement') {
3055: $choose_text = "Choose a placement test";
1.48 raeburn 3056: } else {
3057: $choose_text = "Choose a course";
1.103 raeburn 3058: }
1.28 raeburn 3059: &Apache::lonhtmlcommon::add_breadcrumb
1.37 raeburn 3060: ({href=>"javascript:changePage(document.$firstform,'')",
1.48 raeburn 3061: text=>"Course/Community search"},
1.37 raeburn 3062: {href=>"javascript:changePage(document.$phase,'courselist')",
1.48 raeburn 3063: text=>$choose_text});
1.28 raeburn 3064: if ($phase eq 'courselist') {
1.90 raeburn 3065: &print_course_selection_page($r,$dom,$domdesc,$permission);
1.28 raeburn 3066: } else {
1.71 raeburn 3067: my ($checked,$cdesc,$coursehash) = &check_course($dom,$domdesc);
1.28 raeburn 3068: if ($checked eq 'ok') {
1.48 raeburn 3069: my $enter_text;
3070: if ($type eq 'Community') {
3071: $enter_text = 'Enter community';
1.81 raeburn 3072: } elsif ($type eq 'Placement') {
1.103 raeburn 3073: $enter_text = 'Enter placement test';
1.48 raeburn 3074: } else {
3075: $enter_text = 'Enter course';
3076: }
1.28 raeburn 3077: if ($phase eq 'menu') {
1.37 raeburn 3078: &Apache::lonhtmlcommon::add_breadcrumb
3079: ({href=>"javascript:changePage(document.$phase,'menu')",
3080: text=>"Pick action"});
1.71 raeburn 3081: &print_modification_menu($r,$cdesc,$domdesc,$dom,$type,
1.86 raeburn 3082: $env{'form.pickedcourse'},$coursehash,
3083: $permission);
3084: } elsif ($phase eq 'adhocrole') {
1.37 raeburn 3085: &Apache::lonhtmlcommon::add_breadcrumb
1.86 raeburn 3086: ({href=>"javascript:changePage(document.$phase,'adhocrole')",
1.48 raeburn 3087: text=>$enter_text});
1.90 raeburn 3088: &print_adhocrole_selected($r,$type,$permission);
1.28 raeburn 3089: } else {
1.37 raeburn 3090: &Apache::lonhtmlcommon::add_breadcrumb
3091: ({href=>"javascript:changePage(document.$phase,'menu')",
3092: text=>"Pick action"});
1.28 raeburn 3093: my ($cdom,$cnum) = split(/_/,$env{'form.pickedcourse'});
1.88 raeburn 3094: my ($readonly,$linktext);
3095: if ($permission->{$phase} eq 'view') {
1.103 raeburn 3096: $readonly = 1;
1.88 raeburn 3097: }
1.86 raeburn 3098: if (($phase eq 'setquota') && ($permission->{'setquota'})) {
1.88 raeburn 3099: if ($permission->{'setquota'} eq 'view') {
1.103 raeburn 3100: $linktext = 'Set quota';
1.88 raeburn 3101: } else {
3102: $linktext = 'Display quota';
3103: }
1.28 raeburn 3104: &Apache::lonhtmlcommon::add_breadcrumb
3105: ({href=>"javascript:changePage(document.$phase,'$phase')",
1.89 raeburn 3106: text=>$linktext});
1.88 raeburn 3107: &print_setquota($r,$cdom,$cnum,$cdesc,$type,$readonly);
1.103 raeburn 3108: } elsif (($phase eq 'processquota') && ($permission->{'processquota'})) {
1.28 raeburn 3109: &Apache::lonhtmlcommon::add_breadcrumb
3110: ({href=>"javascript:changePage(document.$phase,'setquota')",
3111: text=>"Set quota"});
3112: &Apache::lonhtmlcommon::add_breadcrumb
3113: ({href=>"javascript:changePage(document.$phase,'$phase')",
3114: text=>"Result"});
1.48 raeburn 3115: &modify_quota($r,$cdom,$cnum,$cdesc,$domdesc,$type);
1.86 raeburn 3116: } elsif (($phase eq 'setanon') && ($permission->{'setanon'})) {
1.57 raeburn 3117: &Apache::lonhtmlcommon::add_breadcrumb
3118: ({href=>"javascript:changePage(document.$phase,'$phase')",
3119: text=>"Threshold for anonymous submissions display"});
1.88 raeburn 3120: &print_set_anonsurvey_threshold($r,$cdom,$cnum,$cdesc,$type,$readonly);
1.86 raeburn 3121: } elsif (($phase eq 'processthreshold') && ($permission->{'processthreshold'})) {
1.57 raeburn 3122: &Apache::lonhtmlcommon::add_breadcrumb
3123: ({href=>"javascript:changePage(document.$phase,'setanon')",
3124: text=>"Threshold for anonymous submissions display"});
3125: &Apache::lonhtmlcommon::add_breadcrumb
3126: ({href=>"javascript:changePage(document.$phase,'$phase')",
3127: text=>"Result"});
3128: &modify_anonsurvey_threshold($r,$cdom,$cnum,$cdesc,$domdesc,$type);
1.86 raeburn 3129: } elsif (($phase eq 'setpostsubmit') && ($permission->{'setpostsubmit'})) {
1.88 raeburn 3130: if ($permission->{'setpostsubmit'} eq 'view') {
3131: $linktext = 'Submit button behavior post-submission';
3132: } else {
3133: $linktext = 'Configure submit button behavior post-submission';
3134: }
1.75 raeburn 3135: &Apache::lonhtmlcommon::add_breadcrumb
3136: ({href=>"javascript:changePage(document.$phase,'$phase')",
1.89 raeburn 3137: text=>$linktext});
1.88 raeburn 3138: &print_postsubmit_config($r,$cdom,$cnum,$cdesc,$type,$readonly);
1.86 raeburn 3139: } elsif (($phase eq 'processpostsubmit') && ($permission->{'processpostsubmit'})) {
1.75 raeburn 3140: &Apache::lonhtmlcommon::add_breadcrumb
3141: ({href=>"javascript:changePage(document.$phase,'$phase')",
3142: text=>"Result"});
3143: &modify_postsubmit_config($r,$cdom,$cnum,$cdesc,$domdesc,$type);
1.86 raeburn 3144: } elsif (($phase eq 'viewparms') && ($permission->{'viewparms'})) {
1.28 raeburn 3145: &Apache::lonhtmlcommon::add_breadcrumb
3146: ({href=>"javascript:changePage(document.$phase,'viewparms')",
3147: text=>"Display settings"});
1.86 raeburn 3148: &print_settings_display($r,$cdom,$cnum,$cdesc,$type,$permission);
3149: } elsif (($phase eq 'setparms') && ($permission->{'setparms'})) {
1.88 raeburn 3150: if ($permission->{'setparms'} eq 'view') {
3151: $linktext = 'Display settings';
3152: } else {
3153: $linktext = 'Change settings';
3154: }
1.28 raeburn 3155: &Apache::lonhtmlcommon::add_breadcrumb
3156: ({href=>"javascript:changePage(document.$phase,'$phase')",
1.89 raeburn 3157: text=>$linktext});
1.88 raeburn 3158: &print_course_modification_page($r,$cdom,$cnum,$cdesc,$type,$readonly);
1.86 raeburn 3159: } elsif (($phase eq 'processparms') && ($permission->{'processparms'})) {
1.28 raeburn 3160: &Apache::lonhtmlcommon::add_breadcrumb
3161: ({href=>"javascript:changePage(document.$phase,'setparms')",
3162: text=>"Change settings"});
3163: &Apache::lonhtmlcommon::add_breadcrumb
3164: ({href=>"javascript:changePage(document.$phase,'$phase')",
3165: text=>"Result"});
1.30 raeburn 3166: &modify_course($r,$cdom,$cnum,$cdesc,$domdesc,$type);
1.86 raeburn 3167: } elsif (($phase eq 'catsettings') && ($permission->{'catsettings'})) {
1.38 raeburn 3168: &Apache::lonhtmlcommon::add_breadcrumb
3169: ({href=>"javascript:changePage(document.$phase,'$phase')",
3170: text=>"Catalog settings"});
1.88 raeburn 3171: &print_catsettings($r,$cdom,$cnum,$cdesc,$type,$readonly);
1.86 raeburn 3172: } elsif (($phase eq 'processcat') && ($permission->{'processcat'})) {
1.38 raeburn 3173: &Apache::lonhtmlcommon::add_breadcrumb
3174: ({href=>"javascript:changePage(document.$phase,'catsettings')",
3175: text=>"Catalog settings"});
3176: &Apache::lonhtmlcommon::add_breadcrumb
3177: ({href=>"javascript:changePage(document.$phase,'$phase')",
3178: text=>"Result"});
1.48 raeburn 3179: &modify_catsettings($r,$cdom,$cnum,$cdesc,$domdesc,$type);
1.86 raeburn 3180: } elsif (($phase eq 'selfenroll') && ($permission->{'selfenroll'})) {
1.72 raeburn 3181: &Apache::lonhtmlcommon::add_breadcrumb
3182: ({href => "javascript:changePage(document.$phase,'$phase')",
3183: text => "Self-enrollment settings"});
3184: if (!exists($env{'form.state'})) {
1.88 raeburn 3185: &print_selfenrollconfig($r,$type,$cdesc,$coursehash,$readonly);
1.72 raeburn 3186: } elsif ($env{'form.state'} eq 'done') {
1.103 raeburn 3187: &Apache::lonhtmlcommon::add_breadcrumb
1.72 raeburn 3188: ({href=>"javascript:changePage(document.$phase,'$phase')",
3189: text=>"Result"});
3190: &modify_selfenrollconfig($r,$type,$cdesc,$coursehash);
3191: }
1.97 raeburn 3192: } elsif (($phase eq 'setltiauth') && ($permission->{'setltiauth'})) {
3193: &Apache::lonhtmlcommon::add_breadcrumb
3194: ({href=>"javascript:changePage(document.$phase,'$phase')",
1.104 ! raeburn 3195: text=>"Authentication post-LTI launch"});
! 3196: &print_default_overrides($r,$cdom,$cnum,$cdesc,$type,$readonly,'ltiauth');
1.97 raeburn 3197: } elsif (($phase eq 'processltiauth') && ($permission->{'processltiauth'})) {
3198: &Apache::lonhtmlcommon::add_breadcrumb
3199: ({href=>"javascript:changePage(document.$phase,'setltiauth')",
1.104 ! raeburn 3200: text=>"Authentication post-LTI launch"},
1.99 raeburn 3201: {href=>"javascript:changePage(document.$phase,'$phase')",
3202: text=>"Result"});
1.104 ! raeburn 3203: &modify_default_overrides($r,$cdom,$cnum,$cdesc,$domdesc,$type,'ltiauth');
1.99 raeburn 3204: } elsif (($phase eq 'setexttool') && ($permission->{'setexttool'})) {
1.97 raeburn 3205: &Apache::lonhtmlcommon::add_breadcrumb
3206: ({href=>"javascript:changePage(document.$phase,'$phase')",
1.99 raeburn 3207: text=>"External Tool permission"});
1.104 ! raeburn 3208: &print_default_overrides($r,$cdom,$cnum,$cdesc,$type,$readonly,'exttool');
1.99 raeburn 3209: } elsif (($phase eq 'processexttool') && ($permission->{'processexttool'})) {
3210: &Apache::lonhtmlcommon::add_breadcrumb
3211: ({href=>"javascript:changePage(document.$phase,'setexttool')",
3212: text=>"External Tool permission"},
3213: {href=>"javascript:changePage(document.$phase,'$phase')",
1.97 raeburn 3214: text=>"Result"});
1.104 ! raeburn 3215: &modify_default_overrides($r,$cdom,$cnum,$cdesc,$domdesc,$type,'exttool');
! 3216: } elsif (($phase eq 'setcrsauthor') && ($permission->{'setcrsauthor'})) {
! 3217: &Apache::lonhtmlcommon::add_breadcrumb
! 3218: ({href=>"javascript:changePage(document.$phase,'$phase')",
! 3219: text=>"In-course authoring permission"});
! 3220: &print_default_overrides($r,$cdom,$cnum,$cdesc,$type,$readonly,'crsauthor');
! 3221: } elsif (($phase eq 'processcrsauthor') && ($permission->{'processcrsauthor'})) {
! 3222: &Apache::lonhtmlcommon::add_breadcrumb
! 3223: ({href=>"javascript:changePage(document.$phase,'setcrsauthor')",
! 3224: text=>"In-course authoring permission"},
! 3225: {href=>"javascript:changePage(document.$phase,'$phase')",
! 3226: text=>"Result"});
! 3227: &modify_default_overrides($r,$cdom,$cnum,$cdesc,$domdesc,$type,'crsauthor');
1.28 raeburn 3228: }
3229: }
3230: } else {
1.48 raeburn 3231: $r->print('<span class="LC_error">');
3232: if ($type eq 'Community') {
1.72 raeburn 3233: $r->print(&mt('The community you selected is not a valid community in this domain'));
1.81 raeburn 3234: } elsif ($type eq 'Placement') {
3235: $r->print(&mt('The course you selected is not a valid placement test in this domain'));
1.72 raeburn 3236: } else {
1.48 raeburn 3237: $r->print(&mt('The course you selected is not a valid course in this domain'));
3238: }
3239: $r->print(" ($domdesc)</span>");
1.28 raeburn 3240: }
3241: }
1.1 raeburn 3242: }
1.28 raeburn 3243: &print_footer($r);
1.1 raeburn 3244: } else {
1.16 albertel 3245: $env{'user.error.msg'}=
1.48 raeburn 3246: "/adm/modifycourse:ccc:0:0:Cannot modify course/community settings";
1.1 raeburn 3247: return HTTP_NOT_ACCEPTABLE;
3248: }
3249: return OK;
3250: }
3251:
3252: 1;
3253: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>