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