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