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