1: # The LearningOnline Network with CAPA
2: # handler for DC-only modifiable course settings
3: #
4: # $Id: lonmodifycourse.pm,v 1.84 2016/07/24 14:34:59 raeburn Exp $
5: #
6: # Copyright Michigan State University Board of Trustees
7: #
8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
9: #
10: # LON-CAPA is free software; you can redistribute it and/or modify
11: # it under the terms of the GNU General Public License as published by
12: # the Free Software Foundation; either version 2 of the License, or
13: # (at your option) any later version.
14: #
15: # LON-CAPA is distributed in the hope that it will be useful,
16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18: # GNU General Public License for more details.
19: #
20: # You should have received a copy of the GNU General Public License
21: # along with LON-CAPA; if not, write to the Free Software
22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23: #
24: # /home/httpd/html/adm/gpl.txt
25: #
26: # http://www.lon-capa.org/
27: #
28: package Apache::lonmodifycourse;
29:
30: use strict;
31: use Apache::Constants qw(:common :http);
32: use Apache::lonnet;
33: use Apache::loncommon;
34: use Apache::lonhtmlcommon;
35: use Apache::lonlocal;
36: use Apache::lonuserutils;
37: use Apache::loncreateuser;
38: use Apache::lonpickcourse;
39: use lib '/home/httpd/lib/perl';
40: use LONCAPA qw(:DEFAULT :match);
41:
42: sub get_dc_settable {
43: my ($type,$cdom) = @_;
44: if ($type eq 'Community') {
45: return ('courseowner','selfenrollmgrdc','selfenrollmgrcc');
46: } else {
47: my @items = ('courseowner','coursecode','authtype','autharg','selfenrollmgrdc','selfenrollmgrcc');
48: if (&showcredits($cdom)) {
49: push(@items,'defaultcredits');
50: }
51: return @items;
52: }
53: }
54:
55: sub autoenroll_keys {
56: my $internals = ['coursecode','courseowner','authtype','autharg','defaultcredits',
57: 'autoadds','autodrops','autostart','autoend','sectionnums',
58: 'crosslistings','co-owners','autodropfailsafe'];
59: my $accessdates = ['default_enrollment_start_date','default_enrollment_end_date'];
60: return ($internals,$accessdates);
61: }
62:
63: sub catalog_settable {
64: my ($confhash,$type) = @_;
65: my @settable;
66: if (ref($confhash) eq 'HASH') {
67: if ($type eq 'Community') {
68: if ($confhash->{'togglecatscomm'} ne 'comm') {
69: push(@settable,'togglecats');
70: }
71: if ($confhash->{'categorizecomm'} ne 'comm') {
72: push(@settable,'categorize');
73: }
74: } elsif ($type eq 'Placement') {
75: if ($confhash->{'togglecatsplace'} ne 'place') {
76: push(@settable,'togglecats');
77: }
78: if ($confhash->{'categorizeplace'} ne 'place') {
79: push(@settable,'categorize');
80: }
81: } else {
82: if ($confhash->{'togglecats'} ne 'crs') {
83: push(@settable,'togglecats');
84: }
85: if ($confhash->{'categorize'} ne 'crs') {
86: push(@settable,'categorize');
87: }
88: }
89: } else {
90: push(@settable,('togglecats','categorize'));
91: }
92: return @settable;
93: }
94:
95: sub get_enrollment_settings {
96: my ($cdom,$cnum) = @_;
97: my ($internals,$accessdates) = &autoenroll_keys();
98: my @items;
99: if ((ref($internals) eq 'ARRAY') && (ref($accessdates) eq 'ARRAY')) {
100: @items = map { 'internal.'.$_; } (@{$internals});
101: push(@items,@{$accessdates});
102: }
103: my %settings = &Apache::lonnet::get('environment',\@items,$cdom,$cnum);
104: my %enrollvar;
105: $enrollvar{'autharg'} = '';
106: $enrollvar{'authtype'} = '';
107: foreach my $item (keys(%settings)) {
108: if ($item =~ m/^internal\.(.+)$/) {
109: my $type = $1;
110: if ( ($type eq "autoadds") || ($type eq "autodrops") ) {
111: if ($settings{$item} == 1) {
112: $enrollvar{$type} = "ON";
113: } else {
114: $enrollvar{$type} = "OFF";
115: }
116: } elsif ( ($type eq "autostart") || ($type eq "autoend") ) {
117: if ( ($type eq "autoend") && ($settings{$item} == 0) ) {
118: $enrollvar{$type} = &mt('No end date');
119: } else {
120: $enrollvar{$type} = &Apache::lonlocal::locallocaltime($settings{$item});
121: }
122: } elsif (($type eq 'sectionnums') || ($type eq 'co-owners')) {
123: $enrollvar{$type} = $settings{$item};
124: $enrollvar{$type} =~ s/,/, /g;
125: } elsif ($type eq "authtype"
126: || $type eq "autharg" || $type eq "coursecode"
127: || $type eq "crosslistings" || $type eq "selfenrollmgr"
128: || $type eq "autodropfailsafe") {
129: $enrollvar{$type} = $settings{$item};
130: } elsif ($type eq 'defaultcredits') {
131: if (&showcredits($cdom)) {
132: $enrollvar{$type} = $settings{$item};
133: }
134: } elsif ($type eq 'courseowner') {
135: if ($settings{$item} =~ /^[^:]+:[^:]+$/) {
136: $enrollvar{$type} = $settings{$item};
137: } else {
138: if ($settings{$item} ne '') {
139: $enrollvar{$type} = $settings{$item}.':'.$cdom;
140: }
141: }
142: }
143: } elsif ($item =~ m/^default_enrollment_(start|end)_date$/) {
144: my $type = $1;
145: if ( ($type eq 'end') && ($settings{$item} == 0) ) {
146: $enrollvar{$item} = &mt('No end date');
147: } elsif ( ($type eq 'start') && ($settings{$item} eq '') ) {
148: $enrollvar{$item} = 'When enrolled';
149: } else {
150: $enrollvar{$item} = &Apache::lonlocal::locallocaltime($settings{$item});
151: }
152: }
153: }
154: return %enrollvar;
155: }
156:
157: sub print_course_search_page {
158: my ($r,$dom,$domdesc) = @_;
159: my $action = '/adm/modifycourse';
160: my $type = $env{'form.type'};
161: if (!defined($env{'form.type'})) {
162: $type = 'Course';
163: }
164: &print_header($r,$type);
165: my ($filterlist,$filter) = &get_filters($dom);
166: my ($numtitles,$cctitle,$dctitle,@codetitles);
167: my $ccrole = 'cc';
168: if ($type eq 'Community') {
169: $ccrole = 'co';
170: }
171: $cctitle = &Apache::lonnet::plaintext($ccrole,$type);
172: $dctitle = &Apache::lonnet::plaintext('dc');
173: $r->print(&Apache::loncommon::js_changer());
174: if ($type eq 'Community') {
175: $r->print('<h3>'.&mt('Search for a community in the [_1] domain',$domdesc).'</h3>');
176: } elsif ($type eq 'Placement') {
177: $r->print('<h3>'.&mt('Search for a placement test in the [_1] domain',$domdesc).'</h3>');
178: } else {
179: $r->print('<h3>'.&mt('Search for a course in the [_1] domain',$domdesc).'</h3>');
180: }
181: $r->print(&Apache::loncommon::build_filters($filterlist,$type,undef,undef,$filter,$action,
182: \$numtitles,'modifycourse',undef,undef,undef,
183: \@codetitles,$dom));
184: if ($type eq 'Community') {
185: $r->print(&mt('Actions available after searching for a community:').'<ul>'.
186: '<li>'.&mt('Enter the community with the role of [_1]',$cctitle).'</li>'."\n".
187: '<li>'.&mt('View or modify community settings which only a [_1] may modify.',$dctitle).
188: '</li>'."\n".'</ul>');
189: } elsif ($type eq 'Placement') {
190: $r->print(&mt('Actions available after searching for a placement test:').'<ul>'.
191: '<li>'.&mt('Enter the placement test with the role of [_1]',$cctitle).'</li>'."\n".
192: '<li>'.&mt('View or modify placement test settings which only a [_1] may modify.',$dctitle).
193: '</li>'."\n".'</ul>');
194: } else {
195: $r->print(&mt('Actions available after searching for a course:').'<ul>'.
196: '<li>'.&mt('Enter the course with the role of [_1]',$cctitle).'</li>'."\n".
197: '<li>'.&mt('View or modify course settings which only a [_1] may modify.',$dctitle).
198: '</li>'."\n".'</ul>');
199: }
200: return;
201: }
202:
203: sub print_course_selection_page {
204: my ($r,$dom,$domdesc) = @_;
205: my $type = $env{'form.type'};
206: if (!defined($type)) {
207: $type = 'Course';
208: }
209: &print_header($r,$type);
210:
211: # Criteria for course search
212: my ($filterlist,$filter) = &get_filters();
213: my $action = '/adm/modifycourse';
214: my $dctitle = &Apache::lonnet::plaintext('dc');
215: my ($numtitles,@codetitles);
216: $r->print(&Apache::loncommon::js_changer());
217: $r->print(&mt('Revise your search criteria for this domain').' ('.$domdesc.').<br />');
218: $r->print(&Apache::loncommon::build_filters($filterlist,$type,undef,undef,$filter,$action,
219: \$numtitles,'modifycourse',undef,undef,undef,
220: \@codetitles,$dom,$env{'form.form'}));
221: my %courses = &Apache::loncommon::search_courses($dom,$type,$filter,$numtitles,
222: undef,undef,undef,\@codetitles);
223: &Apache::lonpickcourse::display_matched_courses($r,$type,0,$action,undef,undef,undef,
224: undef,undef,%courses);
225: return;
226: }
227:
228: sub get_filters {
229: my ($dom) = @_;
230: my @filterlist = ('descriptfilter','instcodefilter','ownerfilter',
231: 'ownerdomfilter','coursefilter','sincefilter');
232: # created filter
233: my $loncaparev = &Apache::lonnet::get_server_loncaparev($dom);
234: if ($loncaparev ne 'unknown_cmd') {
235: push(@filterlist,'createdfilter');
236: }
237: my %filter;
238: foreach my $item (@filterlist) {
239: $filter{$item} = $env{'form.'.$item};
240: }
241: return (\@filterlist,\%filter);
242: }
243:
244: sub print_modification_menu {
245: my ($r,$cdesc,$domdesc,$dom,$type,$cid,$coursehash) = @_;
246: &print_header($r,$type);
247: my ($ccrole,$categorytitle,$setquota_text,$setuploadquota_text,$setparams_text,$cat_text,
248: $cdom,$cnum);
249: if (ref($coursehash) eq 'HASH') {
250: $cdom = $coursehash->{'domain'};
251: $cnum = $coursehash->{'num'};
252: } else {
253: ($cdom,$cnum) = split(/_/,$cid);
254: }
255: if ($type eq 'Community') {
256: $ccrole = 'co';
257: } else {
258: $ccrole = 'cc';
259: }
260: if ($type eq 'Community') {
261: $categorytitle = 'View/Modify Community Settings';
262: $setquota_text = &mt('Total disk space allocated for storage of portfolio files in all groups in a community.');
263: $setuploadquota_text = &mt('Disk space allocated for storage of content uploaded directly to a community via Content Editor.');
264: $setparams_text = 'View/Modify community owner';
265: $cat_text = 'View/Modify catalog settings for community';
266: } else {
267: $categorytitle = 'View/Modify Course Settings';
268: $setquota_text = &mt('Total disk space allocated for storage of portfolio files in all groups in a course.');
269: $setuploadquota_text = &mt('Disk space allocated for storage of content uploaded directly to a course via Content Editor.');
270: if (($type ne 'Placement') && (&showcredits($dom))) {
271: $setparams_text = 'View/Modify course owner, institutional code, default authentication, credits, and self-enrollment';
272: } else {
273: $setparams_text = 'View/Modify course owner, institutional code, default authentication, and self-enrollment';
274: }
275: $cat_text = 'View/Modify catalog settings for course';
276: }
277: my $anon_text = &mt('Responder threshold required to display anonymous survey submissions.');
278: my $postsubmit_text = &mt('Override defaults for submit button behavior post-submission for this specific course.');
279:
280: my %domconf = &Apache::lonnet::get_dom('configuration',['coursecategories'],$dom);
281: my @additional_params = &catalog_settable($domconf{'coursecategories'},$type);
282:
283: sub manage_selfenrollment {
284: my ($cdom,$cnum,$type,$coursehash) = @_;
285: my ($managed_by_cc,$managed_by_dc) = &Apache::lonuserutils::selfenrollment_administration($cdom,$cnum,$type,$coursehash);
286: if (ref($managed_by_dc) eq 'ARRAY') {
287: if (@{$managed_by_dc}) {
288: return 1;
289: }
290: }
291: return 0;
292: }
293:
294: sub phaseurl {
295: my $phase = shift;
296: return "javascript:changePage(document.menu,'$phase')"
297: }
298: my @menu =
299: ({ categorytitle => $categorytitle,
300: items => [
301: {
302: linktext => $setparams_text,
303: url => &phaseurl('setparms'),
304: permission => 1,
305: #help => '',
306: icon => 'crsconf.png',
307: linktitle => ''
308: },
309: {
310: linktext => 'View/Modify quotas for group portfolio files, and for uploaded content.',
311: url => &phaseurl('setquota'),
312: permission => 1,
313: #help => '',
314: icon => 'groupportfolioquota.png',
315: linktitle => ''
316: },
317: {
318: linktext => 'View/Modify responders threshold for anonymous survey submissions display',
319: url => &phaseurl('setanon'),
320: permission => 1,
321: #help => '',
322: icon => 'anonsurveythreshold.png',
323: linktitle => ''
324: },
325: {
326: linktext => $cat_text,
327: url => &phaseurl('catsettings'),
328: permission => (@additional_params > 0),
329: #help => '',
330: icon => 'ccatconf.png',
331: linktitle => ''
332: },
333: {
334: linktext => 'Display current settings for automated enrollment',
335: url => &phaseurl('viewparms'),
336: permission => (($type ne 'Community') && ($type ne 'Placement')),
337: #help => '',
338: icon => 'roles.png',
339: linktitle => ''
340: },
341: {
342: linktext => 'View/Modify Self-Enrollment configuration',
343: icon => 'self_enroll.png',
344: #help => 'Course_Self_Enrollment',
345: url => &phaseurl('selfenroll'),
346: permission => &manage_selfenrollment($cdom,$cnum,$type,$coursehash),
347: linktitle => 'Configure user self-enrollment.',
348: },
349: {
350: linktext => 'View/Modify submit button behavior, post-submission',
351: icon => 'emblem-readonly.png',
352: #help => '',
353: url => &phaseurl('setpostsubmit'),
354: permission => 1,
355: linktitle => '',
356: },
357: ]
358: },
359: );
360:
361: my $menu_html =
362: '<h3>'
363: .&mt('View/Modify settings for: [_1]',
364: '<span class="LC_nobreak">'.$cdesc.'</span>')
365: .'</h3>'."\n".'<p>';
366: if ($type eq 'Community') {
367: $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:');
368: } else {
369: $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:');
370: }
371: $menu_html .= '</p>'."\n".'<ul>';
372: if ($type eq 'Community') {
373: $menu_html .= '<li>'.&mt('Community owner (permitted to assign Coordinator roles in the community).').'</li>'."\n".
374: '<li>'.&mt('Override defaults for who configures self-enrollment for this specific community').'</li>'."\n";
375: } else {
376: $menu_html .= '<li>'.&mt('Course owner (permitted to assign Course Coordinator roles in the course).').'</li>'."\n".
377: '<li>'.&mt("Institutional code and default authentication (both required for auto-enrollment of students from institutional datafeeds).").'</li>'."\n";
378: if (($type ne 'Placement') && &showcredits($dom)) {
379: $menu_html .= '<li>'.&mt('Default credits earned by student on course completion.').'</li>'."\n";
380: }
381: $menu_html .= ' <li>'.&mt('Override defaults for who configures self-enrollment for this specific course.').'</li>'."\n";
382: }
383: $menu_html .= '<li>'.$setquota_text.'</li>'."\n".
384: '<li>'.$setuploadquota_text.'</li>'."\n".
385: '<li>'.$anon_text.'</li>'."\n".
386: '<li>'.$postsubmit_text.'</li>'."\n";
387: foreach my $item (@additional_params) {
388: if ($type eq 'Community') {
389: if ($item eq 'togglecats') {
390: $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";
391: } elsif ($item eq 'categorize') {
392: $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";
393: }
394: } else {
395: if ($item eq 'togglecats') {
396: $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";
397: } elsif ($item eq 'categorize') {
398: $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";
399: }
400: }
401: }
402: $menu_html .=
403: ' </ul>'
404: .'<form name="menu" method="post" action="/adm/modifycourse">'
405: ."\n"
406: .&hidden_form_elements();
407:
408: $r->print($menu_html);
409: $r->print(&Apache::lonhtmlcommon::generate_menu(@menu));
410: $r->print('</form>');
411: return;
412: }
413:
414: sub print_ccrole_selected {
415: my ($r,$type) = @_;
416: &print_header($r,$type);
417: my ($cdom,$cnum) = split(/_/,$env{'form.pickedcourse'});
418: $r->print('<form name="ccrole" method="post" action="/adm/roles">
419: <input type="hidden" name="selectrole" value="1" />
420: <input type="hidden" name="newrole" value="cc./'.$cdom.'/'.$cnum.'" />
421: </form>');
422: }
423:
424: sub print_settings_display {
425: my ($r,$cdom,$cnum,$cdesc,$type) = @_;
426: my %enrollvar = &get_enrollment_settings($cdom,$cnum);
427: my %longtype = &course_settings_descrip($type);
428: my %lt = &Apache::lonlocal::texthash(
429: 'valu' => 'Current value',
430: 'cour' => 'Current settings are:',
431: 'cose' => "Settings which control auto-enrollment using classlists from your institution's student information system fall into two groups:",
432: 'dcon' => 'Modifiable only by Domain Coordinator',
433: 'back' => 'Pick another action',
434: );
435: my $ccrole = 'cc';
436: if ($type eq 'Community') {
437: $ccrole = 'co';
438: }
439: my $cctitle = &Apache::lonnet::plaintext($ccrole,$type);
440: my $dctitle = &Apache::lonnet::plaintext('dc');
441: my @modifiable_params = &get_dc_settable($type,$cdom);
442: my ($internals,$accessdates) = &autoenroll_keys();
443: my @items;
444: if ((ref($internals) eq 'ARRAY') && (ref($accessdates) eq 'ARRAY')) {
445: @items = (@{$internals},@{$accessdates});
446: }
447: my $disp_table = &Apache::loncommon::start_data_table()."\n".
448: &Apache::loncommon::start_data_table_header_row()."\n".
449: "<th> </th>\n".
450: "<th>$lt{'valu'}</th>\n".
451: "<th>$lt{'dcon'}</th>\n".
452: &Apache::loncommon::end_data_table_header_row()."\n";
453: foreach my $item (@items) {
454: $disp_table .= &Apache::loncommon::start_data_table_row()."\n".
455: "<td><b>$longtype{$item}</b></td>\n".
456: "<td>$enrollvar{$item}</td>\n";
457: if (grep(/^\Q$item\E$/,@modifiable_params)) {
458: $disp_table .= '<td align="right">'.&mt('Yes').'</td>'."\n";
459: } else {
460: $disp_table .= '<td align="right">'.&mt('No').'</td>'."\n";
461: }
462: $disp_table .= &Apache::loncommon::end_data_table_row()."\n";
463: }
464: $disp_table .= &Apache::loncommon::end_data_table()."\n";
465: &print_header($r,$type);
466: my $newrole = $ccrole.'./'.$cdom.'/'.$cnum;
467: my $escuri = &HTML::Entities::encode('/adm/roles?selectrole=1&'.$newrole.
468: '=1&destinationurl=/adm/populate','&<>"');
469: $r->print('<h3>'.&mt('Current automated enrollment settings for:').
470: ' <span class="LC_nobreak">'.$cdesc.'</span></h3>'.
471: '<form action="/adm/modifycourse" method="post" name="viewparms">'."\n".
472: '<p>'.$lt{'cose'}.'<ul>'.
473: '<li>'.&mt('Settings modifiable by a [_1] via the [_2]Automated Enrollment Manager[_3] in a course.',$cctitle,'<a href="'.$escuri.'">','</a>').'</li>');
474: if (&showcredits($cdom)) {
475: $r->print('<li>'.&mt('Settings modifiable by a [_1] via [_2]View/Modify course owner, institutional code, default authentication, credits, and self-enrollment[_3].',$dctitle,'<a href="javascript:changePage(document.viewparms,'."'setparms'".');">','</a>')."\n");
476: } else {
477: $r->print('<li>'.&mt('Settings modifiable by a [_1] via [_2]View/Modify course owner, institutional code, default authentication, and self-enrollment[_3].',$dctitle,'<a href="javascript:changePage(document.viewparms,'."'setparms'".');">','</a>')."\n");
478: }
479: $r->print('</li></ul></p>'.
480: '<p>'.$lt{'cour'}.'</p><p>'.$disp_table.'</p><p>'.
481: '<a href="javascript:changePage(document.viewparms,'."'menu'".')">'.$lt{'back'}.'</a>'."\n".
482: &hidden_form_elements().
483: '</p></form>'
484: );
485: }
486:
487: sub print_setquota {
488: my ($r,$cdom,$cnum,$cdesc,$type) = @_;
489: my $lctype = lc($type);
490: my $headline = &mt("Set disk space quotas for $lctype: [_1]",
491: '<span class="LC_nobreak">'.$cdesc.'</span>');
492: my %lt = &Apache::lonlocal::texthash(
493: 'gpqu' => 'Disk space for storage of group portfolio files',
494: 'upqu' => 'Disk space for storage of content directly uploaded to course via Content Editor',
495: 'modi' => 'Save',
496: 'back' => 'Pick another action',
497: );
498: my %staticdefaults = (
499: coursequota => 20,
500: uploadquota => 500,
501: );
502: my %settings = &Apache::lonnet::get('environment',['internal.coursequota','internal.uploadquota','internal.coursecode'],
503: $cdom,$cnum);
504: my $coursequota = $settings{'internal.coursequota'};
505: my $uploadquota = $settings{'internal.uploadquota'};
506: if ($coursequota eq '') {
507: $coursequota = $staticdefaults{'coursequota'};
508: }
509: if ($uploadquota eq '') {
510: my %domdefs = &Apache::lonnet::get_domain_defaults($cdom);
511: my $quotatype = &Apache::lonuserutils::get_extended_type($cdom,$cnum,$type,\%settings);
512: $uploadquota = $domdefs{$quotatype.'quota'};
513: if ($uploadquota eq '') {
514: $uploadquota = $staticdefaults{'uploadquota'};
515: }
516: }
517: &print_header($r,$type);
518: my $hidden_elements = &hidden_form_elements();
519: my $porthelpitem = &Apache::loncommon::help_open_topic('Modify_Course_Quota');
520: my $uploadhelpitem = &Apache::loncommon::help_open_topic('Modify_Course_Upload_Quota');
521: $r->print(<<ENDDOCUMENT);
522: <form action="/adm/modifycourse" method="post" name="setquota" onsubmit="return verify_quota();">
523: <h3>$headline</h3>
524: <p><span class="LC_nobreak">
525: $porthelpitem $lt{'gpqu'}: <input type="text" size="4" name="coursequota" value="$coursequota" /> MB
526: </span>
527: <br />
528: <span class="LC_nobreak">
529: $uploadhelpitem $lt{'upqu'}: <input type="text" size="4" name="uploadquota" value="$uploadquota" /> MB
530: </span>
531: </p>
532: <p>
533: <input type="submit" value="$lt{'modi'}" />
534: </p>
535: $hidden_elements
536: <a href="javascript:changePage(document.setquota,'menu')">$lt{'back'}</a>
537: </form>
538: ENDDOCUMENT
539: return;
540: }
541:
542: sub print_set_anonsurvey_threshold {
543: my ($r,$cdom,$cnum,$cdesc,$type) = @_;
544: my %lt = &Apache::lonlocal::texthash(
545: 'resp' => 'Responder threshold for anonymous survey submissions display:',
546: 'sufa' => 'Anonymous survey submissions displayed when responders exceeds',
547: 'modi' => 'Save',
548: 'back' => 'Pick another action',
549: );
550: my %settings = &Apache::lonnet::get('environment',['internal.anonsurvey_threshold'],$cdom,$cnum);
551: my $threshold = $settings{'internal.anonsurvey_threshold'};
552: if ($threshold eq '') {
553: my %domconfig =
554: &Apache::lonnet::get_dom('configuration',['coursedefaults'],$cdom);
555: if (ref($domconfig{'coursedefaults'}) eq 'HASH') {
556: $threshold = $domconfig{'coursedefaults'}{'anonsurvey_threshold'};
557: if ($threshold eq '') {
558: $threshold = 10;
559: }
560: } else {
561: $threshold = 10;
562: }
563: }
564: &print_header($r,$type);
565: my $hidden_elements = &hidden_form_elements();
566: my $helpitem = &Apache::loncommon::help_open_topic('Modify_Anonsurvey_Threshold');
567: $r->print(<<ENDDOCUMENT);
568: <form action="/adm/modifycourse" method="post" name="setanon" onsubmit="return verify_anon_threshold();">
569: <h3>$lt{'resp'} <span class="LC_nobreak">$cdesc</span></h3>
570: <p>
571: $helpitem $lt{'sufa'}: <input type="text" size="4" name="threshold" value="$threshold" />
572: <input type="submit" value="$lt{'modi'}" />
573: </p>
574: $hidden_elements
575: <a href="javascript:changePage(document.setanon,'menu')">$lt{'back'}</a>
576: </form>
577: ENDDOCUMENT
578: return;
579: }
580:
581: sub print_postsubmit_config {
582: my ($r,$cdom,$cnum,$cdesc,$type) = @_;
583: my %lt = &Apache::lonlocal::texthash (
584: 'conf' => 'Configure submit button behavior after student makes a submission',
585: 'disa' => 'Disable submit button/keypress following student submission',
586: 'nums' => 'Number of seconds submit is disabled',
587: 'modi' => 'Save',
588: 'back' => 'Pick another action',
589: 'yes' => 'Yes',
590: 'no' => 'No',
591: );
592: my %settings = &Apache::lonnet::get('environment',['internal.postsubmit','internal.postsubtimeout',
593: 'internal.coursecode','internal.textbook'],$cdom,$cnum);
594: my $postsubmit = $settings{'internal.postsubmit'};
595: if ($postsubmit eq '') {
596: my %domconfig =
597: &Apache::lonnet::get_dom('configuration',['coursedefaults'],$cdom);
598: $postsubmit = 1;
599: if (ref($domconfig{'coursedefaults'}) eq 'HASH') {
600: if (ref($domconfig{'coursedefaults'}{'postsubmit'}) eq 'HASH') {
601: if ($domconfig{'coursedefaults'}{'postsubmit'}{'client'} eq 'off') {
602: $postsubmit = 0;
603: }
604: }
605: }
606: }
607: my ($checkedon,$checkedoff,$display);
608: if ($postsubmit) {
609: $checkedon = 'checked="checked"';
610: $display = 'block';
611: } else {
612: $checkedoff = 'checked="checked"';
613: $display = 'none';
614: }
615: my $postsubtimeout = $settings{'internal.postsubtimeout'};
616: my $default = &domain_postsubtimeout($cdom,$type,\%settings);
617: my $zero = &mt('(Enter 0 to disable until next page reload, or leave blank to use the domain default: [_1])',$default);
618: if ($postsubtimeout eq '') {
619: $postsubtimeout = $default;
620: }
621: &print_header($r,$type);
622: my $hidden_elements = &hidden_form_elements();
623: my $helpitem = &Apache::loncommon::help_open_topic('Modify_Postsubmit_Config');
624: $r->print(<<ENDDOCUMENT);
625: <form action="/adm/modifycourse" method="post" name="setpostsubmit" onsubmit="return verify_postsubmit();">
626: <h3>$lt{'conf'} <span class="LC_nobreak">($cdesc)</span></h3>
627: <p>
628: $helpitem $lt{'disa'}:
629: <label><input type="radio" name="postsubmit" $checkedon onclick="togglePostsubmit('studentsubmission');" value="1" />
630: $lt{'yes'}</label>
631: <label><input type="radio" name="postsubmit" $checkedoff onclick="togglePostsubmit('studentsubmission');" value="0" />
632: $lt{'no'}</label>
633: <div id="studentsubmission" style="display: $display">
634: $lt{'nums'} <input type="text" name="postsubtimeout" value="$postsubtimeout" /><br />
635: $zero</div>
636: <br />
637: <input type="submit" value="$lt{'modi'}" />
638: </p>
639: $hidden_elements
640: <a href="javascript:changePage(document.setpostsubmit,'menu')">$lt{'back'}</a>
641: </form>
642: ENDDOCUMENT
643: return;
644: }
645:
646: sub domain_postsubtimeout {
647: my ($cdom,$type,$settings) = @_;
648: return unless (ref($settings) eq 'HASH');
649: my $lctype = lc($type);
650: unless (($type eq 'Community') || ($type eq 'Placement')) {
651: $lctype = 'unofficial';
652: if ($settings->{'internal.coursecode'}) {
653: $lctype = 'official';
654: } elsif ($settings->{'internal.textbook'}) {
655: $lctype = 'textbook';
656: }
657: }
658: my %domconfig =
659: &Apache::lonnet::get_dom('configuration',['coursedefaults'],$cdom);
660: my $postsubtimeout = 60;
661: if (ref($domconfig{'coursedefaults'}) eq 'HASH') {
662: if (ref($domconfig{'coursedefaults'}{'postsubmit'}) eq 'HASH') {
663: if (ref($domconfig{'coursedefaults'}{'postsubmit'}{'timeout'}) eq 'HASH') {
664: if ($domconfig{'coursedefaults'}{'postsubmit'}{'timeout'}{$lctype} ne '') {
665: $postsubtimeout = $domconfig{'coursedefaults'}{'postsubmit'}{'timeout'}{$lctype};
666: }
667: }
668: }
669: }
670: return $postsubtimeout;
671: }
672:
673: sub print_catsettings {
674: my ($r,$cdom,$cnum,$cdesc,$type) = @_;
675: &print_header($r,$type);
676: my %lt = &Apache::lonlocal::texthash(
677: 'back' => 'Pick another action',
678: 'catset' => 'Catalog Settings for Course',
679: 'visi' => 'Visibility in Course/Community Catalog',
680: 'exclude' => 'Exclude from course catalog:',
681: 'categ' => 'Categorize Course',
682: 'assi' => 'Assign one or more categories and/or subcategories to this course.'
683: );
684: if ($type eq 'Community') {
685: $lt{'catset'} = &mt('Catalog Settings for Community');
686: $lt{'exclude'} = &mt('Exclude from course catalog');
687: $lt{'categ'} = &mt('Categorize Community');
688: $lt{'assi'} = &mt('Assign one or more subcategories to this community.');
689: }
690: $r->print('<form action="/adm/modifycourse" method="post" name="catsettings">'.
691: '<h3>'.$lt{'catset'}.' <span class="LC_nobreak">'.$cdesc.'</span></h3>');
692: my %domconf = &Apache::lonnet::get_dom('configuration',['coursecategories'],$cdom);
693: my @cat_params = &catalog_settable($domconf{'coursecategories'},$type);
694: if (@cat_params > 0) {
695: my %currsettings =
696: &Apache::lonnet::get('environment',['hidefromcat','categories'],$cdom,$cnum);
697: if (grep(/^togglecats$/,@cat_params)) {
698: my $excludeon = '';
699: my $excludeoff = ' checked="checked" ';
700: if ($currsettings{'hidefromcat'} eq 'yes') {
701: $excludeon = $excludeoff;
702: $excludeoff = '';
703: }
704: $r->print('<br /><h4>'.$lt{'visi'}.'</h4>'.
705: $lt{'exclude'}.
706: ' <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>');
707: if ($type eq 'Community') {
708: $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."));
709: } elsif ($type eq 'Placement') {
710: $r->print(&mt("If a placement test has been categorized using at least one of the categories defined for placement tests in the domain, it will be listed in the domain's publicly accessible Course/Community Catalog, unless excluded."));
711: } else {
712: $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>'.
713: '<li>'.&mt('Auto-cataloging is enabled and the course is assigned an institutional code.').'</li>'.
714: '<li>'.&mt('The course has been categorized using at least one of the course categories defined for the domain.').'</li></ul>');
715: }
716: $r->print('</ul></p>');
717: }
718: if (grep(/^categorize$/,@cat_params)) {
719: $r->print('<br /><h4>'.$lt{'categ'}.'</h4>');
720: if (ref($domconf{'coursecategories'}) eq 'HASH') {
721: my $cathash = $domconf{'coursecategories'}{'cats'};
722: if (ref($cathash) eq 'HASH') {
723: $r->print($lt{'assi'}.'<br /><br />'.
724: &Apache::loncommon::assign_categories_table($cathash,
725: $currsettings{'categories'},$type));
726: } else {
727: $r->print(&mt('No categories defined for this domain'));
728: }
729: } else {
730: $r->print(&mt('No categories defined for this domain'));
731: }
732: unless (($type eq 'Community') || ($type eq 'Placement')) {
733: $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>');
734: }
735: }
736: $r->print('<p><input type="button" name="chgcatsettings" value="'.
737: &mt('Save').'" onclick="javascript:changePage(document.catsettings,'."'processcat'".');" /></p>');
738: } else {
739: $r->print('<span class="LC_warning">');
740: if ($type eq 'Community') {
741: $r->print(&mt('Catalog settings in this domain are set in community context via "Community Configuration".'));
742: } else {
743: $r->print(&mt('Catalog settings in this domain are set in course context via "Course Configuration".'));
744: }
745: $r->print('</span><br /><br />'."\n".
746: '<a href="javascript:changePage(document.catsettings,'."'menu'".');">'.
747: $lt{'back'}.'</a>');
748: }
749: $r->print(&hidden_form_elements().'</form>'."\n");
750: return;
751: }
752:
753: sub print_course_modification_page {
754: my ($r,$cdom,$cnum,$cdesc,$crstype) = @_;
755: my %lt=&Apache::lonlocal::texthash(
756: 'actv' => "Active",
757: 'inac' => "Inactive",
758: 'ownr' => "Owner",
759: 'name' => "Name",
760: 'unme' => "Username:Domain",
761: 'stus' => "Status",
762: 'nocc' => 'There is currently no owner set for this course.',
763: 'gobt' => "Save",
764: 'sett' => 'Setting',
765: 'domd' => 'Domain default',
766: 'whom' => 'Who configures',
767: );
768: my ($ownertable,$ccrole,$javascript_validations,$authenitems,$ccname);
769: my %enrollvar = &get_enrollment_settings($cdom,$cnum);
770: my %settings = &Apache::lonnet::get('environment',['internal.coursecode','internal.textbook',
771: 'internal.selfenrollmgrdc','internal.selfenrollmgrcc'],
772: $cdom,$cnum);
773: my $type = &Apache::lonuserutils::get_extended_type($cdom,$cnum,$crstype,\%settings);
774: my @specific_managebydc = split(/,/,$settings{'internal.selfenrollmgrdc'});
775: my @specific_managebycc = split(/,/,$settings{'internal.selfenrollmgrcc'});
776: my %domdefaults = &Apache::lonnet::get_domain_defaults($cdom);
777: my @default_managebydc = split(/,/,$domdefaults{$type.'selfenrolladmdc'});
778: if ($crstype eq 'Community') {
779: $ccrole = 'co';
780: $lt{'nocc'} = &mt('There is currently no owner set for this community.');
781: } else {
782: $ccrole ='cc';
783: ($javascript_validations,$authenitems) = &gather_authenitems($cdom,\%enrollvar);
784: }
785: $ccname = &Apache::lonnet::plaintext($ccrole,$crstype);
786: my %roleshash = &Apache::lonnet::get_my_roles($cnum,$cdom,'','',[$ccrole]);
787: my (@local_ccs,%cc_status,%pname);
788: foreach my $item (keys(%roleshash)) {
789: my ($uname,$udom) = split(/:/,$item);
790: if (!grep(/^\Q$uname\E:\Q$udom\E$/,@local_ccs)) {
791: push(@local_ccs,$uname.':'.$udom);
792: $pname{$uname.':'.$udom} = &Apache::loncommon::plainname($uname,$udom);
793: $cc_status{$uname.':'.$udom} = $lt{'actv'};
794: }
795: }
796: if (($enrollvar{'courseowner'} ne '') &&
797: (!grep(/^$enrollvar{'courseowner'}$/,@local_ccs))) {
798: push(@local_ccs,$enrollvar{'courseowner'});
799: my ($owneruname,$ownerdom) = split(/:/,$enrollvar{'courseowner'});
800: $pname{$enrollvar{'courseowner'}} =
801: &Apache::loncommon::plainname($owneruname,$ownerdom);
802: my $active_cc = &Apache::loncommon::check_user_status($ownerdom,$owneruname,
803: $cdom,$cnum,$ccrole);
804: if ($active_cc eq 'active') {
805: $cc_status{$enrollvar{'courseowner'}} = $lt{'actv'};
806: } else {
807: $cc_status{$enrollvar{'courseowner'}} = $lt{'inac'};
808: }
809: }
810: @local_ccs = sort(@local_ccs);
811: if (@local_ccs == 0) {
812: $ownertable = $lt{'nocc'};
813: } else {
814: my $numlocalcc = scalar(@local_ccs);
815: $ownertable = '<input type="hidden" name="numlocalcc" value="'.$numlocalcc.'" />'.
816: &Apache::loncommon::start_data_table()."\n".
817: &Apache::loncommon::start_data_table_header_row()."\n".
818: '<th>'.$lt{'ownr'}.'</th>'.
819: '<th>'.$lt{'name'}.'</th>'.
820: '<th>'.$lt{'unme'}.'</th>'.
821: '<th>'.$lt{'stus'}.'</th>'.
822: &Apache::loncommon::end_data_table_header_row()."\n";
823: foreach my $cc (@local_ccs) {
824: $ownertable .= &Apache::loncommon::start_data_table_row()."\n";
825: if ($cc eq $enrollvar{'courseowner'}) {
826: $ownertable .= '<td><input type="radio" name="courseowner" value="'.$cc.'" checked="checked" /></td>'."\n";
827: } else {
828: $ownertable .= '<td><input type="radio" name="courseowner" value="'.$cc.'" /></td>'."\n";
829: }
830: $ownertable .=
831: '<td>'.$pname{$cc}.'</td>'."\n".
832: '<td>'.$cc.'</td>'."\n".
833: '<td>'.$cc_status{$cc}.' '.$ccname.'</td>'."\n".
834: &Apache::loncommon::end_data_table_row()."\n";
835: }
836: $ownertable .= &Apache::loncommon::end_data_table();
837: }
838: &print_header($r,$crstype,$javascript_validations);
839: my $dctitle = &Apache::lonnet::plaintext('dc');
840: my $mainheader = &modifiable_only_title($crstype);
841: my $hidden_elements = &hidden_form_elements();
842: $r->print('<form action="/adm/modifycourse" method="post" name="'.$env{'form.phase'}.'">'."\n".
843: '<h3>'.$mainheader.' <span class="LC_nobreak">'.$cdesc.'</span></h3><p>'.
844: &Apache::lonhtmlcommon::start_pick_box());
845: if ($crstype eq 'Community') {
846: $r->print(&Apache::lonhtmlcommon::row_title(
847: &Apache::loncommon::help_open_topic('Modify_Community_Owner').
848: ' '.&mt('Community Owner'))."\n");
849: } else {
850: $r->print(&Apache::lonhtmlcommon::row_title(
851: &Apache::loncommon::help_open_topic('Modify_Course_Instcode').
852: ' '.&mt('Course Code'))."\n".
853: '<input type="text" size="15" name="coursecode" value="'.$enrollvar{'coursecode'}.'" />'.
854: &Apache::lonhtmlcommon::row_closure());
855: if (($crstype eq 'Course') && (&showcredits($cdom))) {
856: $r->print(&Apache::lonhtmlcommon::row_title(
857: &Apache::loncommon::help_open_topic('Modify_Course_Credithours').
858: ' '.&mt('Credits (students)'))."\n".
859: '<input type="text" size="3" name="defaultcredits" value="'.$enrollvar{'defaultcredits'}.'" />'.
860: &Apache::lonhtmlcommon::row_closure());
861: }
862: $r->print(&Apache::lonhtmlcommon::row_title(
863: &Apache::loncommon::help_open_topic('Modify_Course_Defaultauth').
864: ' '.&mt('Default Authentication method'))."\n".
865: $authenitems."\n".
866: &Apache::lonhtmlcommon::row_closure().
867: &Apache::lonhtmlcommon::row_title(
868: &Apache::loncommon::help_open_topic('Modify_Course_Owner').
869: ' '.&mt('Course Owner'))."\n");
870: }
871: my ($cctitle,$rolename,$currmanages,$ccchecked,$dcchecked,$defaultchecked);
872: my ($selfenrollrows,$selfenrolltitles) = &Apache::lonuserutils::get_selfenroll_titles();
873: if ($type eq 'Community') {
874: $cctitle = &mt('Community personnel');
875: } else {
876: $cctitle = &mt('Course personnel');
877: }
878:
879: $r->print($ownertable."\n".&Apache::lonhtmlcommon::row_closure().
880: &Apache::lonhtmlcommon::row_title(
881: &Apache::loncommon::help_open_topic('Modify_Course_Selfenrolladmin').
882: ' '.&mt('Self-enrollment configuration')).
883: &Apache::loncommon::start_data_table()."\n".
884: &Apache::loncommon::start_data_table_header_row()."\n".
885: '<th>'.$lt{'sett'}.'</th>'.
886: '<th>'.$lt{'domd'}.'</th>'.
887: '<th>'.$lt{'whom'}.'</th>'.
888: &Apache::loncommon::end_data_table_header_row()."\n");
889: my %optionname;
890: $optionname{''} = &mt('Use domain default');
891: $optionname{'0'} = $dctitle;
892: $optionname{'1'} = $cctitle;
893: foreach my $item (@{$selfenrollrows}) {
894: my %checked;
895: my $default = $cctitle;
896: if (grep(/^\Q$item\E$/,@default_managebydc)) {
897: $default = $dctitle;
898: }
899: if (grep(/^\Q$item\E$/,@specific_managebydc)) {
900: $checked{'0'} = ' checked="checked"';
901: } elsif (grep(/^\Q$item\E$/,@specific_managebycc)) {
902: $checked{'1'} = ' checked="checked"';
903: } else {
904: $checked{''} = ' checked="checked"';
905: }
906: $r->print(&Apache::loncommon::start_data_table_row()."\n".
907: '<td>'.$selfenrolltitles->{$item}.'</td>'."\n".
908: '<td>'.&mt('[_1] configures',$default).'</td>'."\n".
909: '<td>');
910: foreach my $option ('','0','1') {
911: $r->print('<span class="LC_nobreak"><label>'.
912: '<input type="radio" name="selfenrollmgr_'.$item.'" '.
913: 'value="'.$option.'"'.$checked{$option}.' />'.
914: $optionname{$option}.'</label></span><br />');
915: }
916: $r->print('</td>'."\n".
917: &Apache::loncommon::end_data_table_row()."\n");
918: }
919: $r->print(&Apache::loncommon::end_data_table()."\n".
920: '<br />'.&Apache::lonhtmlcommon::row_closure(1).
921: &Apache::lonhtmlcommon::end_pick_box().'</p><p>'.$hidden_elements.
922: '<input type="button" onclick="javascript:changePage(this.form,'."'processparms'".');');
923: if ($crstype eq 'Community') {
924: $r->print('this.form.submit();"');
925: } else {
926: $r->print('javascript:verify_message(this.form);"');
927: }
928: $r->print(' value="'.$lt{'gobt'}.'" /></p></form>');
929: return;
930: }
931:
932: sub print_selfenrollconfig {
933: my ($r,$type,$cdesc,$coursehash) = @_;
934: return unless(ref($coursehash) eq 'HASH');
935: my $cnum = $coursehash->{'num'};
936: my $cdom = $coursehash->{'domain'};
937: my %currsettings = &get_selfenroll_settings($coursehash);
938: &print_header($r,$type);
939: $r->print('<h3>'.&mt('Self-enrollment with a student role in: [_1]',
940: '<span class="LC_nobreak">'.$cdesc.'</span>').'</h3>'."\n");
941: &Apache::loncreateuser::print_selfenroll_menu($r,'domain',$env{'form.pickedcourse'},
942: $cdom,$cnum,\%currsettings,
943: &hidden_form_elements());
944: return;
945: }
946:
947: sub modify_selfenrollconfig {
948: my ($r,$type,$cdesc,$coursehash) = @_;
949: return unless(ref($coursehash) eq 'HASH');
950: my $cnum = $coursehash->{'num'};
951: my $cdom = $coursehash->{'domain'};
952: my %currsettings = &get_selfenroll_settings($coursehash);
953: &print_header($r,$type);
954: $r->print('<h3>'.&mt('Self-enrollment with a student role in: [_1]',
955: '<span class="LC_nobreak">'.$cdesc.'</span>').'</h3>'."\n");
956: $r->print('<form action="/adm/modifycourse" method="post" name="selfenroll">'."\n".
957: &hidden_form_elements().'<br />');
958: &Apache::loncreateuser::update_selfenroll_config($r,$env{'form.pickedcourse'},
959: $cdom,$cnum,'domain',$type,\%currsettings);
960: $r->print('</form>');
961: return;
962: }
963:
964: sub get_selfenroll_settings {
965: my ($coursehash) = @_;
966: my %currsettings;
967: if (ref($coursehash) eq 'HASH') {
968: %currsettings = (
969: selfenroll_types => $coursehash->{'internal.selfenroll_types'},
970: selfenroll_registered => $coursehash->{'internal.selfenroll_registered'},
971: selfenroll_section => $coursehash->{'internal.selfenroll_section'},
972: selfenroll_notifylist => $coursehash->{'internal.selfenroll_notifylist'},
973: selfenroll_approval => $coursehash->{'internal.selfenroll_approval'},
974: selfenroll_limit => $coursehash->{'internal.selfenroll_limit'},
975: selfenroll_cap => $coursehash->{'internal.selfenroll_cap'},
976: selfenroll_start_date => $coursehash->{'internal.selfenroll_start_date'},
977: selfenroll_end_date => $coursehash->{'internal.selfenroll_end_date'},
978: selfenroll_start_access => $coursehash->{'internal.selfenroll_start_access'},
979: selfenroll_end_access => $coursehash->{'internal.selfenroll_end_access'},
980: default_enrollment_start_date => $coursehash->{'default_enrollment_start_date'},
981: default_enrollment_end_date => $coursehash->{'default_enrollment_end_date'},
982: uniquecode => $coursehash->{'internal.uniquecode'},
983: );
984: }
985: return %currsettings;
986: }
987:
988: sub modifiable_only_title {
989: my ($type) = @_;
990: my $dctitle = &Apache::lonnet::plaintext('dc');
991: if ($type eq 'Community') {
992: return &mt('Community settings modifiable only by [_1] for:',$dctitle);
993: } else {
994: return &mt('Course settings modifiable only by [_1] for:',$dctitle);
995: }
996: }
997:
998: sub gather_authenitems {
999: my ($cdom,$enrollvar) = @_;
1000: my ($krbdef,$krbdefdom)=&Apache::loncommon::get_kerberos_defaults($cdom);
1001: my $curr_authtype = '';
1002: my $curr_authfield = '';
1003: if (ref($enrollvar) eq 'HASH') {
1004: if ($enrollvar->{'authtype'} =~ /^krb/) {
1005: $curr_authtype = 'krb';
1006: } elsif ($enrollvar->{'authtype'} eq 'internal' ) {
1007: $curr_authtype = 'int';
1008: } elsif ($enrollvar->{'authtype'} eq 'localauth' ) {
1009: $curr_authtype = 'loc';
1010: }
1011: }
1012: unless ($curr_authtype eq '') {
1013: $curr_authfield = $curr_authtype.'arg';
1014: }
1015: my $javascript_validations =
1016: &Apache::lonuserutils::javascript_validations('modifycourse',$krbdefdom,
1017: $curr_authtype,$curr_authfield);
1018: my %param = ( formname => 'document.'.$env{'form.phase'},
1019: kerb_def_dom => $krbdefdom,
1020: kerb_def_auth => $krbdef,
1021: mode => 'modifycourse',
1022: curr_authtype => $curr_authtype,
1023: curr_autharg => $enrollvar->{'autharg'}
1024: );
1025: my (%authform,$authenitems);
1026: $authform{'krb'} = &Apache::loncommon::authform_kerberos(%param);
1027: $authform{'int'} = &Apache::loncommon::authform_internal(%param);
1028: $authform{'loc'} = &Apache::loncommon::authform_local(%param);
1029: foreach my $item ('krb','int','loc') {
1030: if ($authform{$item} ne '') {
1031: $authenitems .= $authform{$item}.'<br />';
1032: }
1033: }
1034: return($javascript_validations,$authenitems);
1035: }
1036:
1037: sub modify_course {
1038: my ($r,$cdom,$cnum,$cdesc,$domdesc,$type) = @_;
1039: my %longtype = &course_settings_descrip($type);
1040: my @items = ('internal.courseowner','description','internal.co-owners',
1041: 'internal.pendingco-owners','internal.selfenrollmgrdc',
1042: 'internal.selfenrollmgrcc');
1043: my ($selfenrollrows,$selfenrolltitles) = &Apache::lonuserutils::get_selfenroll_titles();
1044: unless (($type eq 'Community') || ($type eq 'Placement')) {
1045: push(@items,('internal.coursecode','internal.authtype','internal.autharg',
1046: 'internal.sectionnums','internal.crosslistings'));
1047: if (&showcredits($cdom)) {
1048: push(@items,'internal.defaultcredits');
1049: }
1050: }
1051: my %settings = &Apache::lonnet::get('environment',\@items,$cdom,$cnum);
1052: my $description = $settings{'description'};
1053: my ($ccrole,$response,$chgresponse,$nochgresponse,$reply,%currattr,%newattr,
1054: %cenv,%changed,@changes,@nochanges,@sections,@xlists,@warnings);
1055: my @modifiable_params = &get_dc_settable($type,$cdom);
1056: foreach my $param (@modifiable_params) {
1057: $currattr{$param} = $settings{'internal.'.$param};
1058: }
1059: if ($type eq 'Community') {
1060: %changed = ( owner => 0 );
1061: $ccrole = 'co';
1062: } else {
1063: %changed = ( code => 0,
1064: owner => 0,
1065: );
1066: $ccrole = 'cc';
1067: unless ($settings{'internal.sectionnums'} eq '') {
1068: if ($settings{'internal.sectionnums'} =~ m/,/) {
1069: @sections = split/,/,$settings{'internal.sectionnums'};
1070: } else {
1071: $sections[0] = $settings{'internal.sectionnums'};
1072: }
1073: }
1074: unless ($settings{'internal.crosslistings'} eq '') {
1075: if ($settings{'internal.crosslistings'} =~ m/,/) {
1076: @xlists = split/,/,$settings{'internal.crosslistings'};
1077: } else {
1078: $xlists[0] = $settings{'internal.crosslistings'};
1079: }
1080: }
1081: if ($env{'form.login'} eq 'krb') {
1082: $newattr{'authtype'} = $env{'form.login'};
1083: $newattr{'authtype'} .= $env{'form.krbver'};
1084: $newattr{'autharg'} = $env{'form.krbarg'};
1085: } elsif ($env{'form.login'} eq 'int') {
1086: $newattr{'authtype'} ='internal';
1087: if ((defined($env{'form.intarg'})) && ($env{'form.intarg'})) {
1088: $newattr{'autharg'} = $env{'form.intarg'};
1089: }
1090: } elsif ($env{'form.login'} eq 'loc') {
1091: $newattr{'authtype'} = 'localauth';
1092: if ((defined($env{'form.locarg'})) && ($env{'form.locarg'})) {
1093: $newattr{'autharg'} = $env{'form.locarg'};
1094: }
1095: }
1096: if ( $newattr{'authtype'}=~ /^krb/) {
1097: if ($newattr{'autharg'} eq '') {
1098: push(@warnings,
1099: &mt('As you did not include the default Kerberos domain'
1100: .' to be used for authentication in this class, the'
1101: .' institutional data used by the automated'
1102: .' enrollment process must include the Kerberos'
1103: .' domain for each new student.'));
1104: }
1105: }
1106:
1107: if ( exists($env{'form.coursecode'}) ) {
1108: $newattr{'coursecode'}=$env{'form.coursecode'};
1109: unless ( $newattr{'coursecode'} eq $currattr{'coursecode'} ) {
1110: $changed{'code'} = 1;
1111: }
1112: }
1113:
1114: if (($type ne 'Placement') && (&showcredits($cdom) && exists($env{'form.defaultcredits'}))) {
1115: $newattr{'defaultcredits'} =~ s/[^\d\.]//g;
1116: $newattr{'defaultcredits'}=$env{'form.defaultcredits'};
1117: }
1118: }
1119:
1120: my @newmgrdc = ();
1121: my @newmgrcc = ();
1122: my @currmgrdc = split(/,/,$currattr{'selfenrollmgrdc'});
1123: my @currmgrcc = split(/,/,$currattr{'selfenrollmgrcc'});
1124:
1125: foreach my $item (@{$selfenrollrows}) {
1126: if ($env{'form.selfenrollmgr_'.$item} eq '0') {
1127: push(@newmgrdc,$item);
1128: } elsif ($env{'form.selfenrollmgr_'.$item} eq '1') {
1129: push(@newmgrcc,$item);
1130: }
1131: }
1132:
1133: $newattr{'selfenrollmgrdc'}=join(',',@newmgrdc);
1134: $newattr{'selfenrollmgrcc'}=join(',',@newmgrcc);
1135:
1136: my $cctitle;
1137: if ($type eq 'Community') {
1138: $cctitle = &mt('Community personnel');
1139: } else {
1140: $cctitle = &mt('Course personnel');
1141: }
1142: my $dctitle = &Apache::lonnet::plaintext('dc');
1143:
1144: if ( exists($env{'form.courseowner'}) ) {
1145: $newattr{'courseowner'}=$env{'form.courseowner'};
1146: unless ( $newattr{'courseowner'} eq $currattr{'courseowner'} ) {
1147: $changed{'owner'} = 1;
1148: }
1149: }
1150:
1151: if ($changed{'owner'} || $changed{'code'}) {
1152: my %crsinfo = &Apache::lonnet::courseiddump($cdom,'.',1,'.','.',$cnum,
1153: undef,undef,'.');
1154: if (ref($crsinfo{$env{'form.pickedcourse'}}) eq 'HASH') {
1155: if ($changed{'code'}) {
1156: $crsinfo{$env{'form.pickedcourse'}}{'inst_code'} = $env{'form.coursecode'};
1157: }
1158: if ($changed{'owner'}) {
1159: $crsinfo{$env{'form.pickedcourse'}}{'owner'} = $env{'form.courseowner'};
1160: }
1161: my $chome = &Apache::lonnet::homeserver($cnum,$cdom);
1162: my $putres = &Apache::lonnet::courseidput($cdom,\%crsinfo,$chome,'notime');
1163: if ($putres eq 'ok') {
1164: &update_coowners($cdom,$cnum,$chome,\%settings,\%newattr);
1165: }
1166: }
1167: }
1168: foreach my $param (@modifiable_params) {
1169: if ($currattr{$param} eq $newattr{$param}) {
1170: push(@nochanges,$param);
1171: } else {
1172: $cenv{'internal.'.$param} = $newattr{$param};
1173: push(@changes,$param);
1174: }
1175: }
1176: if (@changes > 0) {
1177: $chgresponse = &mt('The following settings have been changed:').'<br/><ul>';
1178: }
1179: if (@nochanges > 0) {
1180: $nochgresponse = &mt('The following settings remain unchanged:').'<br/><ul>';
1181: }
1182: if (@changes > 0) {
1183: my $putreply = &Apache::lonnet::put('environment',\%cenv,$cdom,$cnum);
1184: if ($putreply !~ /^ok$/) {
1185: $response = '<p class="LC_error">'.
1186: &mt('There was a problem processing your requested changes.').'<br />';
1187: if ($type eq 'Community') {
1188: $response .= &mt('Settings for this community have been left unchanged.');
1189: } else {
1190: $response .= &mt('Settings for this course have been left unchanged.');
1191: }
1192: $response .= '<br/>'.&mt('Error: ').$putreply.'</p>';
1193: } else {
1194: if ($env{'course.'.$cdom.'_'.$cnum.'.description'} ne '') {
1195: my %newenv;
1196: map { $newenv{'course.'.$cdom.'_'.$cnum.'.internal.'.$_} = $newattr{$_}; } @changes;
1197: &Apache::lonnet::appenv(\%newenv);
1198: }
1199: foreach my $attr (@modifiable_params) {
1200: if (grep/^\Q$attr\E$/,@changes) {
1201: my $shown = $newattr{$attr};
1202: if ($attr eq 'selfenrollmgrdc') {
1203: $shown = &selfenroll_config_status(\@newmgrdc,$selfenrolltitles);
1204: } elsif ($attr eq 'selfenrollmgrcc') {
1205: $shown = &selfenroll_config_status(\@newmgrcc,$selfenrolltitles);
1206: } elsif (($attr eq 'defaultcredits') && ($shown eq '')) {
1207: $shown = &mt('None');
1208: }
1209: $chgresponse .= '<li>'.&mt('[_1] now set to: [_2]',$longtype{$attr},$shown).'</li>';
1210: } else {
1211: my $shown = $currattr{$attr};
1212: if ($attr eq 'selfenrollmgrdc') {
1213: $shown = &selfenroll_config_status(\@currmgrdc,$selfenrolltitles);
1214: } elsif ($attr eq 'selfenrollmgrcc') {
1215: $shown = &selfenroll_config_status(\@currmgrcc,$selfenrolltitles);
1216: } elsif (($attr eq 'defaultcredits') && ($shown eq '')) {
1217: $shown = &mt('None');
1218: }
1219: $nochgresponse .= '<li>'.&mt('[_1] still set to: [_2]',$longtype{$attr},$shown).'</li>';
1220: }
1221: }
1222: if (($type ne 'Community') && ($type ne 'Placement') && ($changed{'code'} || $changed{'owner'})) {
1223: if ( $newattr{'courseowner'} eq '') {
1224: push(@warnings,&mt('There is no owner associated with this LON-CAPA course.').
1225: '<br />'.&mt('If automated enrollment at your institution requires validation of course owners, automated enrollment will fail.'));
1226: } else {
1227: my %crsenv = &Apache::lonnet::get('environment',['internal.co-owners'],$cdom,$cnum);
1228: my $coowners = $crsenv{'internal.co-owners'};
1229: if (@sections > 0) {
1230: if ($changed{'code'}) {
1231: foreach my $sec (@sections) {
1232: if ($sec =~ m/^(.+):/) {
1233: my $instsec = $1;
1234: my $inst_course_id = $newattr{'coursecode'}.$1;
1235: my $course_check = &Apache::lonnet::auto_validate_courseID($cnum,$cdom,$inst_course_id);
1236: if ($course_check eq 'ok') {
1237: my $outcome = &Apache::lonnet::auto_new_course($cnum,$cdom,$inst_course_id,$newattr{'courseowner'},$coowners);
1238: unless ($outcome eq 'ok') {
1239:
1240: 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/>');
1241: }
1242: } else {
1243: 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));
1244: }
1245: } else {
1246: 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));
1247: }
1248: }
1249: } elsif ($changed{'owner'}) {
1250: foreach my $sec (@sections) {
1251: if ($sec =~ m/^(.+):/) {
1252: my $instsec = $1;
1253: my $inst_course_id = $newattr{'coursecode'}.$instsec;
1254: my $outcome = &Apache::lonnet::auto_new_course($cnum,$cdom,$inst_course_id,$newattr{'courseowner'},$coowners);
1255: unless ($outcome eq 'ok') {
1256: 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));
1257: }
1258: } else {
1259: 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));
1260: }
1261: }
1262: }
1263: } else {
1264: 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'}));
1265: }
1266: if ( (@xlists > 0) && ($changed{'owner'}) ) {
1267: foreach my $xlist (@xlists) {
1268: if ($xlist =~ m/^(.+):/) {
1269: my $instxlist = $1;
1270: my $outcome = &Apache::lonnet::auto_new_course($cnum,$cdom,$instxlist,$newattr{'courseowner'},$coowners);
1271: unless ($outcome eq 'ok') {
1272: 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));
1273: }
1274: }
1275: }
1276: }
1277: }
1278: }
1279: }
1280: } else {
1281: foreach my $attr (@modifiable_params) {
1282: my $shown = $currattr{$attr};
1283: if ($attr eq 'selfenrollmgrdc') {
1284: $shown = &selfenroll_config_status(\@currmgrdc,$selfenrolltitles);
1285: } elsif ($attr eq 'selfenrollmgrcc') {
1286: $shown = &selfenroll_config_status(\@currmgrcc,$selfenrolltitles);
1287: } elsif (($attr eq 'defaultcredits') && ($shown eq '')) {
1288: $shown = &mt('None');
1289: }
1290: $nochgresponse .= '<li>'.&mt('[_1] still set to: [_2]',$longtype{$attr},$shown).'</li>';
1291: }
1292: }
1293:
1294: if (@changes > 0) {
1295: $chgresponse .= "</ul><br/><br/>";
1296: }
1297: if (@nochanges > 0) {
1298: $nochgresponse .= "</ul><br/><br/>";
1299: }
1300: my ($warning,$numwarnings);
1301: my $numwarnings = scalar(@warnings);
1302: if ($numwarnings) {
1303: $warning = &mt('The following [quant,_1,warning was,warnings were] generated when applying your changes to automated enrollment:',$numwarnings).'<p><ul>';
1304: foreach my $warn (@warnings) {
1305: $warning .= '<li><span class="LC_warning">'.$warn.'</span></li>';
1306: }
1307: $warning .= '</ul></p>';
1308: }
1309: if ($response) {
1310: $reply = $response;
1311: } else {
1312: $reply = $chgresponse.$nochgresponse.$warning;
1313: }
1314: &print_header($r,$type);
1315: my $mainheader = &modifiable_only_title($type);
1316: $reply = '<h3>'.$mainheader.' <span class="LC_nobreak">'.$cdesc.'</span></h3>'."\n".
1317: '<p>'.$reply.'</p>'."\n".
1318: '<form action="/adm/modifycourse" method="post" name="processparms">'.
1319: &hidden_form_elements();
1320: my @actions =
1321: ('<a href="javascript:changePage(document.processparms,'."'menu'".')">'.
1322: &mt('Pick another action').'</a>');
1323: if ($numwarnings) {
1324: my $newrole = $ccrole.'./'.$cdom.'/'.$cnum;
1325: my $escuri = &HTML::Entities::encode('/adm/roles?selectrole=1&'.$newrole.
1326: '=1&destinationurl=/adm/populate','&<>"');
1327:
1328: push(@actions, '<a href="'.$escuri.'">'.
1329: &mt('Go to Automated Enrollment Manager for course').'</a>');
1330: }
1331: $reply .= &Apache::lonhtmlcommon::actionbox(\@actions).'</form>';
1332: $r->print($reply);
1333: return;
1334: }
1335:
1336: sub selfenroll_config_status {
1337: my ($items,$selfenrolltitles) = @_;
1338: my $shown;
1339: if ((ref($items) eq 'ARRAY') && (ref($selfenrolltitles) eq 'HASH')) {
1340: if (@{$items} > 0) {
1341: $shown = '<ul>';
1342: foreach my $item (@{$items}) {
1343: $shown .= '<li>'.$selfenrolltitles->{$item}.'</li>';
1344: }
1345: $shown .= '</ul>';
1346: } else {
1347: $shown = &mt('None');
1348: }
1349: }
1350: return $shown;
1351: }
1352:
1353: sub update_coowners {
1354: my ($cdom,$cnum,$chome,$settings,$newattr) = @_;
1355: return unless ((ref($settings) eq 'HASH') && (ref($newattr) eq 'HASH'));
1356: my %designhash = &Apache::loncommon::get_domainconf($cdom);
1357: my (%cchash,$autocoowners);
1358: if ($designhash{$cdom.'.autoassign.co-owners'}) {
1359: $autocoowners = 1;
1360: %cchash = &Apache::lonnet::get_my_roles($cnum,$cdom,undef,undef,['cc']);
1361: }
1362: if ($settings->{'internal.courseowner'} ne $newattr->{'courseowner'}) {
1363: my $oldowner_to_coowner;
1364: my @types = ('co-owners');
1365: if (($newattr->{'coursecode'}) && ($autocoowners)) {
1366: my $oldowner = $settings->{'internal.courseowner'};
1367: if ($cchash{$oldowner.':cc'}) {
1368: my ($result,$desc) = &Apache::lonnet::auto_validate_instcode($cnum,$cdom,$newattr->{'coursecode'},$oldowner);
1369: if ($result eq 'valid') {
1370: if ($settings->{'internal.co-owner'}) {
1371: my @current = split(',',$settings->{'internal.co-owners'});
1372: unless (grep(/^\Q$oldowner\E$/,@current)) {
1373: $oldowner_to_coowner = 1;
1374: }
1375: } else {
1376: $oldowner_to_coowner = 1;
1377: }
1378: }
1379: }
1380: } else {
1381: push(@types,'pendingco-owners');
1382: }
1383: foreach my $type (@types) {
1384: if ($settings->{'internal.'.$type}) {
1385: my @current = split(',',$settings->{'internal.'.$type});
1386: my $newowner = $newattr->{'courseowner'};
1387: my @newvalues = ();
1388: if (($newowner ne '') && (grep(/^\Q$newowner\E$/,@current))) {
1389: foreach my $person (@current) {
1390: unless ($person eq $newowner) {
1391: push(@newvalues,$person);
1392: }
1393: }
1394: } else {
1395: @newvalues = @current;
1396: }
1397: if ($oldowner_to_coowner) {
1398: push(@newvalues,$settings->{'internal.courseowner'});
1399: @newvalues = sort(@newvalues);
1400: }
1401: my $newownstr = join(',',@newvalues);
1402: if ($newownstr ne $settings->{'internal.'.$type}) {
1403: if ($type eq 'co-owners') {
1404: my $deleted = '';
1405: unless (@newvalues) {
1406: $deleted = 1;
1407: }
1408: &Apache::lonnet::store_coowners($cdom,$cnum,$chome,
1409: $deleted,@newvalues);
1410: } else {
1411: my $pendingcoowners;
1412: my $cid = $cdom.'_'.$cnum;
1413: if (@newvalues) {
1414: $pendingcoowners = join(',',@newvalues);
1415: my %pendinghash = (
1416: 'internal.pendingco-owners' => $pendingcoowners,
1417: );
1418: my $putresult = &Apache::lonnet::put('environment',\%pendinghash,$cdom,$cnum);
1419: if ($putresult eq 'ok') {
1420: if ($env{'course.'.$cid.'.num'} eq $cnum) {
1421: &Apache::lonnet::appenv({'course.'.$cid.'.internal.pendingco-owners' => $pendingcoowners});
1422: }
1423: }
1424: } else {
1425: my $delresult = &Apache::lonnet::del('environment',['internal.pendingco-owners'],$cdom,$cnum);
1426: if ($delresult eq 'ok') {
1427: if ($env{'course.'.$cid.'.internal.pendingco-owners'}) {
1428: &Apache::lonnet::delenv('course.'.$cid.'.internal.pendingco-owners');
1429: }
1430: }
1431: }
1432: }
1433: } elsif ($oldowner_to_coowner) {
1434: &Apache::lonnet::store_coowners($cdom,$cnum,$chome,'',
1435: $settings->{'internal.courseowner'});
1436:
1437: }
1438: } elsif ($oldowner_to_coowner) {
1439: &Apache::lonnet::store_coowners($cdom,$cnum,$chome,'',
1440: $settings->{'internal.courseowner'});
1441: }
1442: }
1443: }
1444: if ($settings->{'internal.coursecode'} ne $newattr->{'coursecode'}) {
1445: if ($newattr->{'coursecode'} ne '') {
1446: my %designhash = &Apache::loncommon::get_domainconf($cdom);
1447: if ($designhash{$cdom.'.autoassign.co-owners'}) {
1448: my @newcoowners = ();
1449: if ($settings->{'internal.co-owners'}) {
1450: my @currcoown = split(',',$settings->{'internal.co-owners'});
1451: my ($updatecoowners,$delcoowners);
1452: foreach my $person (@currcoown) {
1453: my ($result,$desc) = &Apache::lonnet::auto_validate_instcode($cnum,$cdom,$newattr->{'coursecode'},$person);
1454: if ($result eq 'valid') {
1455: push(@newcoowners,$person);
1456: }
1457: }
1458: foreach my $item (sort(keys(%cchash))) {
1459: my ($uname,$udom,$urole) = split(':',$item);
1460: next if ($uname.':'.$udom eq $newattr->{'courseowner'});
1461: unless (grep(/^\Q$uname\E:\Q$udom\E$/,@newcoowners)) {
1462: my ($result,$desc) = &Apache::lonnet::auto_validate_instcode($cnum,$cdom,$newattr->{'coursecode'},$uname.':'.$udom);
1463: if ($result eq 'valid') {
1464: push(@newcoowners,$uname.':'.$udom);
1465: }
1466: }
1467: }
1468: if (@newcoowners) {
1469: my $coowners = join(',',sort(@newcoowners));
1470: unless ($coowners eq $settings->{'internal.co-owners'}) {
1471: $updatecoowners = 1;
1472: }
1473: } else {
1474: $delcoowners = 1;
1475: }
1476: if ($updatecoowners || $delcoowners) {
1477: &Apache::lonnet::store_coowners($cdom,$cnum,$chome,
1478: $delcoowners,@newcoowners);
1479: }
1480: } else {
1481: foreach my $item (sort(keys(%cchash))) {
1482: my ($uname,$udom,$urole) = split(':',$item);
1483: push(@newcoowners,$uname.':'.$udom);
1484: }
1485: if (@newcoowners) {
1486: &Apache::lonnet::store_coowners($cdom,$cnum,$chome,'',
1487: @newcoowners);
1488: }
1489: }
1490: }
1491: }
1492: }
1493: return;
1494: }
1495:
1496: sub modify_quota {
1497: my ($r,$cdom,$cnum,$cdesc,$domdesc,$type) = @_;
1498: &print_header($r,$type);
1499: my $lctype = lc($type);
1500: my $headline = &mt("Disk space quotas for $lctype: [_1]",
1501: '<span class="LC_nobreak">'.$cdesc.'</span>');
1502: $r->print('<form action="/adm/modifycourse" method="post" name="processquota">'."\n".
1503: '<h3>'.$headline.'</h3>');
1504: my %oldsettings = &Apache::lonnet::get('environment',['internal.coursequota','internal.uploadquota'],$cdom,$cnum);
1505: my %staticdefaults = (
1506: coursequota => 20,
1507: uploadquota => 500,
1508: );
1509: my %default;
1510: $default{'coursequota'} = $staticdefaults{'coursequota'};
1511: my %domdefs = &Apache::lonnet::get_domain_defaults($cdom);
1512: $default{'uploadquota'} = $domdefs{'uploadquota'};
1513: if ($default{'uploadquota'} eq '') {
1514: $default{'uploadquota'} = $staticdefaults{'uploadquota'};
1515: }
1516: my (%cenv,%showresult);
1517: foreach my $item ('coursequota','uploadquota') {
1518: if ($env{'form.'.$item} ne '') {
1519: my $newquota = $env{'form.'.$item};
1520: if ($newquota =~ /^\s*(\d+\.?\d*|\.\d+)\s*$/) {
1521: $newquota = $1;
1522: if ($oldsettings{'internal.'.$item} == $newquota) {
1523: if ($item eq 'coursequota') {
1524: $r->print(&mt('The disk space allocated for group portfolio files remains unchanged as [_1] MB.',$newquota).'<br />');
1525: } else {
1526: $r->print(&mt('The disk space allocated for files uploaded via the Content Editor remains unchanged as [_1] MB.',$newquota).'<br />');
1527: }
1528: } else {
1529: $cenv{'internal.'.$item} = $newquota;
1530: $showresult{$item} = 1;
1531: }
1532: } else {
1533: if ($item eq 'coursequota') {
1534: $r->print(&mt('The proposed group portfolio quota contained invalid characters, so the quota is unchanged.').'<br />');
1535: } else {
1536: $r->print(&mt('The proposed quota for content uploaded via the Content Editor contained invalid characters, so the quota is unchanged.').'<br />');
1537:
1538: }
1539: }
1540: }
1541: }
1542: if (keys(%cenv)) {
1543: my $putreply = &Apache::lonnet::put('environment',\%cenv,$cdom,
1544: $cnum);
1545: foreach my $key (sort(keys(%showresult))) {
1546: if (($oldsettings{'internal.'.$key} eq '') &&
1547: ($env{'form.'.$key} == $default{$key})) {
1548: if ($key eq 'uploadquota') {
1549: if ($type eq 'Community') {
1550: $r->print(&mt('The disk space allocated for files uploaded to this community via the Content Editor is the default quota for this domain: [_1] MB.',
1551: $default{$key}).'<br />');
1552: } else {
1553: $r->print(&mt('The disk space allocated for files uploaded to this course via the Content Editor is the default quota for this domain: [_1] MB.',
1554: $default{$key}).'<br />');
1555: }
1556: } else {
1557: if ($type eq 'Community') {
1558: $r->print(&mt('The disk space allocated for group portfolio files in this community is the default quota for this domain: [_1] MB.',
1559: $default{$key}).'<br />');
1560: } else {
1561: $r->print(&mt('The disk space allocated for group portfolio files in this course is the default quota for this domain: [_1] MB.',
1562: $default{$key}).'<br />');
1563: }
1564: }
1565: delete($showresult{$key});
1566: }
1567: }
1568: if ($putreply eq 'ok') {
1569: my %updatedsettings = &Apache::lonnet::get('environment',['internal.coursequota','internal.uploadquota'],$cdom,$cnum);
1570: if ($showresult{'coursequota'}) {
1571: $r->print(&mt('The disk space allocated for group portfolio files is now: [_1] MB.',
1572: '<b>'.$updatedsettings{'internal.coursequota'}.'</b>').'<br />');
1573: my $usage = &Apache::longroup::sum_quotas($cdom.'_'.$cnum);
1574: if ($usage >= $updatedsettings{'internal.coursequota'}) {
1575: my $newoverquota;
1576: if ($usage < $oldsettings{'internal.coursequota'}) {
1577: $newoverquota = 'now';
1578: }
1579: $r->print('<p>');
1580: if ($type eq 'Community') {
1581: $r->print(&mt("Disk usage $newoverquota exceeds the quota for this community.").' '.
1582: &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.'));
1583: } else {
1584: $r->print(&mt("Disk usage $newoverquota exceeds the quota for this course.").' '.
1585: &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.'));
1586: }
1587: $r->print('</p>');
1588: }
1589: }
1590: if ($showresult{'uploadquota'}) {
1591: $r->print(&mt('The disk space allocated for content uploaded directly via the Content Editor is now: [_1] MB.',
1592: '<b>'.$updatedsettings{'internal.uploadquota'}.'</b>').'<br />');
1593: }
1594: } else {
1595: $r->print(&mt('An error occurred storing the quota(s) for group portfolio files and/or uploaded content: ').
1596: $putreply);
1597: }
1598: }
1599: $r->print('<p>'.
1600: '<a href="javascript:changePage(document.processquota,'."'menu'".')">'.
1601: &mt('Pick another action').'</a>');
1602: $r->print(&hidden_form_elements().'</form>');
1603: return;
1604: }
1605:
1606: sub modify_anonsurvey_threshold {
1607: my ($r,$cdom,$cnum,$cdesc,$domdesc,$type) = @_;
1608: &print_header($r,$type);
1609: $r->print('<form action="/adm/modifycourse" method="post" name="processthreshold">'."\n".
1610: '<h3>'.&mt('Responder threshold required for display of anonymous survey submissions:').
1611: ' <span class="LC_nobreak">'.$cdesc.'</span></h3><br />');
1612: my %oldsettings = &Apache::lonnet::get('environment',['internal.anonsurvey_threshold'],$cdom,$cnum);
1613: my %domconfig =
1614: &Apache::lonnet::get_dom('configuration',['coursedefaults'],$cdom);
1615: my $defaultthreshold;
1616: if (ref($domconfig{'coursedefaults'}) eq 'HASH') {
1617: $defaultthreshold = $domconfig{'coursedefaults'}{'anonsurvey_threshold'};
1618: if ($defaultthreshold eq '') {
1619: $defaultthreshold = 10;
1620: }
1621: } else {
1622: $defaultthreshold = 10;
1623: }
1624: if ($env{'form.threshold'} eq '') {
1625: $r->print(&mt('The proposed responder threshold for display of anonymous survey submissions was blank, so the threshold is unchanged.'));
1626: } else {
1627: my $newthreshold = $env{'form.threshold'};
1628: if ($newthreshold =~ /^\s*(\d+)\s*$/) {
1629: $newthreshold = $1;
1630: if ($oldsettings{'internal.anonsurvey_threshold'} eq $env{'form.threshold'}) {
1631: $r->print(&mt('Responder threshold for anonymous survey submissions display remains unchanged: [_1].',$env{'form.threshold'}));
1632: } else {
1633: my %cenv = (
1634: 'internal.anonsurvey_threshold' => $env{'form.threshold'},
1635: );
1636: my $putreply = &Apache::lonnet::put('environment',\%cenv,$cdom,
1637: $cnum);
1638: if ($putreply eq 'ok') {
1639: if ($env{'course.'.$cdom.'_'.$cnum.'.description'} ne '') {
1640: &Apache::lonnet::appenv(
1641: {'course.'.$cdom.'_'.$cnum.'.internal.anonsurvey_threshold' => $env{'form.threshold'}});
1642: }
1643: }
1644: if (($oldsettings{'internal.anonsurvey_threshold'} eq '') &&
1645: ($env{'form.threshold'} == $defaultthreshold)) {
1646: $r->print(&mt('The responder threshold for display of anonymous survey submissions is the default for this domain: [_1].',$defaultthreshold));
1647: } else {
1648: if ($putreply eq 'ok') {
1649: my %updatedsettings = &Apache::lonnet::get('environment',['internal.anonsurvey_threshold'],$cdom,$cnum);
1650: $r->print(&mt('The responder threshold for display of anonymous survey submissions is now: [_1].','<b>'.$updatedsettings{'internal.anonsurvey_threshold'}.'</b>'));
1651: } else {
1652: $r->print(&mt('An error occurred storing the responder threshold for anonymous submissions display: ').
1653: $putreply);
1654: }
1655: }
1656: }
1657: } else {
1658: $r->print(&mt('The proposed responder threshold for display of anonymous submissions contained invalid characters, so the threshold is unchanged.'));
1659: }
1660: }
1661: $r->print('<p>'.
1662: '<a href="javascript:changePage(document.processthreshold,'."'menu'".')">'.
1663: &mt('Pick another action').'</a></p>');
1664: $r->print(&hidden_form_elements().'</form>');
1665: return;
1666: }
1667:
1668: sub modify_postsubmit_config {
1669: my ($r,$cdom,$cnum,$cdesc,$domdesc,$type) = @_;
1670: &print_header($r,$type);
1671: my %lt = &Apache::lonlocal::texthash(
1672: subb => 'Submit button behavior after student makes a submission:',
1673: unch => 'Post submission behavior of the Submit button is unchanged.',
1674: erro => 'An error occurred when saving your proposed changes.',
1675: inva => 'An invalid response was recorded.',
1676: pick => 'Pick another action',
1677: );
1678: $r->print('<form action="/adm/modifycourse" method="post" name="processpostsubmit">'."\n".
1679: '<h3>'.$lt{'subb'}.' <span class="LC_nobreak">('.$cdesc.')</span></h3><br />');
1680: my %oldsettings =
1681: &Apache::lonnet::get('environment',['internal.postsubmit','internal.postsubtimeout','internal.coursecode','internal.textbook'],$cdom,$cnum);
1682: my $postsubmit = $env{'form.postsubmit'};
1683: if ($postsubmit eq '1') {
1684: my $postsubtimeout = $env{'form.postsubtimeout'};
1685: $postsubtimeout =~ s/[^\d\.]+//g;
1686: if (($oldsettings{'internal.postsubmit'} eq $postsubmit) && ($oldsettings{'internal.postsubtimeout'} eq $postsubtimeout)) {
1687: $r->print($lt{'unch'});
1688: } else {
1689: my %cenv = (
1690: 'internal.postsubmit' => $postsubmit,
1691: );
1692: if ($postsubtimeout eq '') {
1693: my $putreply = &Apache::lonnet::put('environment',\%cenv,$cdom,$cnum);
1694: if ($putreply eq 'ok') {
1695: my $defaulttimeout = &domain_postsubtimeout($cdom,$type,\%oldsettings);
1696: $r->print(&mt('The proposed duration for disabling the Submit button post-submission was blank, so the domain default of [quant,_1,second] will be used.',$defaulttimeout));
1697: if (exists($oldsettings{'internal.postsubtimeout'})) {
1698: &Apache::lonnet::del('environment',['internal.postsubtimeout'],$cdom,$cnum);
1699: }
1700: } else {
1701: $r->print($lt{'erro'});
1702: }
1703: } else {
1704: $cenv{'internal.postsubtimeout'} = $postsubtimeout;
1705: my $putreply = &Apache::lonnet::put('environment',\%cenv,$cdom,$cnum);
1706: if ($putreply eq 'ok') {
1707: if ($postsubtimeout eq '0') {
1708: $r->print(&mt('Submit button will be disabled after student submission until page is reloaded.'));
1709: } else {
1710: $r->print(&mt('Submit button will be disabled after student submission for [quant,_1,second].',$postsubtimeout));
1711: }
1712: } else {
1713: $r->print($lt{'erro'});
1714: }
1715: }
1716: }
1717: } elsif ($postsubmit eq '0') {
1718: if ($oldsettings{'internal.postsubmit'} eq $postsubmit) {
1719: $r->print($lt{'unch'});
1720: } else {
1721: if (exists($oldsettings{'internal.postsubtimeout'})) {
1722: &Apache::lonnet::del('environment',['internal.postsubtimeout'],$cdom,$cnum);
1723: }
1724: my %cenv = (
1725: 'internal.postsubmit' => $postsubmit,
1726: );
1727: my $putreply = &Apache::lonnet::put('environment',\%cenv,$cdom,$cnum);
1728: if ($putreply eq 'ok') {
1729: $r->print(&mt('Submit button will not be disabled after student submission'));
1730: } else {
1731: $r->print($lt{'erro'});
1732: }
1733: }
1734: } else {
1735: $r->print($lt{'inva'}.' '.$lt{'unch'});
1736: }
1737: $r->print('<p>'.
1738: '<a href="javascript:changePage(document.processpostsubmit,'."'menu'".')">'.
1739: &mt('Pick another action').'</a></p>');
1740: $r->print(&hidden_form_elements().'</form>');
1741: return;
1742: }
1743:
1744: sub modify_catsettings {
1745: my ($r,$cdom,$cnum,$cdesc,$domdesc,$type) = @_;
1746: &print_header($r,$type);
1747: my ($ccrole,%desc);
1748: if ($type eq 'Community') {
1749: $desc{'hidefromcat'} = &mt('Excluded from community catalog');
1750: $desc{'categories'} = &mt('Assigned categories for this community');
1751: $ccrole = 'co';
1752: } else {
1753: $desc{'hidefromcat'} = &mt('Excluded from course catalog');
1754: $desc{'categories'} = &mt('Assigned categories for this course');
1755: $ccrole = 'cc';
1756: }
1757: $r->print('
1758: <form action="/adm/modifycourse" method="post" name="processcat">
1759: <h3>'.&mt('Category settings').'</h3>');
1760: my %domconf = &Apache::lonnet::get_dom('configuration',['coursecategories'],$cdom);
1761: my @cat_params = &catalog_settable($domconf{'coursecategories'},$type);
1762: if (@cat_params > 0) {
1763: my (%cenv,@changes,@nochanges);
1764: my %currsettings =
1765: &Apache::lonnet::get('environment',['hidefromcat','categories'],$cdom,$cnum);
1766: my (@newcategories,%showitem);
1767: if (grep(/^togglecats$/,@cat_params)) {
1768: if ($currsettings{'hidefromcat'} ne $env{'form.hidefromcat'}) {
1769: push(@changes,'hidefromcat');
1770: $cenv{'hidefromcat'} = $env{'form.hidefromcat'};
1771: } else {
1772: push(@nochanges,'hidefromcat');
1773: }
1774: if ($env{'form.hidefromcat'} eq 'yes') {
1775: $showitem{'hidefromcat'} = '"'.&mt('Yes')."'";
1776: } else {
1777: $showitem{'hidefromcat'} = '"'.&mt('No').'"';
1778: }
1779: }
1780: if (grep(/^categorize$/,@cat_params)) {
1781: my (@cats,@trails,%allitems,%idx,@jsarray);
1782: if (ref($domconf{'coursecategories'}) eq 'HASH') {
1783: my $cathash = $domconf{'coursecategories'}{'cats'};
1784: if (ref($cathash) eq 'HASH') {
1785: &Apache::loncommon::extract_categories($cathash,\@cats,\@trails,
1786: \%allitems,\%idx,\@jsarray);
1787: }
1788: }
1789: @newcategories = &Apache::loncommon::get_env_multiple('form.usecategory');
1790: if (@newcategories == 0) {
1791: $showitem{'categories'} = '"'.&mt('None').'"';
1792: } else {
1793: $showitem{'categories'} = '<ul>';
1794: foreach my $item (@newcategories) {
1795: $showitem{'categories'} .= '<li>'.$trails[$allitems{$item}].'</li>';
1796: }
1797: $showitem{'categories'} .= '</ul>';
1798: }
1799: my $catchg = 0;
1800: if ($currsettings{'categories'} ne '') {
1801: my @currcategories = split('&',$currsettings{'categories'});
1802: foreach my $cat (@currcategories) {
1803: if (!grep(/^\Q$cat\E$/,@newcategories)) {
1804: $catchg = 1;
1805: last;
1806: }
1807: }
1808: if (!$catchg) {
1809: foreach my $cat (@newcategories) {
1810: if (!grep(/^\Q$cat\E$/,@currcategories)) {
1811: $catchg = 1;
1812: last;
1813: }
1814: }
1815: }
1816: } else {
1817: if (@newcategories > 0) {
1818: $catchg = 1;
1819: }
1820: }
1821: if ($catchg) {
1822: $cenv{'categories'} = join('&',@newcategories);
1823: push(@changes,'categories');
1824: } else {
1825: push(@nochanges,'categories');
1826: }
1827: if (@changes > 0) {
1828: my $putreply = &Apache::lonnet::put('environment',\%cenv,$cdom,$cnum);
1829: if ($putreply eq 'ok') {
1830: if ($env{'course.'.$cdom.'_'.$cnum.'.description'} ne '') {
1831: my %newenvhash;
1832: foreach my $item (@changes) {
1833: $newenvhash{'course.'.$cdom.'_'.$cnum.'.'.$item} = $cenv{$item};
1834: }
1835: &Apache::lonnet::appenv(\%newenvhash);
1836: }
1837: my %crsinfo = &Apache::lonnet::courseiddump($cdom,'.',1,'.','.',
1838: $cnum,undef,undef,'.');
1839: if (ref($crsinfo{$env{'form.pickedcourse'}}) eq 'HASH') {
1840: if (grep(/^hidefromcat$/,@changes)) {
1841: $crsinfo{$env{'form.pickedcourse'}}{'hidefromcat'} = $env{'form.hidefromcat'};
1842: }
1843: if (grep(/^categories$/,@changes)) {
1844: $crsinfo{$env{'form.pickedcourse'}}{'categories'} = $cenv{'categories'};
1845: }
1846: my $chome = &Apache::lonnet::homeserver($cnum,$cdom);
1847: my $putres = &Apache::lonnet::courseidput($cdom,\%crsinfo,$chome,'notime');
1848: }
1849: $r->print(&mt('The following changes occurred:').'<ul>');
1850: foreach my $item (@changes) {
1851: $r->print('<li>'.&mt('[_1] now set to: [_2]',$desc{$item},$showitem{$item}).'</li>');
1852: }
1853: $r->print('</ul><br />');
1854: }
1855: }
1856: if (@nochanges > 0) {
1857: $r->print(&mt('The following were unchanged:').'<ul>');
1858: foreach my $item (@nochanges) {
1859: $r->print('<li>'.&mt('[_1] still set to: [_2]',$desc{$item},$showitem{$item}).'</li>');
1860: }
1861: $r->print('</ul>');
1862: }
1863: }
1864: } else {
1865: my $newrole = $ccrole.'./'.$cdom.'/'.$cnum;
1866: my $escuri = &HTML::Entities::encode('/adm/roles?selectrole=1&'.$newrole.
1867: '=1&destinationurl=/adm/courseprefs','&<>"');
1868: if ($type eq 'Community') {
1869: $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 />');
1870: } else {
1871: $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 />');
1872: }
1873: }
1874: $r->print('<br />'."\n".
1875: '<a href="javascript:changePage(document.processcat,'."'menu'".')">'.
1876: &mt('Pick another action').'</a>');
1877: $r->print(&hidden_form_elements().'</form>');
1878: return;
1879: }
1880:
1881: sub print_header {
1882: my ($r,$type,$javascript_validations) = @_;
1883: my $phase = "start";
1884: if ( exists($env{'form.phase'}) ) {
1885: $phase = $env{'form.phase'};
1886: }
1887: my $js = qq|
1888:
1889: function changePage(formname,newphase) {
1890: formname.phase.value = newphase;
1891: if (newphase == 'processparms') {
1892: return;
1893: }
1894: formname.submit();
1895: }
1896:
1897: |;
1898: if ($phase eq 'setparms') {
1899: $js .= $javascript_validations;
1900: } elsif ($phase eq 'courselist') {
1901: $js .= qq|
1902:
1903: function gochoose(cname,cdom,cdesc) {
1904: document.courselist.pickedcourse.value = cdom+'_'+cname;
1905: document.courselist.submit();
1906: }
1907:
1908: function hide_searching() {
1909: if (document.getElementById('searching')) {
1910: document.getElementById('searching').style.display = 'none';
1911: }
1912: return;
1913: }
1914:
1915: |;
1916: } elsif ($phase eq 'setquota') {
1917: my $invalid = &mt('The quota you entered contained invalid characters.');
1918: my $alert = &mt('You must enter a number');
1919: &js_escape(\$invalid);
1920: &js_escape(\$alert);
1921: my $regexp = '/^\s*(\d+\.?\d*|\.\d+)\s*$/';
1922: $js .= <<"ENDSCRIPT";
1923:
1924: function verify_quota() {
1925: var newquota = document.setquota.coursequota.value;
1926: var num_reg = $regexp;
1927: if (num_reg.test(newquota)) {
1928: changePage(document.setquota,'processquota');
1929: } else {
1930: alert("$invalid\\n$alert");
1931: return false;
1932: }
1933: return true;
1934: }
1935:
1936: ENDSCRIPT
1937: } elsif ($phase eq 'setanon') {
1938: my $invalid = &mt('The responder threshold you entered is invalid.');
1939: my $alert = &mt('You must enter a positive integer.');
1940: &js_escape(\$invalid);
1941: &js_escape(\$alert);
1942: my $regexp = ' /^\s*\d+\s*$/';
1943: $js .= <<"ENDSCRIPT";
1944:
1945: function verify_anon_threshold() {
1946: var newthreshold = document.setanon.threshold.value;
1947: var num_reg = $regexp;
1948: if (num_reg.test(newthreshold)) {
1949: if (newthreshold > 0) {
1950: changePage(document.setanon,'processthreshold');
1951: } else {
1952: alert("$invalid\\n$alert");
1953: return false;
1954: }
1955: } else {
1956: alert("$invalid\\n$alert");
1957: return false;
1958: }
1959: return true;
1960: }
1961:
1962: ENDSCRIPT
1963: } elsif ($phase eq 'setpostsubmit') {
1964: my $invalid = &mt('The choice entered for disabling the submit button is invalid.');
1965: my $invalidtimeout = &mt('The timeout you entered for disabling the submit button is invalid.');
1966: my $alert = &mt('Enter one of: a positive integer, 0 (for no timeout), or leave blank to use domain default');
1967: &js_escape(\$invalid);
1968: &js_escape(\$invalidtimeout);
1969: &js_escape(\$alert);
1970: my $regexp = ' /^\s*\d+\s*$/';
1971:
1972: $js .= <<"ENDSCRIPT";
1973:
1974: function verify_postsubmit() {
1975: var optionsElement = document.setpostsubmit.postsubmit;
1976: var verified = '';
1977: if (optionsElement.length) {
1978: var currval;
1979: for (var i=0; i<optionsElement.length; i++) {
1980: if (optionsElement[i].checked) {
1981: currval = optionsElement[i].value;
1982: }
1983: }
1984: if (currval == 1) {
1985: var newtimeout = document.setpostsubmit.postsubtimeout.value;
1986: if (newtimeout == '') {
1987: verified = 'ok';
1988: } else {
1989: var num_reg = $regexp;
1990: if (num_reg.test(newtimeout)) {
1991: if (newtimeout>= 0) {
1992: verified = 'ok';
1993: } else {
1994: alert("$invalidtimeout\\n$alert");
1995: return false;
1996: }
1997: } else {
1998: alert("$invalid\\n$alert");
1999: return false;
2000: }
2001: }
2002: } else {
2003: if (currval == 0) {
2004: verified = 'ok';
2005: } else {
2006: alert('$invalid');
2007: return false;
2008: }
2009: }
2010: if (verified == 'ok') {
2011: changePage(document.setpostsubmit,'processpostsubmit');
2012: return true;
2013: }
2014: }
2015: return false;
2016: }
2017:
2018: function togglePostsubmit(caller) {
2019: var optionsElement = document.setpostsubmit.postsubmit;
2020: if (document.getElementById(caller)) {
2021: var divitem = document.getElementById(caller);
2022: var optionsElement = document.setpostsubmit.postsubmit;
2023: if (optionsElement.length) {
2024: var currval;
2025: for (var i=0; i<optionsElement.length; i++) {
2026: if (optionsElement[i].checked) {
2027: currval = optionsElement[i].value;
2028: }
2029: }
2030: if (currval == 1) {
2031: divitem.style.display = 'block';
2032: } else {
2033: divitem.style.display = 'none';
2034: }
2035: }
2036: }
2037: return;
2038: }
2039:
2040: ENDSCRIPT
2041:
2042: }
2043: my $starthash;
2044: if ($env{'form.phase'} eq 'ccrole') {
2045: $starthash = {
2046: add_entries => {'onload' => "javascript:document.ccrole.submit();"},
2047: };
2048: } elsif ($phase eq 'courselist') {
2049: $starthash = {
2050: add_entries => {'onload' => "hide_searching(); courseSet(document.filterpicker.official, 'load');"},
2051: };
2052: }
2053: $r->print(&Apache::loncommon::start_page('View/Modify Course/Community Settings',
2054: &Apache::lonhtmlcommon::scripttag($js),
2055: $starthash));
2056: my $bread_text = "View/Modify Courses/Communities";
2057: if ($type eq 'Community') {
2058: $bread_text = 'Community Settings';
2059: } elsif ($type eq 'Placement') {
2060: $bread_text = 'Placement Test Settings';
2061: } else {
2062: $bread_text = 'Course Settings';
2063: }
2064: $r->print(&Apache::lonhtmlcommon::breadcrumbs($bread_text));
2065: return;
2066: }
2067:
2068: sub print_footer {
2069: my ($r) = @_;
2070: $r->print('<br />'.&Apache::loncommon::end_page());
2071: return;
2072: }
2073:
2074: sub check_course {
2075: my ($dom,$domdesc) = @_;
2076: my ($ok_course,$description,$instcode);
2077: my %coursehash;
2078: if ($env{'form.pickedcourse'} =~ /^$match_domain\_$match_courseid$/) {
2079: my %args;
2080: unless ($env{'course.'.$env{'form.pickedcourse'}.'.description'}) {
2081: %args = (
2082: 'one_time' => 1,
2083: 'freshen_cache' => 1,
2084: );
2085: }
2086: %coursehash =
2087: &Apache::lonnet::coursedescription($env{'form.pickedcourse'},\%args);
2088: my $cnum = $coursehash{'num'};
2089: my $cdom = $coursehash{'domain'};
2090: $description = $coursehash{'description'};
2091: $instcode = $coursehash{'internal.coursecode'};
2092: if ($instcode) {
2093: $description .= " ($instcode)";
2094: }
2095: if (($cdom eq $dom) && ($cnum =~ /^$match_courseid$/)) {
2096: my %courseIDs = &Apache::lonnet::courseiddump($cdom,'.',1,'.','.',
2097: $cnum,undef,undef,'.');
2098: if ($courseIDs{$cdom.'_'.$cnum}) {
2099: $ok_course = 'ok';
2100: }
2101: }
2102: }
2103: return ($ok_course,$description,\%coursehash);
2104: }
2105:
2106: sub course_settings_descrip {
2107: my ($type) = @_;
2108: my %longtype;
2109: if ($type eq 'Community') {
2110: %longtype = &Apache::lonlocal::texthash(
2111: 'courseowner' => "Username:domain of community owner",
2112: 'co-owners' => "Username:domain of each co-owner",
2113: 'selfenrollmgrdc' => "Community-specific self-enrollment configuration by Domain Coordinator",
2114: 'selfenrollmgrcc' => "Community-specific self-enrollment configuration by Community personnel",
2115: );
2116: } else {
2117: %longtype = &Apache::lonlocal::texthash(
2118: 'authtype' => 'Default authentication method',
2119: 'autharg' => 'Default authentication parameter',
2120: 'autoadds' => 'Automated adds',
2121: 'autodrops' => 'Automated drops',
2122: 'autostart' => 'Date of first automated enrollment',
2123: 'autoend' => 'Date of last automated enrollment',
2124: 'default_enrollment_start_date' => 'Date of first student access',
2125: 'default_enrollment_end_date' => 'Date of last student access',
2126: 'coursecode' => 'Official course code',
2127: 'courseowner' => "Username:domain of course owner",
2128: 'co-owners' => "Username:domain of each co-owner",
2129: 'notifylist' => 'Course Coordinators to be notified of enrollment changes',
2130: 'sectionnums' => 'Course section number:LON-CAPA section',
2131: 'crosslistings' => 'Crosslisted class:LON-CAPA section',
2132: 'defaultcredits' => 'Credits',
2133: 'autodropfailsafe' => "Failsafe section enrollment count",
2134: 'selfenrollmgrdc' => "Course-specific self-enrollment configuration by Domain Coordinator",
2135: 'selfenrollmgrcc' => "Course-specific self-enrollment configuration by Course personnel",
2136:
2137: );
2138: }
2139: return %longtype;
2140: }
2141:
2142: sub hidden_form_elements {
2143: my $hidden_elements =
2144: &Apache::lonhtmlcommon::echo_form_input(['gosearch','updater','coursecode',
2145: 'prevphase','numlocalcc','courseowner','login','coursequota','intarg',
2146: 'locarg','krbarg','krbver','counter','hidefromcat','usecategory',
2147: 'threshold','postsubmit','postsubtimeout','defaultcredits','uploadquota',
2148: 'selfenrollmgrdc','selfenrollmgrcc','action','state','currsec_st',
2149: 'sections','newsec'],['^selfenrollmgr_'])."\n".
2150: '<input type="hidden" name="prevphase" value="'.$env{'form.phase'}.'" />';
2151: return $hidden_elements;
2152: }
2153:
2154: sub showcredits {
2155: my ($dom) = @_;
2156: my %domdefaults = &Apache::lonnet::get_domain_defaults($dom);
2157: if ($domdefaults{'officialcredits'} || $domdefaults{'unofficialcredits'} || $domdefaults{'textbookcredits'}) {
2158: return 1;
2159: }
2160: }
2161:
2162: sub handler {
2163: my $r = shift;
2164: if ($r->header_only) {
2165: &Apache::loncommon::content_type($r,'text/html');
2166: $r->send_http_header;
2167: return OK;
2168: }
2169:
2170: my $dom = $env{'request.role.domain'};
2171: my $domdesc = &Apache::lonnet::domain($dom,'description');
2172:
2173: if (&Apache::lonnet::allowed('ccc',$dom)) {
2174: &Apache::loncommon::content_type($r,'text/html');
2175: $r->send_http_header;
2176:
2177: &Apache::lonhtmlcommon::clear_breadcrumbs();
2178:
2179: my $phase = $env{'form.phase'};
2180: if ($env{'form.updater'}) {
2181: $phase = '';
2182: }
2183: if ($phase eq '') {
2184: &Apache::lonhtmlcommon::add_breadcrumb
2185: ({href=>"/adm/modifycourse",
2186: text=>"Course/Community search"});
2187: &print_course_search_page($r,$dom,$domdesc);
2188: } else {
2189: my $firstform = $phase;
2190: if ($phase eq 'courselist') {
2191: $firstform = 'filterpicker';
2192: }
2193: my $choose_text;
2194: my $type = $env{'form.type'};
2195: if ($type eq '') {
2196: $type = 'Course';
2197: }
2198: if ($type eq 'Community') {
2199: $choose_text = "Choose a community";
2200: } elsif ($type eq 'Placement') {
2201: $choose_text = "Choose a placement test";
2202: } else {
2203: $choose_text = "Choose a course";
2204: }
2205: &Apache::lonhtmlcommon::add_breadcrumb
2206: ({href=>"javascript:changePage(document.$firstform,'')",
2207: text=>"Course/Community search"},
2208: {href=>"javascript:changePage(document.$phase,'courselist')",
2209: text=>$choose_text});
2210: if ($phase eq 'courselist') {
2211: &print_course_selection_page($r,$dom,$domdesc);
2212: } else {
2213: my ($checked,$cdesc,$coursehash) = &check_course($dom,$domdesc);
2214: if ($checked eq 'ok') {
2215: my $enter_text;
2216: if ($type eq 'Community') {
2217: $enter_text = 'Enter community';
2218: } elsif ($type eq 'Placement') {
2219: $enter_text = 'Enter placement test';
2220: } else {
2221: $enter_text = 'Enter course';
2222: }
2223: if ($phase eq 'menu') {
2224: &Apache::lonhtmlcommon::add_breadcrumb
2225: ({href=>"javascript:changePage(document.$phase,'menu')",
2226: text=>"Pick action"});
2227: &print_modification_menu($r,$cdesc,$domdesc,$dom,$type,
2228: $env{'form.pickedcourse'},$coursehash);
2229: } elsif ($phase eq 'ccrole') {
2230: &Apache::lonhtmlcommon::add_breadcrumb
2231: ({href=>"javascript:changePage(document.$phase,'ccrole')",
2232: text=>$enter_text});
2233: &print_ccrole_selected($r,$type);
2234: } else {
2235: &Apache::lonhtmlcommon::add_breadcrumb
2236: ({href=>"javascript:changePage(document.$phase,'menu')",
2237: text=>"Pick action"});
2238: my ($cdom,$cnum) = split(/_/,$env{'form.pickedcourse'});
2239: if ($phase eq 'setquota') {
2240: &Apache::lonhtmlcommon::add_breadcrumb
2241: ({href=>"javascript:changePage(document.$phase,'$phase')",
2242: text=>"Set quota"});
2243: &print_setquota($r,$cdom,$cnum,$cdesc,$type);
2244: } elsif ($phase eq 'processquota') {
2245: &Apache::lonhtmlcommon::add_breadcrumb
2246: ({href=>"javascript:changePage(document.$phase,'setquota')",
2247: text=>"Set quota"});
2248: &Apache::lonhtmlcommon::add_breadcrumb
2249: ({href=>"javascript:changePage(document.$phase,'$phase')",
2250: text=>"Result"});
2251: &modify_quota($r,$cdom,$cnum,$cdesc,$domdesc,$type);
2252: } elsif ($phase eq 'setanon') {
2253: &Apache::lonhtmlcommon::add_breadcrumb
2254: ({href=>"javascript:changePage(document.$phase,'$phase')",
2255: text=>"Threshold for anonymous submissions display"});
2256: &print_set_anonsurvey_threshold($r,$cdom,$cnum,$cdesc,$type);
2257: } elsif ($phase eq 'processthreshold') {
2258: &Apache::lonhtmlcommon::add_breadcrumb
2259: ({href=>"javascript:changePage(document.$phase,'setanon')",
2260: text=>"Threshold for anonymous submissions display"});
2261: &Apache::lonhtmlcommon::add_breadcrumb
2262: ({href=>"javascript:changePage(document.$phase,'$phase')",
2263: text=>"Result"});
2264: &modify_anonsurvey_threshold($r,$cdom,$cnum,$cdesc,$domdesc,$type);
2265: } elsif ($phase eq 'setpostsubmit') {
2266: &Apache::lonhtmlcommon::add_breadcrumb
2267: ({href=>"javascript:changePage(document.$phase,'$phase')",
2268: text=>"Configure submit button behavior post-submission"});
2269: &print_postsubmit_config($r,$cdom,$cnum,$cdesc,$type);
2270: } elsif ($phase eq 'processpostsubmit') {
2271: &Apache::lonhtmlcommon::add_breadcrumb
2272: ({href=>"javascript:changePage(document.$phase,'$phase')",
2273: text=>"Result"});
2274: &modify_postsubmit_config($r,$cdom,$cnum,$cdesc,$domdesc,$type);
2275: } elsif ($phase eq 'viewparms') {
2276: &Apache::lonhtmlcommon::add_breadcrumb
2277: ({href=>"javascript:changePage(document.$phase,'viewparms')",
2278: text=>"Display settings"});
2279: &print_settings_display($r,$cdom,$cnum,$cdesc,$type);
2280: } elsif ($phase eq 'setparms') {
2281: &Apache::lonhtmlcommon::add_breadcrumb
2282: ({href=>"javascript:changePage(document.$phase,'$phase')",
2283: text=>"Change settings"});
2284: &print_course_modification_page($r,$cdom,$cnum,$cdesc,$type);
2285: } elsif ($phase eq 'processparms') {
2286: &Apache::lonhtmlcommon::add_breadcrumb
2287: ({href=>"javascript:changePage(document.$phase,'setparms')",
2288: text=>"Change settings"});
2289: &Apache::lonhtmlcommon::add_breadcrumb
2290: ({href=>"javascript:changePage(document.$phase,'$phase')",
2291: text=>"Result"});
2292: &modify_course($r,$cdom,$cnum,$cdesc,$domdesc,$type);
2293: } elsif ($phase eq 'catsettings') {
2294: &Apache::lonhtmlcommon::add_breadcrumb
2295: ({href=>"javascript:changePage(document.$phase,'$phase')",
2296: text=>"Catalog settings"});
2297: &print_catsettings($r,$cdom,$cnum,$cdesc,$type);
2298: } elsif ($phase eq 'processcat') {
2299: &Apache::lonhtmlcommon::add_breadcrumb
2300: ({href=>"javascript:changePage(document.$phase,'catsettings')",
2301: text=>"Catalog settings"});
2302: &Apache::lonhtmlcommon::add_breadcrumb
2303: ({href=>"javascript:changePage(document.$phase,'$phase')",
2304: text=>"Result"});
2305: &modify_catsettings($r,$cdom,$cnum,$cdesc,$domdesc,$type);
2306: } elsif ($phase eq 'selfenroll') {
2307: &Apache::lonhtmlcommon::add_breadcrumb
2308: ({href => "javascript:changePage(document.$phase,'$phase')",
2309: text => "Self-enrollment settings"});
2310: if (!exists($env{'form.state'})) {
2311: &print_selfenrollconfig($r,$type,$cdesc,$coursehash);
2312: } elsif ($env{'form.state'} eq 'done') {
2313: &Apache::lonhtmlcommon::add_breadcrumb
2314: ({href=>"javascript:changePage(document.$phase,'$phase')",
2315: text=>"Result"});
2316: &modify_selfenrollconfig($r,$type,$cdesc,$coursehash);
2317: }
2318: }
2319: }
2320: } else {
2321: $r->print('<span class="LC_error">');
2322: if ($type eq 'Community') {
2323: $r->print(&mt('The community you selected is not a valid community in this domain'));
2324: } elsif ($type eq 'Placement') {
2325: $r->print(&mt('The course you selected is not a valid placement test in this domain'));
2326: } else {
2327: $r->print(&mt('The course you selected is not a valid course in this domain'));
2328: }
2329: $r->print(" ($domdesc)</span>");
2330: }
2331: }
2332: }
2333: &print_footer($r);
2334: } else {
2335: $env{'user.error.msg'}=
2336: "/adm/modifycourse:ccc:0:0:Cannot modify course/community settings";
2337: return HTTP_NOT_ACCEPTABLE;
2338: }
2339: return OK;
2340: }
2341:
2342: 1;
2343: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>