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