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