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