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