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