Annotation of loncom/interface/lonmodifycourse.pm, revision 1.92
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.92 ! raeburn 4: # $Id: lonmodifycourse.pm,v 1.91 2017/01/22 19:22:04 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';
1280: }
1.2 raeburn 1281: }
1282: unless ($curr_authtype eq '') {
1283: $curr_authfield = $curr_authtype.'arg';
1.33 raeburn 1284: }
1.48 raeburn 1285: my $javascript_validations =
1286: &Apache::lonuserutils::javascript_validations('modifycourse',$krbdefdom,
1287: $curr_authtype,$curr_authfield);
1.35 raeburn 1288: my %param = ( formname => 'document.'.$env{'form.phase'},
1.48 raeburn 1289: kerb_def_dom => $krbdefdom,
1290: kerb_def_auth => $krbdef,
1.2 raeburn 1291: mode => 'modifycourse',
1292: curr_authtype => $curr_authtype,
1.88 raeburn 1293: curr_autharg => $enrollvar->{'autharg'},
1294: readonly => $readonly,
1.48 raeburn 1295: );
1.32 raeburn 1296: my (%authform,$authenitems);
1297: $authform{'krb'} = &Apache::loncommon::authform_kerberos(%param);
1298: $authform{'int'} = &Apache::loncommon::authform_internal(%param);
1299: $authform{'loc'} = &Apache::loncommon::authform_local(%param);
1300: foreach my $item ('krb','int','loc') {
1301: if ($authform{$item} ne '') {
1302: $authenitems .= $authform{$item}.'<br />';
1303: }
1.1 raeburn 1304: }
1.48 raeburn 1305: return($javascript_validations,$authenitems);
1.1 raeburn 1306: }
1307:
1308: sub modify_course {
1.30 raeburn 1309: my ($r,$cdom,$cnum,$cdesc,$domdesc,$type) = @_;
1.48 raeburn 1310: my %longtype = &course_settings_descrip($type);
1.50 raeburn 1311: my @items = ('internal.courseowner','description','internal.co-owners',
1.72 raeburn 1312: 'internal.pendingco-owners','internal.selfenrollmgrdc',
1.85 raeburn 1313: 'internal.selfenrollmgrcc','internal.mysqltables');
1.72 raeburn 1314: my ($selfenrollrows,$selfenrolltitles) = &Apache::lonuserutils::get_selfenroll_titles();
1.81 raeburn 1315: unless (($type eq 'Community') || ($type eq 'Placement')) {
1.48 raeburn 1316: push(@items,('internal.coursecode','internal.authtype','internal.autharg',
1317: 'internal.sectionnums','internal.crosslistings'));
1.60 raeburn 1318: if (&showcredits($cdom)) {
1319: push(@items,'internal.defaultcredits');
1320: }
1.1 raeburn 1321: }
1.48 raeburn 1322: my %settings = &Apache::lonnet::get('environment',\@items,$cdom,$cnum);
1323: my $description = $settings{'description'};
1.60 raeburn 1324: my ($ccrole,$response,$chgresponse,$nochgresponse,$reply,%currattr,%newattr,
1325: %cenv,%changed,@changes,@nochanges,@sections,@xlists,@warnings);
1326: my @modifiable_params = &get_dc_settable($type,$cdom);
1.28 raeburn 1327: foreach my $param (@modifiable_params) {
1.48 raeburn 1328: $currattr{$param} = $settings{'internal.'.$param};
1.1 raeburn 1329: }
1.48 raeburn 1330: if ($type eq 'Community') {
1331: %changed = ( owner => 0 );
1332: $ccrole = 'co';
1333: } else {
1334: %changed = ( code => 0,
1335: owner => 0,
1336: );
1337: $ccrole = 'cc';
1338: unless ($settings{'internal.sectionnums'} eq '') {
1339: if ($settings{'internal.sectionnums'} =~ m/,/) {
1340: @sections = split/,/,$settings{'internal.sectionnums'};
1341: } else {
1342: $sections[0] = $settings{'internal.sectionnums'};
1343: }
1344: }
1.60 raeburn 1345: unless ($settings{'internal.crosslistings'} eq '') {
1.48 raeburn 1346: if ($settings{'internal.crosslistings'} =~ m/,/) {
1347: @xlists = split/,/,$settings{'internal.crosslistings'};
1348: } else {
1349: $xlists[0] = $settings{'internal.crosslistings'};
1350: }
1351: }
1352: if ($env{'form.login'} eq 'krb') {
1353: $newattr{'authtype'} = $env{'form.login'};
1354: $newattr{'authtype'} .= $env{'form.krbver'};
1355: $newattr{'autharg'} = $env{'form.krbarg'};
1356: } elsif ($env{'form.login'} eq 'int') {
1357: $newattr{'authtype'} ='internal';
1358: if ((defined($env{'form.intarg'})) && ($env{'form.intarg'})) {
1359: $newattr{'autharg'} = $env{'form.intarg'};
1360: }
1361: } elsif ($env{'form.login'} eq 'loc') {
1362: $newattr{'authtype'} = 'localauth';
1363: if ((defined($env{'form.locarg'})) && ($env{'form.locarg'})) {
1364: $newattr{'autharg'} = $env{'form.locarg'};
1365: }
1366: }
1367: if ( $newattr{'authtype'}=~ /^krb/) {
1368: if ($newattr{'autharg'} eq '') {
1369: push(@warnings,
1370: &mt('As you did not include the default Kerberos domain'
1.45 bisitz 1371: .' to be used for authentication in this class, the'
1372: .' institutional data used by the automated'
1373: .' enrollment process must include the Kerberos'
1.48 raeburn 1374: .' domain for each new student.'));
1375: }
1376: }
1377:
1378: if ( exists($env{'form.coursecode'}) ) {
1379: $newattr{'coursecode'}=$env{'form.coursecode'};
1380: unless ( $newattr{'coursecode'} eq $currattr{'coursecode'} ) {
1381: $changed{'code'} = 1;
1382: }
1.1 raeburn 1383: }
1.85 raeburn 1384: if ( exists($env{'form.mysqltables'}) ) {
1385: $newattr{'mysqltables'} = $env{'form.mysqltables'};
1386: $newattr{'mysqltables'} =~ s/\D+//g;
1387: }
1.83 raeburn 1388: if (($type ne 'Placement') && (&showcredits($cdom) && exists($env{'form.defaultcredits'}))) {
1.85 raeburn 1389: $newattr{'defaultcredits'}=$env{'form.defaultcredits'};
1.60 raeburn 1390: $newattr{'defaultcredits'} =~ s/[^\d\.]//g;
1391: }
1.72 raeburn 1392: }
1393:
1394: my @newmgrdc = ();
1395: my @newmgrcc = ();
1396: my @currmgrdc = split(/,/,$currattr{'selfenrollmgrdc'});
1397: my @currmgrcc = split(/,/,$currattr{'selfenrollmgrcc'});
1.60 raeburn 1398:
1.72 raeburn 1399: foreach my $item (@{$selfenrollrows}) {
1400: if ($env{'form.selfenrollmgr_'.$item} eq '0') {
1401: push(@newmgrdc,$item);
1402: } elsif ($env{'form.selfenrollmgr_'.$item} eq '1') {
1403: push(@newmgrcc,$item);
1404: }
1405: }
1406:
1407: $newattr{'selfenrollmgrdc'}=join(',',@newmgrdc);
1408: $newattr{'selfenrollmgrcc'}=join(',',@newmgrcc);
1409:
1410: my $cctitle;
1411: if ($type eq 'Community') {
1412: $cctitle = &mt('Community personnel');
1413: } else {
1414: $cctitle = &mt('Course personnel');
1.1 raeburn 1415: }
1.72 raeburn 1416: my $dctitle = &Apache::lonnet::plaintext('dc');
1.1 raeburn 1417:
1.16 albertel 1418: if ( exists($env{'form.courseowner'}) ) {
1419: $newattr{'courseowner'}=$env{'form.courseowner'};
1.14 raeburn 1420: unless ( $newattr{'courseowner'} eq $currattr{'courseowner'} ) {
1.38 raeburn 1421: $changed{'owner'} = 1;
1.1 raeburn 1422: }
1423: }
1.48 raeburn 1424:
1.50 raeburn 1425: if ($changed{'owner'} || $changed{'code'}) {
1.38 raeburn 1426: my %crsinfo = &Apache::lonnet::courseiddump($cdom,'.',1,'.','.',$cnum,
1427: undef,undef,'.');
1428: if (ref($crsinfo{$env{'form.pickedcourse'}}) eq 'HASH') {
1.48 raeburn 1429: if ($changed{'code'}) {
1430: $crsinfo{$env{'form.pickedcourse'}}{'inst_code'} = $env{'form.coursecode'};
1431: }
1432: if ($changed{'owner'}) {
1433: $crsinfo{$env{'form.pickedcourse'}}{'owner'} = $env{'form.courseowner'};
1434: }
1.38 raeburn 1435: my $chome = &Apache::lonnet::homeserver($cnum,$cdom);
1436: my $putres = &Apache::lonnet::courseidput($cdom,\%crsinfo,$chome,'notime');
1.50 raeburn 1437: if ($putres eq 'ok') {
1438: &update_coowners($cdom,$cnum,$chome,\%settings,\%newattr);
1439: }
1.38 raeburn 1440: }
1.14 raeburn 1441: }
1.28 raeburn 1442: foreach my $param (@modifiable_params) {
1443: if ($currattr{$param} eq $newattr{$param}) {
1444: push(@nochanges,$param);
1.1 raeburn 1445: } else {
1.48 raeburn 1446: $cenv{'internal.'.$param} = $newattr{$param};
1.28 raeburn 1447: push(@changes,$param);
1.1 raeburn 1448: }
1449: }
1450: if (@changes > 0) {
1.62 bisitz 1451: $chgresponse = &mt('The following settings have been changed:').'<br/><ul>';
1.1 raeburn 1452: }
1.48 raeburn 1453: if (@nochanges > 0) {
1.62 bisitz 1454: $nochgresponse = &mt('The following settings remain unchanged:').'<br/><ul>';
1.1 raeburn 1455: }
1.33 raeburn 1456: if (@changes > 0) {
1.28 raeburn 1457: my $putreply = &Apache::lonnet::put('environment',\%cenv,$cdom,$cnum);
1.1 raeburn 1458: if ($putreply !~ /^ok$/) {
1.48 raeburn 1459: $response = '<p class="LC_error">'.
1460: &mt('There was a problem processing your requested changes.').'<br />';
1461: if ($type eq 'Community') {
1462: $response .= &mt('Settings for this community have been left unchanged.');
1463: } else {
1464: $response .= &mt('Settings for this course have been left unchanged.');
1465: }
1466: $response .= '<br/>'.&mt('Error: ').$putreply.'</p>';
1.1 raeburn 1467: } else {
1.72 raeburn 1468: if ($env{'course.'.$cdom.'_'.$cnum.'.description'} ne '') {
1469: my %newenv;
1470: map { $newenv{'course.'.$cdom.'_'.$cnum.'.internal.'.$_} = $newattr{$_}; } @changes;
1471: &Apache::lonnet::appenv(\%newenv);
1472: }
1.28 raeburn 1473: foreach my $attr (@modifiable_params) {
1.48 raeburn 1474: if (grep/^\Q$attr\E$/,@changes) {
1.72 raeburn 1475: my $shown = $newattr{$attr};
1476: if ($attr eq 'selfenrollmgrdc') {
1477: $shown = &selfenroll_config_status(\@newmgrdc,$selfenrolltitles);
1478: } elsif ($attr eq 'selfenrollmgrcc') {
1479: $shown = &selfenroll_config_status(\@newmgrcc,$selfenrolltitles);
1480: } elsif (($attr eq 'defaultcredits') && ($shown eq '')) {
1481: $shown = &mt('None');
1.85 raeburn 1482: } elsif (($attr eq 'mysqltables') && ($shown eq '')) {
1483: $shown = &mt('domain default');
1.72 raeburn 1484: }
1485: $chgresponse .= '<li>'.&mt('[_1] now set to: [_2]',$longtype{$attr},$shown).'</li>';
1.1 raeburn 1486: } else {
1.72 raeburn 1487: my $shown = $currattr{$attr};
1488: if ($attr eq 'selfenrollmgrdc') {
1489: $shown = &selfenroll_config_status(\@currmgrdc,$selfenrolltitles);
1490: } elsif ($attr eq 'selfenrollmgrcc') {
1491: $shown = &selfenroll_config_status(\@currmgrcc,$selfenrolltitles);
1492: } elsif (($attr eq 'defaultcredits') && ($shown eq '')) {
1493: $shown = &mt('None');
1.85 raeburn 1494: } elsif (($attr eq 'mysqltables') && ($shown eq '')) {
1495: $shown = &mt('domain default');
1.72 raeburn 1496: }
1497: $nochgresponse .= '<li>'.&mt('[_1] still set to: [_2]',$longtype{$attr},$shown).'</li>';
1.1 raeburn 1498: }
1499: }
1.81 raeburn 1500: if (($type ne 'Community') && ($type ne 'Placement') && ($changed{'code'} || $changed{'owner'})) {
1.1 raeburn 1501: if ( $newattr{'courseowner'} eq '') {
1.48 raeburn 1502: push(@warnings,&mt('There is no owner associated with this LON-CAPA course.').
1503: '<br />'.&mt('If automated enrollment at your institution requires validation of course owners, automated enrollment will fail.'));
1.1 raeburn 1504: } else {
1.59 raeburn 1505: my %crsenv = &Apache::lonnet::get('environment',['internal.co-owners'],$cdom,$cnum);
1506: my $coowners = $crsenv{'internal.co-owners'};
1.1 raeburn 1507: if (@sections > 0) {
1.38 raeburn 1508: if ($changed{'code'}) {
1.2 raeburn 1509: foreach my $sec (@sections) {
1510: if ($sec =~ m/^(.+):/) {
1.48 raeburn 1511: my $instsec = $1;
1.8 raeburn 1512: my $inst_course_id = $newattr{'coursecode'}.$1;
1.28 raeburn 1513: my $course_check = &Apache::lonnet::auto_validate_courseID($cnum,$cdom,$inst_course_id);
1.7 raeburn 1514: if ($course_check eq 'ok') {
1.58 raeburn 1515: my $outcome = &Apache::lonnet::auto_new_course($cnum,$cdom,$inst_course_id,$newattr{'courseowner'},$coowners);
1.48 raeburn 1516: unless ($outcome eq 'ok') {
1517:
1.53 raeburn 1518: 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 1519: }
1520: } else {
1.53 raeburn 1521: 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 1522: }
1523: } else {
1.48 raeburn 1524: 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 1525: }
1526: }
1.38 raeburn 1527: } elsif ($changed{'owner'}) {
1.4 raeburn 1528: foreach my $sec (@sections) {
1529: if ($sec =~ m/^(.+):/) {
1.48 raeburn 1530: my $instsec = $1;
1531: my $inst_course_id = $newattr{'coursecode'}.$instsec;
1.58 raeburn 1532: my $outcome = &Apache::lonnet::auto_new_course($cnum,$cdom,$inst_course_id,$newattr{'courseowner'},$coowners);
1.4 raeburn 1533: unless ($outcome eq 'ok') {
1.53 raeburn 1534: 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 1535: }
1536: } else {
1.53 raeburn 1537: 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 1538: }
1539: }
1540: }
1.1 raeburn 1541: } else {
1.53 raeburn 1542: 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 1543: }
1.38 raeburn 1544: if ( (@xlists > 0) && ($changed{'owner'}) ) {
1.1 raeburn 1545: foreach my $xlist (@xlists) {
1546: if ($xlist =~ m/^(.+):/) {
1.48 raeburn 1547: my $instxlist = $1;
1.58 raeburn 1548: my $outcome = &Apache::lonnet::auto_new_course($cnum,$cdom,$instxlist,$newattr{'courseowner'},$coowners);
1.1 raeburn 1549: unless ($outcome eq 'ok') {
1.48 raeburn 1550: 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 1551: }
1.28 raeburn 1552: }
1.1 raeburn 1553: }
1554: }
1555: }
1556: }
1557: }
1.2 raeburn 1558: } else {
1.28 raeburn 1559: foreach my $attr (@modifiable_params) {
1.72 raeburn 1560: my $shown = $currattr{$attr};
1561: if ($attr eq 'selfenrollmgrdc') {
1562: $shown = &selfenroll_config_status(\@currmgrdc,$selfenrolltitles);
1563: } elsif ($attr eq 'selfenrollmgrcc') {
1564: $shown = &selfenroll_config_status(\@currmgrcc,$selfenrolltitles);
1565: } elsif (($attr eq 'defaultcredits') && ($shown eq '')) {
1566: $shown = &mt('None');
1.85 raeburn 1567: } elsif (($attr eq 'mysqltables') && ($shown eq '')) {
1568: $shown = &mt('domain default');
1.72 raeburn 1569: }
1570: $nochgresponse .= '<li>'.&mt('[_1] still set to: [_2]',$longtype{$attr},$shown).'</li>';
1.2 raeburn 1571: }
1.1 raeburn 1572: }
1573:
1574: if (@changes > 0) {
1575: $chgresponse .= "</ul><br/><br/>";
1576: }
1577: if (@nochanges > 0) {
1578: $nochgresponse .= "</ul><br/><br/>";
1579: }
1.48 raeburn 1580: my ($warning,$numwarnings);
1581: my $numwarnings = scalar(@warnings);
1582: if ($numwarnings) {
1583: $warning = &mt('The following [quant,_1,warning was,warnings were] generated when applying your changes to automated enrollment:',$numwarnings).'<p><ul>';
1584: foreach my $warn (@warnings) {
1585: $warning .= '<li><span class="LC_warning">'.$warn.'</span></li>';
1586: }
1587: $warning .= '</ul></p>';
1.1 raeburn 1588: }
1.48 raeburn 1589: if ($response) {
1590: $reply = $response;
1591: } else {
1.1 raeburn 1592: $reply = $chgresponse.$nochgresponse.$warning;
1593: }
1.48 raeburn 1594: &print_header($r,$type);
1595: my $mainheader = &modifiable_only_title($type);
1596: $reply = '<h3>'.$mainheader.' <span class="LC_nobreak">'.$cdesc.'</span></h3>'."\n".
1597: '<p>'.$reply.'</p>'."\n".
1.28 raeburn 1598: '<form action="/adm/modifycourse" method="post" name="processparms">'.
1.66 bisitz 1599: &hidden_form_elements();
1600: my @actions =
1601: ('<a href="javascript:changePage(document.processparms,'."'menu'".')">'.
1602: &mt('Pick another action').'</a>');
1.48 raeburn 1603: if ($numwarnings) {
1604: my $newrole = $ccrole.'./'.$cdom.'/'.$cnum;
1605: my $escuri = &HTML::Entities::encode('/adm/roles?selectrole=1&'.$newrole.
1606: '=1&destinationurl=/adm/populate','&<>"');
1607:
1.66 bisitz 1608: push(@actions, '<a href="'.$escuri.'">'.
1609: &mt('Go to Automated Enrollment Manager for course').'</a>');
1.48 raeburn 1610: }
1.66 bisitz 1611: $reply .= &Apache::lonhtmlcommon::actionbox(\@actions).'</form>';
1.3 raeburn 1612: $r->print($reply);
1.28 raeburn 1613: return;
1614: }
1615:
1.72 raeburn 1616: sub selfenroll_config_status {
1617: my ($items,$selfenrolltitles) = @_;
1618: my $shown;
1619: if ((ref($items) eq 'ARRAY') && (ref($selfenrolltitles) eq 'HASH')) {
1620: if (@{$items} > 0) {
1621: $shown = '<ul>';
1622: foreach my $item (@{$items}) {
1623: $shown .= '<li>'.$selfenrolltitles->{$item}.'</li>';
1624: }
1625: $shown .= '</ul>';
1626: } else {
1627: $shown = &mt('None');
1628: }
1629: }
1630: return $shown;
1631: }
1632:
1.50 raeburn 1633: sub update_coowners {
1634: my ($cdom,$cnum,$chome,$settings,$newattr) = @_;
1635: return unless ((ref($settings) eq 'HASH') && (ref($newattr) eq 'HASH'));
1636: my %designhash = &Apache::loncommon::get_domainconf($cdom);
1637: my (%cchash,$autocoowners);
1638: if ($designhash{$cdom.'.autoassign.co-owners'}) {
1639: $autocoowners = 1;
1640: %cchash = &Apache::lonnet::get_my_roles($cnum,$cdom,undef,undef,['cc']);
1641: }
1642: if ($settings->{'internal.courseowner'} ne $newattr->{'courseowner'}) {
1643: my $oldowner_to_coowner;
1.51 raeburn 1644: my @types = ('co-owners');
1.50 raeburn 1645: if (($newattr->{'coursecode'}) && ($autocoowners)) {
1646: my $oldowner = $settings->{'internal.courseowner'};
1647: if ($cchash{$oldowner.':cc'}) {
1.51 raeburn 1648: my ($result,$desc) = &Apache::lonnet::auto_validate_instcode($cnum,$cdom,$newattr->{'coursecode'},$oldowner);
1649: if ($result eq 'valid') {
1650: if ($settings->{'internal.co-owner'}) {
1651: my @current = split(',',$settings->{'internal.co-owners'});
1652: unless (grep(/^\Q$oldowner\E$/,@current)) {
1653: $oldowner_to_coowner = 1;
1654: }
1655: } else {
1.50 raeburn 1656: $oldowner_to_coowner = 1;
1657: }
1658: }
1659: }
1.51 raeburn 1660: } else {
1661: push(@types,'pendingco-owners');
1.50 raeburn 1662: }
1.51 raeburn 1663: foreach my $type (@types) {
1.50 raeburn 1664: if ($settings->{'internal.'.$type}) {
1665: my @current = split(',',$settings->{'internal.'.$type});
1666: my $newowner = $newattr->{'courseowner'};
1667: my @newvalues = ();
1668: if (($newowner ne '') && (grep(/^\Q$newowner\E$/,@current))) {
1669: foreach my $person (@current) {
1670: unless ($person eq $newowner) {
1671: push(@newvalues,$person);
1672: }
1673: }
1674: } else {
1675: @newvalues = @current;
1676: }
1677: if ($oldowner_to_coowner) {
1678: push(@newvalues,$settings->{'internal.courseowner'});
1679: @newvalues = sort(@newvalues);
1680: }
1681: my $newownstr = join(',',@newvalues);
1682: if ($newownstr ne $settings->{'internal.'.$type}) {
1683: if ($type eq 'co-owners') {
1684: my $deleted = '';
1685: unless (@newvalues) {
1686: $deleted = 1;
1687: }
1688: &Apache::lonnet::store_coowners($cdom,$cnum,$chome,
1689: $deleted,@newvalues);
1690: } else {
1691: my $pendingcoowners;
1692: my $cid = $cdom.'_'.$cnum;
1693: if (@newvalues) {
1694: $pendingcoowners = join(',',@newvalues);
1695: my %pendinghash = (
1696: 'internal.pendingco-owners' => $pendingcoowners,
1697: );
1.52 raeburn 1698: my $putresult = &Apache::lonnet::put('environment',\%pendinghash,$cdom,$cnum);
1.50 raeburn 1699: if ($putresult eq 'ok') {
1700: if ($env{'course.'.$cid.'.num'} eq $cnum) {
1.52 raeburn 1701: &Apache::lonnet::appenv({'course.'.$cid.'.internal.pendingco-owners' => $pendingcoowners});
1.50 raeburn 1702: }
1703: }
1704: } else {
1705: my $delresult = &Apache::lonnet::del('environment',['internal.pendingco-owners'],$cdom,$cnum);
1706: if ($delresult eq 'ok') {
1707: if ($env{'course.'.$cid.'.internal.pendingco-owners'}) {
1708: &Apache::lonnet::delenv('course.'.$cid.'.internal.pendingco-owners');
1709: }
1710: }
1711: }
1712: }
1713: } elsif ($oldowner_to_coowner) {
1714: &Apache::lonnet::store_coowners($cdom,$cnum,$chome,'',
1715: $settings->{'internal.courseowner'});
1716:
1717: }
1718: } elsif ($oldowner_to_coowner) {
1719: &Apache::lonnet::store_coowners($cdom,$cnum,$chome,'',
1720: $settings->{'internal.courseowner'});
1721: }
1722: }
1723: }
1724: if ($settings->{'internal.coursecode'} ne $newattr->{'coursecode'}) {
1725: if ($newattr->{'coursecode'} ne '') {
1726: my %designhash = &Apache::loncommon::get_domainconf($cdom);
1727: if ($designhash{$cdom.'.autoassign.co-owners'}) {
1728: my @newcoowners = ();
1729: if ($settings->{'internal.co-owners'}) {
1.58 raeburn 1730: my @currcoown = split(',',$settings->{'internal.co-owners'});
1.50 raeburn 1731: my ($updatecoowners,$delcoowners);
1732: foreach my $person (@currcoown) {
1.51 raeburn 1733: my ($result,$desc) = &Apache::lonnet::auto_validate_instcode($cnum,$cdom,$newattr->{'coursecode'},$person);
1.50 raeburn 1734: if ($result eq 'valid') {
1735: push(@newcoowners,$person);
1736: }
1737: }
1738: foreach my $item (sort(keys(%cchash))) {
1739: my ($uname,$udom,$urole) = split(':',$item);
1.51 raeburn 1740: next if ($uname.':'.$udom eq $newattr->{'courseowner'});
1.50 raeburn 1741: unless (grep(/^\Q$uname\E:\Q$udom\E$/,@newcoowners)) {
1.51 raeburn 1742: my ($result,$desc) = &Apache::lonnet::auto_validate_instcode($cnum,$cdom,$newattr->{'coursecode'},$uname.':'.$udom);
1743: if ($result eq 'valid') {
1744: push(@newcoowners,$uname.':'.$udom);
1745: }
1.50 raeburn 1746: }
1747: }
1748: if (@newcoowners) {
1749: my $coowners = join(',',sort(@newcoowners));
1750: unless ($coowners eq $settings->{'internal.co-owners'}) {
1751: $updatecoowners = 1;
1752: }
1753: } else {
1754: $delcoowners = 1;
1755: }
1756: if ($updatecoowners || $delcoowners) {
1757: &Apache::lonnet::store_coowners($cdom,$cnum,$chome,
1758: $delcoowners,@newcoowners);
1759: }
1760: } else {
1761: foreach my $item (sort(keys(%cchash))) {
1762: my ($uname,$udom,$urole) = split(':',$item);
1763: push(@newcoowners,$uname.':'.$udom);
1764: }
1765: if (@newcoowners) {
1766: &Apache::lonnet::store_coowners($cdom,$cnum,$chome,'',
1767: @newcoowners);
1768: }
1769: }
1770: }
1771: }
1772: }
1773: return;
1774: }
1775:
1.28 raeburn 1776: sub modify_quota {
1.48 raeburn 1777: my ($r,$cdom,$cnum,$cdesc,$domdesc,$type) = @_;
1778: &print_header($r,$type);
1.61 raeburn 1779: my $lctype = lc($type);
1780: my $headline = &mt("Disk space quotas for $lctype: [_1]",
1781: '<span class="LC_nobreak">'.$cdesc.'</span>');
1.48 raeburn 1782: $r->print('<form action="/adm/modifycourse" method="post" name="processquota">'."\n".
1.61 raeburn 1783: '<h3>'.$headline.'</h3>');
1784: my %oldsettings = &Apache::lonnet::get('environment',['internal.coursequota','internal.uploadquota'],$cdom,$cnum);
1785: my %staticdefaults = (
1786: coursequota => 20,
1787: uploadquota => 500,
1788: );
1789: my %default;
1790: $default{'coursequota'} = $staticdefaults{'coursequota'};
1791: my %domdefs = &Apache::lonnet::get_domain_defaults($cdom);
1792: $default{'uploadquota'} = $domdefs{'uploadquota'};
1793: if ($default{'uploadquota'} eq '') {
1794: $default{'uploadquota'} = $staticdefaults{'uploadquota'};
1795: }
1796: my (%cenv,%showresult);
1797: foreach my $item ('coursequota','uploadquota') {
1798: if ($env{'form.'.$item} ne '') {
1799: my $newquota = $env{'form.'.$item};
1800: if ($newquota =~ /^\s*(\d+\.?\d*|\.\d+)\s*$/) {
1801: $newquota = $1;
1802: if ($oldsettings{'internal.'.$item} == $newquota) {
1803: if ($item eq 'coursequota') {
1804: $r->print(&mt('The disk space allocated for group portfolio files remains unchanged as [_1] MB.',$newquota).'<br />');
1805: } else {
1806: $r->print(&mt('The disk space allocated for files uploaded via the Content Editor remains unchanged as [_1] MB.',$newquota).'<br />');
1807: }
1808: } else {
1809: $cenv{'internal.'.$item} = $newquota;
1810: $showresult{$item} = 1;
1811: }
1.28 raeburn 1812: } else {
1.61 raeburn 1813: if ($item eq 'coursequota') {
1814: $r->print(&mt('The proposed group portfolio quota contained invalid characters, so the quota is unchanged.').'<br />');
1815: } else {
1816: $r->print(&mt('The proposed quota for content uploaded via the Content Editor contained invalid characters, so the quota is unchanged.').'<br />');
1817:
1818: }
1819: }
1820: }
1821: }
1822: if (keys(%cenv)) {
1823: my $putreply = &Apache::lonnet::put('environment',\%cenv,$cdom,
1824: $cnum);
1825: foreach my $key (sort(keys(%showresult))) {
1826: if (($oldsettings{'internal.'.$key} eq '') &&
1827: ($env{'form.'.$key} == $default{$key})) {
1828: if ($key eq 'uploadquota') {
1829: if ($type eq 'Community') {
1830: $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.',
1831: $default{$key}).'<br />');
1832: } else {
1833: $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.',
1834: $default{$key}).'<br />');
1835: }
1836: } else {
1.48 raeburn 1837: if ($type eq 'Community') {
1.61 raeburn 1838: $r->print(&mt('The disk space allocated for group portfolio files in this community is the default quota for this domain: [_1] MB.',
1839: $default{$key}).'<br />');
1.48 raeburn 1840: } else {
1.61 raeburn 1841: $r->print(&mt('The disk space allocated for group portfolio files in this course is the default quota for this domain: [_1] MB.',
1842: $default{$key}).'<br />');
1.48 raeburn 1843: }
1.61 raeburn 1844: }
1845: delete($showresult{$key});
1846: }
1847: }
1848: if ($putreply eq 'ok') {
1849: my %updatedsettings = &Apache::lonnet::get('environment',['internal.coursequota','internal.uploadquota'],$cdom,$cnum);
1850: if ($showresult{'coursequota'}) {
1851: $r->print(&mt('The disk space allocated for group portfolio files is now: [_1] MB.',
1852: '<b>'.$updatedsettings{'internal.coursequota'}.'</b>').'<br />');
1853: my $usage = &Apache::longroup::sum_quotas($cdom.'_'.$cnum);
1854: if ($usage >= $updatedsettings{'internal.coursequota'}) {
1855: my $newoverquota;
1856: if ($usage < $oldsettings{'internal.coursequota'}) {
1857: $newoverquota = 'now';
1858: }
1859: $r->print('<p>');
1860: if ($type eq 'Community') {
1.67 bisitz 1861: $r->print(&mt("Disk usage $newoverquota exceeds the quota for this community.").' '.
1.61 raeburn 1862: &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 1863: } else {
1.67 bisitz 1864: $r->print(&mt("Disk usage $newoverquota exceeds the quota for this course.").' '.
1.61 raeburn 1865: &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 1866: }
1.61 raeburn 1867: $r->print('</p>');
1.28 raeburn 1868: }
1869: }
1.61 raeburn 1870: if ($showresult{'uploadquota'}) {
1871: $r->print(&mt('The disk space allocated for content uploaded directly via the Content Editor is now: [_1] MB.',
1872: '<b>'.$updatedsettings{'internal.uploadquota'}.'</b>').'<br />');
1873: }
1.28 raeburn 1874: } else {
1.63 raeburn 1875: $r->print(&mt('An error occurred storing the quota(s) for group portfolio files and/or uploaded content: ').
1.61 raeburn 1876: $putreply);
1.28 raeburn 1877: }
1878: }
1.48 raeburn 1879: $r->print('<p>'.
1880: '<a href="javascript:changePage(document.processquota,'."'menu'".')">'.
1881: &mt('Pick another action').'</a>');
1.28 raeburn 1882: $r->print(&hidden_form_elements().'</form>');
1883: return;
1.1 raeburn 1884: }
1885:
1.57 raeburn 1886: sub modify_anonsurvey_threshold {
1887: my ($r,$cdom,$cnum,$cdesc,$domdesc,$type) = @_;
1888: &print_header($r,$type);
1889: $r->print('<form action="/adm/modifycourse" method="post" name="processthreshold">'."\n".
1890: '<h3>'.&mt('Responder threshold required for display of anonymous survey submissions:').
1891: ' <span class="LC_nobreak">'.$cdesc.'</span></h3><br />');
1892: my %oldsettings = &Apache::lonnet::get('environment',['internal.anonsurvey_threshold'],$cdom,$cnum);
1893: my %domconfig =
1894: &Apache::lonnet::get_dom('configuration',['coursedefaults'],$cdom);
1895: my $defaultthreshold;
1896: if (ref($domconfig{'coursedefaults'}) eq 'HASH') {
1897: $defaultthreshold = $domconfig{'coursedefaults'}{'anonsurvey_threshold'};
1898: if ($defaultthreshold eq '') {
1899: $defaultthreshold = 10;
1900: }
1901: } else {
1902: $defaultthreshold = 10;
1903: }
1904: if ($env{'form.threshold'} eq '') {
1905: $r->print(&mt('The proposed responder threshold for display of anonymous survey submissions was blank, so the threshold is unchanged.'));
1906: } else {
1907: my $newthreshold = $env{'form.threshold'};
1908: if ($newthreshold =~ /^\s*(\d+)\s*$/) {
1909: $newthreshold = $1;
1910: if ($oldsettings{'internal.anonsurvey_threshold'} eq $env{'form.threshold'}) {
1911: $r->print(&mt('Responder threshold for anonymous survey submissions display remains unchanged: [_1].',$env{'form.threshold'}));
1912: } else {
1913: my %cenv = (
1914: 'internal.anonsurvey_threshold' => $env{'form.threshold'},
1915: );
1916: my $putreply = &Apache::lonnet::put('environment',\%cenv,$cdom,
1917: $cnum);
1.72 raeburn 1918: if ($putreply eq 'ok') {
1919: if ($env{'course.'.$cdom.'_'.$cnum.'.description'} ne '') {
1920: &Apache::lonnet::appenv(
1921: {'course.'.$cdom.'_'.$cnum.'.internal.anonsurvey_threshold' => $env{'form.threshold'}});
1922: }
1923: }
1.57 raeburn 1924: if (($oldsettings{'internal.anonsurvey_threshold'} eq '') &&
1925: ($env{'form.threshold'} == $defaultthreshold)) {
1926: $r->print(&mt('The responder threshold for display of anonymous survey submissions is the default for this domain: [_1].',$defaultthreshold));
1927: } else {
1928: if ($putreply eq 'ok') {
1929: my %updatedsettings = &Apache::lonnet::get('environment',['internal.anonsurvey_threshold'],$cdom,$cnum);
1930: $r->print(&mt('The responder threshold for display of anonymous survey submissions is now: [_1].','<b>'.$updatedsettings{'internal.anonsurvey_threshold'}.'</b>'));
1931: } else {
1932: $r->print(&mt('An error occurred storing the responder threshold for anonymous submissions display: ').
1933: $putreply);
1934: }
1935: }
1936: }
1937: } else {
1938: $r->print(&mt('The proposed responder threshold for display of anonymous submissions contained invalid characters, so the threshold is unchanged.'));
1939: }
1940: }
1941: $r->print('<p>'.
1942: '<a href="javascript:changePage(document.processthreshold,'."'menu'".')">'.
1.75 raeburn 1943: &mt('Pick another action').'</a></p>');
1944: $r->print(&hidden_form_elements().'</form>');
1945: return;
1946: }
1947:
1948: sub modify_postsubmit_config {
1949: my ($r,$cdom,$cnum,$cdesc,$domdesc,$type) = @_;
1950: &print_header($r,$type);
1951: my %lt = &Apache::lonlocal::texthash(
1952: subb => 'Submit button behavior after student makes a submission:',
1953: unch => 'Post submission behavior of the Submit button is unchanged.',
1954: erro => 'An error occurred when saving your proposed changes.',
1955: inva => 'An invalid response was recorded.',
1956: pick => 'Pick another action',
1957: );
1958: $r->print('<form action="/adm/modifycourse" method="post" name="processpostsubmit">'."\n".
1959: '<h3>'.$lt{'subb'}.' <span class="LC_nobreak">('.$cdesc.')</span></h3><br />');
1960: my %oldsettings =
1961: &Apache::lonnet::get('environment',['internal.postsubmit','internal.postsubtimeout','internal.coursecode','internal.textbook'],$cdom,$cnum);
1962: my $postsubmit = $env{'form.postsubmit'};
1963: if ($postsubmit eq '1') {
1964: my $postsubtimeout = $env{'form.postsubtimeout'};
1965: $postsubtimeout =~ s/[^\d\.]+//g;
1966: if (($oldsettings{'internal.postsubmit'} eq $postsubmit) && ($oldsettings{'internal.postsubtimeout'} eq $postsubtimeout)) {
1967: $r->print($lt{'unch'});
1968: } else {
1969: my %cenv = (
1970: 'internal.postsubmit' => $postsubmit,
1971: );
1972: if ($postsubtimeout eq '') {
1973: my $putreply = &Apache::lonnet::put('environment',\%cenv,$cdom,$cnum);
1974: if ($putreply eq 'ok') {
1975: my $defaulttimeout = &domain_postsubtimeout($cdom,$type,\%oldsettings);
1976: $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));
1977: if (exists($oldsettings{'internal.postsubtimeout'})) {
1978: &Apache::lonnet::del('environment',['internal.postsubtimeout'],$cdom,$cnum);
1979: }
1980: } else {
1981: $r->print($lt{'erro'});
1982: }
1983: } else {
1984: $cenv{'internal.postsubtimeout'} = $postsubtimeout;
1985: my $putreply = &Apache::lonnet::put('environment',\%cenv,$cdom,$cnum);
1986: if ($putreply eq 'ok') {
1987: if ($postsubtimeout eq '0') {
1988: $r->print(&mt('Submit button will be disabled after student submission until page is reloaded.'));
1989: } else {
1990: $r->print(&mt('Submit button will be disabled after student submission for [quant,_1,second].',$postsubtimeout));
1991: }
1992: } else {
1993: $r->print($lt{'erro'});
1994: }
1995: }
1996: }
1997: } elsif ($postsubmit eq '0') {
1998: if ($oldsettings{'internal.postsubmit'} eq $postsubmit) {
1999: $r->print($lt{'unch'});
2000: } else {
2001: if (exists($oldsettings{'internal.postsubtimeout'})) {
2002: &Apache::lonnet::del('environment',['internal.postsubtimeout'],$cdom,$cnum);
2003: }
2004: my %cenv = (
2005: 'internal.postsubmit' => $postsubmit,
2006: );
2007: my $putreply = &Apache::lonnet::put('environment',\%cenv,$cdom,$cnum);
2008: if ($putreply eq 'ok') {
1.76 droeschl 2009: $r->print(&mt('Submit button will not be disabled after student submission'));
1.75 raeburn 2010: } else {
2011: $r->print($lt{'erro'});
2012: }
2013: }
2014: } else {
2015: $r->print($lt{'inva'}.' '.$lt{'unch'});
2016: }
2017: $r->print('<p>'.
2018: '<a href="javascript:changePage(document.processpostsubmit,'."'menu'".')">'.
2019: &mt('Pick another action').'</a></p>');
1.57 raeburn 2020: $r->print(&hidden_form_elements().'</form>');
2021: return;
2022: }
2023:
1.38 raeburn 2024: sub modify_catsettings {
1.48 raeburn 2025: my ($r,$cdom,$cnum,$cdesc,$domdesc,$type) = @_;
2026: &print_header($r,$type);
2027: my ($ccrole,%desc);
2028: if ($type eq 'Community') {
2029: $desc{'hidefromcat'} = &mt('Excluded from community catalog');
2030: $desc{'categories'} = &mt('Assigned categories for this community');
2031: $ccrole = 'co';
2032: } else {
2033: $desc{'hidefromcat'} = &mt('Excluded from course catalog');
2034: $desc{'categories'} = &mt('Assigned categories for this course');
2035: $ccrole = 'cc';
2036: }
1.38 raeburn 2037: $r->print('
2038: <form action="/adm/modifycourse" method="post" name="processcat">
2039: <h3>'.&mt('Category settings').'</h3>');
2040: my %domconf = &Apache::lonnet::get_dom('configuration',['coursecategories'],$cdom);
1.49 raeburn 2041: my @cat_params = &catalog_settable($domconf{'coursecategories'},$type);
1.38 raeburn 2042: if (@cat_params > 0) {
2043: my (%cenv,@changes,@nochanges);
2044: my %currsettings =
2045: &Apache::lonnet::get('environment',['hidefromcat','categories'],$cdom,$cnum);
2046: my (@newcategories,%showitem);
2047: if (grep(/^togglecats$/,@cat_params)) {
2048: if ($currsettings{'hidefromcat'} ne $env{'form.hidefromcat'}) {
2049: push(@changes,'hidefromcat');
2050: $cenv{'hidefromcat'} = $env{'form.hidefromcat'};
2051: } else {
2052: push(@nochanges,'hidefromcat');
2053: }
2054: if ($env{'form.hidefromcat'} eq 'yes') {
2055: $showitem{'hidefromcat'} = '"'.&mt('Yes')."'";
2056: } else {
2057: $showitem{'hidefromcat'} = '"'.&mt('No').'"';
2058: }
2059: }
2060: if (grep(/^categorize$/,@cat_params)) {
2061: my (@cats,@trails,%allitems,%idx,@jsarray);
2062: if (ref($domconf{'coursecategories'}) eq 'HASH') {
2063: my $cathash = $domconf{'coursecategories'}{'cats'};
2064: if (ref($cathash) eq 'HASH') {
2065: &Apache::loncommon::extract_categories($cathash,\@cats,\@trails,
2066: \%allitems,\%idx,\@jsarray);
2067: }
2068: }
2069: @newcategories = &Apache::loncommon::get_env_multiple('form.usecategory');
2070: if (@newcategories == 0) {
2071: $showitem{'categories'} = '"'.&mt('None').'"';
2072: } else {
2073: $showitem{'categories'} = '<ul>';
2074: foreach my $item (@newcategories) {
2075: $showitem{'categories'} .= '<li>'.$trails[$allitems{$item}].'</li>';
2076: }
2077: $showitem{'categories'} .= '</ul>';
2078: }
2079: my $catchg = 0;
2080: if ($currsettings{'categories'} ne '') {
2081: my @currcategories = split('&',$currsettings{'categories'});
2082: foreach my $cat (@currcategories) {
2083: if (!grep(/^\Q$cat\E$/,@newcategories)) {
2084: $catchg = 1;
2085: last;
2086: }
2087: }
2088: if (!$catchg) {
2089: foreach my $cat (@newcategories) {
2090: if (!grep(/^\Q$cat\E$/,@currcategories)) {
2091: $catchg = 1;
2092: last;
2093: }
2094: }
2095: }
2096: } else {
2097: if (@newcategories > 0) {
2098: $catchg = 1;
2099: }
2100: }
2101: if ($catchg) {
2102: $cenv{'categories'} = join('&',@newcategories);
2103: push(@changes,'categories');
2104: } else {
2105: push(@nochanges,'categories');
2106: }
2107: if (@changes > 0) {
2108: my $putreply = &Apache::lonnet::put('environment',\%cenv,$cdom,$cnum);
2109: if ($putreply eq 'ok') {
1.72 raeburn 2110: if ($env{'course.'.$cdom.'_'.$cnum.'.description'} ne '') {
2111: my %newenvhash;
2112: foreach my $item (@changes) {
2113: $newenvhash{'course.'.$cdom.'_'.$cnum.'.'.$item} = $cenv{$item};
2114: }
2115: &Apache::lonnet::appenv(\%newenvhash);
2116: }
1.38 raeburn 2117: my %crsinfo = &Apache::lonnet::courseiddump($cdom,'.',1,'.','.',
2118: $cnum,undef,undef,'.');
2119: if (ref($crsinfo{$env{'form.pickedcourse'}}) eq 'HASH') {
2120: if (grep(/^hidefromcat$/,@changes)) {
2121: $crsinfo{$env{'form.pickedcourse'}}{'hidefromcat'} = $env{'form.hidefromcat'};
2122: }
2123: if (grep(/^categories$/,@changes)) {
2124: $crsinfo{$env{'form.pickedcourse'}}{'categories'} = $cenv{'categories'};
2125: }
2126: my $chome = &Apache::lonnet::homeserver($cnum,$cdom);
2127: my $putres = &Apache::lonnet::courseidput($cdom,\%crsinfo,$chome,'notime');
2128: }
1.48 raeburn 2129: $r->print(&mt('The following changes occurred:').'<ul>');
1.38 raeburn 2130: foreach my $item (@changes) {
1.48 raeburn 2131: $r->print('<li>'.&mt('[_1] now set to: [_2]',$desc{$item},$showitem{$item}).'</li>');
1.38 raeburn 2132: }
2133: $r->print('</ul><br />');
2134: }
2135: }
2136: if (@nochanges > 0) {
1.48 raeburn 2137: $r->print(&mt('The following were unchanged:').'<ul>');
1.38 raeburn 2138: foreach my $item (@nochanges) {
1.48 raeburn 2139: $r->print('<li>'.&mt('[_1] still set to: [_2]',$desc{$item},$showitem{$item}).'</li>');
1.38 raeburn 2140: }
2141: $r->print('</ul>');
2142: }
2143: }
2144: } else {
1.48 raeburn 2145: my $newrole = $ccrole.'./'.$cdom.'/'.$cnum;
2146: my $escuri = &HTML::Entities::encode('/adm/roles?selectrole=1&'.$newrole.
2147: '=1&destinationurl=/adm/courseprefs','&<>"');
2148: if ($type eq 'Community') {
2149: $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 />');
2150: } else {
2151: $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 />');
2152: }
1.38 raeburn 2153: }
2154: $r->print('<br />'."\n".
2155: '<a href="javascript:changePage(document.processcat,'."'menu'".')">'.
1.48 raeburn 2156: &mt('Pick another action').'</a>');
1.38 raeburn 2157: $r->print(&hidden_form_elements().'</form>');
2158: return;
2159: }
2160:
1.1 raeburn 2161: sub print_header {
1.48 raeburn 2162: my ($r,$type,$javascript_validations) = @_;
1.28 raeburn 2163: my $phase = "start";
2164: if ( exists($env{'form.phase'}) ) {
2165: $phase = $env{'form.phase'};
2166: }
2167: my $js = qq|
1.60 raeburn 2168:
1.28 raeburn 2169: function changePage(formname,newphase) {
2170: formname.phase.value = newphase;
2171: if (newphase == 'processparms') {
2172: return;
1.1 raeburn 2173: }
1.28 raeburn 2174: formname.submit();
2175: }
1.60 raeburn 2176:
1.28 raeburn 2177: |;
2178: if ($phase eq 'setparms') {
1.60 raeburn 2179: $js .= $javascript_validations;
1.28 raeburn 2180: } elsif ($phase eq 'courselist') {
1.90 raeburn 2181: $js .= <<"ENDJS";
1.60 raeburn 2182: function hide_searching() {
2183: if (document.getElementById('searching')) {
2184: document.getElementById('searching').style.display = 'none';
2185: }
2186: return;
2187: }
2188:
1.90 raeburn 2189: ENDJS
1.28 raeburn 2190: } elsif ($phase eq 'setquota') {
1.57 raeburn 2191: my $invalid = &mt('The quota you entered contained invalid characters.');
2192: my $alert = &mt('You must enter a number');
1.78 damieng 2193: &js_escape(\$invalid);
2194: &js_escape(\$alert);
1.57 raeburn 2195: my $regexp = '/^\s*(\d+\.?\d*|\.\d+)\s*$/';
2196: $js .= <<"ENDSCRIPT";
1.60 raeburn 2197:
1.57 raeburn 2198: function verify_quota() {
2199: var newquota = document.setquota.coursequota.value;
2200: var num_reg = $regexp;
1.28 raeburn 2201: if (num_reg.test(newquota)) {
1.57 raeburn 2202: changePage(document.setquota,'processquota');
1.1 raeburn 2203: } else {
1.57 raeburn 2204: alert("$invalid\\n$alert");
2205: return false;
1.1 raeburn 2206: }
1.57 raeburn 2207: return true;
2208: }
1.60 raeburn 2209:
1.57 raeburn 2210: ENDSCRIPT
2211: } elsif ($phase eq 'setanon') {
2212: my $invalid = &mt('The responder threshold you entered is invalid.');
2213: my $alert = &mt('You must enter a positive integer.');
1.78 damieng 2214: &js_escape(\$invalid);
2215: &js_escape(\$alert);
1.57 raeburn 2216: my $regexp = ' /^\s*\d+\s*$/';
2217: $js .= <<"ENDSCRIPT";
1.60 raeburn 2218:
1.57 raeburn 2219: function verify_anon_threshold() {
2220: var newthreshold = document.setanon.threshold.value;
2221: var num_reg = $regexp;
2222: if (num_reg.test(newthreshold)) {
2223: if (newthreshold > 0) {
2224: changePage(document.setanon,'processthreshold');
2225: } else {
2226: alert("$invalid\\n$alert");
2227: return false;
2228: }
2229: } else {
2230: alert("$invalid\\n$alert");
2231: return false;
2232: }
2233: return true;
1.28 raeburn 2234: }
1.60 raeburn 2235:
1.28 raeburn 2236: ENDSCRIPT
1.75 raeburn 2237: } elsif ($phase eq 'setpostsubmit') {
2238: my $invalid = &mt('The choice entered for disabling the submit button is invalid.');
2239: my $invalidtimeout = &mt('The timeout you entered for disabling the submit button is invalid.');
2240: my $alert = &mt('Enter one of: a positive integer, 0 (for no timeout), or leave blank to use domain default');
1.78 damieng 2241: &js_escape(\$invalid);
2242: &js_escape(\$invalidtimeout);
2243: &js_escape(\$alert);
1.75 raeburn 2244: my $regexp = ' /^\s*\d+\s*$/';
2245:
2246: $js .= <<"ENDSCRIPT";
2247:
2248: function verify_postsubmit() {
2249: var optionsElement = document.setpostsubmit.postsubmit;
2250: var verified = '';
2251: if (optionsElement.length) {
2252: var currval;
2253: for (var i=0; i<optionsElement.length; i++) {
2254: if (optionsElement[i].checked) {
2255: currval = optionsElement[i].value;
2256: }
2257: }
2258: if (currval == 1) {
2259: var newtimeout = document.setpostsubmit.postsubtimeout.value;
2260: if (newtimeout == '') {
2261: verified = 'ok';
2262: } else {
2263: var num_reg = $regexp;
2264: if (num_reg.test(newtimeout)) {
2265: if (newtimeout>= 0) {
2266: verified = 'ok';
2267: } else {
2268: alert("$invalidtimeout\\n$alert");
2269: return false;
2270: }
2271: } else {
2272: alert("$invalid\\n$alert");
2273: return false;
2274: }
2275: }
2276: } else {
2277: if (currval == 0) {
2278: verified = 'ok';
2279: } else {
2280: alert('$invalid');
2281: return false;
2282: }
2283: }
2284: if (verified == 'ok') {
2285: changePage(document.setpostsubmit,'processpostsubmit');
2286: return true;
2287: }
2288: }
2289: return false;
2290: }
2291:
2292: function togglePostsubmit(caller) {
2293: var optionsElement = document.setpostsubmit.postsubmit;
2294: if (document.getElementById(caller)) {
2295: var divitem = document.getElementById(caller);
2296: var optionsElement = document.setpostsubmit.postsubmit;
2297: if (optionsElement.length) {
2298: var currval;
2299: for (var i=0; i<optionsElement.length; i++) {
2300: if (optionsElement[i].checked) {
2301: currval = optionsElement[i].value;
2302: }
2303: }
2304: if (currval == 1) {
2305: divitem.style.display = 'block';
2306: } else {
2307: divitem.style.display = 'none';
2308: }
2309: }
1.1 raeburn 2310: }
1.75 raeburn 2311: return;
2312: }
1.60 raeburn 2313:
1.75 raeburn 2314: ENDSCRIPT
2315:
2316: }
1.37 raeburn 2317: my $starthash;
1.86 raeburn 2318: if ($env{'form.phase'} eq 'adhocrole') {
1.37 raeburn 2319: $starthash = {
1.86 raeburn 2320: add_entries => {'onload' => "javascript:document.adhocrole.submit();"},
1.37 raeburn 2321: };
1.60 raeburn 2322: } elsif ($phase eq 'courselist') {
2323: $starthash = {
1.74 musolffc 2324: add_entries => {'onload' => "hide_searching(); courseSet(document.filterpicker.official, 'load');"},
1.60 raeburn 2325: };
1.37 raeburn 2326: }
1.48 raeburn 2327: $r->print(&Apache::loncommon::start_page('View/Modify Course/Community Settings',
1.60 raeburn 2328: &Apache::lonhtmlcommon::scripttag($js),
2329: $starthash));
1.48 raeburn 2330: my $bread_text = "View/Modify Courses/Communities";
2331: if ($type eq 'Community') {
2332: $bread_text = 'Community Settings';
1.81 raeburn 2333: } elsif ($type eq 'Placement') {
2334: $bread_text = 'Placement Test Settings';
1.41 raeburn 2335: } else {
1.48 raeburn 2336: $bread_text = 'Course Settings';
1.41 raeburn 2337: }
1.48 raeburn 2338: $r->print(&Apache::lonhtmlcommon::breadcrumbs($bread_text));
1.5 raeburn 2339: return;
1.1 raeburn 2340: }
2341:
2342: sub print_footer {
1.23 albertel 2343: my ($r) = @_;
2344: $r->print('<br />'.&Apache::loncommon::end_page());
1.5 raeburn 2345: return;
1.3 raeburn 2346: }
2347:
2348: sub check_course {
1.71 raeburn 2349: my ($dom,$domdesc) = @_;
2350: my ($ok_course,$description,$instcode);
2351: my %coursehash;
2352: if ($env{'form.pickedcourse'} =~ /^$match_domain\_$match_courseid$/) {
2353: my %args;
2354: unless ($env{'course.'.$env{'form.pickedcourse'}.'.description'}) {
2355: %args = (
2356: 'one_time' => 1,
2357: 'freshen_cache' => 1,
2358: );
2359: }
2360: %coursehash =
2361: &Apache::lonnet::coursedescription($env{'form.pickedcourse'},\%args);
2362: my $cnum = $coursehash{'num'};
2363: my $cdom = $coursehash{'domain'};
2364: $description = $coursehash{'description'};
2365: $instcode = $coursehash{'internal.coursecode'};
2366: if ($instcode) {
2367: $description .= " ($instcode)";
2368: }
2369: if (($cdom eq $dom) && ($cnum =~ /^$match_courseid$/)) {
2370: my %courseIDs = &Apache::lonnet::courseiddump($cdom,'.',1,'.','.',
2371: $cnum,undef,undef,'.');
2372: if ($courseIDs{$cdom.'_'.$cnum}) {
2373: $ok_course = 'ok';
1.5 raeburn 2374: }
1.3 raeburn 2375: }
2376: }
1.71 raeburn 2377: return ($ok_course,$description,\%coursehash);
1.1 raeburn 2378: }
2379:
1.28 raeburn 2380: sub course_settings_descrip {
1.48 raeburn 2381: my ($type) = @_;
2382: my %longtype;
2383: if ($type eq 'Community') {
2384: %longtype = &Apache::lonlocal::texthash(
1.72 raeburn 2385: 'courseowner' => "Username:domain of community owner",
2386: 'co-owners' => "Username:domain of each co-owner",
2387: 'selfenrollmgrdc' => "Community-specific self-enrollment configuration by Domain Coordinator",
2388: 'selfenrollmgrcc' => "Community-specific self-enrollment configuration by Community personnel",
1.85 raeburn 2389: 'mysqltables' => '"Temporary" student performance tables lifetime (seconds)',
1.48 raeburn 2390: );
2391: } else {
2392: %longtype = &Apache::lonlocal::texthash(
1.28 raeburn 2393: 'authtype' => 'Default authentication method',
2394: 'autharg' => 'Default authentication parameter',
2395: 'autoadds' => 'Automated adds',
2396: 'autodrops' => 'Automated drops',
2397: 'autostart' => 'Date of first automated enrollment',
2398: 'autoend' => 'Date of last automated enrollment',
2399: 'default_enrollment_start_date' => 'Date of first student access',
2400: 'default_enrollment_end_date' => 'Date of last student access',
2401: 'coursecode' => 'Official course code',
2402: 'courseowner' => "Username:domain of course owner",
1.50 raeburn 2403: 'co-owners' => "Username:domain of each co-owner",
1.28 raeburn 2404: 'notifylist' => 'Course Coordinators to be notified of enrollment changes',
1.48 raeburn 2405: 'sectionnums' => 'Course section number:LON-CAPA section',
2406: 'crosslistings' => 'Crosslisted class:LON-CAPA section',
1.72 raeburn 2407: 'defaultcredits' => 'Credits',
1.84 raeburn 2408: 'autodropfailsafe' => "Failsafe section enrollment count",
1.72 raeburn 2409: 'selfenrollmgrdc' => "Course-specific self-enrollment configuration by Domain Coordinator",
2410: 'selfenrollmgrcc' => "Course-specific self-enrollment configuration by Course personnel",
1.85 raeburn 2411: 'mysqltables' => '"Temporary" student performance tables lifetime (seconds)',
1.48 raeburn 2412: );
2413: }
1.28 raeburn 2414: return %longtype;
2415: }
2416:
2417: sub hidden_form_elements {
2418: my $hidden_elements =
1.46 raeburn 2419: &Apache::lonhtmlcommon::echo_form_input(['gosearch','updater','coursecode',
1.37 raeburn 2420: 'prevphase','numlocalcc','courseowner','login','coursequota','intarg',
1.57 raeburn 2421: 'locarg','krbarg','krbver','counter','hidefromcat','usecategory',
1.75 raeburn 2422: 'threshold','postsubmit','postsubtimeout','defaultcredits','uploadquota',
2423: 'selfenrollmgrdc','selfenrollmgrcc','action','state','currsec_st',
1.85 raeburn 2424: 'sections','newsec','mysqltables'],['^selfenrollmgr_','^selfenroll_'])."\n".
1.37 raeburn 2425: '<input type="hidden" name="prevphase" value="'.$env{'form.phase'}.'" />';
1.28 raeburn 2426: return $hidden_elements;
2427: }
1.1 raeburn 2428:
1.60 raeburn 2429: sub showcredits {
2430: my ($dom) = @_;
2431: my %domdefaults = &Apache::lonnet::get_domain_defaults($dom);
1.79 raeburn 2432: if ($domdefaults{'officialcredits'} || $domdefaults{'unofficialcredits'} || $domdefaults{'textbookcredits'}) {
1.60 raeburn 2433: return 1;
2434: }
2435: }
2436:
1.86 raeburn 2437: sub get_permission {
2438: my ($dom) = @_;
2439: my ($allowed,%permission);
2440: if (&Apache::lonnet::allowed('ccc',$dom)) {
2441: $allowed = 1;
2442: %permission = (
1.88 raeburn 2443: setquota => 'edit',
2444: processquota => 'edit',
2445: setanon => 'edit',
2446: processthreshold => 'edit',
2447: setpostsubmit => 'edit',
2448: processpostsubmit => 'edit',
2449: viewparms => 'view',
2450: setparms => 'edit',
2451: processparms => 'edit',
2452: catsettings => 'edit',
2453: processcat => 'edit',
2454: selfenroll => 'edit',
1.90 raeburn 2455: adhocrole => 'coord',
1.86 raeburn 2456: );
2457: } elsif (&Apache::lonnet::allowed('rar',$dom)) {
2458: $allowed = 1;
2459: %permission = (
1.88 raeburn 2460: setquota => 'view',
2461: viewparms => 'view',
2462: setanon => 'view',
2463: setpostsubmit => 'view',
2464: setparms => 'view',
2465: catsettings => 'view',
2466: selfenroll => 'view',
1.90 raeburn 2467: adhocrole => 'custom',
1.86 raeburn 2468: );
2469: }
2470: return ($allowed,\%permission);
2471: }
2472:
1.1 raeburn 2473: sub handler {
2474: my $r = shift;
2475: if ($r->header_only) {
2476: &Apache::loncommon::content_type($r,'text/html');
2477: $r->send_http_header;
2478: return OK;
2479: }
1.72 raeburn 2480:
1.28 raeburn 2481: my $dom = $env{'request.role.domain'};
1.31 albertel 2482: my $domdesc = &Apache::lonnet::domain($dom,'description');
1.86 raeburn 2483: my ($allowed,$permission) = &get_permission($dom);
2484: if ($allowed) {
1.1 raeburn 2485: &Apache::loncommon::content_type($r,'text/html');
2486: $r->send_http_header;
2487:
1.28 raeburn 2488: &Apache::lonhtmlcommon::clear_breadcrumbs();
2489:
2490: my $phase = $env{'form.phase'};
1.46 raeburn 2491: if ($env{'form.updater'}) {
2492: $phase = '';
2493: }
1.37 raeburn 2494: if ($phase eq '') {
2495: &Apache::lonhtmlcommon::add_breadcrumb
1.28 raeburn 2496: ({href=>"/adm/modifycourse",
1.48 raeburn 2497: text=>"Course/Community search"});
1.28 raeburn 2498: &print_course_search_page($r,$dom,$domdesc);
1.1 raeburn 2499: } else {
1.37 raeburn 2500: my $firstform = $phase;
2501: if ($phase eq 'courselist') {
2502: $firstform = 'filterpicker';
1.48 raeburn 2503: }
2504: my $choose_text;
2505: my $type = $env{'form.type'};
2506: if ($type eq '') {
2507: $type = 'Course';
2508: }
2509: if ($type eq 'Community') {
2510: $choose_text = "Choose a community";
1.81 raeburn 2511: } elsif ($type eq 'Placement') {
2512: $choose_text = "Choose a placement test";
1.48 raeburn 2513: } else {
2514: $choose_text = "Choose a course";
1.37 raeburn 2515: }
1.28 raeburn 2516: &Apache::lonhtmlcommon::add_breadcrumb
1.37 raeburn 2517: ({href=>"javascript:changePage(document.$firstform,'')",
1.48 raeburn 2518: text=>"Course/Community search"},
1.37 raeburn 2519: {href=>"javascript:changePage(document.$phase,'courselist')",
1.48 raeburn 2520: text=>$choose_text});
1.28 raeburn 2521: if ($phase eq 'courselist') {
1.90 raeburn 2522: &print_course_selection_page($r,$dom,$domdesc,$permission);
1.28 raeburn 2523: } else {
1.71 raeburn 2524: my ($checked,$cdesc,$coursehash) = &check_course($dom,$domdesc);
1.28 raeburn 2525: if ($checked eq 'ok') {
1.48 raeburn 2526: my $enter_text;
2527: if ($type eq 'Community') {
2528: $enter_text = 'Enter community';
1.81 raeburn 2529: } elsif ($type eq 'Placement') {
2530: $enter_text = 'Enter placement test';
1.48 raeburn 2531: } else {
2532: $enter_text = 'Enter course';
2533: }
1.28 raeburn 2534: if ($phase eq 'menu') {
1.37 raeburn 2535: &Apache::lonhtmlcommon::add_breadcrumb
2536: ({href=>"javascript:changePage(document.$phase,'menu')",
2537: text=>"Pick action"});
1.71 raeburn 2538: &print_modification_menu($r,$cdesc,$domdesc,$dom,$type,
1.86 raeburn 2539: $env{'form.pickedcourse'},$coursehash,
2540: $permission);
2541: } elsif ($phase eq 'adhocrole') {
1.37 raeburn 2542: &Apache::lonhtmlcommon::add_breadcrumb
1.86 raeburn 2543: ({href=>"javascript:changePage(document.$phase,'adhocrole')",
1.48 raeburn 2544: text=>$enter_text});
1.90 raeburn 2545: &print_adhocrole_selected($r,$type,$permission);
1.28 raeburn 2546: } else {
1.37 raeburn 2547: &Apache::lonhtmlcommon::add_breadcrumb
2548: ({href=>"javascript:changePage(document.$phase,'menu')",
2549: text=>"Pick action"});
1.28 raeburn 2550: my ($cdom,$cnum) = split(/_/,$env{'form.pickedcourse'});
1.88 raeburn 2551: my ($readonly,$linktext);
2552: if ($permission->{$phase} eq 'view') {
2553: $readonly = 1;
2554: }
1.86 raeburn 2555: if (($phase eq 'setquota') && ($permission->{'setquota'})) {
1.88 raeburn 2556: if ($permission->{'setquota'} eq 'view') {
2557: $linktext = 'Set quota';
2558: } else {
2559: $linktext = 'Display quota';
2560: }
1.28 raeburn 2561: &Apache::lonhtmlcommon::add_breadcrumb
2562: ({href=>"javascript:changePage(document.$phase,'$phase')",
1.89 raeburn 2563: text=>$linktext});
1.88 raeburn 2564: &print_setquota($r,$cdom,$cnum,$cdesc,$type,$readonly);
1.86 raeburn 2565: } elsif (($phase eq 'processquota') && ($permission->{'processquota'})) {
1.28 raeburn 2566: &Apache::lonhtmlcommon::add_breadcrumb
2567: ({href=>"javascript:changePage(document.$phase,'setquota')",
2568: text=>"Set quota"});
2569: &Apache::lonhtmlcommon::add_breadcrumb
2570: ({href=>"javascript:changePage(document.$phase,'$phase')",
2571: text=>"Result"});
1.48 raeburn 2572: &modify_quota($r,$cdom,$cnum,$cdesc,$domdesc,$type);
1.86 raeburn 2573: } elsif (($phase eq 'setanon') && ($permission->{'setanon'})) {
1.57 raeburn 2574: &Apache::lonhtmlcommon::add_breadcrumb
2575: ({href=>"javascript:changePage(document.$phase,'$phase')",
2576: text=>"Threshold for anonymous submissions display"});
1.88 raeburn 2577: &print_set_anonsurvey_threshold($r,$cdom,$cnum,$cdesc,$type,$readonly);
1.86 raeburn 2578: } elsif (($phase eq 'processthreshold') && ($permission->{'processthreshold'})) {
1.57 raeburn 2579: &Apache::lonhtmlcommon::add_breadcrumb
2580: ({href=>"javascript:changePage(document.$phase,'setanon')",
2581: text=>"Threshold for anonymous submissions display"});
2582: &Apache::lonhtmlcommon::add_breadcrumb
2583: ({href=>"javascript:changePage(document.$phase,'$phase')",
2584: text=>"Result"});
2585: &modify_anonsurvey_threshold($r,$cdom,$cnum,$cdesc,$domdesc,$type);
1.86 raeburn 2586: } elsif (($phase eq 'setpostsubmit') && ($permission->{'setpostsubmit'})) {
1.88 raeburn 2587: if ($permission->{'setpostsubmit'} eq 'view') {
2588: $linktext = 'Submit button behavior post-submission';
2589: } else {
2590: $linktext = 'Configure submit button behavior post-submission';
2591: }
1.75 raeburn 2592: &Apache::lonhtmlcommon::add_breadcrumb
2593: ({href=>"javascript:changePage(document.$phase,'$phase')",
1.89 raeburn 2594: text=>$linktext});
1.88 raeburn 2595: &print_postsubmit_config($r,$cdom,$cnum,$cdesc,$type,$readonly);
1.86 raeburn 2596: } elsif (($phase eq 'processpostsubmit') && ($permission->{'processpostsubmit'})) {
1.75 raeburn 2597: &Apache::lonhtmlcommon::add_breadcrumb
2598: ({href=>"javascript:changePage(document.$phase,'$phase')",
2599: text=>"Result"});
2600: &modify_postsubmit_config($r,$cdom,$cnum,$cdesc,$domdesc,$type);
1.86 raeburn 2601: } elsif (($phase eq 'viewparms') && ($permission->{'viewparms'})) {
1.28 raeburn 2602: &Apache::lonhtmlcommon::add_breadcrumb
2603: ({href=>"javascript:changePage(document.$phase,'viewparms')",
2604: text=>"Display settings"});
1.86 raeburn 2605: &print_settings_display($r,$cdom,$cnum,$cdesc,$type,$permission);
2606: } elsif (($phase eq 'setparms') && ($permission->{'setparms'})) {
1.88 raeburn 2607: if ($permission->{'setparms'} eq 'view') {
2608: $linktext = 'Display settings';
2609: } else {
2610: $linktext = 'Change settings';
2611: }
1.28 raeburn 2612: &Apache::lonhtmlcommon::add_breadcrumb
2613: ({href=>"javascript:changePage(document.$phase,'$phase')",
1.89 raeburn 2614: text=>$linktext});
1.88 raeburn 2615: &print_course_modification_page($r,$cdom,$cnum,$cdesc,$type,$readonly);
1.86 raeburn 2616: } elsif (($phase eq 'processparms') && ($permission->{'processparms'})) {
1.28 raeburn 2617: &Apache::lonhtmlcommon::add_breadcrumb
2618: ({href=>"javascript:changePage(document.$phase,'setparms')",
2619: text=>"Change settings"});
2620: &Apache::lonhtmlcommon::add_breadcrumb
2621: ({href=>"javascript:changePage(document.$phase,'$phase')",
2622: text=>"Result"});
1.30 raeburn 2623: &modify_course($r,$cdom,$cnum,$cdesc,$domdesc,$type);
1.86 raeburn 2624: } elsif (($phase eq 'catsettings') && ($permission->{'catsettings'})) {
1.38 raeburn 2625: &Apache::lonhtmlcommon::add_breadcrumb
2626: ({href=>"javascript:changePage(document.$phase,'$phase')",
2627: text=>"Catalog settings"});
1.88 raeburn 2628: &print_catsettings($r,$cdom,$cnum,$cdesc,$type,$readonly);
1.86 raeburn 2629: } elsif (($phase eq 'processcat') && ($permission->{'processcat'})) {
1.38 raeburn 2630: &Apache::lonhtmlcommon::add_breadcrumb
2631: ({href=>"javascript:changePage(document.$phase,'catsettings')",
2632: text=>"Catalog settings"});
2633: &Apache::lonhtmlcommon::add_breadcrumb
2634: ({href=>"javascript:changePage(document.$phase,'$phase')",
2635: text=>"Result"});
1.48 raeburn 2636: &modify_catsettings($r,$cdom,$cnum,$cdesc,$domdesc,$type);
1.86 raeburn 2637: } elsif (($phase eq 'selfenroll') && ($permission->{'selfenroll'})) {
1.72 raeburn 2638: &Apache::lonhtmlcommon::add_breadcrumb
2639: ({href => "javascript:changePage(document.$phase,'$phase')",
2640: text => "Self-enrollment settings"});
2641: if (!exists($env{'form.state'})) {
1.88 raeburn 2642: &print_selfenrollconfig($r,$type,$cdesc,$coursehash,$readonly);
1.72 raeburn 2643: } elsif ($env{'form.state'} eq 'done') {
2644: &Apache::lonhtmlcommon::add_breadcrumb
2645: ({href=>"javascript:changePage(document.$phase,'$phase')",
2646: text=>"Result"});
2647: &modify_selfenrollconfig($r,$type,$cdesc,$coursehash);
2648: }
1.28 raeburn 2649: }
2650: }
2651: } else {
1.48 raeburn 2652: $r->print('<span class="LC_error">');
2653: if ($type eq 'Community') {
1.72 raeburn 2654: $r->print(&mt('The community you selected is not a valid community in this domain'));
1.81 raeburn 2655: } elsif ($type eq 'Placement') {
2656: $r->print(&mt('The course you selected is not a valid placement test in this domain'));
1.72 raeburn 2657: } else {
1.48 raeburn 2658: $r->print(&mt('The course you selected is not a valid course in this domain'));
2659: }
2660: $r->print(" ($domdesc)</span>");
1.28 raeburn 2661: }
2662: }
1.1 raeburn 2663: }
1.28 raeburn 2664: &print_footer($r);
1.1 raeburn 2665: } else {
1.16 albertel 2666: $env{'user.error.msg'}=
1.48 raeburn 2667: "/adm/modifycourse:ccc:0:0:Cannot modify course/community settings";
1.1 raeburn 2668: return HTTP_NOT_ACCEPTABLE;
2669: }
2670: return OK;
2671: }
2672:
2673: 1;
2674: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>