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