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