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