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