Annotation of loncom/interface/lonmodifycourse.pm, revision 1.50
1.20 albertel 1: # The LearningOnline Network with CAPA
1.28 raeburn 2: # handler for DC-only modifiable course settings
1.20 albertel 3: #
1.50 ! raeburn 4: # $Id: lonmodifycourse.pm,v 1.49 2009/11/23 21:45:18 raeburn Exp $
1.20 albertel 5: #
1.3 raeburn 6: # Copyright Michigan State University Board of Trustees
7: #
8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
9: #
10: # LON-CAPA is free software; you can redistribute it and/or modify
11: # it under the terms of the GNU General Public License as published by
12: # the Free Software Foundation; either version 2 of the License, or
13: # (at your option) any later version.
14: #
15: # LON-CAPA is distributed in the hope that it will be useful,
16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18: # GNU General Public License for more details.
19: #
20: # You should have received a copy of the GNU General Public License
21: # along with LON-CAPA; if not, write to the Free Software
22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23: #
24: # /home/httpd/html/adm/gpl.txt
25: #
26: # http://www.lon-capa.org/
27: #
1.1 raeburn 28: package Apache::lonmodifycourse;
29:
30: use strict;
31: use Apache::Constants qw(:common :http);
32: use Apache::lonnet;
33: use Apache::loncommon;
1.28 raeburn 34: use Apache::lonhtmlcommon;
1.1 raeburn 35: use Apache::lonlocal;
1.36 raeburn 36: use Apache::lonuserutils;
1.28 raeburn 37: use Apache::lonpickcourse;
1.1 raeburn 38: use lib '/home/httpd/lib/perl';
1.25 www 39: use LONCAPA;
1.1 raeburn 40:
1.28 raeburn 41: sub get_dc_settable {
1.48 raeburn 42: my ($type) = @_;
43: if ($type eq 'Community') {
44: return ('courseowner');
45: } else {
46: return ('courseowner','coursecode','authtype','autharg');
47: }
48: }
49:
50: sub autoenroll_keys {
51: my $internals = ['coursecode','courseowner','authtype','autharg','autoadds','autodrops',
1.50 ! raeburn 52: 'autostart','autoend','sectionnums','crosslistings',
! 53: 'co-owners'];
1.48 raeburn 54: my $accessdates = ['default_enrollment_start_date','default_enrollment_end_date'];
55: return ($internals,$accessdates);
1.28 raeburn 56: }
57:
1.38 raeburn 58: sub catalog_settable {
1.49 raeburn 59: my ($confhash,$type) = @_;
1.38 raeburn 60: my @settable;
61: if (ref($confhash) eq 'HASH') {
1.49 raeburn 62: if ($type eq 'Community') {
63: if ($confhash->{'togglecatscomm'} ne 'comm') {
64: push(@settable,'togglecats');
65: }
66: if ($confhash->{'categorizecomm'} ne 'comm') {
67: push(@settable,'categorize');
68: }
69: } else {
70: if ($confhash->{'togglecats'} ne 'crs') {
71: push(@settable,'togglecats');
72: }
73: if ($confhash->{'categorize'} ne 'crs') {
74: push(@settable,'categorize');
75: }
1.38 raeburn 76: }
77: } else {
78: push(@settable,('togglecats','categorize'));
79: }
80: return @settable;
81: }
82:
1.28 raeburn 83: sub get_enrollment_settings {
84: my ($cdom,$cnum) = @_;
1.48 raeburn 85: my ($internals,$accessdates) = &autoenroll_keys();
86: my @items;
87: if ((ref($internals) eq 'ARRAY') && (ref($accessdates) eq 'ARRAY')) {
88: @items = map { 'internal.'.$_; } (@{$internals});
89: push(@items,@{$accessdates});
90: }
91: my %settings = &Apache::lonnet::get('environment',\@items,$cdom,$cnum);
1.28 raeburn 92: my %enrollvar;
93: $enrollvar{'autharg'} = '';
94: $enrollvar{'authtype'} = '';
1.48 raeburn 95: foreach my $item (keys(%settings)) {
1.28 raeburn 96: if ($item =~ m/^internal\.(.+)$/) {
97: my $type = $1;
98: if ( ($type eq "autoadds") || ($type eq "autodrops") ) {
99: if ($settings{$item} == 1) {
100: $enrollvar{$type} = "ON";
101: } else {
102: $enrollvar{$type} = "OFF";
1.10 raeburn 103: }
1.28 raeburn 104: } elsif ( ($type eq "autostart") || ($type eq "autoend") ) {
105: if ( ($type eq "autoend") && ($settings{$item} == 0) ) {
1.48 raeburn 106: $enrollvar{$type} = &mt('No end date');
1.28 raeburn 107: } else {
1.48 raeburn 108: $enrollvar{$type} = &Apache::lonlocal::locallocaltime($settings{$item});
1.14 raeburn 109: }
1.50 ! raeburn 110: } elsif (($type eq 'sectionnums') || ($type eq 'co-owners')) {
1.28 raeburn 111: $enrollvar{$type} = $settings{$item};
112: $enrollvar{$type} =~ s/,/, /g;
113: } elsif ($type eq "authtype"
114: || $type eq "autharg" || $type eq "coursecode"
115: || $type eq "crosslistings") {
116: $enrollvar{$type} = $settings{$item};
117: } elsif ($type eq 'courseowner') {
118: if ($settings{$item} =~ /^[^:]+:[^:]+$/) {
119: $enrollvar{$type} = $settings{$item};
120: } else {
121: if ($settings{$item} ne '') {
122: $enrollvar{$type} = $settings{$item}.':'.$cdom;
1.26 raeburn 123: }
1.1 raeburn 124: }
1.28 raeburn 125: }
126: } elsif ($item =~ m/^default_enrollment_(start|end)_date$/) {
127: my $type = $1;
128: if ( ($type eq 'end') && ($settings{$item} == 0) ) {
1.48 raeburn 129: $enrollvar{$item} = &mt('No end date');
1.28 raeburn 130: } elsif ( ($type eq 'start') && ($settings{$item} eq '') ) {
131: $enrollvar{$item} = 'When enrolled';
132: } else {
1.48 raeburn 133: $enrollvar{$item} = &Apache::lonlocal::locallocaltime($settings{$item});
1.1 raeburn 134: }
135: }
136: }
1.28 raeburn 137: return %enrollvar;
138: }
139:
140: sub print_course_search_page {
141: my ($r,$dom,$domdesc) = @_;
1.48 raeburn 142: my $action = '/adm/modifycourse';
143: my $type = $env{'form.type'};
144: if (!defined($env{'form.type'})) {
145: $type = 'Course';
146: }
147: &print_header($r,$type);
1.28 raeburn 148: my $filterlist = ['descriptfilter',
149: 'instcodefilter','ownerfilter',
1.44 raeburn 150: 'coursefilter'];
1.28 raeburn 151: my $filter = {};
1.48 raeburn 152: my ($numtitles,$cctitle,$dctitle);
153: my $ccrole = 'cc';
154: if ($type eq 'Community') {
155: $ccrole = 'co';
1.46 raeburn 156: }
1.48 raeburn 157: $cctitle = &Apache::lonnet::plaintext($ccrole,$type);
1.46 raeburn 158: $dctitle = &Apache::lonnet::plaintext('dc');
159: $r->print(&Apache::lonpickcourse::js_changer());
1.48 raeburn 160: if ($type eq 'Community') {
161: $r->print('<h3>'.&mt('Search for a community in the [_1] domain',$domdesc).'</h3>');
162: } else {
163: $r->print('<h3>'.&mt('Search for a course in the [_1] domain',$domdesc).'</h3>');
1.46 raeburn 164: }
1.28 raeburn 165: $r->print(&Apache::lonpickcourse::build_filters($filterlist,$type,
1.44 raeburn 166: undef,undef,$filter,$action,\$numtitles,'modifycourse'));
1.48 raeburn 167: if ($type eq 'Community') {
168: $r->print(&mt('Actions available after searching for a community:').'<ul>'.
169: '<li>'.&mt('Enter the community with the role of [_1]',$cctitle).'</li>'."\n".
170: '<li>'.&mt('View or modify community settings which only a [_1] may modify.',$dctitle).
171: '</li>'."\n".'</ul>');
172: } else {
173: $r->print(&mt('Actions available after searching for a course:').'<ul>'.
174: '<li>'.&mt('Enter the course with the role of [_1]',$cctitle).'</li>'."\n".
175: '<li>'.&mt('View or modify course settings which only a [_1] may modify.',$dctitle).
176: '</li>'."\n".'</ul>');
177: }
1.28 raeburn 178: }
179:
180: sub print_course_selection_page {
181: my ($r,$dom,$domdesc) = @_;
1.48 raeburn 182: my $type = $env{'form.type'};
183: if (!defined($type)) {
184: $type = 'Course';
185: }
186: &print_header($r,$type);
1.28 raeburn 187:
188: # Criteria for course search
189: my $filterlist = ['descriptfilter',
190: 'instcodefilter','ownerfilter',
191: 'ownerdomfilter','coursefilter'];
192: my %filter;
193: my $action = '/adm/modifycourse';
194: my $dctitle = &Apache::lonnet::plaintext('dc');
1.46 raeburn 195: my $numtitles;
196: $r->print(&Apache::lonpickcourse::js_changer());
1.48 raeburn 197: $r->print(&mt('Revise your search criteria for this domain').' ('.$domdesc.').<br />');
1.28 raeburn 198: $r->print(&Apache::lonpickcourse::build_filters($filterlist,$type,
1.46 raeburn 199: undef,undef,\%filter,$action,\$numtitles));
1.28 raeburn 200: $filter{'domainfilter'} = $dom;
201: my %courses = &Apache::lonpickcourse::search_courses($r,$type,0,
1.46 raeburn 202: \%filter,$numtitles);
203: &Apache::lonpickcourse::display_matched_courses($r,$type,0,$action,undef,undef,undef,
1.28 raeburn 204: %courses);
1.1 raeburn 205: return;
206: }
207:
1.28 raeburn 208: sub print_modification_menu {
1.48 raeburn 209: my ($r,$cdesc,$domdesc,$dom,$type) = @_;
210: &print_header($r,$type);
211: my ($ccrole,$setquota_text,$setparams_text,$cat_text);
212: if ($type eq 'Community') {
213: $ccrole = 'co';
214: } else {
215: $ccrole = 'cc';
216: }
1.37 raeburn 217: my $action = '/adm/modifycourse';
1.48 raeburn 218: if ($type eq 'Community') {
219: $setquota_text = &mt('Total disk space allocated for storage of portfolio files in all groups in a community.');
220: $setparams_text = 'View/Modify community owner';
221: $cat_text = 'View/Modify catalog settings for community';
222: } else {
223: $setquota_text = &mt('Total disk space allocated for storage of portfolio files in all groups in a course.');
224: $setparams_text = 'View/Modify course owner, institutional code, and default authentication';
225: $cat_text = 'View/Modify catalog settings for course';
226: }
1.28 raeburn 227: my @menu =
228: (
1.48 raeburn 229: { text => $setparams_text,
230: phase => 'setparms',
231: },
232: { text => 'View/Modify quota for group portfolio files',
1.28 raeburn 233: phase => 'setquota',
1.48 raeburn 234: }
235: );
1.38 raeburn 236: my %domconf = &Apache::lonnet::get_dom('configuration',['coursecategories'],$dom);
1.49 raeburn 237: my @additional_params = &catalog_settable($domconf{'coursecategories'},$type);
1.38 raeburn 238: if (@additional_params > 0) {
1.48 raeburn 239: push (@menu, { text => $cat_text,
1.38 raeburn 240: phase => 'catsettings',
241: });
242: }
1.48 raeburn 243: unless ($type eq 'Community') {
244: push(@menu,
245: { text => 'Display current settings for automated enrollment',
246: phase => 'viewparms',
247: }
248: );
249: }
250: my $menu_html = '<h3>'.&mt('View/Modify settings for: ').
251: ' <span class="LC_nobreak">'.$cdesc.'</span></h3>'."\n";
252: if ($type eq 'Community') {
253: $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:');
254: } else {
255: $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:');
256: }
257: $menu_html .= '<ul>';
258: if ($type eq 'Community') {
259: $menu_html .= '<li>'.&mt('Community owner (permitted to assign Coordinator roles in the community).').'</li>';
260: } else {
261: $menu_html .= '<li>'.&mt('Course owner (permitted to assign Course Coordinator roles in the course).').'</li>'.
262: '<li>'.&mt("Institutional code and default authentication (both required for auto-enrollment of students from institutional datafeeds).").'</li>';
263: }
264: $menu_html .= '<li>'.$setquota_text.'</li>'."\n";
1.38 raeburn 265: foreach my $item (@additional_params) {
1.48 raeburn 266: if ($type eq 'Community') {
267: if ($item eq 'togglecats') {
268: $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";
269: } elsif ($item eq 'categorize') {
270: $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";
271: }
272: } else {
273: if ($item eq 'togglecats') {
274: $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";
275: } elsif ($item eq 'categorize') {
276: $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";
277: }
1.38 raeburn 278: }
279: }
280: $menu_html .= ' </ul>
1.37 raeburn 281: <form name="menu" method="post" action="'.$action.'" />'."\n".
282: &hidden_form_elements();
1.28 raeburn 283: foreach my $menu_item (@menu) {
1.48 raeburn 284: $menu_html.='<h3>';
1.28 raeburn 285: $menu_html.=
286: qq|<a href="javascript:changePage(document.menu,'$menu_item->{'phase'}')">|;
1.48 raeburn 287: $menu_html.= &mt($menu_item->{'text'}).'</a>';
288: $menu_html.='</h3>';
1.3 raeburn 289: }
1.28 raeburn 290:
291: $r->print($menu_html);
292: return;
293: }
294:
1.37 raeburn 295: sub print_ccrole_selected {
1.48 raeburn 296: my ($r,$type) = @_;
297: &print_header($r,$type);
1.37 raeburn 298: my ($cdom,$cnum) = split(/_/,$env{'form.pickedcourse'});
299: $r->print('<form name="ccrole" method="post" action="/adm/roles">
300: <input type="hidden" name="selectrole" value="1" />
301: <input type="hidden" name="newrole" value="cc./'.$cdom.'/'.$cnum.'" />
302: </form>');
303: }
304:
1.28 raeburn 305: sub print_settings_display {
306: my ($r,$cdom,$cnum,$cdesc,$type) = @_;
307: my %enrollvar = &get_enrollment_settings($cdom,$cnum);
1.48 raeburn 308: my %longtype = &course_settings_descrip($type);
1.28 raeburn 309: my %lt = &Apache::lonlocal::texthash(
1.48 raeburn 310: 'valu' => 'Current value',
311: 'cour' => 'Current settings are:',
312: 'cose' => "Settings which control auto-enrollment using classlists from your institution's student information system fall into two groups:",
313: 'dcon' => 'Modifiable only by Domain Coordinator',
314: 'back' => 'Pick another action',
1.28 raeburn 315: );
1.48 raeburn 316: my $ccrole = 'cc';
317: if ($type eq 'Community') {
318: $ccrole = 'co';
319: }
320: my $cctitle = &Apache::lonnet::plaintext($ccrole,$type);
1.28 raeburn 321: my $dctitle = &Apache::lonnet::plaintext('dc');
1.48 raeburn 322: my @modifiable_params = &get_dc_settable($type);
323: my ($internals,$accessdates) = &autoenroll_keys();
324: my @items;
325: if ((ref($internals) eq 'ARRAY') && (ref($accessdates) eq 'ARRAY')) {
326: @items = (@{$internals},@{$accessdates});
327: }
1.28 raeburn 328: my $disp_table = &Apache::loncommon::start_data_table()."\n".
329: &Apache::loncommon::start_data_table_header_row()."\n".
1.48 raeburn 330: "<th> </th>\n".
1.28 raeburn 331: "<th>$lt{'valu'}</th>\n".
332: "<th>$lt{'dcon'}</th>\n".
333: &Apache::loncommon::end_data_table_header_row()."\n";
1.48 raeburn 334: foreach my $item (@items) {
1.28 raeburn 335: $disp_table .= &Apache::loncommon::start_data_table_row()."\n".
1.48 raeburn 336: "<td><b>$longtype{$item}</b></td>\n".
337: "<td>$enrollvar{$item}</td>\n";
338: if (grep(/^\Q$item\E$/,@modifiable_params)) {
1.50 ! raeburn 339: $disp_table .= '<td align="right">'.&mt('Yes').'</td>'."\n";
1.28 raeburn 340: } else {
1.48 raeburn 341: $disp_table .= '<td align="right">'.&mt('No').'</td>'."\n";
1.28 raeburn 342: }
343: $disp_table .= &Apache::loncommon::end_data_table_row()."\n";
1.3 raeburn 344: }
1.28 raeburn 345: $disp_table .= &Apache::loncommon::end_data_table()."\n";
1.48 raeburn 346: &print_header($r,$type);
347: my $newrole = $ccrole.'./'.$cdom.'/'.$cnum;
348: my $escuri = &HTML::Entities::encode('/adm/roles?selectrole=1&'.$newrole.
349: '=1&destinationurl=/adm/populate','&<>"');
350: $r->print('<h3>'.&mt('Current automated enrollment settings for:').
351: ' <span class="LC_nobreak">'.$cdesc.'</span></h3>'.
352: '<form action="/adm/modifycourse" method="post" name="viewparms">'."\n".
353: '<p>'.$lt{'cose'}.'<ul>'.
354: '<li>'.&mt('Settings modifiable by a [_1] via the [_2]Automated Enrollment Manager[_3] in a course.',$cctitle,'<a href="'.$escuri.'">','</a>').'</li>'.
355: '<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".
356: '</li></ul></p>'.
357: '<p>'.$lt{'cour'}.'</p><p>'.$disp_table.'</p><p>'.
358: '<a href="javascript:changePage(document.viewparms,'."'menu'".')">'.$lt{'back'}.'</a>'."\n".
359: &hidden_form_elements().
360: '</p></form>'
361: );
1.28 raeburn 362: }
1.3 raeburn 363:
1.28 raeburn 364: sub print_setquota {
365: my ($r,$cdom,$cnum,$cdesc,$type) = @_;
366: my %lt = &Apache::lonlocal::texthash(
1.48 raeburn 367: 'cquo' => 'Disk space for storage of group portfolio files for:',
1.28 raeburn 368: 'gpqu' => 'Course portfolio files disk space',
1.42 schafran 369: 'modi' => 'Save',
1.48 raeburn 370: 'back' => 'Pick another action',
1.28 raeburn 371: );
1.48 raeburn 372: if ($type eq 'Community') {
373: $lt{'gpqu'} = &mt('Community portfolio files disk space');
374: }
1.28 raeburn 375: my %settings = &Apache::lonnet::get('environment',['internal.coursequota'],$cdom,$cnum);
376: my $coursequota = $settings{'internal.coursequota'};
377: if ($coursequota eq '') {
378: $coursequota = 20;
1.3 raeburn 379: }
1.48 raeburn 380: &print_header($r,$type);
1.28 raeburn 381: my $hidden_elements = &hidden_form_elements();
1.48 raeburn 382: my $helpitem = &Apache::loncommon::help_open_topic('Modify_Course_Quota');
1.28 raeburn 383: $r->print(<<ENDDOCUMENT);
384: <form action="/adm/modifycourse" method="post" name="setquota">
1.48 raeburn 385: <h3>$lt{'cquo'} <span class="LC_nobreak">$cdesc</span></h3>
1.28 raeburn 386: <p>
1.48 raeburn 387: $helpitem $lt{'gpqu'}: <input type="text" size="4" name="coursequota" value="$coursequota" /> Mb
1.28 raeburn 388: <input type="button" onClick="javascript:verify_quota(this.form)" value="$lt{'modi'}" />
389: </p>
390: $hidden_elements
391: <a href="javascript:changePage(document.setquota,'menu')">$lt{'back'}</a>
392: </form>
393: ENDDOCUMENT
394: return;
395: }
1.3 raeburn 396:
1.38 raeburn 397: sub print_catsettings {
1.48 raeburn 398: my ($r,$cdom,$cnum,$cdesc,$type) = @_;
399: &print_header($r,$type);
1.38 raeburn 400: my %lt = &Apache::lonlocal::texthash(
1.48 raeburn 401: 'back' => 'Pick another action',
402: 'catset' => 'Catalog Settings for Course',
403: 'visi' => 'Visibility in Course/Community Catalog',
404: 'exclude' => 'Exclude from course catalog:',
405: 'categ' => 'Categorize Course',
406: 'assi' => 'Assign one or more categories and/or subcategories to this course.'
1.38 raeburn 407: );
1.48 raeburn 408: if ($type eq 'Community') {
409: $lt{'catset'} = &mt('Catalog Settings for Community');
410: $lt{'exclude'} = &mt('Exclude from course catalog');
411: $lt{'categ'} = &mt('Categorize Community');
1.49 raeburn 412: $lt{'assi'} = &mt('Assign one or more subcategories to this community.');
1.48 raeburn 413: }
1.38 raeburn 414: $r->print('<form action="/adm/modifycourse" method="post" name="catsettings">'.
1.48 raeburn 415: '<h3>'.$lt{'catset'}.' <span class="LC_nobreak">'.$cdesc.'</span></h3>');
1.38 raeburn 416: my %domconf = &Apache::lonnet::get_dom('configuration',['coursecategories'],$cdom);
1.49 raeburn 417: my @cat_params = &catalog_settable($domconf{'coursecategories'},$type);
1.38 raeburn 418: if (@cat_params > 0) {
419: my %currsettings =
420: &Apache::lonnet::get('environment',['hidefromcat','categories'],$cdom,$cnum);
421: if (grep(/^togglecats$/,@cat_params)) {
422: my $excludeon = '';
423: my $excludeoff = ' checked="checked" ';
424: if ($currsettings{'hidefromcat'} eq 'yes') {
425: $excludeon = $excludeoff;
426: $excludeoff = '';
427: }
1.48 raeburn 428: $r->print('<br /><h4>'.$lt{'visi'}.'</h4>'.
429: $lt{'exclude'}.
430: ' <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>');
431: if ($type eq 'Community') {
432: $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."));
433: } else {
434: $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>'.
435: '<li>'.&mt('Auto-cataloging is enabled and the course is assigned an institutional code.').'</li>'.
436: '<li>'.&mt('The course has been categorized using at least one of the course categories defined for the domain.').'</li></ul>');
437: }
438: $r->print('</ul></p>');
1.38 raeburn 439: }
440: if (grep(/^categorize$/,@cat_params)) {
1.48 raeburn 441: $r->print('<br /><h4>'.$lt{'categ'}.'</h4>');
1.38 raeburn 442: if (ref($domconf{'coursecategories'}) eq 'HASH') {
443: my $cathash = $domconf{'coursecategories'}{'cats'};
444: if (ref($cathash) eq 'HASH') {
1.48 raeburn 445: $r->print($lt{'assi'}.'<br /><br />'.
1.38 raeburn 446: &Apache::loncommon::assign_categories_table($cathash,
1.49 raeburn 447: $currsettings{'categories'},$type));
1.38 raeburn 448: } else {
449: $r->print(&mt('No categories defined for this domain'));
450: }
451: } else {
452: $r->print(&mt('No categories defined for this domain'));
453: }
1.48 raeburn 454: unless ($type eq 'Community') {
455: $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>');
456: }
1.38 raeburn 457: }
1.48 raeburn 458: $r->print('<p><input type="button" name="chgcatsettings" value="'.
459: &mt('Save').'" onclick="javascript:changePage(document.catsettings,'."'processcat'".');" /></p>');
1.38 raeburn 460: } else {
1.48 raeburn 461: $r->print('<span class="LC_warning">');
462: if ($type eq 'Community') {
463: $r->print(&mt('Catalog settings in this domain are set in community context via "Community Configuration".'));
464: } else {
465: $r->print(&mt('Catalog settings in this domain are set in course context via "Course Configuration".'));
466: }
467: $r->print('</span><br /><br />'."\n".
1.38 raeburn 468: '<a href="javascript:changePage(document.catsettings,'."'menu'".');">'.
469: $lt{'back'}.'</a>');
470: }
471: $r->print(&hidden_form_elements().'</form>'."\n");
472: return;
473: }
474:
1.28 raeburn 475: sub print_course_modification_page {
1.48 raeburn 476: my ($r,$cdom,$cnum,$cdesc,$type) = @_;
1.2 raeburn 477: my %lt=&Apache::lonlocal::texthash(
478: 'actv' => "Active",
479: 'inac' => "Inactive",
480: 'ownr' => "Owner",
481: 'name' => "Name",
1.26 raeburn 482: 'unme' => "Username:Domain",
1.2 raeburn 483: 'stus' => "Status",
1.48 raeburn 484: 'nocc' => 'There is currently no owner set for this course.',
1.32 raeburn 485: 'gobt' => "Save",
1.2 raeburn 486: );
1.48 raeburn 487: my ($ownertable,$ccrole,$javascript_validations,$authenitems,$ccname);
488: my %enrollvar = &get_enrollment_settings($cdom,$cnum);
489: if ($type eq 'Community') {
490: $ccrole = 'co';
491: $lt{'nocc'} = &mt('There is currently no owner set for this community.');
492: } else {
493: $ccrole ='cc';
494: ($javascript_validations,$authenitems) = &gather_authenitems($cdom,\%enrollvar);
495: }
496: $ccname = &Apache::lonnet::plaintext($ccrole,$type);
497: my %roleshash = &Apache::lonnet::get_my_roles($cnum,$cdom,'','',[$ccrole]);
498: my (@local_ccs,%cc_status,%pname);
499: foreach my $item (keys(%roleshash)) {
500: my ($uname,$udom) = split(/:/,$item);
501: if (!grep(/^\Q$uname\E:\Q$udom\E$/,@local_ccs)) {
502: push(@local_ccs,$uname.':'.$udom);
503: $pname{$uname.':'.$udom} = &Apache::loncommon::plainname($uname,$udom);
504: $cc_status{$uname.':'.$udom} = $lt{'actv'};
1.1 raeburn 505: }
506: }
1.48 raeburn 507: if (($enrollvar{'courseowner'} ne '') &&
508: (!grep(/^$enrollvar{'courseowner'}$/,@local_ccs))) {
509: push(@local_ccs,$enrollvar{'courseowner'});
1.26 raeburn 510: my ($owneruname,$ownerdom) = split(/:/,$enrollvar{'courseowner'});
511: $pname{$enrollvar{'courseowner'}} =
512: &Apache::loncommon::plainname($owneruname,$ownerdom);
1.48 raeburn 513: my $active_cc = &Apache::loncommon::check_user_status($ownerdom,$owneruname,
514: $cdom,$cnum,$ccrole);
1.19 raeburn 515: if ($active_cc eq 'active') {
1.2 raeburn 516: $cc_status{$enrollvar{'courseowner'}} = $lt{'actv'};
1.1 raeburn 517: } else {
1.2 raeburn 518: $cc_status{$enrollvar{'courseowner'}} = $lt{'inac'};
1.1 raeburn 519: }
520: }
1.48 raeburn 521: @local_ccs = sort(@local_ccs);
522: if (@local_ccs == 0) {
523: $ownertable = $lt{'nocc'};
524: } else {
525: my $numlocalcc = scalar(@local_ccs);
526: $ownertable = '<input type="hidden" name="numlocalcc" value="'.$numlocalcc.'" />'.
527: &Apache::loncommon::start_data_table()."\n".
528: &Apache::loncommon::start_data_table_header_row()."\n".
529: '<th>'.$lt{'ownr'}.'</th>'.
530: '<th>'.$lt{'name'}.'</th>'.
531: '<th>'.$lt{'unme'}.'</th>'.
532: '<th>'.$lt{'stus'}.'</th>'.
533: &Apache::loncommon::end_data_table_header_row()."\n";
534: foreach my $cc (@local_ccs) {
535: $ownertable .= &Apache::loncommon::start_data_table_row()."\n";
536: if ($cc eq $enrollvar{'courseowner'}) {
537: $ownertable .= '<td><input type="radio" name="courseowner" value="'.$cc.'" checked="checked" /></td>'."\n";
538: } else {
539: $ownertable .= '<td><input type="radio" name="courseowner" value="'.$cc.'" /></td>'."\n";
540: }
541: $ownertable .=
542: '<td>'.$pname{$cc}.'</td>'."\n".
543: '<td>'.$cc.'</td>'."\n".
544: '<td>'.$cc_status{$cc}.' '.$ccname.'</td>'."\n".
545: &Apache::loncommon::end_data_table_row()."\n";
546: }
547: $ownertable .= &Apache::loncommon::end_data_table();
548: }
549: &print_header($r,$type,$javascript_validations);
550: my $dctitle = &Apache::lonnet::plaintext('dc');
551: my $mainheader = &modifiable_only_title($type);
552: my $hidden_elements = &hidden_form_elements();
553: $r->print('<form action="/adm/modifycourse" method="post" name="'.$env{'form.phase'}.'">'."\n".
554: '<h3>'.$mainheader.' <span class="LC_nobreak">'.$cdesc.'</span></h3><p>'.
555: &Apache::lonhtmlcommon::start_pick_box());
556: if ($type eq 'Community') {
557: $r->print(&Apache::lonhtmlcommon::row_title(
558: &Apache::loncommon::help_open_topic('Modify_Community_Owner').
559: ' '.&mt('Community Owner'))."\n");
560: } else {
561: $r->print(&Apache::lonhtmlcommon::row_title(
562: &Apache::loncommon::help_open_topic('Modify_Course_Instcode').
563: ' '.&mt('Course Code'))."\n".
564: '<input type="text" size="10" name="coursecode" value="'.$enrollvar{'coursecode'}.'" />'.
565: &Apache::lonhtmlcommon::row_closure().
566: &Apache::lonhtmlcommon::row_title(
567: &Apache::loncommon::help_open_topic('Modify_Course_Defaultauth').
568: ' '.&mt('Default Authentication method'))."\n".
569: $authenitems."\n".
570: &Apache::lonhtmlcommon::row_closure().
571: &Apache::lonhtmlcommon::row_title(
572: &Apache::loncommon::help_open_topic('Modify_Course_Owner').
573: ' '.&mt('Course Owner'))."\n");
574: }
575: $r->print($ownertable."\n".&Apache::lonhtmlcommon::row_closure(1).
576: &Apache::lonhtmlcommon::end_pick_box().'</p><p>'.$hidden_elements.
577: '<input type="button" onclick="javascript:changePage(this.form,'."'processparms'".');');
578: if ($type eq 'Community') {
579: $r->print('this.form.submit();"');
580: } else {
581: $r->print('javascript:verify_message(this.form);"');
582: }
583: $r->print('value="'.$lt{'gobt'}.'" /></p></form>');
584: return;
585: }
586:
587: sub modifiable_only_title {
588: my ($type) = @_;
589: my $dctitle = &Apache::lonnet::plaintext('dc');
590: if ($type eq 'Community') {
591: return &mt('Community settings modifiable only by [_1] for:',$dctitle);
592: } else {
593: return &mt('Course settings modifiable only by [_1] for:',$dctitle);
594: }
595: }
1.24 albertel 596:
1.48 raeburn 597: sub gather_authenitems {
598: my ($cdom,$enrollvar) = @_;
1.28 raeburn 599: my ($krbdef,$krbdefdom)=&Apache::loncommon::get_kerberos_defaults($cdom);
1.2 raeburn 600: my $curr_authtype = '';
601: my $curr_authfield = '';
1.48 raeburn 602: if (ref($enrollvar) eq 'HASH') {
603: if ($enrollvar->{'authtype'} =~ /^krb/) {
604: $curr_authtype = 'krb';
605: } elsif ($enrollvar->{'authtype'} eq 'internal' ) {
606: $curr_authtype = 'int';
607: } elsif ($enrollvar->{'authtype'} eq 'localauth' ) {
608: $curr_authtype = 'loc';
609: }
1.2 raeburn 610: }
611: unless ($curr_authtype eq '') {
612: $curr_authfield = $curr_authtype.'arg';
1.33 raeburn 613: }
1.48 raeburn 614: my $javascript_validations =
615: &Apache::lonuserutils::javascript_validations('modifycourse',$krbdefdom,
616: $curr_authtype,$curr_authfield);
1.35 raeburn 617: my %param = ( formname => 'document.'.$env{'form.phase'},
1.48 raeburn 618: kerb_def_dom => $krbdefdom,
619: kerb_def_auth => $krbdef,
1.2 raeburn 620: mode => 'modifycourse',
621: curr_authtype => $curr_authtype,
1.48 raeburn 622: curr_autharg => $enrollvar->{'autharg'}
623: );
1.32 raeburn 624: my (%authform,$authenitems);
625: $authform{'krb'} = &Apache::loncommon::authform_kerberos(%param);
626: $authform{'int'} = &Apache::loncommon::authform_internal(%param);
627: $authform{'loc'} = &Apache::loncommon::authform_local(%param);
628: foreach my $item ('krb','int','loc') {
629: if ($authform{$item} ne '') {
630: $authenitems .= $authform{$item}.'<br />';
631: }
1.1 raeburn 632: }
1.48 raeburn 633: return($javascript_validations,$authenitems);
1.1 raeburn 634: }
635:
636: sub modify_course {
1.30 raeburn 637: my ($r,$cdom,$cnum,$cdesc,$domdesc,$type) = @_;
1.48 raeburn 638: my %longtype = &course_settings_descrip($type);
1.50 ! raeburn 639: my @items = ('internal.courseowner','description','internal.co-owners',
! 640: 'internal.pendingco-owners');
1.48 raeburn 641: unless ($type eq 'Community') {
642: push(@items,('internal.coursecode','internal.authtype','internal.autharg',
643: 'internal.sectionnums','internal.crosslistings'));
1.1 raeburn 644: }
1.48 raeburn 645: my %settings = &Apache::lonnet::get('environment',\@items,$cdom,$cnum);
646: my $description = $settings{'description'};
647: my ($ccrole,$response,$chgresponse,$nochgresponse,$reply,%currattr,%newattr,%cenv,%changed,
648: @changes,@nochanges,@sections,@xlists,@warnings);
649: my @modifiable_params = &get_dc_settable($type);
1.28 raeburn 650: foreach my $param (@modifiable_params) {
1.48 raeburn 651: $currattr{$param} = $settings{'internal.'.$param};
1.1 raeburn 652: }
1.48 raeburn 653: if ($type eq 'Community') {
654: %changed = ( owner => 0 );
655: $ccrole = 'co';
656: } else {
657: %changed = ( code => 0,
658: owner => 0,
659: );
660: $ccrole = 'cc';
661: unless ($settings{'internal.sectionnums'} eq '') {
662: if ($settings{'internal.sectionnums'} =~ m/,/) {
663: @sections = split/,/,$settings{'internal.sectionnums'};
664: } else {
665: $sections[0] = $settings{'internal.sectionnums'};
666: }
667: }
668: unless ($settings{'internal.crosslistings'} eq'') {
669: if ($settings{'internal.crosslistings'} =~ m/,/) {
670: @xlists = split/,/,$settings{'internal.crosslistings'};
671: } else {
672: $xlists[0] = $settings{'internal.crosslistings'};
673: }
674: }
675: if ($env{'form.login'} eq 'krb') {
676: $newattr{'authtype'} = $env{'form.login'};
677: $newattr{'authtype'} .= $env{'form.krbver'};
678: $newattr{'autharg'} = $env{'form.krbarg'};
679: } elsif ($env{'form.login'} eq 'int') {
680: $newattr{'authtype'} ='internal';
681: if ((defined($env{'form.intarg'})) && ($env{'form.intarg'})) {
682: $newattr{'autharg'} = $env{'form.intarg'};
683: }
684: } elsif ($env{'form.login'} eq 'loc') {
685: $newattr{'authtype'} = 'localauth';
686: if ((defined($env{'form.locarg'})) && ($env{'form.locarg'})) {
687: $newattr{'autharg'} = $env{'form.locarg'};
688: }
689: }
690: if ( $newattr{'authtype'}=~ /^krb/) {
691: if ($newattr{'autharg'} eq '') {
692: push(@warnings,
693: &mt('As you did not include the default Kerberos domain'
1.45 bisitz 694: .' to be used for authentication in this class, the'
695: .' institutional data used by the automated'
696: .' enrollment process must include the Kerberos'
1.48 raeburn 697: .' domain for each new student.'));
698: }
699: }
700:
701: if ( exists($env{'form.coursecode'}) ) {
702: $newattr{'coursecode'}=$env{'form.coursecode'};
703: unless ( $newattr{'coursecode'} eq $currattr{'coursecode'} ) {
704: $changed{'code'} = 1;
705: }
1.1 raeburn 706: }
707: }
708:
1.16 albertel 709: if ( exists($env{'form.courseowner'}) ) {
710: $newattr{'courseowner'}=$env{'form.courseowner'};
1.14 raeburn 711: unless ( $newattr{'courseowner'} eq $currattr{'courseowner'} ) {
1.38 raeburn 712: $changed{'owner'} = 1;
1.1 raeburn 713: }
714: }
1.48 raeburn 715:
1.50 ! raeburn 716: if ($changed{'owner'} || $changed{'code'}) {
1.38 raeburn 717: my %crsinfo = &Apache::lonnet::courseiddump($cdom,'.',1,'.','.',$cnum,
718: undef,undef,'.');
719: if (ref($crsinfo{$env{'form.pickedcourse'}}) eq 'HASH') {
1.48 raeburn 720: if ($changed{'code'}) {
721: $crsinfo{$env{'form.pickedcourse'}}{'inst_code'} = $env{'form.coursecode'};
722: }
723: if ($changed{'owner'}) {
724: $crsinfo{$env{'form.pickedcourse'}}{'owner'} = $env{'form.courseowner'};
725: }
1.38 raeburn 726: my $chome = &Apache::lonnet::homeserver($cnum,$cdom);
727: my $putres = &Apache::lonnet::courseidput($cdom,\%crsinfo,$chome,'notime');
1.50 ! raeburn 728: if ($putres eq 'ok') {
! 729: &update_coowners($cdom,$cnum,$chome,\%settings,\%newattr);
! 730: }
1.38 raeburn 731: }
1.14 raeburn 732: }
1.28 raeburn 733: foreach my $param (@modifiable_params) {
734: if ($currattr{$param} eq $newattr{$param}) {
735: push(@nochanges,$param);
1.1 raeburn 736: } else {
1.48 raeburn 737: $cenv{'internal.'.$param} = $newattr{$param};
1.28 raeburn 738: push(@changes,$param);
1.1 raeburn 739: }
740: }
741: if (@changes > 0) {
1.48 raeburn 742: $chgresponse = &mt("The following settings have been changed:<br/><ul>");
1.1 raeburn 743: }
1.48 raeburn 744: if (@nochanges > 0) {
745: $nochgresponse = &mt("The following settings remain unchanged:<br/><ul>");
1.1 raeburn 746: }
1.33 raeburn 747: if (@changes > 0) {
1.28 raeburn 748: my $putreply = &Apache::lonnet::put('environment',\%cenv,$cdom,$cnum);
1.1 raeburn 749: if ($putreply !~ /^ok$/) {
1.48 raeburn 750: $response = '<p class="LC_error">'.
751: &mt('There was a problem processing your requested changes.').'<br />';
752: if ($type eq 'Community') {
753: $response .= &mt('Settings for this community have been left unchanged.');
754: } else {
755: $response .= &mt('Settings for this course have been left unchanged.');
756: }
757: $response .= '<br/>'.&mt('Error: ').$putreply.'</p>';
1.1 raeburn 758: } else {
1.28 raeburn 759: foreach my $attr (@modifiable_params) {
1.48 raeburn 760: if (grep/^\Q$attr\E$/,@changes) {
761: $chgresponse .= '<li>'.$longtype{$attr}.' '.&mt('now set to:').' "'.$newattr{$attr}.'".</li>';
1.1 raeburn 762: } else {
1.48 raeburn 763: $nochgresponse .= '<li>'.$longtype{$attr}.' '.&mt('still set to:').' "'.$currattr{$attr}.'".</li>';
1.1 raeburn 764: }
765: }
1.48 raeburn 766: if (($type ne 'Community') && ($changed{'code'} || $changed{'owner'})) {
1.1 raeburn 767: if ( $newattr{'courseowner'} eq '') {
1.48 raeburn 768: push(@warnings,&mt('There is no owner associated with this LON-CAPA course.').
769: '<br />'.&mt('If automated enrollment at your institution requires validation of course owners, automated enrollment will fail.'));
1.1 raeburn 770: } else {
771: if (@sections > 0) {
1.38 raeburn 772: if ($changed{'code'}) {
1.2 raeburn 773: foreach my $sec (@sections) {
774: if ($sec =~ m/^(.+):/) {
1.48 raeburn 775: my $instsec = $1;
1.8 raeburn 776: my $inst_course_id = $newattr{'coursecode'}.$1;
1.28 raeburn 777: my $course_check = &Apache::lonnet::auto_validate_courseID($cnum,$cdom,$inst_course_id);
1.7 raeburn 778: if ($course_check eq 'ok') {
1.28 raeburn 779: my $outcome = &Apache::lonnet::auto_new_course($cnum,$cdom,$inst_course_id,$newattr{'courseowner'});
1.48 raeburn 780: unless ($outcome eq 'ok') {
781:
782: push(@warnings,&mt('If automatic enrollment is enabled for "[_1]" automated enrollment may fail for "[_2]" - section: [_3], for the following reason: "[_4]"',$description,$newattr{'coursecode'},$instsec,$outcome).'<br/>');
1.1 raeburn 783: }
784: } else {
1.48 raeburn 785: push(@warnings,&mt('If automatic enrollment is enabled for "[_1]" automated enrollment may fail for "[_2]" - section: [_3], for the following reason: "[_4]"',$description,$newattr{'coursecode'},$instsec,$course_check));
1.1 raeburn 786: }
787: } else {
1.48 raeburn 788: push(@warnings,&mt('If automatic enrollment is enabled for "[_1]", automated enrollment may fail for "[_2]" - section: [_3], because this is not a valid section entry.',$description,$newattr{'coursecode'},$sec));
1.1 raeburn 789: }
790: }
1.38 raeburn 791: } elsif ($changed{'owner'}) {
1.4 raeburn 792: foreach my $sec (@sections) {
793: if ($sec =~ m/^(.+):/) {
1.48 raeburn 794: my $instsec = $1;
795: my $inst_course_id = $newattr{'coursecode'}.$instsec;
1.28 raeburn 796: my $outcome = &Apache::lonnet::auto_new_course($cnum,$cdom,$inst_course_id,$newattr{'courseowner'});
1.4 raeburn 797: unless ($outcome eq 'ok') {
1.48 raeburn 798: push(@warnings,&mt('If automatic enrollment is enabled for "[_1]", automated enrollment may fail for "[_2]" - section [_3] for the following reason: "[_4]".',$description,$newattr{'coursecode'},$instsec,$outcome));
1.4 raeburn 799: }
800: } else {
1.48 raeburn 801: push(@warnings,&mt('If automatic enrollment is enabled for "[_1]", automated enrollment may fail for "[_2]" - section [_3] because this is not a valid section entry.',$description,$newattr{'coursecode'},$sec));
1.4 raeburn 802: }
803: }
804: }
1.1 raeburn 805: } else {
1.48 raeburn 806: push(@warnings,&mt('As no section numbers are currently listed for "[_1]" automated enrollment will not occur for any sections of institutional course code: "[_2]".',$description,$newattr{'coursecode'}));
1.1 raeburn 807: }
1.38 raeburn 808: if ( (@xlists > 0) && ($changed{'owner'}) ) {
1.1 raeburn 809: foreach my $xlist (@xlists) {
810: if ($xlist =~ m/^(.+):/) {
1.48 raeburn 811: my $instxlist = $1;
812: my $outcome = &Apache::lonnet::auto_new_course($cnum,$cdom,$instxlist,$newattr{'courseowner'});
1.1 raeburn 813: unless ($outcome eq 'ok') {
1.48 raeburn 814: push(@warnings,&mt('If automatic enrollment is enabled for "[_1]", automated enrollment may fail for crosslisted class "[_2]" for the following reason: "[_3]".',$description,$instxlist,$outcome));
1.1 raeburn 815: }
1.28 raeburn 816: }
1.1 raeburn 817: }
818: }
819: }
820: }
821: }
1.2 raeburn 822: } else {
1.28 raeburn 823: foreach my $attr (@modifiable_params) {
1.48 raeburn 824: $nochgresponse .= '<li>'.$longtype{$attr}.' '.&mt('still set to').' "'.$currattr{$attr}.'".</li>';
1.2 raeburn 825: }
1.1 raeburn 826: }
827:
828: if (@changes > 0) {
829: $chgresponse .= "</ul><br/><br/>";
830: }
831: if (@nochanges > 0) {
832: $nochgresponse .= "</ul><br/><br/>";
833: }
1.48 raeburn 834: my ($warning,$numwarnings);
835: my $numwarnings = scalar(@warnings);
836: if ($numwarnings) {
837: $warning = &mt('The following [quant,_1,warning was,warnings were] generated when applying your changes to automated enrollment:',$numwarnings).'<p><ul>';
838: foreach my $warn (@warnings) {
839: $warning .= '<li><span class="LC_warning">'.$warn.'</span></li>';
840: }
841: $warning .= '</ul></p>';
1.1 raeburn 842: }
1.48 raeburn 843: if ($response) {
844: $reply = $response;
845: } else {
1.1 raeburn 846: $reply = $chgresponse.$nochgresponse.$warning;
847: }
1.48 raeburn 848: &print_header($r,$type);
849: my $mainheader = &modifiable_only_title($type);
850: $reply = '<h3>'.$mainheader.' <span class="LC_nobreak">'.$cdesc.'</span></h3>'."\n".
851: '<p>'.$reply.'</p>'."\n".
1.28 raeburn 852: '<form action="/adm/modifycourse" method="post" name="processparms">'.
853: &hidden_form_elements().
1.48 raeburn 854: '<a href="javascript:changePage(document.processparms,'."'menu'".')">'.
855: &mt('Pick another action').'</a>';
856: if ($numwarnings) {
857: my $newrole = $ccrole.'./'.$cdom.'/'.$cnum;
858: my $escuri = &HTML::Entities::encode('/adm/roles?selectrole=1&'.$newrole.
859: '=1&destinationurl=/adm/populate','&<>"');
860:
861: $reply .= '<br /><a href="'.$escuri.'">'.
862: &mt('Go to Automated Enrollment Manager for course').'</a>';
863: }
864: $reply .= '</form>';
1.3 raeburn 865: $r->print($reply);
1.28 raeburn 866: return;
867: }
868:
1.50 ! raeburn 869: sub update_coowners {
! 870: my ($cdom,$cnum,$chome,$settings,$newattr) = @_;
! 871: return unless ((ref($settings) eq 'HASH') && (ref($newattr) eq 'HASH'));
! 872: my %designhash = &Apache::loncommon::get_domainconf($cdom);
! 873: my (%cchash,$autocoowners);
! 874: if ($designhash{$cdom.'.autoassign.co-owners'}) {
! 875: $autocoowners = 1;
! 876: %cchash = &Apache::lonnet::get_my_roles($cnum,$cdom,undef,undef,['cc']);
! 877: }
! 878: if ($settings->{'internal.courseowner'} ne $newattr->{'courseowner'}) {
! 879: my $oldowner_to_coowner;
! 880: if (($newattr->{'coursecode'}) && ($autocoowners)) {
! 881: my $oldowner = $settings->{'internal.courseowner'};
! 882: if ($cchash{$oldowner.':cc'}) {
! 883: if ($settings->{'internal.co-owner'}) {
! 884: my @current = split(',',$settings->{'internal.co-owners'});
! 885: unless (grep(/^\Q$oldowner\E$/,@current)) {
! 886: $oldowner_to_coowner = 1;
! 887: }
! 888: } else {
! 889: $oldowner_to_coowner = 1;
! 890: }
! 891: }
! 892: }
! 893: foreach my $type ('co-owners','pendingco-owners') {
! 894: if ($settings->{'internal.'.$type}) {
! 895: my @current = split(',',$settings->{'internal.'.$type});
! 896: my $newowner = $newattr->{'courseowner'};
! 897: my @newvalues = ();
! 898: if (($newowner ne '') && (grep(/^\Q$newowner\E$/,@current))) {
! 899: foreach my $person (@current) {
! 900: unless ($person eq $newowner) {
! 901: push(@newvalues,$person);
! 902: }
! 903: }
! 904: } else {
! 905: @newvalues = @current;
! 906: }
! 907: if ($oldowner_to_coowner) {
! 908: push(@newvalues,$settings->{'internal.courseowner'});
! 909: @newvalues = sort(@newvalues);
! 910: }
! 911: my $newownstr = join(',',@newvalues);
! 912: if ($newownstr ne $settings->{'internal.'.$type}) {
! 913: if ($type eq 'co-owners') {
! 914: my $deleted = '';
! 915: unless (@newvalues) {
! 916: $deleted = 1;
! 917: }
! 918: &Apache::lonnet::store_coowners($cdom,$cnum,$chome,
! 919: $deleted,@newvalues);
! 920: } else {
! 921: my $pendingcoowners;
! 922: my $cid = $cdom.'_'.$cnum;
! 923: if (@newvalues) {
! 924: $pendingcoowners = join(',',@newvalues);
! 925: my %pendinghash = (
! 926: 'internal.pendingco-owners' => $pendingcoowners,
! 927: );
! 928: my $putresult = &put('environment',\%pendinghash,$cdom,$cnum);
! 929: if ($putresult eq 'ok') {
! 930: if ($env{'course.'.$cid.'.num'} eq $cnum) {
! 931: &appenv({'course.'.$cid.'.internal.pendingco-owners' => $pendingcoowners});
! 932: }
! 933: }
! 934: } else {
! 935: my $delresult = &Apache::lonnet::del('environment',['internal.pendingco-owners'],$cdom,$cnum);
! 936: if ($delresult eq 'ok') {
! 937: if ($env{'course.'.$cid.'.internal.pendingco-owners'}) {
! 938: &Apache::lonnet::delenv('course.'.$cid.'.internal.pendingco-owners');
! 939: }
! 940: }
! 941: }
! 942: }
! 943: } elsif ($oldowner_to_coowner) {
! 944: &Apache::lonnet::store_coowners($cdom,$cnum,$chome,'',
! 945: $settings->{'internal.courseowner'});
! 946:
! 947: }
! 948: } elsif ($oldowner_to_coowner) {
! 949: &Apache::lonnet::store_coowners($cdom,$cnum,$chome,'',
! 950: $settings->{'internal.courseowner'});
! 951: }
! 952: }
! 953: }
! 954: if ($settings->{'internal.coursecode'} ne $newattr->{'coursecode'}) {
! 955: if ($newattr->{'coursecode'} ne '') {
! 956: my %designhash = &Apache::loncommon::get_domainconf($cdom);
! 957: if ($designhash{$cdom.'.autoassign.co-owners'}) {
! 958: my @newcoowners = ();
! 959: if ($settings->{'internal.co-owners'}) {
! 960: my @currcoown = split(',',$settings->{'internal.coowners'});
! 961: my ($updatecoowners,$delcoowners);
! 962: foreach my $person (@currcoown) {
! 963: my ($result,$desc) = &Apache::lonnet::valid_instcode();
! 964: if ($result eq 'valid') {
! 965: push(@newcoowners,$person);
! 966: }
! 967: }
! 968: foreach my $item (sort(keys(%cchash))) {
! 969: my ($uname,$udom,$urole) = split(':',$item);
! 970: unless (grep(/^\Q$uname\E:\Q$udom\E$/,@newcoowners)) {
! 971: push(@newcoowners,$uname.':'.$udom);
! 972: }
! 973: }
! 974: if (@newcoowners) {
! 975: my $coowners = join(',',sort(@newcoowners));
! 976: unless ($coowners eq $settings->{'internal.co-owners'}) {
! 977: $updatecoowners = 1;
! 978: }
! 979: } else {
! 980: $delcoowners = 1;
! 981: }
! 982: if ($updatecoowners || $delcoowners) {
! 983: &Apache::lonnet::store_coowners($cdom,$cnum,$chome,
! 984: $delcoowners,@newcoowners);
! 985: }
! 986: } else {
! 987: foreach my $item (sort(keys(%cchash))) {
! 988: my ($uname,$udom,$urole) = split(':',$item);
! 989: push(@newcoowners,$uname.':'.$udom);
! 990: }
! 991: if (@newcoowners) {
! 992: &Apache::lonnet::store_coowners($cdom,$cnum,$chome,'',
! 993: @newcoowners);
! 994: }
! 995: }
! 996: }
! 997: }
! 998: }
! 999: return;
! 1000: }
! 1001:
1.28 raeburn 1002: sub modify_quota {
1.48 raeburn 1003: my ($r,$cdom,$cnum,$cdesc,$domdesc,$type) = @_;
1004: &print_header($r,$type);
1005: $r->print('<form action="/adm/modifycourse" method="post" name="processquota">'."\n".
1006: '<h3>'.&mt('Disk space for storage of group portfolio files for:').
1007: ' <span class="LC_nobreak">'.$cdesc.'</span></h3><br />');
1.28 raeburn 1008: my %oldsettings = &Apache::lonnet::get('environment',['internal.coursequota'],$cdom,$cnum);
1009: my $defaultquota = 20;
1010: if ($env{'form.coursequota'} ne '') {
1011: my $newquota = $env{'form.coursequota'};
1012: if ($newquota =~ /^\s*(\d+\.?\d*|\.\d+)\s*$/) {
1013: $newquota = $1;
1014: if ($oldsettings{'internal.coursequota'} eq $env{'form.coursequota'}) {
1.48 raeburn 1015: $r->print(&mt('The disk space allocated for group portfolio files remains unchanged as [_1] Mb.',$env{'form.coursequota'}));
1.28 raeburn 1016: } else {
1017: my %cenv = (
1018: 'internal.coursequota' => $env{'form.coursequota'},
1019: );
1020: my $putreply = &Apache::lonnet::put('environment',\%cenv,$cdom,
1021: $cnum);
1022: if (($oldsettings{'internal.coursequota'} eq '') &&
1023: ($env{'form.coursequota'} == $defaultquota)) {
1.48 raeburn 1024: if ($type eq 'Community') {
1025: $r->print(&mt('The disk space allocated for group portfolio files in this community is the default quota for this domain: [_1] Mb.',$defaultquota));
1026: } else {
1027: $r->print(&mt('The disk space allocated for group portfolio files in this course is the default quota for this domain: [_1] Mb.',$defaultquota));
1028: }
1.28 raeburn 1029: } else {
1030: if ($putreply eq 'ok') {
1031: my %updatedsettings = &Apache::lonnet::get('environment',['internal.coursequota'],$cdom,$cnum);
1.48 raeburn 1032: $r->print(&mt('The disk space allocated for group portfolio files is now: [_1] Mb.',$updatedsettings{'internal.coursequota'}));
1.28 raeburn 1033: my $usage = &Apache::longroup::sum_quotas($cdom.'_'.$cnum);
1034: if ($usage >= $updatedsettings{'internal.coursequota'}) {
1035: my $newoverquota;
1036: if ($usage < $oldsettings{'internal.coursequota'}) {
1037: $newoverquota = 'now';
1038: }
1.48 raeburn 1039: $r->print('<p>');
1040: if ($type eq 'Community') {
1041: $r->print(&mt('Disk usage [_1] exceeds the quota for this community.',$newoverquota).' '.
1042: &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.'));
1043: } else {
1044: $r->print(&mt('Disk usage [_1] exceeds the quota for this course.',$newoverquota).' '.
1045: &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.'));
1046: }
1047: $r->print('</p>');
1.28 raeburn 1048: }
1049: } else {
1.48 raeburn 1050: $r->print(&mt('An error occurred storing the quota for group portfolio files: ').
1051: $putreply);
1.28 raeburn 1052: }
1053: }
1054: }
1055: } else {
1056: $r->print(&mt('The new quota requested contained invalid characters, so the quota is unchanged.'));
1057: }
1058: }
1.48 raeburn 1059: $r->print('<p>'.
1060: '<a href="javascript:changePage(document.processquota,'."'menu'".')">'.
1061: &mt('Pick another action').'</a>');
1.28 raeburn 1062: $r->print(&hidden_form_elements().'</form>');
1063: return;
1.1 raeburn 1064: }
1065:
1.38 raeburn 1066: sub modify_catsettings {
1.48 raeburn 1067: my ($r,$cdom,$cnum,$cdesc,$domdesc,$type) = @_;
1068: &print_header($r,$type);
1069: my ($ccrole,%desc);
1070: if ($type eq 'Community') {
1071: $desc{'hidefromcat'} = &mt('Excluded from community catalog');
1072: $desc{'categories'} = &mt('Assigned categories for this community');
1073: $ccrole = 'co';
1074: } else {
1075: $desc{'hidefromcat'} = &mt('Excluded from course catalog');
1076: $desc{'categories'} = &mt('Assigned categories for this course');
1077: $ccrole = 'cc';
1078: }
1.38 raeburn 1079: $r->print('
1080: <form action="/adm/modifycourse" method="post" name="processcat">
1081: <h3>'.&mt('Category settings').'</h3>');
1082: my %domconf = &Apache::lonnet::get_dom('configuration',['coursecategories'],$cdom);
1.49 raeburn 1083: my @cat_params = &catalog_settable($domconf{'coursecategories'},$type);
1.38 raeburn 1084: if (@cat_params > 0) {
1085: my (%cenv,@changes,@nochanges);
1086: my %currsettings =
1087: &Apache::lonnet::get('environment',['hidefromcat','categories'],$cdom,$cnum);
1088: my (@newcategories,%showitem);
1089: if (grep(/^togglecats$/,@cat_params)) {
1090: if ($currsettings{'hidefromcat'} ne $env{'form.hidefromcat'}) {
1091: push(@changes,'hidefromcat');
1092: $cenv{'hidefromcat'} = $env{'form.hidefromcat'};
1093: } else {
1094: push(@nochanges,'hidefromcat');
1095: }
1096: if ($env{'form.hidefromcat'} eq 'yes') {
1097: $showitem{'hidefromcat'} = '"'.&mt('Yes')."'";
1098: } else {
1099: $showitem{'hidefromcat'} = '"'.&mt('No').'"';
1100: }
1101: }
1102: if (grep(/^categorize$/,@cat_params)) {
1103: my (@cats,@trails,%allitems,%idx,@jsarray);
1104: if (ref($domconf{'coursecategories'}) eq 'HASH') {
1105: my $cathash = $domconf{'coursecategories'}{'cats'};
1106: if (ref($cathash) eq 'HASH') {
1107: &Apache::loncommon::extract_categories($cathash,\@cats,\@trails,
1108: \%allitems,\%idx,\@jsarray);
1109: }
1110: }
1111: @newcategories = &Apache::loncommon::get_env_multiple('form.usecategory');
1112: if (@newcategories == 0) {
1113: $showitem{'categories'} = '"'.&mt('None').'"';
1114: } else {
1115: $showitem{'categories'} = '<ul>';
1116: foreach my $item (@newcategories) {
1117: $showitem{'categories'} .= '<li>'.$trails[$allitems{$item}].'</li>';
1118: }
1119: $showitem{'categories'} .= '</ul>';
1120: }
1121: my $catchg = 0;
1122: if ($currsettings{'categories'} ne '') {
1123: my @currcategories = split('&',$currsettings{'categories'});
1124: foreach my $cat (@currcategories) {
1125: if (!grep(/^\Q$cat\E$/,@newcategories)) {
1126: $catchg = 1;
1127: last;
1128: }
1129: }
1130: if (!$catchg) {
1131: foreach my $cat (@newcategories) {
1132: if (!grep(/^\Q$cat\E$/,@currcategories)) {
1133: $catchg = 1;
1134: last;
1135: }
1136: }
1137: }
1138: } else {
1139: if (@newcategories > 0) {
1140: $catchg = 1;
1141: }
1142: }
1143: if ($catchg) {
1144: $cenv{'categories'} = join('&',@newcategories);
1145: push(@changes,'categories');
1146: } else {
1147: push(@nochanges,'categories');
1148: }
1149: if (@changes > 0) {
1150: my $putreply = &Apache::lonnet::put('environment',\%cenv,$cdom,$cnum);
1151: if ($putreply eq 'ok') {
1152: my %crsinfo = &Apache::lonnet::courseiddump($cdom,'.',1,'.','.',
1153: $cnum,undef,undef,'.');
1154: if (ref($crsinfo{$env{'form.pickedcourse'}}) eq 'HASH') {
1155: if (grep(/^hidefromcat$/,@changes)) {
1156: $crsinfo{$env{'form.pickedcourse'}}{'hidefromcat'} = $env{'form.hidefromcat'};
1157: }
1158: if (grep(/^categories$/,@changes)) {
1159: $crsinfo{$env{'form.pickedcourse'}}{'categories'} = $cenv{'categories'};
1160: }
1161: my $chome = &Apache::lonnet::homeserver($cnum,$cdom);
1162: my $putres = &Apache::lonnet::courseidput($cdom,\%crsinfo,$chome,'notime');
1163: }
1.48 raeburn 1164: $r->print(&mt('The following changes occurred:').'<ul>');
1.38 raeburn 1165: foreach my $item (@changes) {
1.48 raeburn 1166: $r->print('<li>'.&mt('[_1] now set to: [_2]',$desc{$item},$showitem{$item}).'</li>');
1.38 raeburn 1167: }
1168: $r->print('</ul><br />');
1169: }
1170: }
1171: if (@nochanges > 0) {
1.48 raeburn 1172: $r->print(&mt('The following were unchanged:').'<ul>');
1.38 raeburn 1173: foreach my $item (@nochanges) {
1.48 raeburn 1174: $r->print('<li>'.&mt('[_1] still set to: [_2]',$desc{$item},$showitem{$item}).'</li>');
1.38 raeburn 1175: }
1176: $r->print('</ul>');
1177: }
1178: }
1179: } else {
1.48 raeburn 1180: my $newrole = $ccrole.'./'.$cdom.'/'.$cnum;
1181: my $escuri = &HTML::Entities::encode('/adm/roles?selectrole=1&'.$newrole.
1182: '=1&destinationurl=/adm/courseprefs','&<>"');
1183: if ($type eq 'Community') {
1184: $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 />');
1185: } else {
1186: $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 />');
1187: }
1.38 raeburn 1188: }
1189: $r->print('<br />'."\n".
1190: '<a href="javascript:changePage(document.processcat,'."'menu'".')">'.
1.48 raeburn 1191: &mt('Pick another action').'</a>');
1.38 raeburn 1192: $r->print(&hidden_form_elements().'</form>');
1193: return;
1194: }
1195:
1.1 raeburn 1196: sub print_header {
1.48 raeburn 1197: my ($r,$type,$javascript_validations) = @_;
1.28 raeburn 1198: my $phase = "start";
1199: if ( exists($env{'form.phase'}) ) {
1200: $phase = $env{'form.phase'};
1201: }
1202: my $js = qq|
1203: <script type="text/javascript">
1204: function changePage(formname,newphase) {
1205: formname.phase.value = newphase;
1206: if (newphase == 'processparms') {
1207: return;
1.1 raeburn 1208: }
1.28 raeburn 1209: formname.submit();
1210: }
1211: </script>
1212: |;
1213: if ($phase eq 'setparms') {
1214: $js .= qq|
1215: <script type="text/javascript">
1216: $javascript_validations
1217: </script>
1218: |;
1219: } elsif ($phase eq 'courselist') {
1220: $js .= qq|
1221: <script type="text/javascript">
1222: function gochoose(cname,cdom,cdesc) {
1223: document.courselist.pickedcourse.value = cdom+'_'+cname;
1224: document.courselist.submit();
1225: }
1226: </script>
1227: |;
1228: } elsif ($phase eq 'setquota') {
1229: $js .= <<'ENDSCRIPT';
1230: <script type="text/javascript">
1231: function verify_quota(formname) {
1232: var newquota = formname.coursequota.value;
1233: var num_reg = /^\s*(\d+\.?\d*|\.\d+)\s*$/;
1234: if (num_reg.test(newquota)) {
1235: changePage(formname,'processquota');
1.1 raeburn 1236: } else {
1.28 raeburn 1237: alert("The quota you entered contained invalid characters.\nYou must enter a number");
1.1 raeburn 1238: }
1.28 raeburn 1239: return;
1240: }
1241: </script>
1242: ENDSCRIPT
1.1 raeburn 1243: }
1.37 raeburn 1244: my $starthash;
1245: if ($env{'form.phase'} eq 'ccrole') {
1246: $starthash = {
1247: add_entries => {'onload' => "javascript:document.ccrole.submit();"},
1248: };
1249: }
1.48 raeburn 1250: $r->print(&Apache::loncommon::start_page('View/Modify Course/Community Settings',
1.37 raeburn 1251: $js,$starthash));
1.48 raeburn 1252: my $bread_text = "View/Modify Courses/Communities";
1253: if ($type eq 'Community') {
1254: $bread_text = 'Community Settings';
1.41 raeburn 1255: } else {
1.48 raeburn 1256: $bread_text = 'Course Settings';
1.41 raeburn 1257: }
1.48 raeburn 1258: $r->print(&Apache::lonhtmlcommon::breadcrumbs($bread_text));
1.5 raeburn 1259: return;
1.1 raeburn 1260: }
1261:
1262: sub print_footer {
1.23 albertel 1263: my ($r) = @_;
1264: $r->print('<br />'.&Apache::loncommon::end_page());
1.5 raeburn 1265: return;
1.3 raeburn 1266: }
1267:
1268: sub check_course {
1.28 raeburn 1269: my ($r,$dom,$domdesc) = @_;
1270: my ($ok_course,$description,$instcode,$owner);
1.35 raeburn 1271: my %args = (
1272: one_time => 1,
1273: );
1274: my %coursehash =
1275: &Apache::lonnet::coursedescription($env{'form.pickedcourse'},\%args);
1276: my $cnum = $coursehash{'num'};
1277: my $cdom = $coursehash{'domain'};
1278: if ($cdom eq $dom) {
1279: my $description;
1280: my %courseIDs = &Apache::lonnet::courseiddump($cdom,'.',1,'.','.',
1.38 raeburn 1281: $cnum,undef,undef,'.');
1.35 raeburn 1282: if (keys(%courseIDs) > 0) {
1283: $ok_course = 'ok';
1284: my ($instcode,$owner);
1285: if (ref($courseIDs{$cdom.'_'.$cnum}) eq 'HASH') {
1286: $description = $courseIDs{$cdom.'_'.$cnum}{'description'};
1287: $instcode = $courseIDs{$cdom.'_'.$cnum}{'inst_code'};
1288: $owner = $courseIDs{$cdom.'_'.$cnum}{'owner'};
1289: } else {
1290: ($description,$instcode,$owner) =
1291: split(/:/,$courseIDs{$cdom.'_'.$cnum});
1292: }
1293: $description = &unescape($description);
1294: $instcode = &unescape($instcode);
1295: if ($instcode) {
1296: $description .= " ($instcode)";
1.5 raeburn 1297: }
1.35 raeburn 1298: return ($ok_course,$description);
1.3 raeburn 1299: }
1300: }
1.1 raeburn 1301: }
1302:
1.28 raeburn 1303: sub course_settings_descrip {
1.48 raeburn 1304: my ($type) = @_;
1305: my %longtype;
1306: if ($type eq 'Community') {
1307: %longtype = &Apache::lonlocal::texthash(
1308: 'courseowner' => "Username:domain of community owner",
1.50 ! raeburn 1309: 'co-owners' => "Username:domain of each co-owner",
1.48 raeburn 1310: );
1311: } else {
1312: %longtype = &Apache::lonlocal::texthash(
1.28 raeburn 1313: 'authtype' => 'Default authentication method',
1314: 'autharg' => 'Default authentication parameter',
1315: 'autoadds' => 'Automated adds',
1316: 'autodrops' => 'Automated drops',
1317: 'autostart' => 'Date of first automated enrollment',
1318: 'autoend' => 'Date of last automated enrollment',
1319: 'default_enrollment_start_date' => 'Date of first student access',
1320: 'default_enrollment_end_date' => 'Date of last student access',
1321: 'coursecode' => 'Official course code',
1322: 'courseowner' => "Username:domain of course owner",
1.50 ! raeburn 1323: 'co-owners' => "Username:domain of each co-owner",
1.28 raeburn 1324: 'notifylist' => 'Course Coordinators to be notified of enrollment changes',
1.48 raeburn 1325: 'sectionnums' => 'Course section number:LON-CAPA section',
1326: 'crosslistings' => 'Crosslisted class:LON-CAPA section',
1327: );
1328: }
1.28 raeburn 1329: return %longtype;
1330: }
1331:
1332: sub hidden_form_elements {
1333: my $hidden_elements =
1.46 raeburn 1334: &Apache::lonhtmlcommon::echo_form_input(['gosearch','updater','coursecode',
1.37 raeburn 1335: 'prevphase','numlocalcc','courseowner','login','coursequota','intarg',
1.38 raeburn 1336: 'locarg','krbarg','krbver','counter','hidefromcat','usecategory'])."\n".
1.37 raeburn 1337: '<input type="hidden" name="prevphase" value="'.$env{'form.phase'}.'" />';
1.28 raeburn 1338: return $hidden_elements;
1339: }
1.1 raeburn 1340:
1341: sub handler {
1342: my $r = shift;
1343: if ($r->header_only) {
1344: &Apache::loncommon::content_type($r,'text/html');
1345: $r->send_http_header;
1346: return OK;
1347: }
1.28 raeburn 1348: my $dom = $env{'request.role.domain'};
1.31 albertel 1349: my $domdesc = &Apache::lonnet::domain($dom,'description');
1.28 raeburn 1350: if (&Apache::lonnet::allowed('ccc',$dom)) {
1.1 raeburn 1351: &Apache::loncommon::content_type($r,'text/html');
1352: $r->send_http_header;
1353:
1.28 raeburn 1354: &Apache::lonhtmlcommon::clear_breadcrumbs();
1355:
1356: my $phase = $env{'form.phase'};
1.46 raeburn 1357: if ($env{'form.updater'}) {
1358: $phase = '';
1359: }
1.37 raeburn 1360: if ($phase eq '') {
1361: &Apache::lonhtmlcommon::add_breadcrumb
1.28 raeburn 1362: ({href=>"/adm/modifycourse",
1.48 raeburn 1363: text=>"Course/Community search"});
1.28 raeburn 1364: &print_course_search_page($r,$dom,$domdesc);
1.1 raeburn 1365: } else {
1.37 raeburn 1366: my $firstform = $phase;
1367: if ($phase eq 'courselist') {
1368: $firstform = 'filterpicker';
1.48 raeburn 1369: }
1370: my $choose_text;
1371: my $type = $env{'form.type'};
1372: if ($type eq '') {
1373: $type = 'Course';
1374: }
1375: if ($type eq 'Community') {
1376: $choose_text = "Choose a community";
1377: } else {
1378: $choose_text = "Choose a course";
1.37 raeburn 1379: }
1.28 raeburn 1380: &Apache::lonhtmlcommon::add_breadcrumb
1.37 raeburn 1381: ({href=>"javascript:changePage(document.$firstform,'')",
1.48 raeburn 1382: text=>"Course/Community search"},
1.37 raeburn 1383: {href=>"javascript:changePage(document.$phase,'courselist')",
1.48 raeburn 1384: text=>$choose_text});
1.28 raeburn 1385: if ($phase eq 'courselist') {
1386: &print_course_selection_page($r,$dom,$domdesc);
1387: } else {
1388: my ($checked,$cdesc) = &check_course($r,$dom,$domdesc);
1389: if ($checked eq 'ok') {
1.48 raeburn 1390: my $enter_text;
1391: if ($type eq 'Community') {
1392: $enter_text = 'Enter community';
1393: } else {
1394: $enter_text = 'Enter course';
1395: }
1.28 raeburn 1396: if ($phase eq 'menu') {
1.37 raeburn 1397: &Apache::lonhtmlcommon::add_breadcrumb
1398: ({href=>"javascript:changePage(document.$phase,'menu')",
1399: text=>"Pick action"});
1.48 raeburn 1400: &print_modification_menu($r,$cdesc,$domdesc,$dom,$type);
1.37 raeburn 1401: } elsif ($phase eq 'ccrole') {
1402: &Apache::lonhtmlcommon::add_breadcrumb
1403: ({href=>"javascript:changePage(document.$phase,'ccrole')",
1.48 raeburn 1404: text=>$enter_text});
1405: &print_ccrole_selected($r,$type);
1.28 raeburn 1406: } else {
1.37 raeburn 1407: &Apache::lonhtmlcommon::add_breadcrumb
1408: ({href=>"javascript:changePage(document.$phase,'menu')",
1409: text=>"Pick action"});
1.28 raeburn 1410: my ($cdom,$cnum) = split(/_/,$env{'form.pickedcourse'});
1411: if ($phase eq 'setquota') {
1412: &Apache::lonhtmlcommon::add_breadcrumb
1413: ({href=>"javascript:changePage(document.$phase,'$phase')",
1414: text=>"Set quota"});
1.38 raeburn 1415: &print_setquota($r,$cdom,$cnum,$cdesc,$type);
1.28 raeburn 1416: } elsif ($phase eq 'processquota') {
1417: &Apache::lonhtmlcommon::add_breadcrumb
1418: ({href=>"javascript:changePage(document.$phase,'setquota')",
1419: text=>"Set quota"});
1420: &Apache::lonhtmlcommon::add_breadcrumb
1421: ({href=>"javascript:changePage(document.$phase,'$phase')",
1422: text=>"Result"});
1.48 raeburn 1423: &modify_quota($r,$cdom,$cnum,$cdesc,$domdesc,$type);
1.28 raeburn 1424: } elsif ($phase eq 'viewparms') {
1425: &Apache::lonhtmlcommon::add_breadcrumb
1426: ({href=>"javascript:changePage(document.$phase,'viewparms')",
1427: text=>"Display settings"});
1428: &print_settings_display($r,$cdom,$cnum,$cdesc,$type);
1429: } elsif ($phase eq 'setparms') {
1430: &Apache::lonhtmlcommon::add_breadcrumb
1431: ({href=>"javascript:changePage(document.$phase,'$phase')",
1432: text=>"Change settings"});
1.48 raeburn 1433: &print_course_modification_page($r,$cdom,$cnum,$cdesc,$type);
1.28 raeburn 1434: } elsif ($phase eq 'processparms') {
1435: &Apache::lonhtmlcommon::add_breadcrumb
1436: ({href=>"javascript:changePage(document.$phase,'setparms')",
1437: text=>"Change settings"});
1438: &Apache::lonhtmlcommon::add_breadcrumb
1439: ({href=>"javascript:changePage(document.$phase,'$phase')",
1440: text=>"Result"});
1.30 raeburn 1441: &modify_course($r,$cdom,$cnum,$cdesc,$domdesc,$type);
1.38 raeburn 1442: } elsif ($phase eq 'catsettings') {
1443: &Apache::lonhtmlcommon::add_breadcrumb
1444: ({href=>"javascript:changePage(document.$phase,'$phase')",
1445: text=>"Catalog settings"});
1446: &print_catsettings($r,$cdom,$cnum,$cdesc,$type);
1447: } elsif ($phase eq 'processcat') {
1448: &Apache::lonhtmlcommon::add_breadcrumb
1449: ({href=>"javascript:changePage(document.$phase,'catsettings')",
1450: text=>"Catalog settings"});
1451: &Apache::lonhtmlcommon::add_breadcrumb
1452: ({href=>"javascript:changePage(document.$phase,'$phase')",
1453: text=>"Result"});
1.48 raeburn 1454: &modify_catsettings($r,$cdom,$cnum,$cdesc,$domdesc,$type);
1.28 raeburn 1455: }
1456: }
1457: } else {
1.48 raeburn 1458: $r->print('<span class="LC_error">');
1459: if ($type eq 'Community') {
1460: $r->print(&mt('The course you selected is not a valid course in this domain'));
1461: } else {
1462: $r->print(&mt('The community you selected is not a valid community in this domain'));
1463: }
1464: $r->print(" ($domdesc)</span>");
1.28 raeburn 1465: }
1466: }
1.1 raeburn 1467: }
1.28 raeburn 1468: &print_footer($r);
1.1 raeburn 1469: } else {
1.16 albertel 1470: $env{'user.error.msg'}=
1.48 raeburn 1471: "/adm/modifycourse:ccc:0:0:Cannot modify course/community settings";
1.1 raeburn 1472: return HTTP_NOT_ACCEPTABLE;
1473: }
1474: return OK;
1475: }
1476:
1477: 1;
1478: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>