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