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