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