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