Annotation of loncom/interface/lonmodifycourse.pm, revision 1.103
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.103 ! raeburn 4: # $Id: lonmodifycourse.pm,v 1.102 2023/08/03 15:57:23 raeburn Exp $
1.20 albertel 5: #
1.3 raeburn 6: # Copyright Michigan State University Board of Trustees
7: #
8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
9: #
10: # LON-CAPA is free software; you can redistribute it and/or modify
11: # it under the terms of the GNU General Public License as published by
12: # the Free Software Foundation; either version 2 of the License, or
13: # (at your option) any later version.
14: #
15: # LON-CAPA is distributed in the hope that it will be useful,
16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18: # GNU General Public License for more details.
19: #
20: # You should have received a copy of the GNU General Public License
21: # along with LON-CAPA; if not, write to the Free Software
22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23: #
24: # /home/httpd/html/adm/gpl.txt
25: #
26: # http://www.lon-capa.org/
27: #
1.1 raeburn 28: package Apache::lonmodifycourse;
29:
30: use strict;
31: use Apache::Constants qw(:common :http);
32: use Apache::lonnet;
33: use Apache::loncommon;
1.28 raeburn 34: use Apache::lonhtmlcommon;
1.1 raeburn 35: use Apache::lonlocal;
1.36 raeburn 36: use Apache::lonuserutils;
1.72 raeburn 37: use Apache::loncreateuser;
1.28 raeburn 38: use Apache::lonpickcourse;
1.1 raeburn 39: use lib '/home/httpd/lib/perl';
1.72 raeburn 40: use LONCAPA qw(:DEFAULT :match);
1.1 raeburn 41:
1.95 raeburn 42: my $registered_cleanup;
43: my $modified_dom;
44:
1.28 raeburn 45: sub get_dc_settable {
1.60 raeburn 46: my ($type,$cdom) = @_;
1.83 raeburn 47: if ($type eq 'Community') {
1.72 raeburn 48: return ('courseowner','selfenrollmgrdc','selfenrollmgrcc');
1.48 raeburn 49: } else {
1.85 raeburn 50: my @items = ('courseowner','coursecode','authtype','autharg','selfenrollmgrdc',
51: 'selfenrollmgrcc','mysqltables');
1.60 raeburn 52: if (&showcredits($cdom)) {
53: push(@items,'defaultcredits');
54: }
1.94 raeburn 55: my %passwdconf = &Apache::lonnet::get_passwdconf($cdom);
56: if (($passwdconf{'crsownerchg'}) && ($type ne 'Placement')) {
57: push(@items,'nopasswdchg');
58: }
1.60 raeburn 59: return @items;
1.48 raeburn 60: }
61: }
62:
63: sub autoenroll_keys {
1.60 raeburn 64: my $internals = ['coursecode','courseowner','authtype','autharg','defaultcredits',
65: 'autoadds','autodrops','autostart','autoend','sectionnums',
1.84 raeburn 66: 'crosslistings','co-owners','autodropfailsafe'];
1.48 raeburn 67: my $accessdates = ['default_enrollment_start_date','default_enrollment_end_date'];
68: return ($internals,$accessdates);
1.28 raeburn 69: }
70:
1.38 raeburn 71: sub catalog_settable {
1.49 raeburn 72: my ($confhash,$type) = @_;
1.38 raeburn 73: my @settable;
74: if (ref($confhash) eq 'HASH') {
1.49 raeburn 75: if ($type eq 'Community') {
76: if ($confhash->{'togglecatscomm'} ne 'comm') {
77: push(@settable,'togglecats');
78: }
79: if ($confhash->{'categorizecomm'} ne 'comm') {
80: push(@settable,'categorize');
81: }
1.81 raeburn 82: } elsif ($type eq 'Placement') {
83: if ($confhash->{'togglecatsplace'} ne 'place') {
84: push(@settable,'togglecats');
85: }
86: if ($confhash->{'categorizeplace'} ne 'place') {
87: push(@settable,'categorize');
88: }
1.49 raeburn 89: } else {
90: if ($confhash->{'togglecats'} ne 'crs') {
91: push(@settable,'togglecats');
92: }
93: if ($confhash->{'categorize'} ne 'crs') {
94: push(@settable,'categorize');
95: }
1.38 raeburn 96: }
97: } else {
98: push(@settable,('togglecats','categorize'));
99: }
100: return @settable;
101: }
102:
1.28 raeburn 103: sub get_enrollment_settings {
104: my ($cdom,$cnum) = @_;
1.48 raeburn 105: my ($internals,$accessdates) = &autoenroll_keys();
106: my @items;
1.103 ! raeburn 107: if ((ref($internals) eq 'ARRAY') && (ref($accessdates) eq 'ARRAY')) {
1.48 raeburn 108: @items = map { 'internal.'.$_; } (@{$internals});
109: push(@items,@{$accessdates});
110: }
1.94 raeburn 111: push(@items,'internal.nopasswdchg');
1.48 raeburn 112: my %settings = &Apache::lonnet::get('environment',\@items,$cdom,$cnum);
1.28 raeburn 113: my %enrollvar;
114: $enrollvar{'autharg'} = '';
115: $enrollvar{'authtype'} = '';
1.48 raeburn 116: foreach my $item (keys(%settings)) {
1.28 raeburn 117: if ($item =~ m/^internal\.(.+)$/) {
118: my $type = $1;
119: if ( ($type eq "autoadds") || ($type eq "autodrops") ) {
120: if ($settings{$item} == 1) {
121: $enrollvar{$type} = "ON";
122: } else {
123: $enrollvar{$type} = "OFF";
1.10 raeburn 124: }
1.28 raeburn 125: } elsif ( ($type eq "autostart") || ($type eq "autoend") ) {
126: if ( ($type eq "autoend") && ($settings{$item} == 0) ) {
1.48 raeburn 127: $enrollvar{$type} = &mt('No end date');
1.28 raeburn 128: } else {
1.48 raeburn 129: $enrollvar{$type} = &Apache::lonlocal::locallocaltime($settings{$item});
1.14 raeburn 130: }
1.50 raeburn 131: } elsif (($type eq 'sectionnums') || ($type eq 'co-owners')) {
1.28 raeburn 132: $enrollvar{$type} = $settings{$item};
133: $enrollvar{$type} =~ s/,/, /g;
134: } elsif ($type eq "authtype"
135: || $type eq "autharg" || $type eq "coursecode"
1.84 raeburn 136: || $type eq "crosslistings" || $type eq "selfenrollmgr"
1.94 raeburn 137: || $type eq "autodropfailsafe" || $type eq 'nopasswdchg') {
1.28 raeburn 138: $enrollvar{$type} = $settings{$item};
1.60 raeburn 139: } elsif ($type eq 'defaultcredits') {
140: if (&showcredits($cdom)) {
141: $enrollvar{$type} = $settings{$item};
142: }
1.28 raeburn 143: } elsif ($type eq 'courseowner') {
144: if ($settings{$item} =~ /^[^:]+:[^:]+$/) {
145: $enrollvar{$type} = $settings{$item};
146: } else {
147: if ($settings{$item} ne '') {
148: $enrollvar{$type} = $settings{$item}.':'.$cdom;
1.26 raeburn 149: }
1.1 raeburn 150: }
1.28 raeburn 151: }
152: } elsif ($item =~ m/^default_enrollment_(start|end)_date$/) {
153: my $type = $1;
154: if ( ($type eq 'end') && ($settings{$item} == 0) ) {
1.48 raeburn 155: $enrollvar{$item} = &mt('No end date');
1.28 raeburn 156: } elsif ( ($type eq 'start') && ($settings{$item} eq '') ) {
157: $enrollvar{$item} = 'When enrolled';
158: } else {
1.48 raeburn 159: $enrollvar{$item} = &Apache::lonlocal::locallocaltime($settings{$item});
1.1 raeburn 160: }
161: }
162: }
1.28 raeburn 163: return %enrollvar;
164: }
165:
166: sub print_course_search_page {
167: my ($r,$dom,$domdesc) = @_;
1.48 raeburn 168: my $action = '/adm/modifycourse';
169: my $type = $env{'form.type'};
170: if (!defined($env{'form.type'})) {
171: $type = 'Course';
172: }
173: &print_header($r,$type);
1.70 raeburn 174: my ($filterlist,$filter) = &get_filters($dom);
1.56 raeburn 175: my ($numtitles,$cctitle,$dctitle,@codetitles);
1.48 raeburn 176: my $ccrole = 'cc';
177: if ($type eq 'Community') {
178: $ccrole = 'co';
1.46 raeburn 179: }
1.48 raeburn 180: $cctitle = &Apache::lonnet::plaintext($ccrole,$type);
1.46 raeburn 181: $dctitle = &Apache::lonnet::plaintext('dc');
1.70 raeburn 182: $r->print(&Apache::loncommon::js_changer());
1.48 raeburn 183: if ($type eq 'Community') {
184: $r->print('<h3>'.&mt('Search for a community in the [_1] domain',$domdesc).'</h3>');
1.81 raeburn 185: } elsif ($type eq 'Placement') {
186: $r->print('<h3>'.&mt('Search for a placement test in the [_1] domain',$domdesc).'</h3>');
1.48 raeburn 187: } else {
188: $r->print('<h3>'.&mt('Search for a course in the [_1] domain',$domdesc).'</h3>');
1.69 raeburn 189: }
190: $r->print(&Apache::loncommon::build_filters($filterlist,$type,undef,undef,$filter,$action,
191: \$numtitles,'modifycourse',undef,undef,undef,
1.70 raeburn 192: \@codetitles,$dom));
1.87 raeburn 193:
1.86 raeburn 194: my ($actiontext,$roleoption,$settingsoption);
1.48 raeburn 195: if ($type eq 'Community') {
1.86 raeburn 196: $actiontext = &mt('Actions available after searching for a community:');
1.81 raeburn 197: } elsif ($type eq 'Placement') {
1.86 raeburn 198: $actiontext = &mt('Actions available after searching for a placement test:')
199: } else {
200: $actiontext = &mt('Actions available after searching for a course:');
1.48 raeburn 201: }
1.86 raeburn 202: if (&Apache::lonnet::allowed('ccc',$dom)) {
203: if ($type eq 'Community') {
204: $roleoption = &mt('Enter the community with the role of [_1]',$cctitle);
205: $settingsoption = &mt('View or modify community settings which only a [_1] may modify.',$dctitle);
206: } elsif ($type eq 'Placement') {
207: $roleoption = &mt('Enter the placement test with the role of [_1]',$cctitle);
208: $settingsoption = &mt('View or modify placement test settings which only a [_1] may modify.',$dctitle);
209: } else {
210: $roleoption = &mt('Enter the course with the role of [_1]',$cctitle);
211: $settingsoption = &mt('View or modify course settings which only a [_1] may modify.',$dctitle);
212: }
213: } elsif (&Apache::lonnet::allowed('rar',$dom)) {
1.90 raeburn 214: my ($roles_by_num,$description,$accessref,$accessinfo) = &Apache::lonnet::get_all_adhocroles($dom);
215: if ((ref($roles_by_num) eq 'ARRAY') && (ref($description) eq 'HASH')) {
216: if (@{$roles_by_num} > 1) {
1.86 raeburn 217: if ($type eq 'Community') {
1.90 raeburn 218: $roleoption = &mt('Enter the community with one of the available ad hoc roles');
1.86 raeburn 219: } elsif ($type eq 'Placement') {
1.90 raeburn 220: $roleoption = &mt('Enter the placement test with one of the available ad hoc roles.');
1.86 raeburn 221: } else {
1.90 raeburn 222: $roleoption = &mt('Enter the course with one of the available ad hoc roles.');
1.86 raeburn 223: }
224: } else {
1.90 raeburn 225: my $rolename = $description->{$roles_by_num->[0]};
1.86 raeburn 226: if ($type eq 'Community') {
1.90 raeburn 227: $roleoption = &mt('Enter the community with the ad hoc role of: [_1]',$rolename);
1.86 raeburn 228: } elsif ($type eq 'Placement') {
1.90 raeburn 229: $roleoption = &mt('Enter the placement test with the ad hoc role of: [_1]',$rolename);
1.86 raeburn 230: } else {
1.90 raeburn 231: $roleoption = &mt('Enter the course with the ad hoc role of: [_1]',$rolename);
1.86 raeburn 232: }
233: }
234: }
235: if ($type eq 'Community') {
236: $settingsoption = &mt('View community settings which only a [_1] may modify.',$dctitle);
237: } elsif ($type eq 'Placement') {
238: $settingsoption = &mt('View placement test settings which only a [_1] may modify.',$dctitle);
239: } else {
240: $settingsoption = &mt('View course settings which only a [_1] may modify.',$dctitle);
241: }
242: }
243: $r->print($actiontext.'<ul>');
244: if ($roleoption) {
245: $r->print('<li>'.$roleoption.'</li>'."\n");
246: }
247: $r->print('<li>'.$settingsoption.'</li>'."\n".'</ul>');
1.69 raeburn 248: return;
1.28 raeburn 249: }
250:
251: sub print_course_selection_page {
1.90 raeburn 252: my ($r,$dom,$domdesc,$permission) = @_;
1.48 raeburn 253: my $type = $env{'form.type'};
254: if (!defined($type)) {
255: $type = 'Course';
256: }
257: &print_header($r,$type);
1.28 raeburn 258:
1.90 raeburn 259: if ($permission->{'adhocrole'} eq 'custom') {
260: my %lt = &Apache::lonlocal::texthash(
261: title => 'Ad hoc role selection',
262: preamble => 'Please choose an ad hoc role in the course.',
263: cancel => 'Click "OK" to enter the course, or "Cancel" to choose a different course.',
264: );
265: my %jslt = &Apache::lonlocal::texthash (
266: none => 'You are not eligible to use an ad hoc role for the selected course',
267: ok => 'OK',
268: exit => 'Cancel',
269: );
270: &js_escape(\%jslt);
271: $r->print(<<"END");
272: <script type="text/javascript">
273: // <![CDATA[
274: \$(document).ready(function(){
275: \$( "#LC_adhocrole_chooser" ).dialog({ autoOpen: false });
276: });
277:
278: function gochoose(cname,cdom,cdesc) {
279: document.courselist.pickedcourse.value = cdom+'_'+cname;
280: \$("#LC_choose_adhoc").empty();
281: var pickedaction = \$('input[name=phase]:checked', '#LCcoursepicker').val();
282: if (pickedaction == 'adhocrole') {
283: var http = new XMLHttpRequest();
284: var url = "/adm/pickcourse";
285: var params = "cid="+cdom+"_"+cname+"&context=adhoc";
286: http.open("POST", url, true);
287: http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
288: http.onreadystatechange = function() {
289: if (http.readyState == 4 && http.status == 200) {
290: var data = \$.parseJSON(http.responseText);
291: var len = data.roles.length;
292: if (len == '' || len == null || len == 0) {
293: alert('$jslt{none}');
294: } else {
295: if (len == 1) {
296: \$( '[name="adhocrole"]' )[0].value = data.roles[0].name;
297: document.courselist.submit();
298: } else {
299: var str = '';
1.92 raeburn 300: \$("#LC_choose_adhoc").empty();
1.90 raeburn 301: for (var i=0; i<data.roles.length; i++) {
302: \$("<label><input type='radio' value='"+data.roles[i].name+"' name='LC_get_role' id='LC_get_role_"+i+"' />"+data.roles[i].desc+"</label><span> </span>")
303: .appendTo("#LC_choose_adhoc");
304: }
1.92 raeburn 305: \$( "#LC_adhocrole_chooser" ).toggle( true );
1.90 raeburn 306: \$( "#LC_get_role_0").prop("checked", true);
307: \$( "#LC_adhocrole_chooser" ).dialog({ autoOpen: false });
308: \$( "#LC_adhocrole_chooser" ).dialog("open");
309: \$( "#LC_adhocrole_chooser" ).dialog({
310: height: 400,
311: width: 500,
312: modal: true,
313: resizable: false,
314: buttons: [
315: {
316: text: "$jslt{'ok'}",
317: click: function() {
318: var rolename = \$('input[name=LC_get_role]:checked', '#LChelpdeskpicker').val();
319: \$( '[name="adhocrole"]' )[0].value = rolename;
320: document.courselist.submit();
321: }
322: },
323: {
324: text: "$jslt{'exit'}",
325: click: function() {
326: \$("#LC_adhocrole_chooser").dialog( "close" );
327: }
328: }
329: ],
330: });
331: \$( "#LC_adhocrole_chooser" ).find( "form" ).on( "submit", function( event ) {
332: event.preventDefault();
333: var rolename = \$('input[name=LC_get_role]:checked', '#LChelpdeskpicker').val()
334: \$( '[name="adhocrole"]' )[0].value = rolename;
335: document.courselist.submit();
336: \$("#LC_adhocrole_chooser").dialog( "close" );
337: });
338: }
339: }
340: }
341: }
342: http.send(params);
343: } else {
344: document.courselist.submit();
345: }
346: return;
347: }
348: // ]]>
349: </script>
350:
1.92 raeburn 351: <div id="LC_adhocrole_chooser" title="$lt{'title'}" style="display:none">
1.90 raeburn 352: <p>$lt{'preamble'}</p>
353: <form name="LChelpdeskadhoc" id="LChelpdeskpicker" action="">
354: <div id="LC_choose_adhoc">
355: </div>
356: <input type="hidden" name="adhocrole" id="LCadhocrole" value="" />
357: <input type="submit" tabindex="-1" style="position:absolute; top:-1000px" />
358: </form>
359: <p>$lt{'cancel'}</p>
360: </div>
361: END
362: } elsif ($permission->{'adhocrole'} eq 'coord') {
363: $r->print(<<"END");
364: <script type="text/javascript">
365: // <![CDATA[
366:
367: function gochoose(cname,cdom,cdesc) {
368: document.courselist.pickedcourse.value = cdom+'_'+cname;
369: document.courselist.submit();
370: return;
371: }
372:
373: // ]]>
374: </script>
375: END
376: }
377:
378: # Criteria for course search
1.69 raeburn 379: my ($filterlist,$filter) = &get_filters();
1.28 raeburn 380: my $action = '/adm/modifycourse';
381: my $dctitle = &Apache::lonnet::plaintext('dc');
1.56 raeburn 382: my ($numtitles,@codetitles);
1.70 raeburn 383: $r->print(&Apache::loncommon::js_changer());
1.48 raeburn 384: $r->print(&mt('Revise your search criteria for this domain').' ('.$domdesc.').<br />');
1.69 raeburn 385: $r->print(&Apache::loncommon::build_filters($filterlist,$type,undef,undef,$filter,$action,
386: \$numtitles,'modifycourse',undef,undef,undef,
1.70 raeburn 387: \@codetitles,$dom,$env{'form.form'}));
388: my %courses = &Apache::loncommon::search_courses($dom,$type,$filter,$numtitles,
389: undef,undef,undef,\@codetitles);
1.46 raeburn 390: &Apache::lonpickcourse::display_matched_courses($r,$type,0,$action,undef,undef,undef,
1.86 raeburn 391: $dom,undef,%courses);
1.1 raeburn 392: return;
393: }
394:
1.69 raeburn 395: sub get_filters {
1.70 raeburn 396: my ($dom) = @_;
1.69 raeburn 397: my @filterlist = ('descriptfilter','instcodefilter','ownerfilter',
398: 'ownerdomfilter','coursefilter','sincefilter');
399: # created filter
1.70 raeburn 400: my $loncaparev = &Apache::lonnet::get_server_loncaparev($dom);
1.69 raeburn 401: if ($loncaparev ne 'unknown_cmd') {
402: push(@filterlist,'createdfilter');
403: }
404: my %filter;
405: foreach my $item (@filterlist) {
406: $filter{$item} = $env{'form.'.$item};
407: }
408: return (\@filterlist,\%filter);
409: }
410:
1.28 raeburn 411: sub print_modification_menu {
1.86 raeburn 412: my ($r,$cdesc,$domdesc,$dom,$type,$cid,$coursehash,$permission) = @_;
1.48 raeburn 413: &print_header($r,$type);
1.102 raeburn 414: my ($ccrole,$categorytitle,$setquota_text,$setuploadquota_text,$cdom,$cnum,
415: $extendedtype);
1.71 raeburn 416: if (ref($coursehash) eq 'HASH') {
417: $cdom = $coursehash->{'domain'};
418: $cnum = $coursehash->{'num'};
419: } else {
420: ($cdom,$cnum) = split(/_/,$cid);
421: }
1.48 raeburn 422: if ($type eq 'Community') {
423: $ccrole = 'co';
424: } else {
425: $ccrole = 'cc';
1.61 raeburn 426: }
1.88 raeburn 427: my %linktext;
428: if ($permission->{'setparms'} eq 'edit') {
429: %linktext = (
430: 'setquota' => 'View/Modify quotas for group portfolio files, and for uploaded content',
431: 'setanon' => 'View/Modify responders threshold for anonymous survey submissions display',
432: 'selfenroll' => 'View/Modify Self-Enrollment configuration',
433: 'setpostsubmit' => 'View/Modify submit button behavior, post-submission',
1.97 raeburn 434: 'setltiauth' => 'View/Modify re-authentication requirement for LTI launch of deep-linked item',
1.99 raeburn 435: 'setexttool' => 'View/Modify External Tools permissions',
1.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.103 ! raeburn 448: if ($permission->{'setparms'} eq 'edit') {
1.88 raeburn 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.103 ! 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.');
1.103 ! raeburn 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') {
1.103 ! raeburn 618: my ($okroles,$description) = &Apache::lonnet::get_my_adhocroles($env{'form.pickedcourse'},1);
1.90 raeburn 619: if (ref($okroles) eq 'ARRAY') {
1.103 ! raeburn 620: my $possrole = $env{'form.adhocrole'};
1.90 raeburn 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 '') {
1.103 ! raeburn 820: my %domconfig =
1.57 raeburn 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) {
1.103 ! raeburn 835: $disabled = ' disabled="disabled"';
1.88 raeburn 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);
1.103 ! raeburn 875: $postsubmit = 1;
1.75 raeburn 876: if (ref($domconfig{'coursedefaults'}) eq 'HASH') {
877: if (ref($domconfig{'coursedefaults'}{'postsubmit'}) eq 'HASH') {
878: if ($domconfig{'coursedefaults'}{'postsubmit'}{'client'} eq 'off') {
1.103 ! raeburn 879: $postsubmit = 0;
1.75 raeburn 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>
1.103 ! raeburn 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) = @_;
1.103 ! raeburn 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.103 ! raeburn 996: my %currsettings =
1.38 raeburn 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;
1.103 ! raeburn 1003: $excludeoff = '';
1.38 raeburn 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',
1.103 ! raeburn 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.103 ! raeburn 1120: if (($enrollvar{'courseowner'} ne '') &&
1.48 raeburn 1121: (!grep(/^$enrollvar{'courseowner'}$/,@local_ccs))) {
1122: push(@local_ccs,$enrollvar{'courseowner'});
1.26 raeburn 1123: my ($owneruname,$ownerdom) = split(/:/,$enrollvar{'courseowner'});
1.103 ! raeburn 1124: $pname{$enrollvar{'courseowner'}} =
1.26 raeburn 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: }
1.103 ! raeburn 1154: $ownertable .=
1.48 raeburn 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;
1.103 ! raeburn 1231: $optionname{''} = &mt('Use domain default');
1.72 raeburn 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"';
1.103 ! raeburn 1246: }
1.72 raeburn 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>');
1.103 ! raeburn 1251: foreach my $option ('','0','1') {
1.72 raeburn 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.103 ! raeburn 1320: $domdefdisplay = $lt{'logi'};
1.97 raeburn 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) {
1.103 ! raeburn 1412: $domdefdisplay = $titles{'dom'};
1.99 raeburn 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 => '',
1.103 ! raeburn 1423: );
1.99 raeburn 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) {
1.103 ! raeburn 1430: $crschecked{$option} = ' checked="checked"';
1.99 raeburn 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.103 ! raeburn 1580: my $javascript_validations =
1.48 raeburn 1581: &Apache::lonuserutils::javascript_validations('modifycourse',$krbdefdom,
1582: $curr_authtype,$curr_authfield);
1.35 raeburn 1583: my %param = ( formname => 'document.'.$env{'form.phase'},
1.48 raeburn 1584: kerb_def_dom => $krbdefdom,
1585: kerb_def_auth => $krbdef,
1.2 raeburn 1586: mode => 'modifycourse',
1587: curr_authtype => $curr_authtype,
1.88 raeburn 1588: curr_autharg => $enrollvar->{'autharg'},
1589: readonly => $readonly,
1.48 raeburn 1590: );
1.32 raeburn 1591: my (%authform,$authenitems);
1592: $authform{'krb'} = &Apache::loncommon::authform_kerberos(%param);
1593: $authform{'int'} = &Apache::loncommon::authform_internal(%param);
1594: $authform{'loc'} = &Apache::loncommon::authform_local(%param);
1.93 raeburn 1595: $authform{'lti'} = &Apache::loncommon::authform_lti(%param);
1596: foreach my $item ('krb','int','loc','lti') {
1.32 raeburn 1597: if ($authform{$item} ne '') {
1598: $authenitems .= $authform{$item}.'<br />';
1599: }
1.1 raeburn 1600: }
1.48 raeburn 1601: return($javascript_validations,$authenitems);
1.1 raeburn 1602: }
1603:
1604: sub modify_course {
1.30 raeburn 1605: my ($r,$cdom,$cnum,$cdesc,$domdesc,$type) = @_;
1.48 raeburn 1606: my %longtype = &course_settings_descrip($type);
1.50 raeburn 1607: my @items = ('internal.courseowner','description','internal.co-owners',
1.72 raeburn 1608: 'internal.pendingco-owners','internal.selfenrollmgrdc',
1.85 raeburn 1609: 'internal.selfenrollmgrcc','internal.mysqltables');
1.72 raeburn 1610: my ($selfenrollrows,$selfenrolltitles) = &Apache::lonuserutils::get_selfenroll_titles();
1.81 raeburn 1611: unless (($type eq 'Community') || ($type eq 'Placement')) {
1.48 raeburn 1612: push(@items,('internal.coursecode','internal.authtype','internal.autharg',
1613: 'internal.sectionnums','internal.crosslistings'));
1.103 ! raeburn 1614: if (&showcredits($cdom)) {
1.60 raeburn 1615: push(@items,'internal.defaultcredits');
1616: }
1.94 raeburn 1617: my %passwdconf = &Apache::lonnet::get_passwdconf($cdom);
1618: if ($passwdconf{'crsownerchg'}) {
1619: push(@items,'internal.nopasswdchg');
1620: }
1.1 raeburn 1621: }
1.48 raeburn 1622: my %settings = &Apache::lonnet::get('environment',\@items,$cdom,$cnum);
1623: my $description = $settings{'description'};
1.60 raeburn 1624: my ($ccrole,$response,$chgresponse,$nochgresponse,$reply,%currattr,%newattr,
1625: %cenv,%changed,@changes,@nochanges,@sections,@xlists,@warnings);
1626: my @modifiable_params = &get_dc_settable($type,$cdom);
1.28 raeburn 1627: foreach my $param (@modifiable_params) {
1.48 raeburn 1628: $currattr{$param} = $settings{'internal.'.$param};
1.1 raeburn 1629: }
1.48 raeburn 1630: if ($type eq 'Community') {
1631: %changed = ( owner => 0 );
1632: $ccrole = 'co';
1633: } else {
1634: %changed = ( code => 0,
1635: owner => 0,
1.94 raeburn 1636: passwd => 0,
1.48 raeburn 1637: );
1638: $ccrole = 'cc';
1639: unless ($settings{'internal.sectionnums'} eq '') {
1640: if ($settings{'internal.sectionnums'} =~ m/,/) {
1641: @sections = split/,/,$settings{'internal.sectionnums'};
1642: } else {
1643: $sections[0] = $settings{'internal.sectionnums'};
1644: }
1645: }
1.60 raeburn 1646: unless ($settings{'internal.crosslistings'} eq '') {
1.48 raeburn 1647: if ($settings{'internal.crosslistings'} =~ m/,/) {
1648: @xlists = split/,/,$settings{'internal.crosslistings'};
1649: } else {
1650: $xlists[0] = $settings{'internal.crosslistings'};
1651: }
1652: }
1653: if ($env{'form.login'} eq 'krb') {
1654: $newattr{'authtype'} = $env{'form.login'};
1655: $newattr{'authtype'} .= $env{'form.krbver'};
1656: $newattr{'autharg'} = $env{'form.krbarg'};
1657: } elsif ($env{'form.login'} eq 'int') {
1658: $newattr{'authtype'} ='internal';
1659: if ((defined($env{'form.intarg'})) && ($env{'form.intarg'})) {
1660: $newattr{'autharg'} = $env{'form.intarg'};
1661: }
1662: } elsif ($env{'form.login'} eq 'loc') {
1663: $newattr{'authtype'} = 'localauth';
1664: if ((defined($env{'form.locarg'})) && ($env{'form.locarg'})) {
1665: $newattr{'autharg'} = $env{'form.locarg'};
1666: }
1.93 raeburn 1667: } elsif ($env{'form.login'} eq 'lti') {
1668: $newattr{'authtype'} = 'lti';
1.48 raeburn 1669: }
1670: if ( $newattr{'authtype'}=~ /^krb/) {
1671: if ($newattr{'autharg'} eq '') {
1672: push(@warnings,
1673: &mt('As you did not include the default Kerberos domain'
1.45 bisitz 1674: .' to be used for authentication in this class, the'
1675: .' institutional data used by the automated'
1676: .' enrollment process must include the Kerberos'
1.48 raeburn 1677: .' domain for each new student.'));
1678: }
1679: }
1680:
1681: if ( exists($env{'form.coursecode'}) ) {
1682: $newattr{'coursecode'}=$env{'form.coursecode'};
1683: unless ( $newattr{'coursecode'} eq $currattr{'coursecode'} ) {
1684: $changed{'code'} = 1;
1685: }
1.1 raeburn 1686: }
1.85 raeburn 1687: if ( exists($env{'form.mysqltables'}) ) {
1688: $newattr{'mysqltables'} = $env{'form.mysqltables'};
1689: $newattr{'mysqltables'} =~ s/\D+//g;
1690: }
1.94 raeburn 1691: if ($type ne 'Placement') {
1692: if (&showcredits($cdom) && exists($env{'form.defaultcredits'})) {
1693: $newattr{'defaultcredits'}=$env{'form.defaultcredits'};
1694: $newattr{'defaultcredits'} =~ s/[^\d\.]//g;
1695: }
1696: if (grep(/^nopasswdchg$/,@modifiable_params)) {
1697: if ($env{'form.nopasswdchg'}) {
1698: $newattr{'nopasswdchg'} = 1;
1699: unless ($currattr{'nopasswdchg'}) {
1700: $changed{'passwd'} = 1;
1701: }
1702: } elsif ($currattr{'nopasswdchg'}) {
1703: $changed{'passwd'} = 1;
1704: }
1705: }
1.60 raeburn 1706: }
1.72 raeburn 1707: }
1708:
1709: my @newmgrdc = ();
1710: my @newmgrcc = ();
1711: my @currmgrdc = split(/,/,$currattr{'selfenrollmgrdc'});
1712: my @currmgrcc = split(/,/,$currattr{'selfenrollmgrcc'});
1.60 raeburn 1713:
1.72 raeburn 1714: foreach my $item (@{$selfenrollrows}) {
1715: if ($env{'form.selfenrollmgr_'.$item} eq '0') {
1716: push(@newmgrdc,$item);
1717: } elsif ($env{'form.selfenrollmgr_'.$item} eq '1') {
1718: push(@newmgrcc,$item);
1719: }
1720: }
1721:
1722: $newattr{'selfenrollmgrdc'}=join(',',@newmgrdc);
1723: $newattr{'selfenrollmgrcc'}=join(',',@newmgrcc);
1724:
1725: my $cctitle;
1726: if ($type eq 'Community') {
1727: $cctitle = &mt('Community personnel');
1728: } else {
1729: $cctitle = &mt('Course personnel');
1.1 raeburn 1730: }
1.72 raeburn 1731: my $dctitle = &Apache::lonnet::plaintext('dc');
1.1 raeburn 1732:
1.16 albertel 1733: if ( exists($env{'form.courseowner'}) ) {
1734: $newattr{'courseowner'}=$env{'form.courseowner'};
1.14 raeburn 1735: unless ( $newattr{'courseowner'} eq $currattr{'courseowner'} ) {
1.38 raeburn 1736: $changed{'owner'} = 1;
1.103 ! raeburn 1737: }
1.1 raeburn 1738: }
1.48 raeburn 1739:
1.94 raeburn 1740: if ($changed{'owner'} || $changed{'code'} || $changed{'passwd'}) {
1.38 raeburn 1741: my %crsinfo = &Apache::lonnet::courseiddump($cdom,'.',1,'.','.',$cnum,
1742: undef,undef,'.');
1743: if (ref($crsinfo{$env{'form.pickedcourse'}}) eq 'HASH') {
1.48 raeburn 1744: if ($changed{'code'}) {
1745: $crsinfo{$env{'form.pickedcourse'}}{'inst_code'} = $env{'form.coursecode'};
1746: }
1747: if ($changed{'owner'}) {
1748: $crsinfo{$env{'form.pickedcourse'}}{'owner'} = $env{'form.courseowner'};
1749: }
1.94 raeburn 1750: if ($changed{'passwd'}) {
1751: if ($env{'form.nopasswdchg'}) {
1752: $crsinfo{$env{'form.pickedcourse'}}{'nopasswdchg'} = 1;
1753: } else {
1754: delete($crsinfo{'nopasswdchg'});
1755: }
1756: }
1.38 raeburn 1757: my $chome = &Apache::lonnet::homeserver($cnum,$cdom);
1758: my $putres = &Apache::lonnet::courseidput($cdom,\%crsinfo,$chome,'notime');
1.94 raeburn 1759: if (($putres eq 'ok') && (($changed{'owner'} || $changed{'code'}))) {
1.50 raeburn 1760: &update_coowners($cdom,$cnum,$chome,\%settings,\%newattr);
1.95 raeburn 1761: if ($changed{'code'}) {
1762: &Apache::lonnet::devalidate_cache_new('instcats',$cdom);
1763: # Update cache of self-cataloging courses on institution's server(s).
1764: if (&Apache::lonnet::shared_institution($cdom)) {
1765: unless ($registered_cleanup) {
1766: my $handlers = $r->get_handlers('PerlCleanupHandler');
1767: $r->set_handlers('PerlCleanupHandler' => [\&devalidate_remote_instcats,@{$handlers}]);
1768: $registered_cleanup=1;
1769: $modified_dom = $cdom;
1770: }
1771: }
1772: }
1.50 raeburn 1773: }
1.38 raeburn 1774: }
1.14 raeburn 1775: }
1.28 raeburn 1776: foreach my $param (@modifiable_params) {
1777: if ($currattr{$param} eq $newattr{$param}) {
1778: push(@nochanges,$param);
1.1 raeburn 1779: } else {
1.48 raeburn 1780: $cenv{'internal.'.$param} = $newattr{$param};
1.28 raeburn 1781: push(@changes,$param);
1.1 raeburn 1782: }
1783: }
1784: if (@changes > 0) {
1.62 bisitz 1785: $chgresponse = &mt('The following settings have been changed:').'<br/><ul>';
1.1 raeburn 1786: }
1.48 raeburn 1787: if (@nochanges > 0) {
1.62 bisitz 1788: $nochgresponse = &mt('The following settings remain unchanged:').'<br/><ul>';
1.1 raeburn 1789: }
1.33 raeburn 1790: if (@changes > 0) {
1.28 raeburn 1791: my $putreply = &Apache::lonnet::put('environment',\%cenv,$cdom,$cnum);
1.1 raeburn 1792: if ($putreply !~ /^ok$/) {
1.48 raeburn 1793: $response = '<p class="LC_error">'.
1794: &mt('There was a problem processing your requested changes.').'<br />';
1795: if ($type eq 'Community') {
1796: $response .= &mt('Settings for this community have been left unchanged.');
1797: } else {
1798: $response .= &mt('Settings for this course have been left unchanged.');
1799: }
1800: $response .= '<br/>'.&mt('Error: ').$putreply.'</p>';
1.1 raeburn 1801: } else {
1.72 raeburn 1802: if ($env{'course.'.$cdom.'_'.$cnum.'.description'} ne '') {
1803: my %newenv;
1.103 ! raeburn 1804: map { $newenv{'course.'.$cdom.'_'.$cnum.'.internal.'.$_} = $newattr{$_}; } @changes;
1.72 raeburn 1805: &Apache::lonnet::appenv(\%newenv);
1806: }
1.28 raeburn 1807: foreach my $attr (@modifiable_params) {
1.48 raeburn 1808: if (grep/^\Q$attr\E$/,@changes) {
1.72 raeburn 1809: my $shown = $newattr{$attr};
1810: if ($attr eq 'selfenrollmgrdc') {
1811: $shown = &selfenroll_config_status(\@newmgrdc,$selfenrolltitles);
1812: } elsif ($attr eq 'selfenrollmgrcc') {
1813: $shown = &selfenroll_config_status(\@newmgrcc,$selfenrolltitles);
1814: } elsif (($attr eq 'defaultcredits') && ($shown eq '')) {
1815: $shown = &mt('None');
1.85 raeburn 1816: } elsif (($attr eq 'mysqltables') && ($shown eq '')) {
1817: $shown = &mt('domain default');
1.94 raeburn 1818: } elsif ($attr eq 'nopasswdchg') {
1819: if ($shown) {
1820: $shown = &mt('Yes');
1821: } else {
1822: $shown = &mt('No');
1823: }
1.72 raeburn 1824: }
1825: $chgresponse .= '<li>'.&mt('[_1] now set to: [_2]',$longtype{$attr},$shown).'</li>';
1.1 raeburn 1826: } else {
1.72 raeburn 1827: my $shown = $currattr{$attr};
1828: if ($attr eq 'selfenrollmgrdc') {
1829: $shown = &selfenroll_config_status(\@currmgrdc,$selfenrolltitles);
1830: } elsif ($attr eq 'selfenrollmgrcc') {
1831: $shown = &selfenroll_config_status(\@currmgrcc,$selfenrolltitles);
1832: } elsif (($attr eq 'defaultcredits') && ($shown eq '')) {
1833: $shown = &mt('None');
1.85 raeburn 1834: } elsif (($attr eq 'mysqltables') && ($shown eq '')) {
1835: $shown = &mt('domain default');
1.94 raeburn 1836: } elsif ($attr eq 'nopasswdchg') {
1837: if ($shown) {
1838: $shown = &mt('Yes');
1839: } else {
1840: $shown = &mt('No');
1841: }
1.72 raeburn 1842: }
1843: $nochgresponse .= '<li>'.&mt('[_1] still set to: [_2]',$longtype{$attr},$shown).'</li>';
1.1 raeburn 1844: }
1845: }
1.81 raeburn 1846: if (($type ne 'Community') && ($type ne 'Placement') && ($changed{'code'} || $changed{'owner'})) {
1.1 raeburn 1847: if ( $newattr{'courseowner'} eq '') {
1.48 raeburn 1848: push(@warnings,&mt('There is no owner associated with this LON-CAPA course.').
1849: '<br />'.&mt('If automated enrollment at your institution requires validation of course owners, automated enrollment will fail.'));
1.1 raeburn 1850: } else {
1.59 raeburn 1851: my %crsenv = &Apache::lonnet::get('environment',['internal.co-owners'],$cdom,$cnum);
1852: my $coowners = $crsenv{'internal.co-owners'};
1.1 raeburn 1853: if (@sections > 0) {
1.38 raeburn 1854: if ($changed{'code'}) {
1.2 raeburn 1855: foreach my $sec (@sections) {
1856: if ($sec =~ m/^(.+):/) {
1.48 raeburn 1857: my $instsec = $1;
1.8 raeburn 1858: my $inst_course_id = $newattr{'coursecode'}.$1;
1.28 raeburn 1859: my $course_check = &Apache::lonnet::auto_validate_courseID($cnum,$cdom,$inst_course_id);
1.7 raeburn 1860: if ($course_check eq 'ok') {
1.58 raeburn 1861: my $outcome = &Apache::lonnet::auto_new_course($cnum,$cdom,$inst_course_id,$newattr{'courseowner'},$coowners);
1.48 raeburn 1862: unless ($outcome eq 'ok') {
1.53 raeburn 1863: push(@warnings,&mt('If automatic enrollment is enabled for "[_1]", automated enrollment may fail for "[_2]" - section: [_3] for the following reason: "[_4]".',$description,$newattr{'coursecode'},$instsec,$outcome).'<br/>');
1.1 raeburn 1864: }
1865: } else {
1.53 raeburn 1866: push(@warnings,&mt('If automatic enrollment is enabled for "[_1]", automated enrollment may fail for "[_2]" - section: [_3] for the following reason: "[_4]".',$description,$newattr{'coursecode'},$instsec,$course_check));
1.1 raeburn 1867: }
1868: } else {
1.48 raeburn 1869: push(@warnings,&mt('If automatic enrollment is enabled for "[_1]", automated enrollment may fail for "[_2]" - section: [_3], because this is not a valid section entry.',$description,$newattr{'coursecode'},$sec));
1.1 raeburn 1870: }
1871: }
1.38 raeburn 1872: } elsif ($changed{'owner'}) {
1.4 raeburn 1873: foreach my $sec (@sections) {
1874: if ($sec =~ m/^(.+):/) {
1.48 raeburn 1875: my $instsec = $1;
1876: my $inst_course_id = $newattr{'coursecode'}.$instsec;
1.58 raeburn 1877: my $outcome = &Apache::lonnet::auto_new_course($cnum,$cdom,$inst_course_id,$newattr{'courseowner'},$coowners);
1.4 raeburn 1878: unless ($outcome eq 'ok') {
1.53 raeburn 1879: push(@warnings,&mt('If automatic enrollment is enabled for "[_1]", automated enrollment may fail for "[_2]" - section: [_3] for the following reason: "[_4]".',$description,$newattr{'coursecode'},$instsec,$outcome));
1.4 raeburn 1880: }
1881: } else {
1.53 raeburn 1882: push(@warnings,&mt('If automatic enrollment is enabled for "[_1]", automated enrollment may fail for "[_2]" - section: [_3], because this is not a valid section entry.',$description,$newattr{'coursecode'},$sec));
1.4 raeburn 1883: }
1884: }
1885: }
1.1 raeburn 1886: } else {
1.53 raeburn 1887: push(@warnings,&mt('As no section numbers are currently listed for "[_1]", automated enrollment will not occur for any sections of institutional course code: "[_2]".',$description,$newattr{'coursecode'}));
1.1 raeburn 1888: }
1.38 raeburn 1889: if ( (@xlists > 0) && ($changed{'owner'}) ) {
1.1 raeburn 1890: foreach my $xlist (@xlists) {
1891: if ($xlist =~ m/^(.+):/) {
1.48 raeburn 1892: my $instxlist = $1;
1.58 raeburn 1893: my $outcome = &Apache::lonnet::auto_new_course($cnum,$cdom,$instxlist,$newattr{'courseowner'},$coowners);
1.1 raeburn 1894: unless ($outcome eq 'ok') {
1.48 raeburn 1895: push(@warnings,&mt('If automatic enrollment is enabled for "[_1]", automated enrollment may fail for crosslisted class "[_2]" for the following reason: "[_3]".',$description,$instxlist,$outcome));
1.1 raeburn 1896: }
1.28 raeburn 1897: }
1.1 raeburn 1898: }
1899: }
1900: }
1901: }
1902: }
1.2 raeburn 1903: } else {
1.28 raeburn 1904: foreach my $attr (@modifiable_params) {
1.72 raeburn 1905: my $shown = $currattr{$attr};
1906: if ($attr eq 'selfenrollmgrdc') {
1907: $shown = &selfenroll_config_status(\@currmgrdc,$selfenrolltitles);
1908: } elsif ($attr eq 'selfenrollmgrcc') {
1909: $shown = &selfenroll_config_status(\@currmgrcc,$selfenrolltitles);
1910: } elsif (($attr eq 'defaultcredits') && ($shown eq '')) {
1911: $shown = &mt('None');
1.85 raeburn 1912: } elsif (($attr eq 'mysqltables') && ($shown eq '')) {
1913: $shown = &mt('domain default');
1.72 raeburn 1914: }
1915: $nochgresponse .= '<li>'.&mt('[_1] still set to: [_2]',$longtype{$attr},$shown).'</li>';
1.2 raeburn 1916: }
1.1 raeburn 1917: }
1918:
1919: if (@changes > 0) {
1920: $chgresponse .= "</ul><br/><br/>";
1921: }
1922: if (@nochanges > 0) {
1923: $nochgresponse .= "</ul><br/><br/>";
1924: }
1.48 raeburn 1925: my ($warning,$numwarnings);
1.103 ! raeburn 1926: my $numwarnings = scalar(@warnings);
1.48 raeburn 1927: if ($numwarnings) {
1928: $warning = &mt('The following [quant,_1,warning was,warnings were] generated when applying your changes to automated enrollment:',$numwarnings).'<p><ul>';
1929: foreach my $warn (@warnings) {
1930: $warning .= '<li><span class="LC_warning">'.$warn.'</span></li>';
1931: }
1932: $warning .= '</ul></p>';
1.1 raeburn 1933: }
1.48 raeburn 1934: if ($response) {
1935: $reply = $response;
1936: } else {
1.1 raeburn 1937: $reply = $chgresponse.$nochgresponse.$warning;
1938: }
1.48 raeburn 1939: &print_header($r,$type);
1.102 raeburn 1940: $reply = '<h3>'.&modifiable_only_title($type).'</h3>'."\n".
1941: '<h4><span class="LC_nobreak">'.&mt($type).': '.$cdesc.'</span></h4>'."\n".
1.48 raeburn 1942: '<p>'.$reply.'</p>'."\n".
1.28 raeburn 1943: '<form action="/adm/modifycourse" method="post" name="processparms">'.
1.66 bisitz 1944: &hidden_form_elements();
1945: my @actions =
1946: ('<a href="javascript:changePage(document.processparms,'."'menu'".')">'.
1947: &mt('Pick another action').'</a>');
1.48 raeburn 1948: if ($numwarnings) {
1949: my $newrole = $ccrole.'./'.$cdom.'/'.$cnum;
1950: my $escuri = &HTML::Entities::encode('/adm/roles?selectrole=1&'.$newrole.
1951: '=1&destinationurl=/adm/populate','&<>"');
1952:
1.66 bisitz 1953: push(@actions, '<a href="'.$escuri.'">'.
1954: &mt('Go to Automated Enrollment Manager for course').'</a>');
1.48 raeburn 1955: }
1.102 raeburn 1956: $reply .= '</form>'.
1957: '<br />'.&Apache::lonhtmlcommon::actionbox(\@actions);
1.3 raeburn 1958: $r->print($reply);
1.28 raeburn 1959: return;
1960: }
1961:
1.72 raeburn 1962: sub selfenroll_config_status {
1963: my ($items,$selfenrolltitles) = @_;
1964: my $shown;
1965: if ((ref($items) eq 'ARRAY') && (ref($selfenrolltitles) eq 'HASH')) {
1966: if (@{$items} > 0) {
1967: $shown = '<ul>';
1968: foreach my $item (@{$items}) {
1969: $shown .= '<li>'.$selfenrolltitles->{$item}.'</li>';
1970: }
1971: $shown .= '</ul>';
1972: } else {
1973: $shown = &mt('None');
1974: }
1975: }
1976: return $shown;
1977: }
1978:
1.50 raeburn 1979: sub update_coowners {
1980: my ($cdom,$cnum,$chome,$settings,$newattr) = @_;
1981: return unless ((ref($settings) eq 'HASH') && (ref($newattr) eq 'HASH'));
1982: my %designhash = &Apache::loncommon::get_domainconf($cdom);
1983: my (%cchash,$autocoowners);
1984: if ($designhash{$cdom.'.autoassign.co-owners'}) {
1985: $autocoowners = 1;
1986: %cchash = &Apache::lonnet::get_my_roles($cnum,$cdom,undef,undef,['cc']);
1987: }
1988: if ($settings->{'internal.courseowner'} ne $newattr->{'courseowner'}) {
1989: my $oldowner_to_coowner;
1.51 raeburn 1990: my @types = ('co-owners');
1.50 raeburn 1991: if (($newattr->{'coursecode'}) && ($autocoowners)) {
1992: my $oldowner = $settings->{'internal.courseowner'};
1993: if ($cchash{$oldowner.':cc'}) {
1.51 raeburn 1994: my ($result,$desc) = &Apache::lonnet::auto_validate_instcode($cnum,$cdom,$newattr->{'coursecode'},$oldowner);
1995: if ($result eq 'valid') {
1996: if ($settings->{'internal.co-owner'}) {
1997: my @current = split(',',$settings->{'internal.co-owners'});
1998: unless (grep(/^\Q$oldowner\E$/,@current)) {
1999: $oldowner_to_coowner = 1;
2000: }
2001: } else {
1.50 raeburn 2002: $oldowner_to_coowner = 1;
2003: }
2004: }
2005: }
1.51 raeburn 2006: } else {
2007: push(@types,'pendingco-owners');
1.50 raeburn 2008: }
1.51 raeburn 2009: foreach my $type (@types) {
1.50 raeburn 2010: if ($settings->{'internal.'.$type}) {
2011: my @current = split(',',$settings->{'internal.'.$type});
2012: my $newowner = $newattr->{'courseowner'};
2013: my @newvalues = ();
2014: if (($newowner ne '') && (grep(/^\Q$newowner\E$/,@current))) {
2015: foreach my $person (@current) {
2016: unless ($person eq $newowner) {
2017: push(@newvalues,$person);
2018: }
2019: }
2020: } else {
2021: @newvalues = @current;
2022: }
2023: if ($oldowner_to_coowner) {
2024: push(@newvalues,$settings->{'internal.courseowner'});
2025: @newvalues = sort(@newvalues);
2026: }
2027: my $newownstr = join(',',@newvalues);
2028: if ($newownstr ne $settings->{'internal.'.$type}) {
2029: if ($type eq 'co-owners') {
2030: my $deleted = '';
2031: unless (@newvalues) {
2032: $deleted = 1;
2033: }
2034: &Apache::lonnet::store_coowners($cdom,$cnum,$chome,
2035: $deleted,@newvalues);
2036: } else {
2037: my $pendingcoowners;
2038: my $cid = $cdom.'_'.$cnum;
2039: if (@newvalues) {
2040: $pendingcoowners = join(',',@newvalues);
2041: my %pendinghash = (
2042: 'internal.pendingco-owners' => $pendingcoowners,
2043: );
1.52 raeburn 2044: my $putresult = &Apache::lonnet::put('environment',\%pendinghash,$cdom,$cnum);
1.50 raeburn 2045: if ($putresult eq 'ok') {
2046: if ($env{'course.'.$cid.'.num'} eq $cnum) {
1.52 raeburn 2047: &Apache::lonnet::appenv({'course.'.$cid.'.internal.pendingco-owners' => $pendingcoowners});
1.50 raeburn 2048: }
2049: }
2050: } else {
2051: my $delresult = &Apache::lonnet::del('environment',['internal.pendingco-owners'],$cdom,$cnum);
2052: if ($delresult eq 'ok') {
2053: if ($env{'course.'.$cid.'.internal.pendingco-owners'}) {
2054: &Apache::lonnet::delenv('course.'.$cid.'.internal.pendingco-owners');
2055: }
2056: }
2057: }
2058: }
2059: } elsif ($oldowner_to_coowner) {
2060: &Apache::lonnet::store_coowners($cdom,$cnum,$chome,'',
2061: $settings->{'internal.courseowner'});
2062:
2063: }
2064: } elsif ($oldowner_to_coowner) {
2065: &Apache::lonnet::store_coowners($cdom,$cnum,$chome,'',
2066: $settings->{'internal.courseowner'});
2067: }
2068: }
2069: }
2070: if ($settings->{'internal.coursecode'} ne $newattr->{'coursecode'}) {
2071: if ($newattr->{'coursecode'} ne '') {
2072: my %designhash = &Apache::loncommon::get_domainconf($cdom);
2073: if ($designhash{$cdom.'.autoassign.co-owners'}) {
2074: my @newcoowners = ();
2075: if ($settings->{'internal.co-owners'}) {
1.58 raeburn 2076: my @currcoown = split(',',$settings->{'internal.co-owners'});
1.50 raeburn 2077: my ($updatecoowners,$delcoowners);
2078: foreach my $person (@currcoown) {
1.51 raeburn 2079: my ($result,$desc) = &Apache::lonnet::auto_validate_instcode($cnum,$cdom,$newattr->{'coursecode'},$person);
1.50 raeburn 2080: if ($result eq 'valid') {
2081: push(@newcoowners,$person);
2082: }
2083: }
2084: foreach my $item (sort(keys(%cchash))) {
2085: my ($uname,$udom,$urole) = split(':',$item);
1.51 raeburn 2086: next if ($uname.':'.$udom eq $newattr->{'courseowner'});
1.50 raeburn 2087: unless (grep(/^\Q$uname\E:\Q$udom\E$/,@newcoowners)) {
1.51 raeburn 2088: my ($result,$desc) = &Apache::lonnet::auto_validate_instcode($cnum,$cdom,$newattr->{'coursecode'},$uname.':'.$udom);
2089: if ($result eq 'valid') {
2090: push(@newcoowners,$uname.':'.$udom);
2091: }
1.50 raeburn 2092: }
2093: }
2094: if (@newcoowners) {
2095: my $coowners = join(',',sort(@newcoowners));
2096: unless ($coowners eq $settings->{'internal.co-owners'}) {
2097: $updatecoowners = 1;
2098: }
2099: } else {
2100: $delcoowners = 1;
2101: }
2102: if ($updatecoowners || $delcoowners) {
2103: &Apache::lonnet::store_coowners($cdom,$cnum,$chome,
2104: $delcoowners,@newcoowners);
2105: }
2106: } else {
2107: foreach my $item (sort(keys(%cchash))) {
2108: my ($uname,$udom,$urole) = split(':',$item);
2109: push(@newcoowners,$uname.':'.$udom);
2110: }
2111: if (@newcoowners) {
2112: &Apache::lonnet::store_coowners($cdom,$cnum,$chome,'',
2113: @newcoowners);
2114: }
2115: }
2116: }
2117: }
2118: }
2119: return;
2120: }
2121:
1.28 raeburn 2122: sub modify_quota {
1.48 raeburn 2123: my ($r,$cdom,$cnum,$cdesc,$domdesc,$type) = @_;
2124: &print_header($r,$type);
1.61 raeburn 2125: my $lctype = lc($type);
1.102 raeburn 2126: $r->print('<h3>'.&mt("Disk space quotas for $lctype")."</h3>\n".
2127: '<h4><span class="LC_nobreak">'.&mt($type).' :'.$cdesc.'</span></h4>'."\n".
2128: '<form action="/adm/modifycourse" method="post" name="processquota">'."\n");
1.61 raeburn 2129: my %oldsettings = &Apache::lonnet::get('environment',['internal.coursequota','internal.uploadquota'],$cdom,$cnum);
2130: my %staticdefaults = (
2131: coursequota => 20,
2132: uploadquota => 500,
2133: );
2134: my %default;
2135: $default{'coursequota'} = $staticdefaults{'coursequota'};
2136: my %domdefs = &Apache::lonnet::get_domain_defaults($cdom);
2137: $default{'uploadquota'} = $domdefs{'uploadquota'};
2138: if ($default{'uploadquota'} eq '') {
2139: $default{'uploadquota'} = $staticdefaults{'uploadquota'};
2140: }
2141: my (%cenv,%showresult);
2142: foreach my $item ('coursequota','uploadquota') {
2143: if ($env{'form.'.$item} ne '') {
2144: my $newquota = $env{'form.'.$item};
2145: if ($newquota =~ /^\s*(\d+\.?\d*|\.\d+)\s*$/) {
2146: $newquota = $1;
2147: if ($oldsettings{'internal.'.$item} == $newquota) {
2148: if ($item eq 'coursequota') {
2149: $r->print(&mt('The disk space allocated for group portfolio files remains unchanged as [_1] MB.',$newquota).'<br />');
2150: } else {
2151: $r->print(&mt('The disk space allocated for files uploaded via the Content Editor remains unchanged as [_1] MB.',$newquota).'<br />');
2152: }
2153: } else {
2154: $cenv{'internal.'.$item} = $newquota;
2155: $showresult{$item} = 1;
2156: }
1.28 raeburn 2157: } else {
1.103 ! raeburn 2158: if ($item eq 'coursequota') {
1.61 raeburn 2159: $r->print(&mt('The proposed group portfolio quota contained invalid characters, so the quota is unchanged.').'<br />');
2160: } else {
2161: $r->print(&mt('The proposed quota for content uploaded via the Content Editor contained invalid characters, so the quota is unchanged.').'<br />');
2162:
2163: }
2164: }
2165: }
2166: }
2167: if (keys(%cenv)) {
2168: my $putreply = &Apache::lonnet::put('environment',\%cenv,$cdom,
2169: $cnum);
2170: foreach my $key (sort(keys(%showresult))) {
1.103 ! raeburn 2171: if (($oldsettings{'internal.'.$key} eq '') &&
1.61 raeburn 2172: ($env{'form.'.$key} == $default{$key})) {
2173: if ($key eq 'uploadquota') {
2174: if ($type eq 'Community') {
2175: $r->print(&mt('The disk space allocated for files uploaded to this community via the Content Editor is the default quota for this domain: [_1] MB.',
2176: $default{$key}).'<br />');
2177: } else {
2178: $r->print(&mt('The disk space allocated for files uploaded to this course via the Content Editor is the default quota for this domain: [_1] MB.',
2179: $default{$key}).'<br />');
2180: }
1.103 ! raeburn 2181: } else {
1.48 raeburn 2182: if ($type eq 'Community') {
1.61 raeburn 2183: $r->print(&mt('The disk space allocated for group portfolio files in this community is the default quota for this domain: [_1] MB.',
2184: $default{$key}).'<br />');
1.48 raeburn 2185: } else {
1.61 raeburn 2186: $r->print(&mt('The disk space allocated for group portfolio files in this course is the default quota for this domain: [_1] MB.',
2187: $default{$key}).'<br />');
1.48 raeburn 2188: }
1.61 raeburn 2189: }
2190: delete($showresult{$key});
2191: }
2192: }
2193: if ($putreply eq 'ok') {
2194: my %updatedsettings = &Apache::lonnet::get('environment',['internal.coursequota','internal.uploadquota'],$cdom,$cnum);
2195: if ($showresult{'coursequota'}) {
2196: $r->print(&mt('The disk space allocated for group portfolio files is now: [_1] MB.',
2197: '<b>'.$updatedsettings{'internal.coursequota'}.'</b>').'<br />');
2198: my $usage = &Apache::longroup::sum_quotas($cdom.'_'.$cnum);
2199: if ($usage >= $updatedsettings{'internal.coursequota'}) {
2200: my $newoverquota;
2201: if ($usage < $oldsettings{'internal.coursequota'}) {
2202: $newoverquota = 'now';
2203: }
2204: $r->print('<p>');
2205: if ($type eq 'Community') {
1.67 bisitz 2206: $r->print(&mt("Disk usage $newoverquota exceeds the quota for this community.").' '.
1.61 raeburn 2207: &mt('Upload of new portfolio files and assignment of a non-zero MB quota to new groups in the community will not be possible until some files have been deleted, and total usage is below community quota.'));
1.28 raeburn 2208: } else {
1.67 bisitz 2209: $r->print(&mt("Disk usage $newoverquota exceeds the quota for this course.").' '.
1.61 raeburn 2210: &mt('Upload of new portfolio files and assignment of a non-zero MB quota to new groups in the course will not be possible until some files have been deleted, and total usage is below course quota.'));
1.28 raeburn 2211: }
1.61 raeburn 2212: $r->print('</p>');
1.28 raeburn 2213: }
2214: }
1.61 raeburn 2215: if ($showresult{'uploadquota'}) {
2216: $r->print(&mt('The disk space allocated for content uploaded directly via the Content Editor is now: [_1] MB.',
2217: '<b>'.$updatedsettings{'internal.uploadquota'}.'</b>').'<br />');
2218: }
1.28 raeburn 2219: } else {
1.63 raeburn 2220: $r->print(&mt('An error occurred storing the quota(s) for group portfolio files and/or uploaded content: ').
1.61 raeburn 2221: $putreply);
1.28 raeburn 2222: }
2223: }
2224: $r->print(&hidden_form_elements().'</form>');
1.102 raeburn 2225: my @actions =
2226: ('<a href="javascript:changePage(document.processparms,'."'menu'".')">'.
2227: &mt('Pick another action').'</a>');
2228: $r->print('<br />'.&Apache::lonhtmlcommon::actionbox(\@actions));
1.28 raeburn 2229: return;
1.1 raeburn 2230: }
2231:
1.57 raeburn 2232: sub modify_anonsurvey_threshold {
2233: my ($r,$cdom,$cnum,$cdesc,$domdesc,$type) = @_;
2234: &print_header($r,$type);
1.102 raeburn 2235: $r->print('<h3>'.&mt('Responder threshold required for display of anonymous survey submissions').'</h3>'."\n".
2236: '<h4><span class="LC_nobreak">'.&mt($type).': '.$cdesc.'</span></h4>'."\n".
2237: '<form action="/adm/modifycourse" method="post" name="processthreshold">'."\n");
1.57 raeburn 2238: my %oldsettings = &Apache::lonnet::get('environment',['internal.anonsurvey_threshold'],$cdom,$cnum);
2239: my %domconfig =
2240: &Apache::lonnet::get_dom('configuration',['coursedefaults'],$cdom);
1.103 ! raeburn 2241: my $defaultthreshold;
1.57 raeburn 2242: if (ref($domconfig{'coursedefaults'}) eq 'HASH') {
2243: $defaultthreshold = $domconfig{'coursedefaults'}{'anonsurvey_threshold'};
2244: if ($defaultthreshold eq '') {
2245: $defaultthreshold = 10;
2246: }
2247: } else {
2248: $defaultthreshold = 10;
2249: }
2250: if ($env{'form.threshold'} eq '') {
2251: $r->print(&mt('The proposed responder threshold for display of anonymous survey submissions was blank, so the threshold is unchanged.'));
2252: } else {
2253: my $newthreshold = $env{'form.threshold'};
2254: if ($newthreshold =~ /^\s*(\d+)\s*$/) {
2255: $newthreshold = $1;
2256: if ($oldsettings{'internal.anonsurvey_threshold'} eq $env{'form.threshold'}) {
2257: $r->print(&mt('Responder threshold for anonymous survey submissions display remains unchanged: [_1].',$env{'form.threshold'}));
2258: } else {
2259: my %cenv = (
2260: 'internal.anonsurvey_threshold' => $env{'form.threshold'},
2261: );
2262: my $putreply = &Apache::lonnet::put('environment',\%cenv,$cdom,
2263: $cnum);
1.72 raeburn 2264: if ($putreply eq 'ok') {
2265: if ($env{'course.'.$cdom.'_'.$cnum.'.description'} ne '') {
2266: &Apache::lonnet::appenv(
2267: {'course.'.$cdom.'_'.$cnum.'.internal.anonsurvey_threshold' => $env{'form.threshold'}});
2268: }
2269: }
1.57 raeburn 2270: if (($oldsettings{'internal.anonsurvey_threshold'} eq '') &&
2271: ($env{'form.threshold'} == $defaultthreshold)) {
2272: $r->print(&mt('The responder threshold for display of anonymous survey submissions is the default for this domain: [_1].',$defaultthreshold));
2273: } else {
2274: if ($putreply eq 'ok') {
2275: my %updatedsettings = &Apache::lonnet::get('environment',['internal.anonsurvey_threshold'],$cdom,$cnum);
2276: $r->print(&mt('The responder threshold for display of anonymous survey submissions is now: [_1].','<b>'.$updatedsettings{'internal.anonsurvey_threshold'}.'</b>'));
2277: } else {
2278: $r->print(&mt('An error occurred storing the responder threshold for anonymous submissions display: ').
2279: $putreply);
2280: }
2281: }
2282: }
2283: } else {
2284: $r->print(&mt('The proposed responder threshold for display of anonymous submissions contained invalid characters, so the threshold is unchanged.'));
2285: }
2286: }
1.75 raeburn 2287: $r->print(&hidden_form_elements().'</form>');
1.102 raeburn 2288: my @actions =
2289: ('<a href="javascript:changePage(document.processthreshold,'."'menu'".')">'.
2290: &mt('Pick another action').'</a>');
2291: $r->print('<br />'.&Apache::lonhtmlcommon::actionbox(\@actions));
1.75 raeburn 2292: return;
2293: }
2294:
2295: sub modify_postsubmit_config {
2296: my ($r,$cdom,$cnum,$cdesc,$domdesc,$type) = @_;
2297: &print_header($r,$type);
2298: my %lt = &Apache::lonlocal::texthash(
2299: subb => 'Submit button behavior after student makes a submission:',
2300: unch => 'Post submission behavior of the Submit button is unchanged.',
2301: erro => 'An error occurred when saving your proposed changes.',
2302: inva => 'An invalid response was recorded.',
1.102 raeburn 2303: back => 'Pick another action',
1.75 raeburn 2304: );
1.102 raeburn 2305: $r->print('<h3>'.$lt{'subb'}.'</h3>'."\n".
2306: '<h4><span class="LC_nobreak">'.&mt($type).': '.$cdesc.'</span></h4>'."\n".
2307: '<form action="/adm/modifycourse" method="post" name="processpostsubmit"><p>'."\n");
1.103 ! raeburn 2308: my %oldsettings =
1.75 raeburn 2309: &Apache::lonnet::get('environment',['internal.postsubmit','internal.postsubtimeout','internal.coursecode','internal.textbook'],$cdom,$cnum);
2310: my $postsubmit = $env{'form.postsubmit'};
2311: if ($postsubmit eq '1') {
2312: my $postsubtimeout = $env{'form.postsubtimeout'};
2313: $postsubtimeout =~ s/[^\d\.]+//g;
2314: if (($oldsettings{'internal.postsubmit'} eq $postsubmit) && ($oldsettings{'internal.postsubtimeout'} eq $postsubtimeout)) {
1.103 ! raeburn 2315: $r->print($lt{'unch'});
1.75 raeburn 2316: } else {
2317: my %cenv = (
2318: 'internal.postsubmit' => $postsubmit,
2319: );
2320: if ($postsubtimeout eq '') {
2321: my $putreply = &Apache::lonnet::put('environment',\%cenv,$cdom,$cnum);
2322: if ($putreply eq 'ok') {
2323: my $defaulttimeout = &domain_postsubtimeout($cdom,$type,\%oldsettings);
2324: $r->print(&mt('The proposed duration for disabling the Submit button post-submission was blank, so the domain default of [quant,_1,second] will be used.',$defaulttimeout));
2325: if (exists($oldsettings{'internal.postsubtimeout'})) {
2326: &Apache::lonnet::del('environment',['internal.postsubtimeout'],$cdom,$cnum);
2327: }
2328: } else {
2329: $r->print($lt{'erro'});
2330: }
1.103 ! raeburn 2331: } else {
1.75 raeburn 2332: $cenv{'internal.postsubtimeout'} = $postsubtimeout;
2333: my $putreply = &Apache::lonnet::put('environment',\%cenv,$cdom,$cnum);
2334: if ($putreply eq 'ok') {
2335: if ($postsubtimeout eq '0') {
1.103 ! raeburn 2336: $r->print(&mt('Submit button will be disabled after student submission until page is reloaded.'));
1.75 raeburn 2337: } else {
2338: $r->print(&mt('Submit button will be disabled after student submission for [quant,_1,second].',$postsubtimeout));
2339: }
2340: } else {
2341: $r->print($lt{'erro'});
2342: }
2343: }
2344: }
2345: } elsif ($postsubmit eq '0') {
2346: if ($oldsettings{'internal.postsubmit'} eq $postsubmit) {
2347: $r->print($lt{'unch'});
2348: } else {
2349: if (exists($oldsettings{'internal.postsubtimeout'})) {
1.103 ! raeburn 2350: &Apache::lonnet::del('environment',['internal.postsubtimeout'],$cdom,$cnum);
1.75 raeburn 2351: }
2352: my %cenv = (
2353: 'internal.postsubmit' => $postsubmit,
2354: );
2355: my $putreply = &Apache::lonnet::put('environment',\%cenv,$cdom,$cnum);
2356: if ($putreply eq 'ok') {
1.76 droeschl 2357: $r->print(&mt('Submit button will not be disabled after student submission'));
1.75 raeburn 2358: } else {
2359: $r->print($lt{'erro'});
2360: }
2361: }
2362: } else {
2363: $r->print($lt{'inva'}.' '.$lt{'unch'});
2364: }
1.102 raeburn 2365: $r->print('</p>'.&hidden_form_elements().'</form>');
2366: my @actions =
2367: ('<a href="javascript:changePage(document.processpostsubmit,'."'menu'".')">'.
2368: $lt{'back'}.'</a>');
2369: $r->print('<br />'.&Apache::lonhtmlcommon::actionbox(\@actions));
1.57 raeburn 2370: return;
2371: }
2372:
1.38 raeburn 2373: sub modify_catsettings {
1.48 raeburn 2374: my ($r,$cdom,$cnum,$cdesc,$domdesc,$type) = @_;
2375: &print_header($r,$type);
2376: my ($ccrole,%desc);
2377: if ($type eq 'Community') {
2378: $desc{'hidefromcat'} = &mt('Excluded from community catalog');
2379: $desc{'categories'} = &mt('Assigned categories for this community');
2380: $ccrole = 'co';
2381: } else {
2382: $desc{'hidefromcat'} = &mt('Excluded from course catalog');
2383: $desc{'categories'} = &mt('Assigned categories for this course');
2384: $ccrole = 'cc';
2385: }
1.102 raeburn 2386: $r->print('<h3>'.&mt('Category settings').'</h3>'."\n".
2387: '<h4><span class="LC_nobreak">'.&mt($type).': '.$cdesc.'</span></h4>'."\n".
2388: '<form action="/adm/modifycourse" method="post" name="processcat"><br />'."\n");
1.38 raeburn 2389: my %domconf = &Apache::lonnet::get_dom('configuration',['coursecategories'],$cdom);
1.49 raeburn 2390: my @cat_params = &catalog_settable($domconf{'coursecategories'},$type);
1.38 raeburn 2391: if (@cat_params > 0) {
2392: my (%cenv,@changes,@nochanges);
2393: my %currsettings =
2394: &Apache::lonnet::get('environment',['hidefromcat','categories'],$cdom,$cnum);
1.103 ! raeburn 2395: my (@newcategories,%showitem);
1.38 raeburn 2396: if (grep(/^togglecats$/,@cat_params)) {
2397: if ($currsettings{'hidefromcat'} ne $env{'form.hidefromcat'}) {
2398: push(@changes,'hidefromcat');
2399: $cenv{'hidefromcat'} = $env{'form.hidefromcat'};
2400: } else {
2401: push(@nochanges,'hidefromcat');
2402: }
2403: if ($env{'form.hidefromcat'} eq 'yes') {
2404: $showitem{'hidefromcat'} = '"'.&mt('Yes')."'";
2405: } else {
2406: $showitem{'hidefromcat'} = '"'.&mt('No').'"';
2407: }
2408: }
2409: if (grep(/^categorize$/,@cat_params)) {
2410: my (@cats,@trails,%allitems,%idx,@jsarray);
2411: if (ref($domconf{'coursecategories'}) eq 'HASH') {
2412: my $cathash = $domconf{'coursecategories'}{'cats'};
2413: if (ref($cathash) eq 'HASH') {
2414: &Apache::loncommon::extract_categories($cathash,\@cats,\@trails,
2415: \%allitems,\%idx,\@jsarray);
2416: }
2417: }
2418: @newcategories = &Apache::loncommon::get_env_multiple('form.usecategory');
2419: if (@newcategories == 0) {
2420: $showitem{'categories'} = '"'.&mt('None').'"';
2421: } else {
2422: $showitem{'categories'} = '<ul>';
2423: foreach my $item (@newcategories) {
2424: $showitem{'categories'} .= '<li>'.$trails[$allitems{$item}].'</li>';
2425: }
2426: $showitem{'categories'} .= '</ul>';
2427: }
2428: my $catchg = 0;
2429: if ($currsettings{'categories'} ne '') {
2430: my @currcategories = split('&',$currsettings{'categories'});
2431: foreach my $cat (@currcategories) {
2432: if (!grep(/^\Q$cat\E$/,@newcategories)) {
2433: $catchg = 1;
2434: last;
2435: }
2436: }
2437: if (!$catchg) {
2438: foreach my $cat (@newcategories) {
2439: if (!grep(/^\Q$cat\E$/,@currcategories)) {
2440: $catchg = 1;
1.103 ! raeburn 2441: last;
! 2442: }
! 2443: }
1.38 raeburn 2444: }
2445: } else {
2446: if (@newcategories > 0) {
2447: $catchg = 1;
2448: }
2449: }
2450: if ($catchg) {
2451: $cenv{'categories'} = join('&',@newcategories);
2452: push(@changes,'categories');
2453: } else {
2454: push(@nochanges,'categories');
2455: }
2456: if (@changes > 0) {
2457: my $putreply = &Apache::lonnet::put('environment',\%cenv,$cdom,$cnum);
2458: if ($putreply eq 'ok') {
1.72 raeburn 2459: if ($env{'course.'.$cdom.'_'.$cnum.'.description'} ne '') {
2460: my %newenvhash;
2461: foreach my $item (@changes) {
2462: $newenvhash{'course.'.$cdom.'_'.$cnum.'.'.$item} = $cenv{$item};
2463: }
2464: &Apache::lonnet::appenv(\%newenvhash);
2465: }
1.38 raeburn 2466: my %crsinfo = &Apache::lonnet::courseiddump($cdom,'.',1,'.','.',
2467: $cnum,undef,undef,'.');
2468: if (ref($crsinfo{$env{'form.pickedcourse'}}) eq 'HASH') {
2469: if (grep(/^hidefromcat$/,@changes)) {
2470: $crsinfo{$env{'form.pickedcourse'}}{'hidefromcat'} = $env{'form.hidefromcat'};
2471: }
2472: if (grep(/^categories$/,@changes)) {
2473: $crsinfo{$env{'form.pickedcourse'}}{'categories'} = $cenv{'categories'};
2474: }
2475: my $chome = &Apache::lonnet::homeserver($cnum,$cdom);
2476: my $putres = &Apache::lonnet::courseidput($cdom,\%crsinfo,$chome,'notime');
2477: }
1.48 raeburn 2478: $r->print(&mt('The following changes occurred:').'<ul>');
1.38 raeburn 2479: foreach my $item (@changes) {
1.48 raeburn 2480: $r->print('<li>'.&mt('[_1] now set to: [_2]',$desc{$item},$showitem{$item}).'</li>');
1.38 raeburn 2481: }
2482: $r->print('</ul><br />');
2483: }
2484: }
2485: if (@nochanges > 0) {
1.48 raeburn 2486: $r->print(&mt('The following were unchanged:').'<ul>');
1.38 raeburn 2487: foreach my $item (@nochanges) {
1.48 raeburn 2488: $r->print('<li>'.&mt('[_1] still set to: [_2]',$desc{$item},$showitem{$item}).'</li>');
1.38 raeburn 2489: }
2490: $r->print('</ul>');
2491: }
2492: }
2493: } else {
1.48 raeburn 2494: my $newrole = $ccrole.'./'.$cdom.'/'.$cnum;
2495: my $escuri = &HTML::Entities::encode('/adm/roles?selectrole=1&'.$newrole.
2496: '=1&destinationurl=/adm/courseprefs','&<>"');
2497: if ($type eq 'Community') {
2498: $r->print(&mt('Category settings for communities in this domain should be modified in community context (via "[_1]Community Configuration[_2]").','<a href="$escuri">','</a>').'<br />');
2499: } else {
2500: $r->print(&mt('Category settings for courses in this domain should be modified in course context (via "[_1]Course Configuration[_2]").','<a href="$escuri">','</a>').'<br />');
2501: }
1.38 raeburn 2502: }
1.102 raeburn 2503: $r->print('<br />'.&hidden_form_elements().'</form>');
2504: my @actions =
2505: ('<a href="javascript:changePage(document.processcat,'."'menu'".')">'.
2506: &mt('Pick another action').'</a>');
2507: $r->print('<br />'.&Apache::lonhtmlcommon::actionbox(\@actions));
1.38 raeburn 2508: return;
2509: }
2510:
1.97 raeburn 2511: sub modify_ltiauth {
2512: my ($r,$cdom,$cnum,$cdesc,$domdesc,$type) = @_;
2513: my %lt = &Apache::lonlocal::texthash(
2514: 'requ' => 'Requirement for re-authentication for student LTI-limited launch of deep-linked item',
2515: 'link' => 'Link protection can be set to accept username for an enrolled student (if sent by Consumer)',
2516: 'logi' => 'Login needed, regardless of user information sent by LTI Consumer in (signed) parameters',
2517: 'used' => 'Use domain default',
2518: 'cour' => 'Use course-specific setting',
2519: 'modi' => 'Save',
2520: 'back' => 'Pick another action',
2521: );
2522: &print_header($r,$type);
1.102 raeburn 2523: $r->print('<h3>'.$lt{'requ'}.'</h3>'."\n".
2524: '<h4><span class="LC_nobreak">'.&mt($type).': '.$cdesc.'</span></h4>'."\n".
2525: '<form action="/adm/modifycourse" method="post" name="processltiauth">'."\n");
1.97 raeburn 2526: my %oldsettings = &Apache::lonnet::get('environment',['internal.ltiauth'],$cdom,$cnum);
2527: my $oldltiauth = $oldsettings{'internal.ltiauth'};
2528: my $domdef;
2529: my %domconfig =
2530: &Apache::lonnet::get_dom('configuration',['coursedefaults'],$cdom);
2531: if (ref($domconfig{'coursedefaults'}) eq 'HASH') {
2532: $domdef = $domconfig{'coursedefaults'}{'ltiauth'};
2533: }
2534: my ($newltiauth,$nochange,$change,$status,$error,$ltiauth);
2535: if ($env{'form.ltiauthset'} eq 'dom') {
2536: if ($oldltiauth eq '') {
2537: $nochange = 1;
2538: } else {
2539: $change = 1;
2540: }
2541: } elsif ($env{'form.ltiauthset'} eq 'course') {
1.103 ! raeburn 2542: if ($env{'form.ltiauth'} =~ /^0|1$/) {
1.97 raeburn 2543: $newltiauth = $env{'form.ltiauth'};
2544: }
2545: if ($oldltiauth == $newltiauth) {
2546: $nochange = 1;
2547: } else {
2548: $change = 1;
2549: }
2550: }
2551: if ($change) {
2552: if ($newltiauth ne '') {
2553: my %cenv = (
2554: 'internal.ltiauth' => $newltiauth,
2555: );
2556: if (&Apache::lonnet::put('environment',\%cenv,$cdom,$cnum) eq 'ok') {
2557: if ($env{'course.'.$cdom.'_'.$cnum.'.description'} ne '') {
2558: &Apache::lonnet::appenv(
2559: {'course.'.$cdom.'_'.$cnum.'.internal.ltiauth' => $newltiauth});
2560: }
2561: } else {
2562: $error = 1;
2563: }
2564: } else {
2565: if (&Apache::lonnet::del('environment',['internal.ltiauth'],$cdom,$cnum) eq 'ok') {
2566: if (exists($env{'course.'.$cdom.'_'.$cnum.'.internal.ltiauth'})) {
2567: &Apache::lonnet::delenv('course.'.$cdom.'_'.$cnum.'.internal.ltiauth');
2568: }
2569: } else {
2570: $error = 1;
2571: }
2572: }
2573: }
2574: if ($error) {
2575: $nochange = 1;
2576: }
2577: if ($nochange) {
2578: $ltiauth = $oldltiauth;
2579: } else {
2580: $ltiauth = $newltiauth;
2581: }
2582: if ($ltiauth eq '') {
2583: $status = $lt{'used'}.': ';
2584: if ($domdef) {
2585: $status .= '<span style="font-style:italic">'.$lt{'link'}.'</span>';
2586: } else {
2587: $status .= '<span style="font-style:italic">'.$lt{'logi'}.'</span>';
2588: }
2589: } else {
2590: $status = $lt{'cour'}.': ';
2591: if ($ltiauth) {
2592: $status .= '<span style="font-style:italic">'.$lt{'link'}.'</span>';
2593: } else {
2594: $status .= '<span style="font-style:italic">'.$lt{'logi'}.'</span>';
2595: }
2596: }
2597: if ($error) {
2598: $r->print('<p class="LC_warning">'.&mt('An error occurred when saving your changes').'</p>');
2599: }
2600: $r->print('<p>');
2601: if ($nochange) {
2602: $r->print(&mt('Re-authentication requirement for LTI launch of deep-linked item is unchanged'));
2603: } elsif ($change) {
2604: $r->print(&mt('Re-authentication requirement for LTI launch of deep-linked changed'));
2605: }
1.102 raeburn 2606: $r->print('<br />'.$status.'</p>'.
2607: &hidden_form_elements().'</form>');
2608: my @actions =
2609: ('<a href="javascript:changePage(document.processltiauth,'."'menu'".')">'.
2610: $lt{'back'}.'</a>');
2611: $r->print('<br />'.&Apache::lonhtmlcommon::actionbox(\@actions));
1.99 raeburn 2612: return;
2613: }
2614:
2615: sub modify_exttool {
2616: my ($r,$cdom,$cnum,$cdesc,$domdesc,$type) = @_;
2617: my %titles = &exttool_titles($type);
2618: &print_header($r,$type);
1.102 raeburn 2619: $r->print('<h3>'.$titles{'extt'}.'</h3>'."\n".
2620: '<h4><span class="LC_nobreak">'.$type.': '.$cdesc.'</span></h4>'."\n".
2621: '<form action="/adm/modifycourse" method="post" name="processexttool">'."\n");
1.99 raeburn 2622: my %oldsettings = &Apache::lonnet::get('environment',['internal.exttool'],$cdom,$cnum);
2623: my $oldcrsexttool = $oldsettings{'internal.exttool'};
2624: my $domdefdom = 1;
2625: my $domdef = 0;
2626: my $domdefdisplay;
2627: my %settings = &Apache::lonnet::get('environment',['internal.coursecode',
2628: 'internal.textbook'],$cdom,$cnum);
2629: my $lctype = &get_lctype($type,\%settings);
2630: my %domconfig =
2631: &Apache::lonnet::get_dom('configuration',['coursedefaults'],$cdom);
2632: if (ref($domconfig{'coursedefaults'}) eq 'HASH') {
2633: if (ref($domconfig{'coursedefaults'}{'domexttool'}) eq 'HASH') {
2634: if (exists($domconfig{'coursedefaults'}{'domexttool'}{$lctype})) {
2635: $domdefdom = $domconfig{'coursedefaults'}{'domexttool'}{$lctype};
2636: }
2637: }
2638: if (ref($domconfig{'coursedefaults'}{'exttool'}) eq 'HASH') {
2639: if (exists($domconfig{'coursedefaults'}{'exttool'}{$lctype})) {
2640: $domdef = $domconfig{'coursedefaults'}{'exttool'}{$lctype};
2641: }
2642: }
2643: }
2644: if ($domdef && $domdefdom) {
2645: $domdefdisplay = $titles{'both'};
2646: } elsif ($domdef) {
2647: $domdefdisplay = $titles{'crs'};
2648: } elsif ($domdefdom) {
2649: $domdefdisplay = $titles{'dom'};
2650: } else {
2651: $domdefdisplay = $titles{'none'};
2652: }
2653: my ($newcrsexttool,$nochange,$change,$status,$error,$exttool);
2654: if ($env{'form.exttoolset'} eq 'dom') {
2655: if ($oldcrsexttool eq '') {
2656: $nochange = 1;
2657: } else {
2658: $change = 1;
2659: }
2660: } elsif ($env{'form.exttoolset'} eq 'course') {
2661: if ($env{'form.exttool'} =~ /^both|dom|crs|none$/) {
2662: $newcrsexttool = $env{'form.exttool'};
2663: }
2664: if ($oldcrsexttool eq $newcrsexttool) {
2665: $nochange = 1;
2666: } else {
2667: $change = 1;
2668: }
2669: }
2670: if ($change) {
2671: if ($newcrsexttool ne '') {
2672: my %cenv = (
2673: 'internal.exttool' => $newcrsexttool,
2674: );
2675: if (&Apache::lonnet::put('environment',\%cenv,$cdom,$cnum) eq 'ok') {
2676: if ($env{'course.'.$cdom.'_'.$cnum.'.description'} ne '') {
2677: &Apache::lonnet::appenv(
2678: {'course.'.$cdom.'_'.$cnum.'.internal.exttool' => $newcrsexttool});
2679: }
2680: } else {
2681: $error = 1;
2682: }
2683: } else {
2684: if (&Apache::lonnet::del('environment',['internal.exttool'],$cdom,$cnum) eq 'ok') {
2685: if (exists($env{'course.'.$cdom.'_'.$cnum.'.internal.exttool'})) {
2686: &Apache::lonnet::delenv('course.'.$cdom.'_'.$cnum.'.internal.exttool');
2687: }
2688: } else {
2689: $error = 1;
2690: }
2691: }
2692: }
2693: if ($error) {
2694: $nochange = 1;
2695: }
2696: if ($nochange) {
2697: $exttool = $oldcrsexttool;
2698: } else {
2699: $exttool = $newcrsexttool;
2700: }
2701: if ($exttool eq '') {
2702: $status = $titles{'used'}.': <span style="font-style:italic">'.$domdefdisplay.'</span>';
2703: } else {
2704: $status = $titles{'cour'}.': <span style="font-style:italic">'.$titles{$exttool}.'</span>';
2705: }
2706: if ($error) {
2707: $r->print('<p class="LC_warning">'.&mt('An error occurred when saving your changes').'</p>');
2708: }
2709: $r->print('<p>');
2710: if ($nochange) {
2711: $r->print(&mt('External Tool permissions unchanged'));
2712: } elsif ($change) {
2713: $r->print(&mt('External Tool permissions changed'));
2714: }
1.102 raeburn 2715: $r->print('<br />'.$status.'</p>'.
2716: &hidden_form_elements().'</form>');
2717: my @actions =
2718: ('<a href="javascript:changePage(document.processexttool,'."'menu'".')">'.
2719: $titles{'back'}.'</a>');
2720: $r->print('<br />'.&Apache::lonhtmlcommon::actionbox(\@actions));
1.97 raeburn 2721: return;
2722: }
2723:
1.1 raeburn 2724: sub print_header {
1.48 raeburn 2725: my ($r,$type,$javascript_validations) = @_;
1.28 raeburn 2726: my $phase = "start";
2727: if ( exists($env{'form.phase'}) ) {
2728: $phase = $env{'form.phase'};
2729: }
2730: my $js = qq|
1.60 raeburn 2731:
1.28 raeburn 2732: function changePage(formname,newphase) {
2733: formname.phase.value = newphase;
2734: if (newphase == 'processparms') {
2735: return;
1.1 raeburn 2736: }
1.28 raeburn 2737: formname.submit();
2738: }
1.60 raeburn 2739:
1.28 raeburn 2740: |;
2741: if ($phase eq 'setparms') {
1.60 raeburn 2742: $js .= $javascript_validations;
1.28 raeburn 2743: } elsif ($phase eq 'courselist') {
1.90 raeburn 2744: $js .= <<"ENDJS";
1.60 raeburn 2745: function hide_searching() {
2746: if (document.getElementById('searching')) {
2747: document.getElementById('searching').style.display = 'none';
2748: }
2749: return;
2750: }
2751:
1.90 raeburn 2752: ENDJS
1.28 raeburn 2753: } elsif ($phase eq 'setquota') {
1.57 raeburn 2754: my $invalid = &mt('The quota you entered contained invalid characters.');
2755: my $alert = &mt('You must enter a number');
1.78 damieng 2756: &js_escape(\$invalid);
2757: &js_escape(\$alert);
1.57 raeburn 2758: my $regexp = '/^\s*(\d+\.?\d*|\.\d+)\s*$/';
2759: $js .= <<"ENDSCRIPT";
1.60 raeburn 2760:
1.57 raeburn 2761: function verify_quota() {
1.101 raeburn 2762: var newcoursequota = document.setquota.coursequota.value;
2763: var newuploadquota = document.setquota.uploadquota.value;
1.57 raeburn 2764: var num_reg = $regexp;
1.101 raeburn 2765: if ((num_reg.test(newcoursequota)) && (num_reg.test(newuploadquota))) {
1.57 raeburn 2766: changePage(document.setquota,'processquota');
1.1 raeburn 2767: } else {
1.57 raeburn 2768: alert("$invalid\\n$alert");
2769: return false;
1.1 raeburn 2770: }
1.57 raeburn 2771: return true;
2772: }
1.60 raeburn 2773:
1.57 raeburn 2774: ENDSCRIPT
2775: } elsif ($phase eq 'setanon') {
2776: my $invalid = &mt('The responder threshold you entered is invalid.');
2777: my $alert = &mt('You must enter a positive integer.');
1.78 damieng 2778: &js_escape(\$invalid);
2779: &js_escape(\$alert);
1.57 raeburn 2780: my $regexp = ' /^\s*\d+\s*$/';
2781: $js .= <<"ENDSCRIPT";
1.60 raeburn 2782:
1.57 raeburn 2783: function verify_anon_threshold() {
2784: var newthreshold = document.setanon.threshold.value;
2785: var num_reg = $regexp;
2786: if (num_reg.test(newthreshold)) {
2787: if (newthreshold > 0) {
2788: changePage(document.setanon,'processthreshold');
2789: } else {
2790: alert("$invalid\\n$alert");
2791: return false;
2792: }
2793: } else {
2794: alert("$invalid\\n$alert");
2795: return false;
2796: }
2797: return true;
1.28 raeburn 2798: }
1.60 raeburn 2799:
1.28 raeburn 2800: ENDSCRIPT
1.75 raeburn 2801: } elsif ($phase eq 'setpostsubmit') {
2802: my $invalid = &mt('The choice entered for disabling the submit button is invalid.');
2803: my $invalidtimeout = &mt('The timeout you entered for disabling the submit button is invalid.');
2804: my $alert = &mt('Enter one of: a positive integer, 0 (for no timeout), or leave blank to use domain default');
1.78 damieng 2805: &js_escape(\$invalid);
2806: &js_escape(\$invalidtimeout);
2807: &js_escape(\$alert);
1.75 raeburn 2808: my $regexp = ' /^\s*\d+\s*$/';
2809:
1.103 ! raeburn 2810: $js .= <<"ENDSCRIPT";
1.75 raeburn 2811:
2812: function verify_postsubmit() {
2813: var optionsElement = document.setpostsubmit.postsubmit;
2814: var verified = '';
2815: if (optionsElement.length) {
2816: var currval;
2817: for (var i=0; i<optionsElement.length; i++) {
2818: if (optionsElement[i].checked) {
2819: currval = optionsElement[i].value;
2820: }
2821: }
2822: if (currval == 1) {
2823: var newtimeout = document.setpostsubmit.postsubtimeout.value;
2824: if (newtimeout == '') {
2825: verified = 'ok';
2826: } else {
2827: var num_reg = $regexp;
2828: if (num_reg.test(newtimeout)) {
2829: if (newtimeout>= 0) {
2830: verified = 'ok';
2831: } else {
2832: alert("$invalidtimeout\\n$alert");
2833: return false;
2834: }
2835: } else {
2836: alert("$invalid\\n$alert");
2837: return false;
2838: }
2839: }
2840: } else {
2841: if (currval == 0) {
1.103 ! raeburn 2842: verified = 'ok';
1.75 raeburn 2843: } else {
2844: alert('$invalid');
2845: return false;
2846: }
2847: }
2848: if (verified == 'ok') {
2849: changePage(document.setpostsubmit,'processpostsubmit');
2850: return true;
2851: }
2852: }
2853: return false;
2854: }
2855:
2856: function togglePostsubmit(caller) {
2857: var optionsElement = document.setpostsubmit.postsubmit;
2858: if (document.getElementById(caller)) {
2859: var divitem = document.getElementById(caller);
1.103 ! raeburn 2860: var optionsElement = document.setpostsubmit.postsubmit;
1.75 raeburn 2861: if (optionsElement.length) {
2862: var currval;
2863: for (var i=0; i<optionsElement.length; i++) {
2864: if (optionsElement[i].checked) {
2865: currval = optionsElement[i].value;
2866: }
2867: }
2868: if (currval == 1) {
2869: divitem.style.display = 'block';
2870: } else {
2871: divitem.style.display = 'none';
2872: }
2873: }
1.1 raeburn 2874: }
1.75 raeburn 2875: return;
2876: }
1.60 raeburn 2877:
1.75 raeburn 2878: ENDSCRIPT
2879:
1.97 raeburn 2880: } elsif ($phase eq 'setltiauth') {
2881: $js .= <<"ENDJS";
2882: function toggleLTIOptions(form) {
2883: var radioname = 'ltiauthset';
2884: var divid = 'crsltiauth';
2885: var num = form.elements[radioname].length;
2886: if (num) {
2887: var setvis = '';
2888: for (var i=0; i<num; i++) {
2889: if (form.elements[radioname][i].checked) {
2890: if (form.elements[radioname][i].value == 'course') {
2891: if (document.getElementById(divid)) {
2892: document.getElementById(divid).style.display = 'inline-block';
2893: }
2894: setvis = 1;
2895: }
2896: break;
2897: }
2898: }
2899: if (!setvis) {
2900: if (document.getElementById(divid)) {
2901: document.getElementById(divid).style.display = 'none';
2902: }
2903: }
2904: }
2905: return;
2906: }
2907:
2908: ENDJS
1.99 raeburn 2909: } elsif ($phase eq 'setexttool') {
2910: $js .= <<"ENDJS";
2911: function toggleExtToolOptions(form) {
2912: var radioname = 'exttoolset';
2913: var divid = 'crsexttool';
2914: var num = form.elements[radioname].length;
2915: if (num) {
2916: var setvis = '';
2917: for (var i=0; i<num; i++) {
2918: if (form.elements[radioname][i].checked) {
2919: if (form.elements[radioname][i].value == 'course') {
2920: if (document.getElementById(divid)) {
2921: document.getElementById(divid).style.display = 'inline-block';
2922: }
2923: setvis = 1;
2924: }
2925: break;
2926: }
2927: }
2928: if (!setvis) {
2929: if (document.getElementById(divid)) {
2930: document.getElementById(divid).style.display = 'none';
2931: }
2932: }
2933: }
2934: return;
2935: }
2936:
2937: ENDJS
1.75 raeburn 2938: }
1.37 raeburn 2939: my $starthash;
1.86 raeburn 2940: if ($env{'form.phase'} eq 'adhocrole') {
1.37 raeburn 2941: $starthash = {
1.86 raeburn 2942: add_entries => {'onload' => "javascript:document.adhocrole.submit();"},
1.37 raeburn 2943: };
1.60 raeburn 2944: } elsif ($phase eq 'courselist') {
2945: $starthash = {
1.74 musolffc 2946: add_entries => {'onload' => "hide_searching(); courseSet(document.filterpicker.official, 'load');"},
1.60 raeburn 2947: };
1.97 raeburn 2948: } elsif ($env{'form.phase'} eq 'setltiauth') {
2949: $starthash = {
2950: add_entries => {'onload' => "toggleLTIOptions(document.setltiauth);"},
2951: };
1.99 raeburn 2952: } elsif ($env{'form.phase'} eq 'setexttool') {
2953: $starthash = {
2954: add_entries => {'onload' => "toggleExtToolOptions(document.setexttool);"},
2955: };
1.37 raeburn 2956: }
1.48 raeburn 2957: $r->print(&Apache::loncommon::start_page('View/Modify Course/Community Settings',
1.60 raeburn 2958: &Apache::lonhtmlcommon::scripttag($js),
2959: $starthash));
1.48 raeburn 2960: my $bread_text = "View/Modify Courses/Communities";
2961: if ($type eq 'Community') {
2962: $bread_text = 'Community Settings';
1.81 raeburn 2963: } elsif ($type eq 'Placement') {
2964: $bread_text = 'Placement Test Settings';
1.41 raeburn 2965: } else {
1.48 raeburn 2966: $bread_text = 'Course Settings';
1.41 raeburn 2967: }
1.102 raeburn 2968: my $helpcomponent;
2969: if ($env{'form.phase'} eq 'menu') {
2970: if ($type eq 'Community') {
2971: $helpcomponent = 'Domain_Modify_Community';
2972: } else {
2973: $helpcomponent = 'Domain_Modify_Course';
2974: }
2975: }
2976: $r->print(&Apache::lonhtmlcommon::breadcrumbs($bread_text,$helpcomponent));
1.5 raeburn 2977: return;
1.1 raeburn 2978: }
2979:
2980: sub print_footer {
1.23 albertel 2981: my ($r) = @_;
2982: $r->print('<br />'.&Apache::loncommon::end_page());
1.5 raeburn 2983: return;
1.3 raeburn 2984: }
2985:
2986: sub check_course {
1.71 raeburn 2987: my ($dom,$domdesc) = @_;
2988: my ($ok_course,$description,$instcode);
2989: my %coursehash;
2990: if ($env{'form.pickedcourse'} =~ /^$match_domain\_$match_courseid$/) {
2991: my %args;
2992: unless ($env{'course.'.$env{'form.pickedcourse'}.'.description'}) {
2993: %args = (
2994: 'one_time' => 1,
2995: 'freshen_cache' => 1,
2996: );
2997: }
2998: %coursehash =
2999: &Apache::lonnet::coursedescription($env{'form.pickedcourse'},\%args);
3000: my $cnum = $coursehash{'num'};
3001: my $cdom = $coursehash{'domain'};
3002: $description = $coursehash{'description'};
3003: $instcode = $coursehash{'internal.coursecode'};
3004: if ($instcode) {
3005: $description .= " ($instcode)";
3006: }
3007: if (($cdom eq $dom) && ($cnum =~ /^$match_courseid$/)) {
3008: my %courseIDs = &Apache::lonnet::courseiddump($cdom,'.',1,'.','.',
3009: $cnum,undef,undef,'.');
3010: if ($courseIDs{$cdom.'_'.$cnum}) {
3011: $ok_course = 'ok';
1.5 raeburn 3012: }
1.3 raeburn 3013: }
3014: }
1.71 raeburn 3015: return ($ok_course,$description,\%coursehash);
1.1 raeburn 3016: }
3017:
1.28 raeburn 3018: sub course_settings_descrip {
1.48 raeburn 3019: my ($type) = @_;
3020: my %longtype;
3021: if ($type eq 'Community') {
3022: %longtype = &Apache::lonlocal::texthash(
1.72 raeburn 3023: 'courseowner' => "Username:domain of community owner",
3024: 'co-owners' => "Username:domain of each co-owner",
3025: 'selfenrollmgrdc' => "Community-specific self-enrollment configuration by Domain Coordinator",
3026: 'selfenrollmgrcc' => "Community-specific self-enrollment configuration by Community personnel",
1.85 raeburn 3027: 'mysqltables' => '"Temporary" student performance tables lifetime (seconds)',
1.48 raeburn 3028: );
3029: } else {
3030: %longtype = &Apache::lonlocal::texthash(
1.28 raeburn 3031: 'authtype' => 'Default authentication method',
3032: 'autharg' => 'Default authentication parameter',
3033: 'autoadds' => 'Automated adds',
3034: 'autodrops' => 'Automated drops',
3035: 'autostart' => 'Date of first automated enrollment',
3036: 'autoend' => 'Date of last automated enrollment',
3037: 'default_enrollment_start_date' => 'Date of first student access',
3038: 'default_enrollment_end_date' => 'Date of last student access',
3039: 'coursecode' => 'Official course code',
3040: 'courseowner' => "Username:domain of course owner",
1.50 raeburn 3041: 'co-owners' => "Username:domain of each co-owner",
1.28 raeburn 3042: 'notifylist' => 'Course Coordinators to be notified of enrollment changes',
1.48 raeburn 3043: 'sectionnums' => 'Course section number:LON-CAPA section',
3044: 'crosslistings' => 'Crosslisted class:LON-CAPA section',
1.72 raeburn 3045: 'defaultcredits' => 'Credits',
1.84 raeburn 3046: 'autodropfailsafe' => "Failsafe section enrollment count",
1.72 raeburn 3047: 'selfenrollmgrdc' => "Course-specific self-enrollment configuration by Domain Coordinator",
3048: 'selfenrollmgrcc' => "Course-specific self-enrollment configuration by Course personnel",
1.85 raeburn 3049: 'mysqltables' => '"Temporary" student performance tables lifetime (seconds)',
1.94 raeburn 3050: 'nopasswdchg' => 'Disable changing password for users with student role by course owner',
1.48 raeburn 3051: );
3052: }
1.28 raeburn 3053: return %longtype;
3054: }
3055:
3056: sub hidden_form_elements {
1.103 ! raeburn 3057: my $hidden_elements =
1.46 raeburn 3058: &Apache::lonhtmlcommon::echo_form_input(['gosearch','updater','coursecode',
1.37 raeburn 3059: 'prevphase','numlocalcc','courseowner','login','coursequota','intarg',
1.57 raeburn 3060: 'locarg','krbarg','krbver','counter','hidefromcat','usecategory',
1.75 raeburn 3061: 'threshold','postsubmit','postsubtimeout','defaultcredits','uploadquota',
3062: 'selfenrollmgrdc','selfenrollmgrcc','action','state','currsec_st',
1.99 raeburn 3063: 'sections','newsec','mysqltables','nopasswdchg','ltiauth','ltiauthset',
3064: 'exttoolset','exttool'],['^selfenrollmgr_','^selfenroll_'])."\n".
1.37 raeburn 3065: '<input type="hidden" name="prevphase" value="'.$env{'form.phase'}.'" />';
1.28 raeburn 3066: return $hidden_elements;
3067: }
1.1 raeburn 3068:
1.60 raeburn 3069: sub showcredits {
3070: my ($dom) = @_;
3071: my %domdefaults = &Apache::lonnet::get_domain_defaults($dom);
1.79 raeburn 3072: if ($domdefaults{'officialcredits'} || $domdefaults{'unofficialcredits'} || $domdefaults{'textbookcredits'}) {
1.60 raeburn 3073: return 1;
3074: }
3075: }
3076:
1.86 raeburn 3077: sub get_permission {
3078: my ($dom) = @_;
3079: my ($allowed,%permission);
1.94 raeburn 3080: my %passwdconf = &Apache::lonnet::get_passwdconf($dom);
1.86 raeburn 3081: if (&Apache::lonnet::allowed('ccc',$dom)) {
3082: $allowed = 1;
3083: %permission = (
1.88 raeburn 3084: setquota => 'edit',
3085: processquota => 'edit',
3086: setanon => 'edit',
3087: processthreshold => 'edit',
3088: setpostsubmit => 'edit',
3089: processpostsubmit => 'edit',
3090: viewparms => 'view',
3091: setparms => 'edit',
3092: processparms => 'edit',
3093: catsettings => 'edit',
3094: processcat => 'edit',
3095: selfenroll => 'edit',
1.90 raeburn 3096: adhocrole => 'coord',
1.97 raeburn 3097: setltiauth => 'edit',
3098: processltiauth => 'edit',
1.99 raeburn 3099: setexttool => 'edit',
3100: processexttool => 'edit',
1.86 raeburn 3101: );
1.94 raeburn 3102: if ($passwdconf{'crsownerchg'}) {
3103: $permission{passwdchg} = 'edit';
3104: }
1.86 raeburn 3105: } elsif (&Apache::lonnet::allowed('rar',$dom)) {
3106: $allowed = 1;
3107: %permission = (
1.88 raeburn 3108: setquota => 'view',
3109: viewparms => 'view',
3110: setanon => 'view',
3111: setpostsubmit => 'view',
3112: setparms => 'view',
3113: catsettings => 'view',
3114: selfenroll => 'view',
1.90 raeburn 3115: adhocrole => 'custom',
1.97 raeburn 3116: setltiauth => 'view',
1.99 raeburn 3117: setexttool => 'view',
1.86 raeburn 3118: );
1.94 raeburn 3119: if ($passwdconf{'crsownerchg'}) {
3120: $permission{passwdchg} = 'view';
3121: }
1.86 raeburn 3122: }
3123: return ($allowed,\%permission);
3124: }
3125:
1.95 raeburn 3126: sub devalidate_remote_instcats {
3127: if ($modified_dom ne '') {
3128: my %servers = &Apache::lonnet::internet_dom_servers($modified_dom);
3129: my %thismachine;
3130: map { $thismachine{$_} = 1; } &Apache::lonnet::current_machine_ids();
3131: if (keys(%servers)) {
3132: foreach my $server (keys(%servers)) {
3133: next if ($thismachine{$server});
3134: &Apache::lonnet::remote_devalidate_cache($server,['instcats:'.$modified_dom]);
3135: }
3136: }
3137: $modified_dom = '';
3138: }
3139: return;
3140: }
3141:
1.1 raeburn 3142: sub handler {
3143: my $r = shift;
3144: if ($r->header_only) {
3145: &Apache::loncommon::content_type($r,'text/html');
3146: $r->send_http_header;
3147: return OK;
3148: }
1.72 raeburn 3149:
1.95 raeburn 3150: $registered_cleanup=0;
3151: $modified_dom = '';
3152:
1.28 raeburn 3153: my $dom = $env{'request.role.domain'};
1.31 albertel 3154: my $domdesc = &Apache::lonnet::domain($dom,'description');
1.86 raeburn 3155: my ($allowed,$permission) = &get_permission($dom);
3156: if ($allowed) {
1.1 raeburn 3157: &Apache::loncommon::content_type($r,'text/html');
3158: $r->send_http_header;
3159:
1.28 raeburn 3160: &Apache::lonhtmlcommon::clear_breadcrumbs();
3161:
3162: my $phase = $env{'form.phase'};
1.46 raeburn 3163: if ($env{'form.updater'}) {
3164: $phase = '';
3165: }
1.37 raeburn 3166: if ($phase eq '') {
3167: &Apache::lonhtmlcommon::add_breadcrumb
1.28 raeburn 3168: ({href=>"/adm/modifycourse",
1.48 raeburn 3169: text=>"Course/Community search"});
1.28 raeburn 3170: &print_course_search_page($r,$dom,$domdesc);
1.1 raeburn 3171: } else {
1.37 raeburn 3172: my $firstform = $phase;
3173: if ($phase eq 'courselist') {
3174: $firstform = 'filterpicker';
1.48 raeburn 3175: }
3176: my $choose_text;
3177: my $type = $env{'form.type'};
3178: if ($type eq '') {
3179: $type = 'Course';
3180: }
3181: if ($type eq 'Community') {
3182: $choose_text = "Choose a community";
1.81 raeburn 3183: } elsif ($type eq 'Placement') {
3184: $choose_text = "Choose a placement test";
1.48 raeburn 3185: } else {
3186: $choose_text = "Choose a course";
1.103 ! raeburn 3187: }
1.28 raeburn 3188: &Apache::lonhtmlcommon::add_breadcrumb
1.37 raeburn 3189: ({href=>"javascript:changePage(document.$firstform,'')",
1.48 raeburn 3190: text=>"Course/Community search"},
1.37 raeburn 3191: {href=>"javascript:changePage(document.$phase,'courselist')",
1.48 raeburn 3192: text=>$choose_text});
1.28 raeburn 3193: if ($phase eq 'courselist') {
1.90 raeburn 3194: &print_course_selection_page($r,$dom,$domdesc,$permission);
1.28 raeburn 3195: } else {
1.71 raeburn 3196: my ($checked,$cdesc,$coursehash) = &check_course($dom,$domdesc);
1.28 raeburn 3197: if ($checked eq 'ok') {
1.48 raeburn 3198: my $enter_text;
3199: if ($type eq 'Community') {
3200: $enter_text = 'Enter community';
1.81 raeburn 3201: } elsif ($type eq 'Placement') {
1.103 ! raeburn 3202: $enter_text = 'Enter placement test';
1.48 raeburn 3203: } else {
3204: $enter_text = 'Enter course';
3205: }
1.28 raeburn 3206: if ($phase eq 'menu') {
1.37 raeburn 3207: &Apache::lonhtmlcommon::add_breadcrumb
3208: ({href=>"javascript:changePage(document.$phase,'menu')",
3209: text=>"Pick action"});
1.71 raeburn 3210: &print_modification_menu($r,$cdesc,$domdesc,$dom,$type,
1.86 raeburn 3211: $env{'form.pickedcourse'},$coursehash,
3212: $permission);
3213: } elsif ($phase eq 'adhocrole') {
1.37 raeburn 3214: &Apache::lonhtmlcommon::add_breadcrumb
1.86 raeburn 3215: ({href=>"javascript:changePage(document.$phase,'adhocrole')",
1.48 raeburn 3216: text=>$enter_text});
1.90 raeburn 3217: &print_adhocrole_selected($r,$type,$permission);
1.28 raeburn 3218: } else {
1.37 raeburn 3219: &Apache::lonhtmlcommon::add_breadcrumb
3220: ({href=>"javascript:changePage(document.$phase,'menu')",
3221: text=>"Pick action"});
1.28 raeburn 3222: my ($cdom,$cnum) = split(/_/,$env{'form.pickedcourse'});
1.88 raeburn 3223: my ($readonly,$linktext);
3224: if ($permission->{$phase} eq 'view') {
1.103 ! raeburn 3225: $readonly = 1;
1.88 raeburn 3226: }
1.86 raeburn 3227: if (($phase eq 'setquota') && ($permission->{'setquota'})) {
1.88 raeburn 3228: if ($permission->{'setquota'} eq 'view') {
1.103 ! raeburn 3229: $linktext = 'Set quota';
1.88 raeburn 3230: } else {
3231: $linktext = 'Display quota';
3232: }
1.28 raeburn 3233: &Apache::lonhtmlcommon::add_breadcrumb
3234: ({href=>"javascript:changePage(document.$phase,'$phase')",
1.89 raeburn 3235: text=>$linktext});
1.88 raeburn 3236: &print_setquota($r,$cdom,$cnum,$cdesc,$type,$readonly);
1.103 ! raeburn 3237: } elsif (($phase eq 'processquota') && ($permission->{'processquota'})) {
1.28 raeburn 3238: &Apache::lonhtmlcommon::add_breadcrumb
3239: ({href=>"javascript:changePage(document.$phase,'setquota')",
3240: text=>"Set quota"});
3241: &Apache::lonhtmlcommon::add_breadcrumb
3242: ({href=>"javascript:changePage(document.$phase,'$phase')",
3243: text=>"Result"});
1.48 raeburn 3244: &modify_quota($r,$cdom,$cnum,$cdesc,$domdesc,$type);
1.86 raeburn 3245: } elsif (($phase eq 'setanon') && ($permission->{'setanon'})) {
1.57 raeburn 3246: &Apache::lonhtmlcommon::add_breadcrumb
3247: ({href=>"javascript:changePage(document.$phase,'$phase')",
3248: text=>"Threshold for anonymous submissions display"});
1.88 raeburn 3249: &print_set_anonsurvey_threshold($r,$cdom,$cnum,$cdesc,$type,$readonly);
1.86 raeburn 3250: } elsif (($phase eq 'processthreshold') && ($permission->{'processthreshold'})) {
1.57 raeburn 3251: &Apache::lonhtmlcommon::add_breadcrumb
3252: ({href=>"javascript:changePage(document.$phase,'setanon')",
3253: text=>"Threshold for anonymous submissions display"});
3254: &Apache::lonhtmlcommon::add_breadcrumb
3255: ({href=>"javascript:changePage(document.$phase,'$phase')",
3256: text=>"Result"});
3257: &modify_anonsurvey_threshold($r,$cdom,$cnum,$cdesc,$domdesc,$type);
1.86 raeburn 3258: } elsif (($phase eq 'setpostsubmit') && ($permission->{'setpostsubmit'})) {
1.88 raeburn 3259: if ($permission->{'setpostsubmit'} eq 'view') {
3260: $linktext = 'Submit button behavior post-submission';
3261: } else {
3262: $linktext = 'Configure submit button behavior post-submission';
3263: }
1.75 raeburn 3264: &Apache::lonhtmlcommon::add_breadcrumb
3265: ({href=>"javascript:changePage(document.$phase,'$phase')",
1.89 raeburn 3266: text=>$linktext});
1.88 raeburn 3267: &print_postsubmit_config($r,$cdom,$cnum,$cdesc,$type,$readonly);
1.86 raeburn 3268: } elsif (($phase eq 'processpostsubmit') && ($permission->{'processpostsubmit'})) {
1.75 raeburn 3269: &Apache::lonhtmlcommon::add_breadcrumb
3270: ({href=>"javascript:changePage(document.$phase,'$phase')",
3271: text=>"Result"});
3272: &modify_postsubmit_config($r,$cdom,$cnum,$cdesc,$domdesc,$type);
1.86 raeburn 3273: } elsif (($phase eq 'viewparms') && ($permission->{'viewparms'})) {
1.28 raeburn 3274: &Apache::lonhtmlcommon::add_breadcrumb
3275: ({href=>"javascript:changePage(document.$phase,'viewparms')",
3276: text=>"Display settings"});
1.86 raeburn 3277: &print_settings_display($r,$cdom,$cnum,$cdesc,$type,$permission);
3278: } elsif (($phase eq 'setparms') && ($permission->{'setparms'})) {
1.88 raeburn 3279: if ($permission->{'setparms'} eq 'view') {
3280: $linktext = 'Display settings';
3281: } else {
3282: $linktext = 'Change settings';
3283: }
1.28 raeburn 3284: &Apache::lonhtmlcommon::add_breadcrumb
3285: ({href=>"javascript:changePage(document.$phase,'$phase')",
1.89 raeburn 3286: text=>$linktext});
1.88 raeburn 3287: &print_course_modification_page($r,$cdom,$cnum,$cdesc,$type,$readonly);
1.86 raeburn 3288: } elsif (($phase eq 'processparms') && ($permission->{'processparms'})) {
1.28 raeburn 3289: &Apache::lonhtmlcommon::add_breadcrumb
3290: ({href=>"javascript:changePage(document.$phase,'setparms')",
3291: text=>"Change settings"});
3292: &Apache::lonhtmlcommon::add_breadcrumb
3293: ({href=>"javascript:changePage(document.$phase,'$phase')",
3294: text=>"Result"});
1.30 raeburn 3295: &modify_course($r,$cdom,$cnum,$cdesc,$domdesc,$type);
1.86 raeburn 3296: } elsif (($phase eq 'catsettings') && ($permission->{'catsettings'})) {
1.38 raeburn 3297: &Apache::lonhtmlcommon::add_breadcrumb
3298: ({href=>"javascript:changePage(document.$phase,'$phase')",
3299: text=>"Catalog settings"});
1.88 raeburn 3300: &print_catsettings($r,$cdom,$cnum,$cdesc,$type,$readonly);
1.86 raeburn 3301: } elsif (($phase eq 'processcat') && ($permission->{'processcat'})) {
1.38 raeburn 3302: &Apache::lonhtmlcommon::add_breadcrumb
3303: ({href=>"javascript:changePage(document.$phase,'catsettings')",
3304: text=>"Catalog settings"});
3305: &Apache::lonhtmlcommon::add_breadcrumb
3306: ({href=>"javascript:changePage(document.$phase,'$phase')",
3307: text=>"Result"});
1.48 raeburn 3308: &modify_catsettings($r,$cdom,$cnum,$cdesc,$domdesc,$type);
1.86 raeburn 3309: } elsif (($phase eq 'selfenroll') && ($permission->{'selfenroll'})) {
1.72 raeburn 3310: &Apache::lonhtmlcommon::add_breadcrumb
3311: ({href => "javascript:changePage(document.$phase,'$phase')",
3312: text => "Self-enrollment settings"});
3313: if (!exists($env{'form.state'})) {
1.88 raeburn 3314: &print_selfenrollconfig($r,$type,$cdesc,$coursehash,$readonly);
1.72 raeburn 3315: } elsif ($env{'form.state'} eq 'done') {
1.103 ! raeburn 3316: &Apache::lonhtmlcommon::add_breadcrumb
1.72 raeburn 3317: ({href=>"javascript:changePage(document.$phase,'$phase')",
3318: text=>"Result"});
3319: &modify_selfenrollconfig($r,$type,$cdesc,$coursehash);
3320: }
1.97 raeburn 3321: } elsif (($phase eq 'setltiauth') && ($permission->{'setltiauth'})) {
3322: &Apache::lonhtmlcommon::add_breadcrumb
3323: ({href=>"javascript:changePage(document.$phase,'$phase')",
3324: text=>"Requirement for re-authentication for LTI launch of deep-linked item"});
3325: &print_set_ltiauth($r,$cdom,$cnum,$cdesc,$type,$readonly);
3326: } elsif (($phase eq 'processltiauth') && ($permission->{'processltiauth'})) {
3327: &Apache::lonhtmlcommon::add_breadcrumb
3328: ({href=>"javascript:changePage(document.$phase,'setltiauth')",
1.99 raeburn 3329: text=>"Requirement for re-authentication for LTI launch of deep-linked item"},
3330: {href=>"javascript:changePage(document.$phase,'$phase')",
3331: text=>"Result"});
3332: &modify_ltiauth($r,$cdom,$cnum,$cdesc,$domdesc,$type);
3333: } elsif (($phase eq 'setexttool') && ($permission->{'setexttool'})) {
1.97 raeburn 3334: &Apache::lonhtmlcommon::add_breadcrumb
3335: ({href=>"javascript:changePage(document.$phase,'$phase')",
1.99 raeburn 3336: text=>"External Tool permission"});
3337: &print_set_exttool($r,$cdom,$cnum,$cdesc,$type,$readonly);
3338: } elsif (($phase eq 'processexttool') && ($permission->{'processexttool'})) {
3339: &Apache::lonhtmlcommon::add_breadcrumb
3340: ({href=>"javascript:changePage(document.$phase,'setexttool')",
3341: text=>"External Tool permission"},
3342: {href=>"javascript:changePage(document.$phase,'$phase')",
1.97 raeburn 3343: text=>"Result"});
1.99 raeburn 3344: &modify_exttool($r,$cdom,$cnum,$cdesc,$domdesc,$type);
1.28 raeburn 3345: }
3346: }
3347: } else {
1.48 raeburn 3348: $r->print('<span class="LC_error">');
3349: if ($type eq 'Community') {
1.72 raeburn 3350: $r->print(&mt('The community you selected is not a valid community in this domain'));
1.81 raeburn 3351: } elsif ($type eq 'Placement') {
3352: $r->print(&mt('The course you selected is not a valid placement test in this domain'));
1.72 raeburn 3353: } else {
1.48 raeburn 3354: $r->print(&mt('The course you selected is not a valid course in this domain'));
3355: }
3356: $r->print(" ($domdesc)</span>");
1.28 raeburn 3357: }
3358: }
1.1 raeburn 3359: }
1.28 raeburn 3360: &print_footer($r);
1.1 raeburn 3361: } else {
1.16 albertel 3362: $env{'user.error.msg'}=
1.48 raeburn 3363: "/adm/modifycourse:ccc:0:0:Cannot modify course/community settings";
1.1 raeburn 3364: return HTTP_NOT_ACCEPTABLE;
3365: }
3366: return OK;
3367: }
3368:
3369: 1;
3370: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>