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