Annotation of loncom/interface/lonmodifycourse.pm, revision 1.88
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.88 ! raeburn 4: # $Id: lonmodifycourse.pm,v 1.87 2016/10/27 21:01:01 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.88 ! 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.88 ! 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',
920: 'internal.mysqltables'],
1.72 raeburn 921: $cdom,$cnum);
922: my $type = &Apache::lonuserutils::get_extended_type($cdom,$cnum,$crstype,\%settings);
923: my @specific_managebydc = split(/,/,$settings{'internal.selfenrollmgrdc'});
924: my @specific_managebycc = split(/,/,$settings{'internal.selfenrollmgrcc'});
925: my %domdefaults = &Apache::lonnet::get_domain_defaults($cdom);
926: my @default_managebydc = split(/,/,$domdefaults{$type.'selfenrolladmdc'});
927: if ($crstype eq 'Community') {
1.48 raeburn 928: $ccrole = 'co';
929: $lt{'nocc'} = &mt('There is currently no owner set for this community.');
930: } else {
931: $ccrole ='cc';
1.88 ! raeburn 932: ($javascript_validations,$authenitems) = &gather_authenitems($cdom,\%enrollvar,$readonly);
1.48 raeburn 933: }
1.72 raeburn 934: $ccname = &Apache::lonnet::plaintext($ccrole,$crstype);
1.88 ! raeburn 935: if ($readonly) {
! 936: $disabled = ' disabled="disabled"';
! 937: }
1.48 raeburn 938: my %roleshash = &Apache::lonnet::get_my_roles($cnum,$cdom,'','',[$ccrole]);
939: my (@local_ccs,%cc_status,%pname);
940: foreach my $item (keys(%roleshash)) {
941: my ($uname,$udom) = split(/:/,$item);
942: if (!grep(/^\Q$uname\E:\Q$udom\E$/,@local_ccs)) {
943: push(@local_ccs,$uname.':'.$udom);
944: $pname{$uname.':'.$udom} = &Apache::loncommon::plainname($uname,$udom);
945: $cc_status{$uname.':'.$udom} = $lt{'actv'};
1.1 raeburn 946: }
947: }
1.48 raeburn 948: if (($enrollvar{'courseowner'} ne '') &&
949: (!grep(/^$enrollvar{'courseowner'}$/,@local_ccs))) {
950: push(@local_ccs,$enrollvar{'courseowner'});
1.26 raeburn 951: my ($owneruname,$ownerdom) = split(/:/,$enrollvar{'courseowner'});
952: $pname{$enrollvar{'courseowner'}} =
953: &Apache::loncommon::plainname($owneruname,$ownerdom);
1.48 raeburn 954: my $active_cc = &Apache::loncommon::check_user_status($ownerdom,$owneruname,
955: $cdom,$cnum,$ccrole);
1.19 raeburn 956: if ($active_cc eq 'active') {
1.2 raeburn 957: $cc_status{$enrollvar{'courseowner'}} = $lt{'actv'};
1.1 raeburn 958: } else {
1.2 raeburn 959: $cc_status{$enrollvar{'courseowner'}} = $lt{'inac'};
1.1 raeburn 960: }
961: }
1.48 raeburn 962: @local_ccs = sort(@local_ccs);
963: if (@local_ccs == 0) {
964: $ownertable = $lt{'nocc'};
965: } else {
966: my $numlocalcc = scalar(@local_ccs);
967: $ownertable = '<input type="hidden" name="numlocalcc" value="'.$numlocalcc.'" />'.
968: &Apache::loncommon::start_data_table()."\n".
969: &Apache::loncommon::start_data_table_header_row()."\n".
970: '<th>'.$lt{'ownr'}.'</th>'.
971: '<th>'.$lt{'name'}.'</th>'.
972: '<th>'.$lt{'unme'}.'</th>'.
973: '<th>'.$lt{'stus'}.'</th>'.
974: &Apache::loncommon::end_data_table_header_row()."\n";
975: foreach my $cc (@local_ccs) {
976: $ownertable .= &Apache::loncommon::start_data_table_row()."\n";
977: if ($cc eq $enrollvar{'courseowner'}) {
1.88 ! raeburn 978: $ownertable .= '<td><input type="radio" name="courseowner" value="'.$cc.'" checked="checked"'.$disabled.' /></td>'."\n";
1.48 raeburn 979: } else {
1.88 ! raeburn 980: $ownertable .= '<td><input type="radio" name="courseowner" value="'.$cc.'"'.$disabled.' /></td>'."\n";
1.48 raeburn 981: }
982: $ownertable .=
983: '<td>'.$pname{$cc}.'</td>'."\n".
984: '<td>'.$cc.'</td>'."\n".
985: '<td>'.$cc_status{$cc}.' '.$ccname.'</td>'."\n".
986: &Apache::loncommon::end_data_table_row()."\n";
987: }
988: $ownertable .= &Apache::loncommon::end_data_table();
989: }
1.72 raeburn 990: &print_header($r,$crstype,$javascript_validations);
1.48 raeburn 991: my $dctitle = &Apache::lonnet::plaintext('dc');
1.72 raeburn 992: my $mainheader = &modifiable_only_title($crstype);
1.48 raeburn 993: my $hidden_elements = &hidden_form_elements();
994: $r->print('<form action="/adm/modifycourse" method="post" name="'.$env{'form.phase'}.'">'."\n".
995: '<h3>'.$mainheader.' <span class="LC_nobreak">'.$cdesc.'</span></h3><p>'.
996: &Apache::lonhtmlcommon::start_pick_box());
1.72 raeburn 997: if ($crstype eq 'Community') {
1.48 raeburn 998: $r->print(&Apache::lonhtmlcommon::row_title(
999: &Apache::loncommon::help_open_topic('Modify_Community_Owner').
1000: ' '.&mt('Community Owner'))."\n");
1001: } else {
1002: $r->print(&Apache::lonhtmlcommon::row_title(
1003: &Apache::loncommon::help_open_topic('Modify_Course_Instcode').
1004: ' '.&mt('Course Code'))."\n".
1.88 ! raeburn 1005: '<input type="text" size="15" name="coursecode" value="'.$enrollvar{'coursecode'}.'"'.$disabled.'/>'.
1.60 raeburn 1006: &Apache::lonhtmlcommon::row_closure());
1.83 raeburn 1007: if (($crstype eq 'Course') && (&showcredits($cdom))) {
1.60 raeburn 1008: $r->print(&Apache::lonhtmlcommon::row_title(
1009: &Apache::loncommon::help_open_topic('Modify_Course_Credithours').
1010: ' '.&mt('Credits (students)'))."\n".
1.88 ! raeburn 1011: '<input type="text" size="3" name="defaultcredits" value="'.$enrollvar{'defaultcredits'}.'"'.$disabled.' />'.
1.60 raeburn 1012: &Apache::lonhtmlcommon::row_closure());
1.83 raeburn 1013: }
1014: $r->print(&Apache::lonhtmlcommon::row_title(
1015: &Apache::loncommon::help_open_topic('Modify_Course_Defaultauth').
1016: ' '.&mt('Default Authentication method'))."\n".
1017: $authenitems."\n".
1018: &Apache::lonhtmlcommon::row_closure().
1019: &Apache::lonhtmlcommon::row_title(
1020: &Apache::loncommon::help_open_topic('Modify_Course_Owner').
1021: ' '.&mt('Course Owner'))."\n");
1.48 raeburn 1022: }
1.72 raeburn 1023: my ($cctitle,$rolename,$currmanages,$ccchecked,$dcchecked,$defaultchecked);
1024: my ($selfenrollrows,$selfenrolltitles) = &Apache::lonuserutils::get_selfenroll_titles();
1025: if ($type eq 'Community') {
1026: $cctitle = &mt('Community personnel');
1027: } else {
1028: $cctitle = &mt('Course personnel');
1029: }
1030:
1031: $r->print($ownertable."\n".&Apache::lonhtmlcommon::row_closure().
1032: &Apache::lonhtmlcommon::row_title(
1033: &Apache::loncommon::help_open_topic('Modify_Course_Selfenrolladmin').
1034: ' '.&mt('Self-enrollment configuration')).
1035: &Apache::loncommon::start_data_table()."\n".
1036: &Apache::loncommon::start_data_table_header_row()."\n".
1037: '<th>'.$lt{'sett'}.'</th>'.
1038: '<th>'.$lt{'domd'}.'</th>'.
1039: '<th>'.$lt{'whom'}.'</th>'.
1040: &Apache::loncommon::end_data_table_header_row()."\n");
1041: my %optionname;
1042: $optionname{''} = &mt('Use domain default');
1043: $optionname{'0'} = $dctitle;
1044: $optionname{'1'} = $cctitle;
1045: foreach my $item (@{$selfenrollrows}) {
1046: my %checked;
1047: my $default = $cctitle;
1048: if (grep(/^\Q$item\E$/,@default_managebydc)) {
1049: $default = $dctitle;
1050: }
1051: if (grep(/^\Q$item\E$/,@specific_managebydc)) {
1052: $checked{'0'} = ' checked="checked"';
1053: } elsif (grep(/^\Q$item\E$/,@specific_managebycc)) {
1054: $checked{'1'} = ' checked="checked"';
1055: } else {
1056: $checked{''} = ' checked="checked"';
1057: }
1058: $r->print(&Apache::loncommon::start_data_table_row()."\n".
1059: '<td>'.$selfenrolltitles->{$item}.'</td>'."\n".
1060: '<td>'.&mt('[_1] configures',$default).'</td>'."\n".
1061: '<td>');
1062: foreach my $option ('','0','1') {
1063: $r->print('<span class="LC_nobreak"><label>'.
1064: '<input type="radio" name="selfenrollmgr_'.$item.'" '.
1.88 ! raeburn 1065: 'value="'.$option.'"'.$checked{$option}.$disabled.' />'.
1.72 raeburn 1066: $optionname{$option}.'</label></span><br />');
1067: }
1068: $r->print('</td>'."\n".
1069: &Apache::loncommon::end_data_table_row()."\n");
1070: }
1071: $r->print(&Apache::loncommon::end_data_table()."\n".
1.85 raeburn 1072: '<br />'.&Apache::lonhtmlcommon::row_closure().
1073: &Apache::lonhtmlcommon::row_title(
1074: &Apache::loncommon::help_open_topic('Modify_Course_Table_Lifetime').
1075: ' '.&mt('"Temporary" Tables Lifetime (s)'))."\n".
1.88 ! raeburn 1076: '<input type="text" size="10" name="mysqltables" value="'.$settings{'internal.mysqltables'}.'"'.$disabled.' />'.
1.85 raeburn 1077: &Apache::lonhtmlcommon::row_closure(1).
1.88 ! raeburn 1078: &Apache::lonhtmlcommon::end_pick_box().'</p><p>'.$hidden_elements);
! 1079: unless ($readonly) {
! 1080: $r->print('<input type="button" onclick="javascript:changePage(this.form,'."'processparms'".');');
! 1081: if ($crstype eq 'Community') {
! 1082: $r->print('this.form.submit();"');
! 1083: } else {
! 1084: $r->print('javascript:verify_message(this.form);"');
! 1085: }
! 1086: $r->print(' value="'.$lt{'gobt'}.'" />');
1.48 raeburn 1087: }
1.88 ! raeburn 1088: $r->print('</p></form>');
1.48 raeburn 1089: return;
1090: }
1091:
1.72 raeburn 1092: sub print_selfenrollconfig {
1.88 ! raeburn 1093: my ($r,$type,$cdesc,$coursehash,$readonly) = @_;
1.72 raeburn 1094: return unless(ref($coursehash) eq 'HASH');
1095: my $cnum = $coursehash->{'num'};
1096: my $cdom = $coursehash->{'domain'};
1097: my %currsettings = &get_selfenroll_settings($coursehash);
1098: &print_header($r,$type);
1099: $r->print('<h3>'.&mt('Self-enrollment with a student role in: [_1]',
1100: '<span class="LC_nobreak">'.$cdesc.'</span>').'</h3>'."\n");
1101: &Apache::loncreateuser::print_selfenroll_menu($r,'domain',$env{'form.pickedcourse'},
1102: $cdom,$cnum,\%currsettings,
1.88 ! raeburn 1103: &hidden_form_elements(),$readonly);
1.72 raeburn 1104: return;
1105: }
1106:
1107: sub modify_selfenrollconfig {
1108: my ($r,$type,$cdesc,$coursehash) = @_;
1109: return unless(ref($coursehash) eq 'HASH');
1110: my $cnum = $coursehash->{'num'};
1111: my $cdom = $coursehash->{'domain'};
1112: my %currsettings = &get_selfenroll_settings($coursehash);
1113: &print_header($r,$type);
1114: $r->print('<h3>'.&mt('Self-enrollment with a student role in: [_1]',
1115: '<span class="LC_nobreak">'.$cdesc.'</span>').'</h3>'."\n");
1116: $r->print('<form action="/adm/modifycourse" method="post" name="selfenroll">'."\n".
1117: &hidden_form_elements().'<br />');
1118: &Apache::loncreateuser::update_selfenroll_config($r,$env{'form.pickedcourse'},
1.73 raeburn 1119: $cdom,$cnum,'domain',$type,\%currsettings);
1.72 raeburn 1120: $r->print('</form>');
1121: return;
1122: }
1123:
1124: sub get_selfenroll_settings {
1125: my ($coursehash) = @_;
1126: my %currsettings;
1127: if (ref($coursehash) eq 'HASH') {
1128: %currsettings = (
1129: selfenroll_types => $coursehash->{'internal.selfenroll_types'},
1130: selfenroll_registered => $coursehash->{'internal.selfenroll_registered'},
1131: selfenroll_section => $coursehash->{'internal.selfenroll_section'},
1132: selfenroll_notifylist => $coursehash->{'internal.selfenroll_notifylist'},
1133: selfenroll_approval => $coursehash->{'internal.selfenroll_approval'},
1134: selfenroll_limit => $coursehash->{'internal.selfenroll_limit'},
1135: selfenroll_cap => $coursehash->{'internal.selfenroll_cap'},
1136: selfenroll_start_date => $coursehash->{'internal.selfenroll_start_date'},
1137: selfenroll_end_date => $coursehash->{'internal.selfenroll_end_date'},
1138: selfenroll_start_access => $coursehash->{'internal.selfenroll_start_access'},
1139: selfenroll_end_access => $coursehash->{'internal.selfenroll_end_access'},
1140: default_enrollment_start_date => $coursehash->{'default_enrollment_start_date'},
1141: default_enrollment_end_date => $coursehash->{'default_enrollment_end_date'},
1.73 raeburn 1142: uniquecode => $coursehash->{'internal.uniquecode'},
1.72 raeburn 1143: );
1144: }
1145: return %currsettings;
1146: }
1147:
1.48 raeburn 1148: sub modifiable_only_title {
1149: my ($type) = @_;
1150: my $dctitle = &Apache::lonnet::plaintext('dc');
1151: if ($type eq 'Community') {
1152: return &mt('Community settings modifiable only by [_1] for:',$dctitle);
1153: } else {
1154: return &mt('Course settings modifiable only by [_1] for:',$dctitle);
1155: }
1156: }
1.24 albertel 1157:
1.48 raeburn 1158: sub gather_authenitems {
1.88 ! raeburn 1159: my ($cdom,$enrollvar,$readonly) = @_;
1.28 raeburn 1160: my ($krbdef,$krbdefdom)=&Apache::loncommon::get_kerberos_defaults($cdom);
1.2 raeburn 1161: my $curr_authtype = '';
1162: my $curr_authfield = '';
1.48 raeburn 1163: if (ref($enrollvar) eq 'HASH') {
1164: if ($enrollvar->{'authtype'} =~ /^krb/) {
1165: $curr_authtype = 'krb';
1166: } elsif ($enrollvar->{'authtype'} eq 'internal' ) {
1167: $curr_authtype = 'int';
1168: } elsif ($enrollvar->{'authtype'} eq 'localauth' ) {
1169: $curr_authtype = 'loc';
1170: }
1.2 raeburn 1171: }
1172: unless ($curr_authtype eq '') {
1173: $curr_authfield = $curr_authtype.'arg';
1.33 raeburn 1174: }
1.48 raeburn 1175: my $javascript_validations =
1176: &Apache::lonuserutils::javascript_validations('modifycourse',$krbdefdom,
1177: $curr_authtype,$curr_authfield);
1.35 raeburn 1178: my %param = ( formname => 'document.'.$env{'form.phase'},
1.48 raeburn 1179: kerb_def_dom => $krbdefdom,
1180: kerb_def_auth => $krbdef,
1.2 raeburn 1181: mode => 'modifycourse',
1182: curr_authtype => $curr_authtype,
1.88 ! raeburn 1183: curr_autharg => $enrollvar->{'autharg'},
! 1184: readonly => $readonly,
1.48 raeburn 1185: );
1.32 raeburn 1186: my (%authform,$authenitems);
1187: $authform{'krb'} = &Apache::loncommon::authform_kerberos(%param);
1188: $authform{'int'} = &Apache::loncommon::authform_internal(%param);
1189: $authform{'loc'} = &Apache::loncommon::authform_local(%param);
1190: foreach my $item ('krb','int','loc') {
1191: if ($authform{$item} ne '') {
1192: $authenitems .= $authform{$item}.'<br />';
1193: }
1.1 raeburn 1194: }
1.48 raeburn 1195: return($javascript_validations,$authenitems);
1.1 raeburn 1196: }
1197:
1198: sub modify_course {
1.30 raeburn 1199: my ($r,$cdom,$cnum,$cdesc,$domdesc,$type) = @_;
1.48 raeburn 1200: my %longtype = &course_settings_descrip($type);
1.50 raeburn 1201: my @items = ('internal.courseowner','description','internal.co-owners',
1.72 raeburn 1202: 'internal.pendingco-owners','internal.selfenrollmgrdc',
1.85 raeburn 1203: 'internal.selfenrollmgrcc','internal.mysqltables');
1.72 raeburn 1204: my ($selfenrollrows,$selfenrolltitles) = &Apache::lonuserutils::get_selfenroll_titles();
1.81 raeburn 1205: unless (($type eq 'Community') || ($type eq 'Placement')) {
1.48 raeburn 1206: push(@items,('internal.coursecode','internal.authtype','internal.autharg',
1207: 'internal.sectionnums','internal.crosslistings'));
1.60 raeburn 1208: if (&showcredits($cdom)) {
1209: push(@items,'internal.defaultcredits');
1210: }
1.1 raeburn 1211: }
1.48 raeburn 1212: my %settings = &Apache::lonnet::get('environment',\@items,$cdom,$cnum);
1213: my $description = $settings{'description'};
1.60 raeburn 1214: my ($ccrole,$response,$chgresponse,$nochgresponse,$reply,%currattr,%newattr,
1215: %cenv,%changed,@changes,@nochanges,@sections,@xlists,@warnings);
1216: my @modifiable_params = &get_dc_settable($type,$cdom);
1.28 raeburn 1217: foreach my $param (@modifiable_params) {
1.48 raeburn 1218: $currattr{$param} = $settings{'internal.'.$param};
1.1 raeburn 1219: }
1.48 raeburn 1220: if ($type eq 'Community') {
1221: %changed = ( owner => 0 );
1222: $ccrole = 'co';
1223: } else {
1224: %changed = ( code => 0,
1225: owner => 0,
1226: );
1227: $ccrole = 'cc';
1228: unless ($settings{'internal.sectionnums'} eq '') {
1229: if ($settings{'internal.sectionnums'} =~ m/,/) {
1230: @sections = split/,/,$settings{'internal.sectionnums'};
1231: } else {
1232: $sections[0] = $settings{'internal.sectionnums'};
1233: }
1234: }
1.60 raeburn 1235: unless ($settings{'internal.crosslistings'} eq '') {
1.48 raeburn 1236: if ($settings{'internal.crosslistings'} =~ m/,/) {
1237: @xlists = split/,/,$settings{'internal.crosslistings'};
1238: } else {
1239: $xlists[0] = $settings{'internal.crosslistings'};
1240: }
1241: }
1242: if ($env{'form.login'} eq 'krb') {
1243: $newattr{'authtype'} = $env{'form.login'};
1244: $newattr{'authtype'} .= $env{'form.krbver'};
1245: $newattr{'autharg'} = $env{'form.krbarg'};
1246: } elsif ($env{'form.login'} eq 'int') {
1247: $newattr{'authtype'} ='internal';
1248: if ((defined($env{'form.intarg'})) && ($env{'form.intarg'})) {
1249: $newattr{'autharg'} = $env{'form.intarg'};
1250: }
1251: } elsif ($env{'form.login'} eq 'loc') {
1252: $newattr{'authtype'} = 'localauth';
1253: if ((defined($env{'form.locarg'})) && ($env{'form.locarg'})) {
1254: $newattr{'autharg'} = $env{'form.locarg'};
1255: }
1256: }
1257: if ( $newattr{'authtype'}=~ /^krb/) {
1258: if ($newattr{'autharg'} eq '') {
1259: push(@warnings,
1260: &mt('As you did not include the default Kerberos domain'
1.45 bisitz 1261: .' to be used for authentication in this class, the'
1262: .' institutional data used by the automated'
1263: .' enrollment process must include the Kerberos'
1.48 raeburn 1264: .' domain for each new student.'));
1265: }
1266: }
1267:
1268: if ( exists($env{'form.coursecode'}) ) {
1269: $newattr{'coursecode'}=$env{'form.coursecode'};
1270: unless ( $newattr{'coursecode'} eq $currattr{'coursecode'} ) {
1271: $changed{'code'} = 1;
1272: }
1.1 raeburn 1273: }
1.85 raeburn 1274: if ( exists($env{'form.mysqltables'}) ) {
1275: $newattr{'mysqltables'} = $env{'form.mysqltables'};
1276: $newattr{'mysqltables'} =~ s/\D+//g;
1277: }
1.83 raeburn 1278: if (($type ne 'Placement') && (&showcredits($cdom) && exists($env{'form.defaultcredits'}))) {
1.85 raeburn 1279: $newattr{'defaultcredits'}=$env{'form.defaultcredits'};
1.60 raeburn 1280: $newattr{'defaultcredits'} =~ s/[^\d\.]//g;
1281: }
1.72 raeburn 1282: }
1283:
1284: my @newmgrdc = ();
1285: my @newmgrcc = ();
1286: my @currmgrdc = split(/,/,$currattr{'selfenrollmgrdc'});
1287: my @currmgrcc = split(/,/,$currattr{'selfenrollmgrcc'});
1.60 raeburn 1288:
1.72 raeburn 1289: foreach my $item (@{$selfenrollrows}) {
1290: if ($env{'form.selfenrollmgr_'.$item} eq '0') {
1291: push(@newmgrdc,$item);
1292: } elsif ($env{'form.selfenrollmgr_'.$item} eq '1') {
1293: push(@newmgrcc,$item);
1294: }
1295: }
1296:
1297: $newattr{'selfenrollmgrdc'}=join(',',@newmgrdc);
1298: $newattr{'selfenrollmgrcc'}=join(',',@newmgrcc);
1299:
1300: my $cctitle;
1301: if ($type eq 'Community') {
1302: $cctitle = &mt('Community personnel');
1303: } else {
1304: $cctitle = &mt('Course personnel');
1.1 raeburn 1305: }
1.72 raeburn 1306: my $dctitle = &Apache::lonnet::plaintext('dc');
1.1 raeburn 1307:
1.16 albertel 1308: if ( exists($env{'form.courseowner'}) ) {
1309: $newattr{'courseowner'}=$env{'form.courseowner'};
1.14 raeburn 1310: unless ( $newattr{'courseowner'} eq $currattr{'courseowner'} ) {
1.38 raeburn 1311: $changed{'owner'} = 1;
1.1 raeburn 1312: }
1313: }
1.48 raeburn 1314:
1.50 raeburn 1315: if ($changed{'owner'} || $changed{'code'}) {
1.38 raeburn 1316: my %crsinfo = &Apache::lonnet::courseiddump($cdom,'.',1,'.','.',$cnum,
1317: undef,undef,'.');
1318: if (ref($crsinfo{$env{'form.pickedcourse'}}) eq 'HASH') {
1.48 raeburn 1319: if ($changed{'code'}) {
1320: $crsinfo{$env{'form.pickedcourse'}}{'inst_code'} = $env{'form.coursecode'};
1321: }
1322: if ($changed{'owner'}) {
1323: $crsinfo{$env{'form.pickedcourse'}}{'owner'} = $env{'form.courseowner'};
1324: }
1.38 raeburn 1325: my $chome = &Apache::lonnet::homeserver($cnum,$cdom);
1326: my $putres = &Apache::lonnet::courseidput($cdom,\%crsinfo,$chome,'notime');
1.50 raeburn 1327: if ($putres eq 'ok') {
1328: &update_coowners($cdom,$cnum,$chome,\%settings,\%newattr);
1329: }
1.38 raeburn 1330: }
1.14 raeburn 1331: }
1.28 raeburn 1332: foreach my $param (@modifiable_params) {
1333: if ($currattr{$param} eq $newattr{$param}) {
1334: push(@nochanges,$param);
1.1 raeburn 1335: } else {
1.48 raeburn 1336: $cenv{'internal.'.$param} = $newattr{$param};
1.28 raeburn 1337: push(@changes,$param);
1.1 raeburn 1338: }
1339: }
1340: if (@changes > 0) {
1.62 bisitz 1341: $chgresponse = &mt('The following settings have been changed:').'<br/><ul>';
1.1 raeburn 1342: }
1.48 raeburn 1343: if (@nochanges > 0) {
1.62 bisitz 1344: $nochgresponse = &mt('The following settings remain unchanged:').'<br/><ul>';
1.1 raeburn 1345: }
1.33 raeburn 1346: if (@changes > 0) {
1.28 raeburn 1347: my $putreply = &Apache::lonnet::put('environment',\%cenv,$cdom,$cnum);
1.1 raeburn 1348: if ($putreply !~ /^ok$/) {
1.48 raeburn 1349: $response = '<p class="LC_error">'.
1350: &mt('There was a problem processing your requested changes.').'<br />';
1351: if ($type eq 'Community') {
1352: $response .= &mt('Settings for this community have been left unchanged.');
1353: } else {
1354: $response .= &mt('Settings for this course have been left unchanged.');
1355: }
1356: $response .= '<br/>'.&mt('Error: ').$putreply.'</p>';
1.1 raeburn 1357: } else {
1.72 raeburn 1358: if ($env{'course.'.$cdom.'_'.$cnum.'.description'} ne '') {
1359: my %newenv;
1360: map { $newenv{'course.'.$cdom.'_'.$cnum.'.internal.'.$_} = $newattr{$_}; } @changes;
1361: &Apache::lonnet::appenv(\%newenv);
1362: }
1.28 raeburn 1363: foreach my $attr (@modifiable_params) {
1.48 raeburn 1364: if (grep/^\Q$attr\E$/,@changes) {
1.72 raeburn 1365: my $shown = $newattr{$attr};
1366: if ($attr eq 'selfenrollmgrdc') {
1367: $shown = &selfenroll_config_status(\@newmgrdc,$selfenrolltitles);
1368: } elsif ($attr eq 'selfenrollmgrcc') {
1369: $shown = &selfenroll_config_status(\@newmgrcc,$selfenrolltitles);
1370: } elsif (($attr eq 'defaultcredits') && ($shown eq '')) {
1371: $shown = &mt('None');
1.85 raeburn 1372: } elsif (($attr eq 'mysqltables') && ($shown eq '')) {
1373: $shown = &mt('domain default');
1.72 raeburn 1374: }
1375: $chgresponse .= '<li>'.&mt('[_1] now set to: [_2]',$longtype{$attr},$shown).'</li>';
1.1 raeburn 1376: } else {
1.72 raeburn 1377: my $shown = $currattr{$attr};
1378: if ($attr eq 'selfenrollmgrdc') {
1379: $shown = &selfenroll_config_status(\@currmgrdc,$selfenrolltitles);
1380: } elsif ($attr eq 'selfenrollmgrcc') {
1381: $shown = &selfenroll_config_status(\@currmgrcc,$selfenrolltitles);
1382: } elsif (($attr eq 'defaultcredits') && ($shown eq '')) {
1383: $shown = &mt('None');
1.85 raeburn 1384: } elsif (($attr eq 'mysqltables') && ($shown eq '')) {
1385: $shown = &mt('domain default');
1.72 raeburn 1386: }
1387: $nochgresponse .= '<li>'.&mt('[_1] still set to: [_2]',$longtype{$attr},$shown).'</li>';
1.1 raeburn 1388: }
1389: }
1.81 raeburn 1390: if (($type ne 'Community') && ($type ne 'Placement') && ($changed{'code'} || $changed{'owner'})) {
1.1 raeburn 1391: if ( $newattr{'courseowner'} eq '') {
1.48 raeburn 1392: push(@warnings,&mt('There is no owner associated with this LON-CAPA course.').
1393: '<br />'.&mt('If automated enrollment at your institution requires validation of course owners, automated enrollment will fail.'));
1.1 raeburn 1394: } else {
1.59 raeburn 1395: my %crsenv = &Apache::lonnet::get('environment',['internal.co-owners'],$cdom,$cnum);
1396: my $coowners = $crsenv{'internal.co-owners'};
1.1 raeburn 1397: if (@sections > 0) {
1.38 raeburn 1398: if ($changed{'code'}) {
1.2 raeburn 1399: foreach my $sec (@sections) {
1400: if ($sec =~ m/^(.+):/) {
1.48 raeburn 1401: my $instsec = $1;
1.8 raeburn 1402: my $inst_course_id = $newattr{'coursecode'}.$1;
1.28 raeburn 1403: my $course_check = &Apache::lonnet::auto_validate_courseID($cnum,$cdom,$inst_course_id);
1.7 raeburn 1404: if ($course_check eq 'ok') {
1.58 raeburn 1405: my $outcome = &Apache::lonnet::auto_new_course($cnum,$cdom,$inst_course_id,$newattr{'courseowner'},$coowners);
1.48 raeburn 1406: unless ($outcome eq 'ok') {
1407:
1.53 raeburn 1408: 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 1409: }
1410: } else {
1.53 raeburn 1411: 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 1412: }
1413: } else {
1.48 raeburn 1414: 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 1415: }
1416: }
1.38 raeburn 1417: } elsif ($changed{'owner'}) {
1.4 raeburn 1418: foreach my $sec (@sections) {
1419: if ($sec =~ m/^(.+):/) {
1.48 raeburn 1420: my $instsec = $1;
1421: my $inst_course_id = $newattr{'coursecode'}.$instsec;
1.58 raeburn 1422: my $outcome = &Apache::lonnet::auto_new_course($cnum,$cdom,$inst_course_id,$newattr{'courseowner'},$coowners);
1.4 raeburn 1423: unless ($outcome eq 'ok') {
1.53 raeburn 1424: 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 1425: }
1426: } else {
1.53 raeburn 1427: 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 1428: }
1429: }
1430: }
1.1 raeburn 1431: } else {
1.53 raeburn 1432: 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 1433: }
1.38 raeburn 1434: if ( (@xlists > 0) && ($changed{'owner'}) ) {
1.1 raeburn 1435: foreach my $xlist (@xlists) {
1436: if ($xlist =~ m/^(.+):/) {
1.48 raeburn 1437: my $instxlist = $1;
1.58 raeburn 1438: my $outcome = &Apache::lonnet::auto_new_course($cnum,$cdom,$instxlist,$newattr{'courseowner'},$coowners);
1.1 raeburn 1439: unless ($outcome eq 'ok') {
1.48 raeburn 1440: 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 1441: }
1.28 raeburn 1442: }
1.1 raeburn 1443: }
1444: }
1445: }
1446: }
1447: }
1.2 raeburn 1448: } else {
1.28 raeburn 1449: foreach my $attr (@modifiable_params) {
1.72 raeburn 1450: my $shown = $currattr{$attr};
1451: if ($attr eq 'selfenrollmgrdc') {
1452: $shown = &selfenroll_config_status(\@currmgrdc,$selfenrolltitles);
1453: } elsif ($attr eq 'selfenrollmgrcc') {
1454: $shown = &selfenroll_config_status(\@currmgrcc,$selfenrolltitles);
1455: } elsif (($attr eq 'defaultcredits') && ($shown eq '')) {
1456: $shown = &mt('None');
1.85 raeburn 1457: } elsif (($attr eq 'mysqltables') && ($shown eq '')) {
1458: $shown = &mt('domain default');
1.72 raeburn 1459: }
1460: $nochgresponse .= '<li>'.&mt('[_1] still set to: [_2]',$longtype{$attr},$shown).'</li>';
1.2 raeburn 1461: }
1.1 raeburn 1462: }
1463:
1464: if (@changes > 0) {
1465: $chgresponse .= "</ul><br/><br/>";
1466: }
1467: if (@nochanges > 0) {
1468: $nochgresponse .= "</ul><br/><br/>";
1469: }
1.48 raeburn 1470: my ($warning,$numwarnings);
1471: my $numwarnings = scalar(@warnings);
1472: if ($numwarnings) {
1473: $warning = &mt('The following [quant,_1,warning was,warnings were] generated when applying your changes to automated enrollment:',$numwarnings).'<p><ul>';
1474: foreach my $warn (@warnings) {
1475: $warning .= '<li><span class="LC_warning">'.$warn.'</span></li>';
1476: }
1477: $warning .= '</ul></p>';
1.1 raeburn 1478: }
1.48 raeburn 1479: if ($response) {
1480: $reply = $response;
1481: } else {
1.1 raeburn 1482: $reply = $chgresponse.$nochgresponse.$warning;
1483: }
1.48 raeburn 1484: &print_header($r,$type);
1485: my $mainheader = &modifiable_only_title($type);
1486: $reply = '<h3>'.$mainheader.' <span class="LC_nobreak">'.$cdesc.'</span></h3>'."\n".
1487: '<p>'.$reply.'</p>'."\n".
1.28 raeburn 1488: '<form action="/adm/modifycourse" method="post" name="processparms">'.
1.66 bisitz 1489: &hidden_form_elements();
1490: my @actions =
1491: ('<a href="javascript:changePage(document.processparms,'."'menu'".')">'.
1492: &mt('Pick another action').'</a>');
1.48 raeburn 1493: if ($numwarnings) {
1494: my $newrole = $ccrole.'./'.$cdom.'/'.$cnum;
1495: my $escuri = &HTML::Entities::encode('/adm/roles?selectrole=1&'.$newrole.
1496: '=1&destinationurl=/adm/populate','&<>"');
1497:
1.66 bisitz 1498: push(@actions, '<a href="'.$escuri.'">'.
1499: &mt('Go to Automated Enrollment Manager for course').'</a>');
1.48 raeburn 1500: }
1.66 bisitz 1501: $reply .= &Apache::lonhtmlcommon::actionbox(\@actions).'</form>';
1.3 raeburn 1502: $r->print($reply);
1.28 raeburn 1503: return;
1504: }
1505:
1.72 raeburn 1506: sub selfenroll_config_status {
1507: my ($items,$selfenrolltitles) = @_;
1508: my $shown;
1509: if ((ref($items) eq 'ARRAY') && (ref($selfenrolltitles) eq 'HASH')) {
1510: if (@{$items} > 0) {
1511: $shown = '<ul>';
1512: foreach my $item (@{$items}) {
1513: $shown .= '<li>'.$selfenrolltitles->{$item}.'</li>';
1514: }
1515: $shown .= '</ul>';
1516: } else {
1517: $shown = &mt('None');
1518: }
1519: }
1520: return $shown;
1521: }
1522:
1.50 raeburn 1523: sub update_coowners {
1524: my ($cdom,$cnum,$chome,$settings,$newattr) = @_;
1525: return unless ((ref($settings) eq 'HASH') && (ref($newattr) eq 'HASH'));
1526: my %designhash = &Apache::loncommon::get_domainconf($cdom);
1527: my (%cchash,$autocoowners);
1528: if ($designhash{$cdom.'.autoassign.co-owners'}) {
1529: $autocoowners = 1;
1530: %cchash = &Apache::lonnet::get_my_roles($cnum,$cdom,undef,undef,['cc']);
1531: }
1532: if ($settings->{'internal.courseowner'} ne $newattr->{'courseowner'}) {
1533: my $oldowner_to_coowner;
1.51 raeburn 1534: my @types = ('co-owners');
1.50 raeburn 1535: if (($newattr->{'coursecode'}) && ($autocoowners)) {
1536: my $oldowner = $settings->{'internal.courseowner'};
1537: if ($cchash{$oldowner.':cc'}) {
1.51 raeburn 1538: my ($result,$desc) = &Apache::lonnet::auto_validate_instcode($cnum,$cdom,$newattr->{'coursecode'},$oldowner);
1539: if ($result eq 'valid') {
1540: if ($settings->{'internal.co-owner'}) {
1541: my @current = split(',',$settings->{'internal.co-owners'});
1542: unless (grep(/^\Q$oldowner\E$/,@current)) {
1543: $oldowner_to_coowner = 1;
1544: }
1545: } else {
1.50 raeburn 1546: $oldowner_to_coowner = 1;
1547: }
1548: }
1549: }
1.51 raeburn 1550: } else {
1551: push(@types,'pendingco-owners');
1.50 raeburn 1552: }
1.51 raeburn 1553: foreach my $type (@types) {
1.50 raeburn 1554: if ($settings->{'internal.'.$type}) {
1555: my @current = split(',',$settings->{'internal.'.$type});
1556: my $newowner = $newattr->{'courseowner'};
1557: my @newvalues = ();
1558: if (($newowner ne '') && (grep(/^\Q$newowner\E$/,@current))) {
1559: foreach my $person (@current) {
1560: unless ($person eq $newowner) {
1561: push(@newvalues,$person);
1562: }
1563: }
1564: } else {
1565: @newvalues = @current;
1566: }
1567: if ($oldowner_to_coowner) {
1568: push(@newvalues,$settings->{'internal.courseowner'});
1569: @newvalues = sort(@newvalues);
1570: }
1571: my $newownstr = join(',',@newvalues);
1572: if ($newownstr ne $settings->{'internal.'.$type}) {
1573: if ($type eq 'co-owners') {
1574: my $deleted = '';
1575: unless (@newvalues) {
1576: $deleted = 1;
1577: }
1578: &Apache::lonnet::store_coowners($cdom,$cnum,$chome,
1579: $deleted,@newvalues);
1580: } else {
1581: my $pendingcoowners;
1582: my $cid = $cdom.'_'.$cnum;
1583: if (@newvalues) {
1584: $pendingcoowners = join(',',@newvalues);
1585: my %pendinghash = (
1586: 'internal.pendingco-owners' => $pendingcoowners,
1587: );
1.52 raeburn 1588: my $putresult = &Apache::lonnet::put('environment',\%pendinghash,$cdom,$cnum);
1.50 raeburn 1589: if ($putresult eq 'ok') {
1590: if ($env{'course.'.$cid.'.num'} eq $cnum) {
1.52 raeburn 1591: &Apache::lonnet::appenv({'course.'.$cid.'.internal.pendingco-owners' => $pendingcoowners});
1.50 raeburn 1592: }
1593: }
1594: } else {
1595: my $delresult = &Apache::lonnet::del('environment',['internal.pendingco-owners'],$cdom,$cnum);
1596: if ($delresult eq 'ok') {
1597: if ($env{'course.'.$cid.'.internal.pendingco-owners'}) {
1598: &Apache::lonnet::delenv('course.'.$cid.'.internal.pendingco-owners');
1599: }
1600: }
1601: }
1602: }
1603: } elsif ($oldowner_to_coowner) {
1604: &Apache::lonnet::store_coowners($cdom,$cnum,$chome,'',
1605: $settings->{'internal.courseowner'});
1606:
1607: }
1608: } elsif ($oldowner_to_coowner) {
1609: &Apache::lonnet::store_coowners($cdom,$cnum,$chome,'',
1610: $settings->{'internal.courseowner'});
1611: }
1612: }
1613: }
1614: if ($settings->{'internal.coursecode'} ne $newattr->{'coursecode'}) {
1615: if ($newattr->{'coursecode'} ne '') {
1616: my %designhash = &Apache::loncommon::get_domainconf($cdom);
1617: if ($designhash{$cdom.'.autoassign.co-owners'}) {
1618: my @newcoowners = ();
1619: if ($settings->{'internal.co-owners'}) {
1.58 raeburn 1620: my @currcoown = split(',',$settings->{'internal.co-owners'});
1.50 raeburn 1621: my ($updatecoowners,$delcoowners);
1622: foreach my $person (@currcoown) {
1.51 raeburn 1623: my ($result,$desc) = &Apache::lonnet::auto_validate_instcode($cnum,$cdom,$newattr->{'coursecode'},$person);
1.50 raeburn 1624: if ($result eq 'valid') {
1625: push(@newcoowners,$person);
1626: }
1627: }
1628: foreach my $item (sort(keys(%cchash))) {
1629: my ($uname,$udom,$urole) = split(':',$item);
1.51 raeburn 1630: next if ($uname.':'.$udom eq $newattr->{'courseowner'});
1.50 raeburn 1631: unless (grep(/^\Q$uname\E:\Q$udom\E$/,@newcoowners)) {
1.51 raeburn 1632: my ($result,$desc) = &Apache::lonnet::auto_validate_instcode($cnum,$cdom,$newattr->{'coursecode'},$uname.':'.$udom);
1633: if ($result eq 'valid') {
1634: push(@newcoowners,$uname.':'.$udom);
1635: }
1.50 raeburn 1636: }
1637: }
1638: if (@newcoowners) {
1639: my $coowners = join(',',sort(@newcoowners));
1640: unless ($coowners eq $settings->{'internal.co-owners'}) {
1641: $updatecoowners = 1;
1642: }
1643: } else {
1644: $delcoowners = 1;
1645: }
1646: if ($updatecoowners || $delcoowners) {
1647: &Apache::lonnet::store_coowners($cdom,$cnum,$chome,
1648: $delcoowners,@newcoowners);
1649: }
1650: } else {
1651: foreach my $item (sort(keys(%cchash))) {
1652: my ($uname,$udom,$urole) = split(':',$item);
1653: push(@newcoowners,$uname.':'.$udom);
1654: }
1655: if (@newcoowners) {
1656: &Apache::lonnet::store_coowners($cdom,$cnum,$chome,'',
1657: @newcoowners);
1658: }
1659: }
1660: }
1661: }
1662: }
1663: return;
1664: }
1665:
1.28 raeburn 1666: sub modify_quota {
1.48 raeburn 1667: my ($r,$cdom,$cnum,$cdesc,$domdesc,$type) = @_;
1668: &print_header($r,$type);
1.61 raeburn 1669: my $lctype = lc($type);
1670: my $headline = &mt("Disk space quotas for $lctype: [_1]",
1671: '<span class="LC_nobreak">'.$cdesc.'</span>');
1.48 raeburn 1672: $r->print('<form action="/adm/modifycourse" method="post" name="processquota">'."\n".
1.61 raeburn 1673: '<h3>'.$headline.'</h3>');
1674: my %oldsettings = &Apache::lonnet::get('environment',['internal.coursequota','internal.uploadquota'],$cdom,$cnum);
1675: my %staticdefaults = (
1676: coursequota => 20,
1677: uploadquota => 500,
1678: );
1679: my %default;
1680: $default{'coursequota'} = $staticdefaults{'coursequota'};
1681: my %domdefs = &Apache::lonnet::get_domain_defaults($cdom);
1682: $default{'uploadquota'} = $domdefs{'uploadquota'};
1683: if ($default{'uploadquota'} eq '') {
1684: $default{'uploadquota'} = $staticdefaults{'uploadquota'};
1685: }
1686: my (%cenv,%showresult);
1687: foreach my $item ('coursequota','uploadquota') {
1688: if ($env{'form.'.$item} ne '') {
1689: my $newquota = $env{'form.'.$item};
1690: if ($newquota =~ /^\s*(\d+\.?\d*|\.\d+)\s*$/) {
1691: $newquota = $1;
1692: if ($oldsettings{'internal.'.$item} == $newquota) {
1693: if ($item eq 'coursequota') {
1694: $r->print(&mt('The disk space allocated for group portfolio files remains unchanged as [_1] MB.',$newquota).'<br />');
1695: } else {
1696: $r->print(&mt('The disk space allocated for files uploaded via the Content Editor remains unchanged as [_1] MB.',$newquota).'<br />');
1697: }
1698: } else {
1699: $cenv{'internal.'.$item} = $newquota;
1700: $showresult{$item} = 1;
1701: }
1.28 raeburn 1702: } else {
1.61 raeburn 1703: if ($item eq 'coursequota') {
1704: $r->print(&mt('The proposed group portfolio quota contained invalid characters, so the quota is unchanged.').'<br />');
1705: } else {
1706: $r->print(&mt('The proposed quota for content uploaded via the Content Editor contained invalid characters, so the quota is unchanged.').'<br />');
1707:
1708: }
1709: }
1710: }
1711: }
1712: if (keys(%cenv)) {
1713: my $putreply = &Apache::lonnet::put('environment',\%cenv,$cdom,
1714: $cnum);
1715: foreach my $key (sort(keys(%showresult))) {
1716: if (($oldsettings{'internal.'.$key} eq '') &&
1717: ($env{'form.'.$key} == $default{$key})) {
1718: if ($key eq 'uploadquota') {
1719: if ($type eq 'Community') {
1720: $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.',
1721: $default{$key}).'<br />');
1722: } else {
1723: $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.',
1724: $default{$key}).'<br />');
1725: }
1726: } else {
1.48 raeburn 1727: if ($type eq 'Community') {
1.61 raeburn 1728: $r->print(&mt('The disk space allocated for group portfolio files in this community is the default quota for this domain: [_1] MB.',
1729: $default{$key}).'<br />');
1.48 raeburn 1730: } else {
1.61 raeburn 1731: $r->print(&mt('The disk space allocated for group portfolio files in this course is the default quota for this domain: [_1] MB.',
1732: $default{$key}).'<br />');
1.48 raeburn 1733: }
1.61 raeburn 1734: }
1735: delete($showresult{$key});
1736: }
1737: }
1738: if ($putreply eq 'ok') {
1739: my %updatedsettings = &Apache::lonnet::get('environment',['internal.coursequota','internal.uploadquota'],$cdom,$cnum);
1740: if ($showresult{'coursequota'}) {
1741: $r->print(&mt('The disk space allocated for group portfolio files is now: [_1] MB.',
1742: '<b>'.$updatedsettings{'internal.coursequota'}.'</b>').'<br />');
1743: my $usage = &Apache::longroup::sum_quotas($cdom.'_'.$cnum);
1744: if ($usage >= $updatedsettings{'internal.coursequota'}) {
1745: my $newoverquota;
1746: if ($usage < $oldsettings{'internal.coursequota'}) {
1747: $newoverquota = 'now';
1748: }
1749: $r->print('<p>');
1750: if ($type eq 'Community') {
1.67 bisitz 1751: $r->print(&mt("Disk usage $newoverquota exceeds the quota for this community.").' '.
1.61 raeburn 1752: &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 1753: } else {
1.67 bisitz 1754: $r->print(&mt("Disk usage $newoverquota exceeds the quota for this course.").' '.
1.61 raeburn 1755: &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 1756: }
1.61 raeburn 1757: $r->print('</p>');
1.28 raeburn 1758: }
1759: }
1.61 raeburn 1760: if ($showresult{'uploadquota'}) {
1761: $r->print(&mt('The disk space allocated for content uploaded directly via the Content Editor is now: [_1] MB.',
1762: '<b>'.$updatedsettings{'internal.uploadquota'}.'</b>').'<br />');
1763: }
1.28 raeburn 1764: } else {
1.63 raeburn 1765: $r->print(&mt('An error occurred storing the quota(s) for group portfolio files and/or uploaded content: ').
1.61 raeburn 1766: $putreply);
1.28 raeburn 1767: }
1768: }
1.48 raeburn 1769: $r->print('<p>'.
1770: '<a href="javascript:changePage(document.processquota,'."'menu'".')">'.
1771: &mt('Pick another action').'</a>');
1.28 raeburn 1772: $r->print(&hidden_form_elements().'</form>');
1773: return;
1.1 raeburn 1774: }
1775:
1.57 raeburn 1776: sub modify_anonsurvey_threshold {
1777: my ($r,$cdom,$cnum,$cdesc,$domdesc,$type) = @_;
1778: &print_header($r,$type);
1779: $r->print('<form action="/adm/modifycourse" method="post" name="processthreshold">'."\n".
1780: '<h3>'.&mt('Responder threshold required for display of anonymous survey submissions:').
1781: ' <span class="LC_nobreak">'.$cdesc.'</span></h3><br />');
1782: my %oldsettings = &Apache::lonnet::get('environment',['internal.anonsurvey_threshold'],$cdom,$cnum);
1783: my %domconfig =
1784: &Apache::lonnet::get_dom('configuration',['coursedefaults'],$cdom);
1785: my $defaultthreshold;
1786: if (ref($domconfig{'coursedefaults'}) eq 'HASH') {
1787: $defaultthreshold = $domconfig{'coursedefaults'}{'anonsurvey_threshold'};
1788: if ($defaultthreshold eq '') {
1789: $defaultthreshold = 10;
1790: }
1791: } else {
1792: $defaultthreshold = 10;
1793: }
1794: if ($env{'form.threshold'} eq '') {
1795: $r->print(&mt('The proposed responder threshold for display of anonymous survey submissions was blank, so the threshold is unchanged.'));
1796: } else {
1797: my $newthreshold = $env{'form.threshold'};
1798: if ($newthreshold =~ /^\s*(\d+)\s*$/) {
1799: $newthreshold = $1;
1800: if ($oldsettings{'internal.anonsurvey_threshold'} eq $env{'form.threshold'}) {
1801: $r->print(&mt('Responder threshold for anonymous survey submissions display remains unchanged: [_1].',$env{'form.threshold'}));
1802: } else {
1803: my %cenv = (
1804: 'internal.anonsurvey_threshold' => $env{'form.threshold'},
1805: );
1806: my $putreply = &Apache::lonnet::put('environment',\%cenv,$cdom,
1807: $cnum);
1.72 raeburn 1808: if ($putreply eq 'ok') {
1809: if ($env{'course.'.$cdom.'_'.$cnum.'.description'} ne '') {
1810: &Apache::lonnet::appenv(
1811: {'course.'.$cdom.'_'.$cnum.'.internal.anonsurvey_threshold' => $env{'form.threshold'}});
1812: }
1813: }
1.57 raeburn 1814: if (($oldsettings{'internal.anonsurvey_threshold'} eq '') &&
1815: ($env{'form.threshold'} == $defaultthreshold)) {
1816: $r->print(&mt('The responder threshold for display of anonymous survey submissions is the default for this domain: [_1].',$defaultthreshold));
1817: } else {
1818: if ($putreply eq 'ok') {
1819: my %updatedsettings = &Apache::lonnet::get('environment',['internal.anonsurvey_threshold'],$cdom,$cnum);
1820: $r->print(&mt('The responder threshold for display of anonymous survey submissions is now: [_1].','<b>'.$updatedsettings{'internal.anonsurvey_threshold'}.'</b>'));
1821: } else {
1822: $r->print(&mt('An error occurred storing the responder threshold for anonymous submissions display: ').
1823: $putreply);
1824: }
1825: }
1826: }
1827: } else {
1828: $r->print(&mt('The proposed responder threshold for display of anonymous submissions contained invalid characters, so the threshold is unchanged.'));
1829: }
1830: }
1831: $r->print('<p>'.
1832: '<a href="javascript:changePage(document.processthreshold,'."'menu'".')">'.
1.75 raeburn 1833: &mt('Pick another action').'</a></p>');
1834: $r->print(&hidden_form_elements().'</form>');
1835: return;
1836: }
1837:
1838: sub modify_postsubmit_config {
1839: my ($r,$cdom,$cnum,$cdesc,$domdesc,$type) = @_;
1840: &print_header($r,$type);
1841: my %lt = &Apache::lonlocal::texthash(
1842: subb => 'Submit button behavior after student makes a submission:',
1843: unch => 'Post submission behavior of the Submit button is unchanged.',
1844: erro => 'An error occurred when saving your proposed changes.',
1845: inva => 'An invalid response was recorded.',
1846: pick => 'Pick another action',
1847: );
1848: $r->print('<form action="/adm/modifycourse" method="post" name="processpostsubmit">'."\n".
1849: '<h3>'.$lt{'subb'}.' <span class="LC_nobreak">('.$cdesc.')</span></h3><br />');
1850: my %oldsettings =
1851: &Apache::lonnet::get('environment',['internal.postsubmit','internal.postsubtimeout','internal.coursecode','internal.textbook'],$cdom,$cnum);
1852: my $postsubmit = $env{'form.postsubmit'};
1853: if ($postsubmit eq '1') {
1854: my $postsubtimeout = $env{'form.postsubtimeout'};
1855: $postsubtimeout =~ s/[^\d\.]+//g;
1856: if (($oldsettings{'internal.postsubmit'} eq $postsubmit) && ($oldsettings{'internal.postsubtimeout'} eq $postsubtimeout)) {
1857: $r->print($lt{'unch'});
1858: } else {
1859: my %cenv = (
1860: 'internal.postsubmit' => $postsubmit,
1861: );
1862: if ($postsubtimeout eq '') {
1863: my $putreply = &Apache::lonnet::put('environment',\%cenv,$cdom,$cnum);
1864: if ($putreply eq 'ok') {
1865: my $defaulttimeout = &domain_postsubtimeout($cdom,$type,\%oldsettings);
1866: $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));
1867: if (exists($oldsettings{'internal.postsubtimeout'})) {
1868: &Apache::lonnet::del('environment',['internal.postsubtimeout'],$cdom,$cnum);
1869: }
1870: } else {
1871: $r->print($lt{'erro'});
1872: }
1873: } else {
1874: $cenv{'internal.postsubtimeout'} = $postsubtimeout;
1875: my $putreply = &Apache::lonnet::put('environment',\%cenv,$cdom,$cnum);
1876: if ($putreply eq 'ok') {
1877: if ($postsubtimeout eq '0') {
1878: $r->print(&mt('Submit button will be disabled after student submission until page is reloaded.'));
1879: } else {
1880: $r->print(&mt('Submit button will be disabled after student submission for [quant,_1,second].',$postsubtimeout));
1881: }
1882: } else {
1883: $r->print($lt{'erro'});
1884: }
1885: }
1886: }
1887: } elsif ($postsubmit eq '0') {
1888: if ($oldsettings{'internal.postsubmit'} eq $postsubmit) {
1889: $r->print($lt{'unch'});
1890: } else {
1891: if (exists($oldsettings{'internal.postsubtimeout'})) {
1892: &Apache::lonnet::del('environment',['internal.postsubtimeout'],$cdom,$cnum);
1893: }
1894: my %cenv = (
1895: 'internal.postsubmit' => $postsubmit,
1896: );
1897: my $putreply = &Apache::lonnet::put('environment',\%cenv,$cdom,$cnum);
1898: if ($putreply eq 'ok') {
1.76 droeschl 1899: $r->print(&mt('Submit button will not be disabled after student submission'));
1.75 raeburn 1900: } else {
1901: $r->print($lt{'erro'});
1902: }
1903: }
1904: } else {
1905: $r->print($lt{'inva'}.' '.$lt{'unch'});
1906: }
1907: $r->print('<p>'.
1908: '<a href="javascript:changePage(document.processpostsubmit,'."'menu'".')">'.
1909: &mt('Pick another action').'</a></p>');
1.57 raeburn 1910: $r->print(&hidden_form_elements().'</form>');
1911: return;
1912: }
1913:
1.38 raeburn 1914: sub modify_catsettings {
1.48 raeburn 1915: my ($r,$cdom,$cnum,$cdesc,$domdesc,$type) = @_;
1916: &print_header($r,$type);
1917: my ($ccrole,%desc);
1918: if ($type eq 'Community') {
1919: $desc{'hidefromcat'} = &mt('Excluded from community catalog');
1920: $desc{'categories'} = &mt('Assigned categories for this community');
1921: $ccrole = 'co';
1922: } else {
1923: $desc{'hidefromcat'} = &mt('Excluded from course catalog');
1924: $desc{'categories'} = &mt('Assigned categories for this course');
1925: $ccrole = 'cc';
1926: }
1.38 raeburn 1927: $r->print('
1928: <form action="/adm/modifycourse" method="post" name="processcat">
1929: <h3>'.&mt('Category settings').'</h3>');
1930: my %domconf = &Apache::lonnet::get_dom('configuration',['coursecategories'],$cdom);
1.49 raeburn 1931: my @cat_params = &catalog_settable($domconf{'coursecategories'},$type);
1.38 raeburn 1932: if (@cat_params > 0) {
1933: my (%cenv,@changes,@nochanges);
1934: my %currsettings =
1935: &Apache::lonnet::get('environment',['hidefromcat','categories'],$cdom,$cnum);
1936: my (@newcategories,%showitem);
1937: if (grep(/^togglecats$/,@cat_params)) {
1938: if ($currsettings{'hidefromcat'} ne $env{'form.hidefromcat'}) {
1939: push(@changes,'hidefromcat');
1940: $cenv{'hidefromcat'} = $env{'form.hidefromcat'};
1941: } else {
1942: push(@nochanges,'hidefromcat');
1943: }
1944: if ($env{'form.hidefromcat'} eq 'yes') {
1945: $showitem{'hidefromcat'} = '"'.&mt('Yes')."'";
1946: } else {
1947: $showitem{'hidefromcat'} = '"'.&mt('No').'"';
1948: }
1949: }
1950: if (grep(/^categorize$/,@cat_params)) {
1951: my (@cats,@trails,%allitems,%idx,@jsarray);
1952: if (ref($domconf{'coursecategories'}) eq 'HASH') {
1953: my $cathash = $domconf{'coursecategories'}{'cats'};
1954: if (ref($cathash) eq 'HASH') {
1955: &Apache::loncommon::extract_categories($cathash,\@cats,\@trails,
1956: \%allitems,\%idx,\@jsarray);
1957: }
1958: }
1959: @newcategories = &Apache::loncommon::get_env_multiple('form.usecategory');
1960: if (@newcategories == 0) {
1961: $showitem{'categories'} = '"'.&mt('None').'"';
1962: } else {
1963: $showitem{'categories'} = '<ul>';
1964: foreach my $item (@newcategories) {
1965: $showitem{'categories'} .= '<li>'.$trails[$allitems{$item}].'</li>';
1966: }
1967: $showitem{'categories'} .= '</ul>';
1968: }
1969: my $catchg = 0;
1970: if ($currsettings{'categories'} ne '') {
1971: my @currcategories = split('&',$currsettings{'categories'});
1972: foreach my $cat (@currcategories) {
1973: if (!grep(/^\Q$cat\E$/,@newcategories)) {
1974: $catchg = 1;
1975: last;
1976: }
1977: }
1978: if (!$catchg) {
1979: foreach my $cat (@newcategories) {
1980: if (!grep(/^\Q$cat\E$/,@currcategories)) {
1981: $catchg = 1;
1982: last;
1983: }
1984: }
1985: }
1986: } else {
1987: if (@newcategories > 0) {
1988: $catchg = 1;
1989: }
1990: }
1991: if ($catchg) {
1992: $cenv{'categories'} = join('&',@newcategories);
1993: push(@changes,'categories');
1994: } else {
1995: push(@nochanges,'categories');
1996: }
1997: if (@changes > 0) {
1998: my $putreply = &Apache::lonnet::put('environment',\%cenv,$cdom,$cnum);
1999: if ($putreply eq 'ok') {
1.72 raeburn 2000: if ($env{'course.'.$cdom.'_'.$cnum.'.description'} ne '') {
2001: my %newenvhash;
2002: foreach my $item (@changes) {
2003: $newenvhash{'course.'.$cdom.'_'.$cnum.'.'.$item} = $cenv{$item};
2004: }
2005: &Apache::lonnet::appenv(\%newenvhash);
2006: }
1.38 raeburn 2007: my %crsinfo = &Apache::lonnet::courseiddump($cdom,'.',1,'.','.',
2008: $cnum,undef,undef,'.');
2009: if (ref($crsinfo{$env{'form.pickedcourse'}}) eq 'HASH') {
2010: if (grep(/^hidefromcat$/,@changes)) {
2011: $crsinfo{$env{'form.pickedcourse'}}{'hidefromcat'} = $env{'form.hidefromcat'};
2012: }
2013: if (grep(/^categories$/,@changes)) {
2014: $crsinfo{$env{'form.pickedcourse'}}{'categories'} = $cenv{'categories'};
2015: }
2016: my $chome = &Apache::lonnet::homeserver($cnum,$cdom);
2017: my $putres = &Apache::lonnet::courseidput($cdom,\%crsinfo,$chome,'notime');
2018: }
1.48 raeburn 2019: $r->print(&mt('The following changes occurred:').'<ul>');
1.38 raeburn 2020: foreach my $item (@changes) {
1.48 raeburn 2021: $r->print('<li>'.&mt('[_1] now set to: [_2]',$desc{$item},$showitem{$item}).'</li>');
1.38 raeburn 2022: }
2023: $r->print('</ul><br />');
2024: }
2025: }
2026: if (@nochanges > 0) {
1.48 raeburn 2027: $r->print(&mt('The following were unchanged:').'<ul>');
1.38 raeburn 2028: foreach my $item (@nochanges) {
1.48 raeburn 2029: $r->print('<li>'.&mt('[_1] still set to: [_2]',$desc{$item},$showitem{$item}).'</li>');
1.38 raeburn 2030: }
2031: $r->print('</ul>');
2032: }
2033: }
2034: } else {
1.48 raeburn 2035: my $newrole = $ccrole.'./'.$cdom.'/'.$cnum;
2036: my $escuri = &HTML::Entities::encode('/adm/roles?selectrole=1&'.$newrole.
2037: '=1&destinationurl=/adm/courseprefs','&<>"');
2038: if ($type eq 'Community') {
2039: $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 />');
2040: } else {
2041: $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 />');
2042: }
1.38 raeburn 2043: }
2044: $r->print('<br />'."\n".
2045: '<a href="javascript:changePage(document.processcat,'."'menu'".')">'.
1.48 raeburn 2046: &mt('Pick another action').'</a>');
1.38 raeburn 2047: $r->print(&hidden_form_elements().'</form>');
2048: return;
2049: }
2050:
1.1 raeburn 2051: sub print_header {
1.48 raeburn 2052: my ($r,$type,$javascript_validations) = @_;
1.28 raeburn 2053: my $phase = "start";
2054: if ( exists($env{'form.phase'}) ) {
2055: $phase = $env{'form.phase'};
2056: }
2057: my $js = qq|
1.60 raeburn 2058:
1.28 raeburn 2059: function changePage(formname,newphase) {
2060: formname.phase.value = newphase;
2061: if (newphase == 'processparms') {
2062: return;
1.1 raeburn 2063: }
1.28 raeburn 2064: formname.submit();
2065: }
1.60 raeburn 2066:
1.28 raeburn 2067: |;
2068: if ($phase eq 'setparms') {
1.60 raeburn 2069: $js .= $javascript_validations;
1.28 raeburn 2070: } elsif ($phase eq 'courselist') {
2071: $js .= qq|
1.60 raeburn 2072:
1.28 raeburn 2073: function gochoose(cname,cdom,cdesc) {
2074: document.courselist.pickedcourse.value = cdom+'_'+cname;
2075: document.courselist.submit();
2076: }
1.60 raeburn 2077:
2078: function hide_searching() {
2079: if (document.getElementById('searching')) {
2080: document.getElementById('searching').style.display = 'none';
2081: }
2082: return;
2083: }
2084:
1.28 raeburn 2085: |;
2086: } elsif ($phase eq 'setquota') {
1.57 raeburn 2087: my $invalid = &mt('The quota you entered contained invalid characters.');
2088: my $alert = &mt('You must enter a number');
1.78 damieng 2089: &js_escape(\$invalid);
2090: &js_escape(\$alert);
1.57 raeburn 2091: my $regexp = '/^\s*(\d+\.?\d*|\.\d+)\s*$/';
2092: $js .= <<"ENDSCRIPT";
1.60 raeburn 2093:
1.57 raeburn 2094: function verify_quota() {
2095: var newquota = document.setquota.coursequota.value;
2096: var num_reg = $regexp;
1.28 raeburn 2097: if (num_reg.test(newquota)) {
1.57 raeburn 2098: changePage(document.setquota,'processquota');
1.1 raeburn 2099: } else {
1.57 raeburn 2100: alert("$invalid\\n$alert");
2101: return false;
1.1 raeburn 2102: }
1.57 raeburn 2103: return true;
2104: }
1.60 raeburn 2105:
1.57 raeburn 2106: ENDSCRIPT
2107: } elsif ($phase eq 'setanon') {
2108: my $invalid = &mt('The responder threshold you entered is invalid.');
2109: my $alert = &mt('You must enter a positive integer.');
1.78 damieng 2110: &js_escape(\$invalid);
2111: &js_escape(\$alert);
1.57 raeburn 2112: my $regexp = ' /^\s*\d+\s*$/';
2113: $js .= <<"ENDSCRIPT";
1.60 raeburn 2114:
1.57 raeburn 2115: function verify_anon_threshold() {
2116: var newthreshold = document.setanon.threshold.value;
2117: var num_reg = $regexp;
2118: if (num_reg.test(newthreshold)) {
2119: if (newthreshold > 0) {
2120: changePage(document.setanon,'processthreshold');
2121: } else {
2122: alert("$invalid\\n$alert");
2123: return false;
2124: }
2125: } else {
2126: alert("$invalid\\n$alert");
2127: return false;
2128: }
2129: return true;
1.28 raeburn 2130: }
1.60 raeburn 2131:
1.28 raeburn 2132: ENDSCRIPT
1.75 raeburn 2133: } elsif ($phase eq 'setpostsubmit') {
2134: my $invalid = &mt('The choice entered for disabling the submit button is invalid.');
2135: my $invalidtimeout = &mt('The timeout you entered for disabling the submit button is invalid.');
2136: my $alert = &mt('Enter one of: a positive integer, 0 (for no timeout), or leave blank to use domain default');
1.78 damieng 2137: &js_escape(\$invalid);
2138: &js_escape(\$invalidtimeout);
2139: &js_escape(\$alert);
1.75 raeburn 2140: my $regexp = ' /^\s*\d+\s*$/';
2141:
2142: $js .= <<"ENDSCRIPT";
2143:
2144: function verify_postsubmit() {
2145: var optionsElement = document.setpostsubmit.postsubmit;
2146: var verified = '';
2147: if (optionsElement.length) {
2148: var currval;
2149: for (var i=0; i<optionsElement.length; i++) {
2150: if (optionsElement[i].checked) {
2151: currval = optionsElement[i].value;
2152: }
2153: }
2154: if (currval == 1) {
2155: var newtimeout = document.setpostsubmit.postsubtimeout.value;
2156: if (newtimeout == '') {
2157: verified = 'ok';
2158: } else {
2159: var num_reg = $regexp;
2160: if (num_reg.test(newtimeout)) {
2161: if (newtimeout>= 0) {
2162: verified = 'ok';
2163: } else {
2164: alert("$invalidtimeout\\n$alert");
2165: return false;
2166: }
2167: } else {
2168: alert("$invalid\\n$alert");
2169: return false;
2170: }
2171: }
2172: } else {
2173: if (currval == 0) {
2174: verified = 'ok';
2175: } else {
2176: alert('$invalid');
2177: return false;
2178: }
2179: }
2180: if (verified == 'ok') {
2181: changePage(document.setpostsubmit,'processpostsubmit');
2182: return true;
2183: }
2184: }
2185: return false;
2186: }
2187:
2188: function togglePostsubmit(caller) {
2189: var optionsElement = document.setpostsubmit.postsubmit;
2190: if (document.getElementById(caller)) {
2191: var divitem = document.getElementById(caller);
2192: var optionsElement = document.setpostsubmit.postsubmit;
2193: if (optionsElement.length) {
2194: var currval;
2195: for (var i=0; i<optionsElement.length; i++) {
2196: if (optionsElement[i].checked) {
2197: currval = optionsElement[i].value;
2198: }
2199: }
2200: if (currval == 1) {
2201: divitem.style.display = 'block';
2202: } else {
2203: divitem.style.display = 'none';
2204: }
2205: }
1.1 raeburn 2206: }
1.75 raeburn 2207: return;
2208: }
1.60 raeburn 2209:
1.75 raeburn 2210: ENDSCRIPT
2211:
2212: }
1.37 raeburn 2213: my $starthash;
1.86 raeburn 2214: if ($env{'form.phase'} eq 'adhocrole') {
1.37 raeburn 2215: $starthash = {
1.86 raeburn 2216: add_entries => {'onload' => "javascript:document.adhocrole.submit();"},
1.37 raeburn 2217: };
1.60 raeburn 2218: } elsif ($phase eq 'courselist') {
2219: $starthash = {
1.74 musolffc 2220: add_entries => {'onload' => "hide_searching(); courseSet(document.filterpicker.official, 'load');"},
1.60 raeburn 2221: };
1.37 raeburn 2222: }
1.48 raeburn 2223: $r->print(&Apache::loncommon::start_page('View/Modify Course/Community Settings',
1.60 raeburn 2224: &Apache::lonhtmlcommon::scripttag($js),
2225: $starthash));
1.48 raeburn 2226: my $bread_text = "View/Modify Courses/Communities";
2227: if ($type eq 'Community') {
2228: $bread_text = 'Community Settings';
1.81 raeburn 2229: } elsif ($type eq 'Placement') {
2230: $bread_text = 'Placement Test Settings';
1.41 raeburn 2231: } else {
1.48 raeburn 2232: $bread_text = 'Course Settings';
1.41 raeburn 2233: }
1.48 raeburn 2234: $r->print(&Apache::lonhtmlcommon::breadcrumbs($bread_text));
1.5 raeburn 2235: return;
1.1 raeburn 2236: }
2237:
2238: sub print_footer {
1.23 albertel 2239: my ($r) = @_;
2240: $r->print('<br />'.&Apache::loncommon::end_page());
1.5 raeburn 2241: return;
1.3 raeburn 2242: }
2243:
2244: sub check_course {
1.71 raeburn 2245: my ($dom,$domdesc) = @_;
2246: my ($ok_course,$description,$instcode);
2247: my %coursehash;
2248: if ($env{'form.pickedcourse'} =~ /^$match_domain\_$match_courseid$/) {
2249: my %args;
2250: unless ($env{'course.'.$env{'form.pickedcourse'}.'.description'}) {
2251: %args = (
2252: 'one_time' => 1,
2253: 'freshen_cache' => 1,
2254: );
2255: }
2256: %coursehash =
2257: &Apache::lonnet::coursedescription($env{'form.pickedcourse'},\%args);
2258: my $cnum = $coursehash{'num'};
2259: my $cdom = $coursehash{'domain'};
2260: $description = $coursehash{'description'};
2261: $instcode = $coursehash{'internal.coursecode'};
2262: if ($instcode) {
2263: $description .= " ($instcode)";
2264: }
2265: if (($cdom eq $dom) && ($cnum =~ /^$match_courseid$/)) {
2266: my %courseIDs = &Apache::lonnet::courseiddump($cdom,'.',1,'.','.',
2267: $cnum,undef,undef,'.');
2268: if ($courseIDs{$cdom.'_'.$cnum}) {
2269: $ok_course = 'ok';
1.5 raeburn 2270: }
1.3 raeburn 2271: }
2272: }
1.71 raeburn 2273: return ($ok_course,$description,\%coursehash);
1.1 raeburn 2274: }
2275:
1.28 raeburn 2276: sub course_settings_descrip {
1.48 raeburn 2277: my ($type) = @_;
2278: my %longtype;
2279: if ($type eq 'Community') {
2280: %longtype = &Apache::lonlocal::texthash(
1.72 raeburn 2281: 'courseowner' => "Username:domain of community owner",
2282: 'co-owners' => "Username:domain of each co-owner",
2283: 'selfenrollmgrdc' => "Community-specific self-enrollment configuration by Domain Coordinator",
2284: 'selfenrollmgrcc' => "Community-specific self-enrollment configuration by Community personnel",
1.85 raeburn 2285: 'mysqltables' => '"Temporary" student performance tables lifetime (seconds)',
1.48 raeburn 2286: );
2287: } else {
2288: %longtype = &Apache::lonlocal::texthash(
1.28 raeburn 2289: 'authtype' => 'Default authentication method',
2290: 'autharg' => 'Default authentication parameter',
2291: 'autoadds' => 'Automated adds',
2292: 'autodrops' => 'Automated drops',
2293: 'autostart' => 'Date of first automated enrollment',
2294: 'autoend' => 'Date of last automated enrollment',
2295: 'default_enrollment_start_date' => 'Date of first student access',
2296: 'default_enrollment_end_date' => 'Date of last student access',
2297: 'coursecode' => 'Official course code',
2298: 'courseowner' => "Username:domain of course owner",
1.50 raeburn 2299: 'co-owners' => "Username:domain of each co-owner",
1.28 raeburn 2300: 'notifylist' => 'Course Coordinators to be notified of enrollment changes',
1.48 raeburn 2301: 'sectionnums' => 'Course section number:LON-CAPA section',
2302: 'crosslistings' => 'Crosslisted class:LON-CAPA section',
1.72 raeburn 2303: 'defaultcredits' => 'Credits',
1.84 raeburn 2304: 'autodropfailsafe' => "Failsafe section enrollment count",
1.72 raeburn 2305: 'selfenrollmgrdc' => "Course-specific self-enrollment configuration by Domain Coordinator",
2306: 'selfenrollmgrcc' => "Course-specific self-enrollment configuration by Course personnel",
1.85 raeburn 2307: 'mysqltables' => '"Temporary" student performance tables lifetime (seconds)',
1.48 raeburn 2308: );
2309: }
1.28 raeburn 2310: return %longtype;
2311: }
2312:
2313: sub hidden_form_elements {
2314: my $hidden_elements =
1.46 raeburn 2315: &Apache::lonhtmlcommon::echo_form_input(['gosearch','updater','coursecode',
1.37 raeburn 2316: 'prevphase','numlocalcc','courseowner','login','coursequota','intarg',
1.57 raeburn 2317: 'locarg','krbarg','krbver','counter','hidefromcat','usecategory',
1.75 raeburn 2318: 'threshold','postsubmit','postsubtimeout','defaultcredits','uploadquota',
2319: 'selfenrollmgrdc','selfenrollmgrcc','action','state','currsec_st',
1.85 raeburn 2320: 'sections','newsec','mysqltables'],['^selfenrollmgr_','^selfenroll_'])."\n".
1.37 raeburn 2321: '<input type="hidden" name="prevphase" value="'.$env{'form.phase'}.'" />';
1.28 raeburn 2322: return $hidden_elements;
2323: }
1.1 raeburn 2324:
1.60 raeburn 2325: sub showcredits {
2326: my ($dom) = @_;
2327: my %domdefaults = &Apache::lonnet::get_domain_defaults($dom);
1.79 raeburn 2328: if ($domdefaults{'officialcredits'} || $domdefaults{'unofficialcredits'} || $domdefaults{'textbookcredits'}) {
1.60 raeburn 2329: return 1;
2330: }
2331: }
2332:
1.86 raeburn 2333: sub get_permission {
2334: my ($dom) = @_;
2335: my ($allowed,%permission);
2336: if (&Apache::lonnet::allowed('ccc',$dom)) {
2337: $allowed = 1;
2338: %permission = (
1.88 ! raeburn 2339: setquota => 'edit',
! 2340: processquota => 'edit',
! 2341: setanon => 'edit',
! 2342: processthreshold => 'edit',
! 2343: setpostsubmit => 'edit',
! 2344: processpostsubmit => 'edit',
! 2345: viewparms => 'view',
! 2346: setparms => 'edit',
! 2347: processparms => 'edit',
! 2348: catsettings => 'edit',
! 2349: processcat => 'edit',
! 2350: selfenroll => 'edit',
1.86 raeburn 2351: );
2352: } elsif (&Apache::lonnet::allowed('rar',$dom)) {
2353: $allowed = 1;
2354: %permission = (
1.88 ! raeburn 2355: setquota => 'view',
! 2356: viewparms => 'view',
! 2357: setanon => 'view',
! 2358: setpostsubmit => 'view',
! 2359: setparms => 'view',
! 2360: catsettings => 'view',
! 2361: selfenroll => 'view',
1.86 raeburn 2362: );
2363: }
2364: return ($allowed,\%permission);
2365: }
2366:
1.1 raeburn 2367: sub handler {
2368: my $r = shift;
2369: if ($r->header_only) {
2370: &Apache::loncommon::content_type($r,'text/html');
2371: $r->send_http_header;
2372: return OK;
2373: }
1.72 raeburn 2374:
1.28 raeburn 2375: my $dom = $env{'request.role.domain'};
1.31 albertel 2376: my $domdesc = &Apache::lonnet::domain($dom,'description');
1.86 raeburn 2377: my ($allowed,$permission) = &get_permission($dom);
2378: if ($allowed) {
1.1 raeburn 2379: &Apache::loncommon::content_type($r,'text/html');
2380: $r->send_http_header;
2381:
1.28 raeburn 2382: &Apache::lonhtmlcommon::clear_breadcrumbs();
2383:
2384: my $phase = $env{'form.phase'};
1.46 raeburn 2385: if ($env{'form.updater'}) {
2386: $phase = '';
2387: }
1.37 raeburn 2388: if ($phase eq '') {
2389: &Apache::lonhtmlcommon::add_breadcrumb
1.28 raeburn 2390: ({href=>"/adm/modifycourse",
1.48 raeburn 2391: text=>"Course/Community search"});
1.28 raeburn 2392: &print_course_search_page($r,$dom,$domdesc);
1.1 raeburn 2393: } else {
1.37 raeburn 2394: my $firstform = $phase;
2395: if ($phase eq 'courselist') {
2396: $firstform = 'filterpicker';
1.48 raeburn 2397: }
2398: my $choose_text;
2399: my $type = $env{'form.type'};
2400: if ($type eq '') {
2401: $type = 'Course';
2402: }
2403: if ($type eq 'Community') {
2404: $choose_text = "Choose a community";
1.81 raeburn 2405: } elsif ($type eq 'Placement') {
2406: $choose_text = "Choose a placement test";
1.48 raeburn 2407: } else {
2408: $choose_text = "Choose a course";
1.37 raeburn 2409: }
1.28 raeburn 2410: &Apache::lonhtmlcommon::add_breadcrumb
1.37 raeburn 2411: ({href=>"javascript:changePage(document.$firstform,'')",
1.48 raeburn 2412: text=>"Course/Community search"},
1.37 raeburn 2413: {href=>"javascript:changePage(document.$phase,'courselist')",
1.48 raeburn 2414: text=>$choose_text});
1.28 raeburn 2415: if ($phase eq 'courselist') {
2416: &print_course_selection_page($r,$dom,$domdesc);
2417: } else {
1.71 raeburn 2418: my ($checked,$cdesc,$coursehash) = &check_course($dom,$domdesc);
1.28 raeburn 2419: if ($checked eq 'ok') {
1.48 raeburn 2420: my $enter_text;
2421: if ($type eq 'Community') {
2422: $enter_text = 'Enter community';
1.81 raeburn 2423: } elsif ($type eq 'Placement') {
2424: $enter_text = 'Enter placement test';
1.48 raeburn 2425: } else {
2426: $enter_text = 'Enter course';
2427: }
1.28 raeburn 2428: if ($phase eq 'menu') {
1.37 raeburn 2429: &Apache::lonhtmlcommon::add_breadcrumb
2430: ({href=>"javascript:changePage(document.$phase,'menu')",
2431: text=>"Pick action"});
1.71 raeburn 2432: &print_modification_menu($r,$cdesc,$domdesc,$dom,$type,
1.86 raeburn 2433: $env{'form.pickedcourse'},$coursehash,
2434: $permission);
2435: } elsif ($phase eq 'adhocrole') {
1.37 raeburn 2436: &Apache::lonhtmlcommon::add_breadcrumb
1.86 raeburn 2437: ({href=>"javascript:changePage(document.$phase,'adhocrole')",
1.48 raeburn 2438: text=>$enter_text});
1.86 raeburn 2439: &print_adhocrole_selected($r,$type);
1.28 raeburn 2440: } else {
1.37 raeburn 2441: &Apache::lonhtmlcommon::add_breadcrumb
2442: ({href=>"javascript:changePage(document.$phase,'menu')",
2443: text=>"Pick action"});
1.28 raeburn 2444: my ($cdom,$cnum) = split(/_/,$env{'form.pickedcourse'});
1.88 ! raeburn 2445: my ($readonly,$linktext);
! 2446: if ($permission->{$phase} eq 'view') {
! 2447: $readonly = 1;
! 2448: }
1.86 raeburn 2449: if (($phase eq 'setquota') && ($permission->{'setquota'})) {
1.88 ! raeburn 2450: if ($permission->{'setquota'} eq 'view') {
! 2451: $linktext = 'Set quota';
! 2452: } else {
! 2453: $linktext = 'Display quota';
! 2454: }
1.28 raeburn 2455: &Apache::lonhtmlcommon::add_breadcrumb
2456: ({href=>"javascript:changePage(document.$phase,'$phase')",
1.88 ! raeburn 2457: text=>"$linktext"});
! 2458: &print_setquota($r,$cdom,$cnum,$cdesc,$type,$readonly);
1.86 raeburn 2459: } elsif (($phase eq 'processquota') && ($permission->{'processquota'})) {
1.28 raeburn 2460: &Apache::lonhtmlcommon::add_breadcrumb
2461: ({href=>"javascript:changePage(document.$phase,'setquota')",
2462: text=>"Set quota"});
2463: &Apache::lonhtmlcommon::add_breadcrumb
2464: ({href=>"javascript:changePage(document.$phase,'$phase')",
2465: text=>"Result"});
1.48 raeburn 2466: &modify_quota($r,$cdom,$cnum,$cdesc,$domdesc,$type);
1.86 raeburn 2467: } elsif (($phase eq 'setanon') && ($permission->{'setanon'})) {
1.57 raeburn 2468: &Apache::lonhtmlcommon::add_breadcrumb
2469: ({href=>"javascript:changePage(document.$phase,'$phase')",
2470: text=>"Threshold for anonymous submissions display"});
1.88 ! raeburn 2471: &print_set_anonsurvey_threshold($r,$cdom,$cnum,$cdesc,$type,$readonly);
1.86 raeburn 2472: } elsif (($phase eq 'processthreshold') && ($permission->{'processthreshold'})) {
1.57 raeburn 2473: &Apache::lonhtmlcommon::add_breadcrumb
2474: ({href=>"javascript:changePage(document.$phase,'setanon')",
2475: text=>"Threshold for anonymous submissions display"});
2476: &Apache::lonhtmlcommon::add_breadcrumb
2477: ({href=>"javascript:changePage(document.$phase,'$phase')",
2478: text=>"Result"});
2479: &modify_anonsurvey_threshold($r,$cdom,$cnum,$cdesc,$domdesc,$type);
1.86 raeburn 2480: } elsif (($phase eq 'setpostsubmit') && ($permission->{'setpostsubmit'})) {
1.88 ! raeburn 2481: if ($permission->{'setpostsubmit'} eq 'view') {
! 2482: $linktext = 'Submit button behavior post-submission';
! 2483: } else {
! 2484: $linktext = 'Configure submit button behavior post-submission';
! 2485: }
1.75 raeburn 2486: &Apache::lonhtmlcommon::add_breadcrumb
2487: ({href=>"javascript:changePage(document.$phase,'$phase')",
2488: text=>"Configure submit button behavior post-submission"});
1.88 ! raeburn 2489: &print_postsubmit_config($r,$cdom,$cnum,$cdesc,$type,$readonly);
1.86 raeburn 2490: } elsif (($phase eq 'processpostsubmit') && ($permission->{'processpostsubmit'})) {
1.75 raeburn 2491: &Apache::lonhtmlcommon::add_breadcrumb
2492: ({href=>"javascript:changePage(document.$phase,'$phase')",
2493: text=>"Result"});
2494: &modify_postsubmit_config($r,$cdom,$cnum,$cdesc,$domdesc,$type);
1.86 raeburn 2495: } elsif (($phase eq 'viewparms') && ($permission->{'viewparms'})) {
1.28 raeburn 2496: &Apache::lonhtmlcommon::add_breadcrumb
2497: ({href=>"javascript:changePage(document.$phase,'viewparms')",
2498: text=>"Display settings"});
1.86 raeburn 2499: &print_settings_display($r,$cdom,$cnum,$cdesc,$type,$permission);
2500: } elsif (($phase eq 'setparms') && ($permission->{'setparms'})) {
1.88 ! raeburn 2501: if ($permission->{'setparms'} eq 'view') {
! 2502: $linktext = 'Display settings';
! 2503: } else {
! 2504: $linktext = 'Change settings';
! 2505: }
1.28 raeburn 2506: &Apache::lonhtmlcommon::add_breadcrumb
2507: ({href=>"javascript:changePage(document.$phase,'$phase')",
1.88 ! raeburn 2508: text=>"$linktext"});
! 2509: &print_course_modification_page($r,$cdom,$cnum,$cdesc,$type,$readonly);
1.86 raeburn 2510: } elsif (($phase eq 'processparms') && ($permission->{'processparms'})) {
1.28 raeburn 2511: &Apache::lonhtmlcommon::add_breadcrumb
2512: ({href=>"javascript:changePage(document.$phase,'setparms')",
2513: text=>"Change settings"});
2514: &Apache::lonhtmlcommon::add_breadcrumb
2515: ({href=>"javascript:changePage(document.$phase,'$phase')",
2516: text=>"Result"});
1.30 raeburn 2517: &modify_course($r,$cdom,$cnum,$cdesc,$domdesc,$type);
1.86 raeburn 2518: } elsif (($phase eq 'catsettings') && ($permission->{'catsettings'})) {
1.38 raeburn 2519: &Apache::lonhtmlcommon::add_breadcrumb
2520: ({href=>"javascript:changePage(document.$phase,'$phase')",
2521: text=>"Catalog settings"});
1.88 ! raeburn 2522: &print_catsettings($r,$cdom,$cnum,$cdesc,$type,$readonly);
1.86 raeburn 2523: } elsif (($phase eq 'processcat') && ($permission->{'processcat'})) {
1.38 raeburn 2524: &Apache::lonhtmlcommon::add_breadcrumb
2525: ({href=>"javascript:changePage(document.$phase,'catsettings')",
2526: text=>"Catalog settings"});
2527: &Apache::lonhtmlcommon::add_breadcrumb
2528: ({href=>"javascript:changePage(document.$phase,'$phase')",
2529: text=>"Result"});
1.48 raeburn 2530: &modify_catsettings($r,$cdom,$cnum,$cdesc,$domdesc,$type);
1.86 raeburn 2531: } elsif (($phase eq 'selfenroll') && ($permission->{'selfenroll'})) {
1.72 raeburn 2532: &Apache::lonhtmlcommon::add_breadcrumb
2533: ({href => "javascript:changePage(document.$phase,'$phase')",
2534: text => "Self-enrollment settings"});
2535: if (!exists($env{'form.state'})) {
1.88 ! raeburn 2536: &print_selfenrollconfig($r,$type,$cdesc,$coursehash,$readonly);
1.72 raeburn 2537: } elsif ($env{'form.state'} eq 'done') {
2538: &Apache::lonhtmlcommon::add_breadcrumb
2539: ({href=>"javascript:changePage(document.$phase,'$phase')",
2540: text=>"Result"});
2541: &modify_selfenrollconfig($r,$type,$cdesc,$coursehash);
2542: }
1.28 raeburn 2543: }
2544: }
2545: } else {
1.48 raeburn 2546: $r->print('<span class="LC_error">');
2547: if ($type eq 'Community') {
1.72 raeburn 2548: $r->print(&mt('The community you selected is not a valid community in this domain'));
1.81 raeburn 2549: } elsif ($type eq 'Placement') {
2550: $r->print(&mt('The course you selected is not a valid placement test in this domain'));
1.72 raeburn 2551: } else {
1.48 raeburn 2552: $r->print(&mt('The course you selected is not a valid course in this domain'));
2553: }
2554: $r->print(" ($domdesc)</span>");
1.28 raeburn 2555: }
2556: }
1.1 raeburn 2557: }
1.28 raeburn 2558: &print_footer($r);
1.1 raeburn 2559: } else {
1.16 albertel 2560: $env{'user.error.msg'}=
1.48 raeburn 2561: "/adm/modifycourse:ccc:0:0:Cannot modify course/community settings";
1.1 raeburn 2562: return HTTP_NOT_ACCEPTABLE;
2563: }
2564: return OK;
2565: }
2566:
2567: 1;
2568: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>