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