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