File:  [LON-CAPA] / loncom / interface / lonmodifycourse.pm
Revision 1.104: download - view: text, annotated - select for diffs
Sat Dec 23 02:17:38 2023 UTC (5 months ago) by raeburn
Branches: MAIN
CVS tags: HEAD
- Availability of "Course Authoring Space" set in Course Community defaults
  in domain (by container type), can be overridden for specific course(s).
- Add some help files for Course Editor and View/modify a course/community
- Add icons for use of Course Authoring Space.

    1: # The LearningOnline Network with CAPA
    2: # handler for DC-only modifiable course settings
    3: #
    4: # $Id: lonmodifycourse.pm,v 1.104 2023/12/23 02:17:38 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: my $registered_cleanup;
   43: my $modified_dom;
   44: 
   45: sub get_dc_settable {
   46:     my ($type,$cdom) = @_;
   47:     if ($type eq 'Community') {
   48:         return ('courseowner','selfenrollmgrdc','selfenrollmgrcc');
   49:     } else {
   50:         my @items = ('courseowner','coursecode','authtype','autharg','selfenrollmgrdc',
   51:                      'selfenrollmgrcc','mysqltables');
   52:         if (&showcredits($cdom)) {
   53:             push(@items,'defaultcredits');
   54:         }
   55:         my %passwdconf = &Apache::lonnet::get_passwdconf($cdom);
   56:         if (($passwdconf{'crsownerchg'}) && ($type ne 'Placement')) {
   57:             push(@items,'nopasswdchg');
   58:         }
   59:         return @items;
   60:     }
   61: }
   62: 
   63: sub autoenroll_keys {
   64:     my $internals = ['coursecode','courseowner','authtype','autharg','defaultcredits',
   65:                      'autoadds','autodrops','autostart','autoend','sectionnums',
   66:                      'crosslistings','co-owners','autodropfailsafe'];
   67:     my $accessdates = ['default_enrollment_start_date','default_enrollment_end_date'];
   68:     return ($internals,$accessdates);
   69: }
   70: 
   71: sub catalog_settable {
   72:     my ($confhash,$type) = @_;
   73:     my @settable;
   74:     if (ref($confhash) eq 'HASH') {
   75:         if ($type eq 'Community') {
   76:             if ($confhash->{'togglecatscomm'} ne 'comm') {
   77:                 push(@settable,'togglecats');
   78:             }
   79:             if ($confhash->{'categorizecomm'} ne 'comm') {
   80:                 push(@settable,'categorize');
   81:             }
   82:         } elsif ($type eq 'Placement') {
   83:             if ($confhash->{'togglecatsplace'} ne 'place') {
   84:                 push(@settable,'togglecats');
   85:             }
   86:             if ($confhash->{'categorizeplace'} ne 'place') {
   87:                 push(@settable,'categorize');
   88:             }
   89:         } else {
   90:             if ($confhash->{'togglecats'} ne 'crs') {
   91:                 push(@settable,'togglecats');
   92:             }
   93:             if ($confhash->{'categorize'} ne 'crs') {
   94:                 push(@settable,'categorize');
   95:             }
   96:         }
   97:     } else {
   98:         push(@settable,('togglecats','categorize'));
   99:     }
  100:     return @settable;
  101: }
  102: 
  103: sub get_enrollment_settings {
  104:     my ($cdom,$cnum) = @_;
  105:     my ($internals,$accessdates) = &autoenroll_keys();
  106:     my @items;
  107:     if ((ref($internals) eq 'ARRAY') && (ref($accessdates) eq 'ARRAY')) {
  108:         @items = map { 'internal.'.$_; } (@{$internals});
  109:         push(@items,@{$accessdates});
  110:     }
  111:     push(@items,'internal.nopasswdchg');
  112:     my %settings = &Apache::lonnet::get('environment',\@items,$cdom,$cnum);
  113:     my %enrollvar;
  114:     $enrollvar{'autharg'} = '';
  115:     $enrollvar{'authtype'} = '';
  116:     foreach my $item (keys(%settings)) {
  117:         if ($item =~ m/^internal\.(.+)$/) {
  118:             my $type = $1;
  119:             if ( ($type eq "autoadds") || ($type eq "autodrops") ) {
  120:                 if ($settings{$item} == 1) {
  121:                     $enrollvar{$type} = "ON";
  122:                 } else {
  123:                     $enrollvar{$type} = "OFF";
  124:                 }
  125:             } elsif ( ($type eq "autostart") || ($type eq "autoend") ) {
  126:                 if ( ($type eq "autoend") && ($settings{$item} == 0) ) {
  127:                     $enrollvar{$type} = &mt('No end date');
  128:                 } else {
  129:                     $enrollvar{$type} = &Apache::lonlocal::locallocaltime($settings{$item});
  130:                 }
  131:             } elsif (($type eq 'sectionnums') || ($type eq 'co-owners')) {
  132:                 $enrollvar{$type} = $settings{$item};
  133:                 $enrollvar{$type} =~ s/,/, /g;
  134:             } elsif ($type eq "authtype"
  135:                      || $type eq "autharg"    || $type eq "coursecode"
  136:                      || $type eq "crosslistings" || $type eq "selfenrollmgr"
  137:                      || $type eq "autodropfailsafe" || $type eq 'nopasswdchg') {
  138:                 $enrollvar{$type} = $settings{$item};
  139:             } elsif ($type eq 'defaultcredits') {
  140:                 if (&showcredits($cdom)) {
  141:                     $enrollvar{$type} = $settings{$item};
  142:                 }
  143:             } elsif ($type eq 'courseowner') {
  144:                 if ($settings{$item} =~ /^[^:]+:[^:]+$/) {
  145:                     $enrollvar{$type} = $settings{$item};
  146:                 } else {
  147:                     if ($settings{$item} ne '') {
  148:                         $enrollvar{$type} = $settings{$item}.':'.$cdom;
  149:                     }
  150:                 }
  151:             }
  152:         } elsif ($item =~ m/^default_enrollment_(start|end)_date$/) {
  153:             my $type = $1;
  154:             if ( ($type eq 'end') && ($settings{$item} == 0) ) {
  155:                 $enrollvar{$item} = &mt('No end date');
  156:             } elsif ( ($type eq 'start') && ($settings{$item} eq '') ) {
  157:                 $enrollvar{$item} = 'When enrolled';
  158:             } else {
  159:                 $enrollvar{$item} = &Apache::lonlocal::locallocaltime($settings{$item});
  160:             }
  161:         }
  162:     }
  163:     return %enrollvar;
  164: }
  165: 
  166: sub print_course_search_page {
  167:     my ($r,$dom,$domdesc) = @_;
  168:     my $action = '/adm/modifycourse';
  169:     my $type = $env{'form.type'};
  170:     if (!defined($env{'form.type'})) {
  171:         $type = 'Course';
  172:     }
  173:     &print_header($r,$type);
  174:     my ($filterlist,$filter) = &get_filters($dom);
  175:     my ($numtitles,$cctitle,$dctitle,@codetitles);
  176:     my $ccrole = 'cc';
  177:     if ($type eq 'Community') {
  178:         $ccrole = 'co';
  179:     }
  180:     $cctitle = &Apache::lonnet::plaintext($ccrole,$type);
  181:     $dctitle = &Apache::lonnet::plaintext('dc');
  182:     $r->print(&Apache::loncommon::js_changer());
  183:     if ($type eq 'Community') {
  184:         $r->print('<h3>'.&mt('Search for a community in the [_1] domain',$domdesc).'</h3>');
  185:     } elsif ($type eq 'Placement') {
  186:         $r->print('<h3>'.&mt('Search for a placement test in the [_1] domain',$domdesc).'</h3>');
  187:     } else {
  188:         $r->print('<h3>'.&mt('Search for a course in the [_1] domain',$domdesc).'</h3>');
  189:     }
  190:     $r->print(&Apache::loncommon::build_filters($filterlist,$type,undef,undef,$filter,$action,
  191:                                                 \$numtitles,'modifycourse',undef,undef,undef,
  192:                                                 \@codetitles,$dom));
  193: 
  194:     my ($actiontext,$roleoption,$settingsoption);
  195:     if ($type eq 'Community') {
  196:         $actiontext = &mt('Actions available after searching for a community:');
  197:     } elsif ($type eq 'Placement') {
  198:         $actiontext = &mt('Actions available after searching for a placement test:')
  199:     } else {
  200:         $actiontext = &mt('Actions available after searching for a course:');
  201:     }
  202:     if (&Apache::lonnet::allowed('ccc',$dom)) {
  203:        if ($type eq 'Community') {
  204:            $roleoption = &mt('Enter the community with the role of [_1]',$cctitle);
  205:            $settingsoption = &mt('View or modify community settings which only a [_1] may modify.',$dctitle);
  206:        } elsif ($type eq 'Placement') {
  207:            $roleoption = &mt('Enter the placement test with the role of [_1]',$cctitle);
  208:            $settingsoption = &mt('View or modify placement test settings which only a [_1] may modify.',$dctitle);
  209:        } else {
  210:            $roleoption = &mt('Enter the course with the role of [_1]',$cctitle);
  211:            $settingsoption = &mt('View or modify course settings which only a [_1] may modify.',$dctitle);
  212:        }
  213:     } elsif (&Apache::lonnet::allowed('rar',$dom)) {
  214:         my ($roles_by_num,$description,$accessref,$accessinfo) = &Apache::lonnet::get_all_adhocroles($dom);
  215:         if ((ref($roles_by_num) eq 'ARRAY') && (ref($description) eq 'HASH')) {
  216:             if (@{$roles_by_num} > 1) {
  217:                 if ($type eq 'Community') {
  218:                     $roleoption = &mt('Enter the community with one of the available ad hoc roles');
  219:                 } elsif ($type eq 'Placement') {
  220:                     $roleoption = &mt('Enter the placement test with one of the available ad hoc roles.');
  221:                 } else {
  222:                     $roleoption = &mt('Enter the course with one of the available ad hoc roles.');
  223:                 }
  224:             } else {
  225:                 my $rolename = $description->{$roles_by_num->[0]};
  226:                 if ($type eq 'Community') {
  227:                     $roleoption = &mt('Enter the community with the ad hoc role of: [_1]',$rolename);
  228:                 } elsif ($type eq 'Placement') {
  229:                     $roleoption = &mt('Enter the placement test with the ad hoc role of: [_1]',$rolename);
  230:                 } else {
  231:                     $roleoption = &mt('Enter the course with the ad hoc role of: [_1]',$rolename);
  232:                 }
  233:             }
  234:         }
  235:         if ($type eq 'Community') {
  236:             $settingsoption = &mt('View community settings which only a [_1] may modify.',$dctitle);
  237:         } elsif ($type eq 'Placement') {
  238:             $settingsoption = &mt('View placement test settings which only a [_1] may modify.',$dctitle);
  239:         } else {
  240:             $settingsoption = &mt('View course settings which only a [_1] may modify.',$dctitle);
  241:         }
  242:     }
  243:     $r->print($actiontext.'<ul>');
  244:     if ($roleoption) {
  245:         $r->print('<li>'.$roleoption.'</li>'."\n");
  246:     }
  247:     $r->print('<li>'.$settingsoption.'</li>'."\n".'</ul>');
  248:     return;
  249: }
  250: 
  251: sub print_course_selection_page {
  252:     my ($r,$dom,$domdesc,$permission) = @_;
  253:     my $type = $env{'form.type'};
  254:     if (!defined($type)) {
  255:         $type = 'Course';
  256:     }
  257:     &print_header($r,$type);
  258: 
  259:     if ($permission->{'adhocrole'} eq 'custom') {
  260:         my %lt = &Apache::lonlocal::texthash(
  261:             title    => 'Ad hoc role selection',
  262:             preamble => 'Please choose an ad hoc role in the course.',
  263:             cancel   => 'Click "OK" to enter the course, or "Cancel" to choose a different course.',
  264:         );
  265:         my %jslt = &Apache::lonlocal::texthash (
  266:             none => 'You are not eligible to use an ad hoc role for the selected course',
  267:             ok   => 'OK',
  268:             exit => 'Cancel',
  269:         );
  270:         &js_escape(\%jslt);
  271:         $r->print(<<"END");
  272: <script type="text/javascript">
  273: // <![CDATA[
  274: \$(document).ready(function(){
  275:     \$( "#LC_adhocrole_chooser" ).dialog({ autoOpen: false });
  276: });
  277: 
  278: function gochoose(cname,cdom,cdesc) {
  279:     document.courselist.pickedcourse.value = cdom+'_'+cname;
  280:     \$("#LC_choose_adhoc").empty();
  281:     var pickedaction = \$('input[name=phase]:checked', '#LCcoursepicker').val();
  282:     if (pickedaction == 'adhocrole') {
  283:         var http = new XMLHttpRequest();
  284:         var url = "/adm/pickcourse";
  285:         var params = "cid="+cdom+"_"+cname+"&context=adhoc";
  286:         http.open("POST", url, true);
  287:         http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  288:         http.onreadystatechange = function() {
  289:             if (http.readyState == 4 && http.status == 200) {
  290:                 var data = \$.parseJSON(http.responseText);
  291:                 var len = data.roles.length;
  292:                 if (len == '' || len == null || len == 0) {
  293:                     alert('$jslt{none}');
  294:                 } else {
  295:                     if (len == 1) {
  296:                         \$( '[name="adhocrole"]' )[0].value = data.roles[0].name;
  297:                         document.courselist.submit();
  298:                     } else {
  299:                         var str = '';
  300:                         \$("#LC_choose_adhoc").empty();
  301:                         for (var i=0; i<data.roles.length; i++) {
  302:                             \$("<label><input type='radio' value='"+data.roles[i].name+"' name='LC_get_role' id='LC_get_role_"+i+"' />"+data.roles[i].desc+"</label><span>&nbsp;&nbsp;</span>")
  303:                             .appendTo("#LC_choose_adhoc");
  304:                         }
  305:                         \$( "#LC_adhocrole_chooser" ).toggle( true );
  306:                         \$( "#LC_get_role_0").prop("checked", true);
  307:                         \$( "#LC_adhocrole_chooser" ).dialog({ autoOpen: false });
  308:                         \$( "#LC_adhocrole_chooser" ).dialog("open");
  309:                         \$( "#LC_adhocrole_chooser" ).dialog({
  310:                             height: 400,
  311:                             width: 500,
  312:                             modal: true,
  313:                             resizable: false,
  314:                             buttons: [
  315:                                   {
  316:                                    text: "$jslt{'ok'}",
  317:                                    click: function() {
  318:                                             var rolename = \$('input[name=LC_get_role]:checked', '#LChelpdeskpicker').val();
  319:                                             \$( '[name="adhocrole"]' )[0].value = rolename;
  320:                                             document.courselist.submit();
  321:                                         }
  322:                                   },
  323:                                   {
  324:                                    text: "$jslt{'exit'}",
  325:                                    click: function() {
  326:                                         \$("#LC_adhocrole_chooser").dialog( "close" );
  327:                                        }
  328:                                   }
  329:                             ],
  330:                         });
  331:                         \$( "#LC_adhocrole_chooser" ).find( "form" ).on( "submit", function( event ) {
  332:                             event.preventDefault();
  333:                             var rolename = \$('input[name=LC_get_role]:checked', '#LChelpdeskpicker').val()
  334:                             \$( '[name="adhocrole"]' )[0].value = rolename;
  335:                             document.courselist.submit();
  336:                             \$("#LC_adhocrole_chooser").dialog( "close" );
  337:                         });
  338:                     }
  339:                 }
  340:             }
  341:         }
  342:         http.send(params);
  343:     } else {
  344:         document.courselist.submit();
  345:     }
  346:     return;
  347: }
  348: // ]]>
  349: </script>
  350: 
  351: <div id="LC_adhocrole_chooser" title="$lt{'title'}" style="display:none">
  352:   <p>$lt{'preamble'}</p>
  353:   <form name="LChelpdeskadhoc" id="LChelpdeskpicker" action="">
  354:     <div id="LC_choose_adhoc">
  355:     </div>
  356:     <input type="hidden" name="adhocrole" id="LCadhocrole" value="" />
  357:     <input type="submit" tabindex="-1" style="position:absolute; top:-1000px" />
  358:   </form>
  359:   <p>$lt{'cancel'}</p>
  360: </div>
  361: END
  362:     } elsif ($permission->{'adhocrole'} eq 'coord') {
  363:         $r->print(<<"END");
  364: <script type="text/javascript">
  365: // <![CDATA[
  366: 
  367: function gochoose(cname,cdom,cdesc) {
  368:     document.courselist.pickedcourse.value = cdom+'_'+cname;
  369:     document.courselist.submit();
  370:     return;
  371: }
  372: 
  373: // ]]>
  374: </script>
  375: END
  376:     }
  377: 
  378: # Criteria for course search
  379:     my ($filterlist,$filter) = &get_filters();
  380:     my $action = '/adm/modifycourse';
  381:     my $dctitle = &Apache::lonnet::plaintext('dc');
  382:     my ($numtitles,@codetitles);
  383:     $r->print(&Apache::loncommon::js_changer());
  384:     $r->print(&mt('Revise your search criteria for this domain').' ('.$domdesc.').<br />');
  385:     $r->print(&Apache::loncommon::build_filters($filterlist,$type,undef,undef,$filter,$action,
  386:                                                 \$numtitles,'modifycourse',undef,undef,undef,
  387:                                                 \@codetitles,$dom,$env{'form.form'}));
  388:     my %courses = &Apache::loncommon::search_courses($dom,$type,$filter,$numtitles,
  389:                                                      undef,undef,undef,\@codetitles);
  390:     &Apache::lonpickcourse::display_matched_courses($r,$type,0,$action,undef,undef,undef,
  391:                                                     $dom,undef,%courses);
  392:     return;
  393: }
  394: 
  395: sub get_filters {
  396:     my ($dom) = @_;
  397:     my @filterlist = ('descriptfilter','instcodefilter','ownerfilter',
  398:                       'ownerdomfilter','coursefilter','sincefilter');
  399:     # created filter
  400:     my $loncaparev = &Apache::lonnet::get_server_loncaparev($dom);
  401:     if ($loncaparev ne 'unknown_cmd') {
  402:         push(@filterlist,'createdfilter');
  403:     }
  404:     my %filter;
  405:     foreach my $item (@filterlist) {
  406:         $filter{$item} = $env{'form.'.$item};
  407:     }
  408:     return (\@filterlist,\%filter);
  409: }
  410: 
  411: sub print_modification_menu {
  412:     my ($r,$cdesc,$domdesc,$dom,$type,$cid,$coursehash,$permission) = @_;
  413:     &print_header($r,$type);
  414:     my ($ccrole,$categorytitle,$setquota_text,$setuploadquota_text,$cdom,$cnum,
  415:         $extendedtype);
  416:     if (ref($coursehash) eq 'HASH') {
  417:         $cdom = $coursehash->{'domain'};
  418:         $cnum = $coursehash->{'num'};
  419:     } else {
  420:          ($cdom,$cnum) = split(/_/,$cid);
  421:     }
  422:     if ($type eq 'Community') {
  423:         $ccrole = 'co';
  424:     } else {
  425:         $ccrole = 'cc';
  426:     }
  427:     my %linktext;
  428:     if ($permission->{'setparms'} eq 'edit') {
  429:         %linktext = (
  430:                       'setquota'      => 'View/Modify quotas for group portfolio files, and for uploaded content',
  431:                       'setanon'       => 'View/Modify responders threshold for anonymous survey submissions display',
  432:                       'selfenroll'    => 'View/Modify Self-Enrollment configuration',
  433:                       'setpostsubmit' => 'View/Modify submit button behavior, post-submission',
  434:                       'setltiauth'    => 'View/Modify re-authentication requirement for LTI launch of deep-linked item',
  435:                       'setexttool'    => 'View/Modify External Tools permissions',
  436:                       'setcrsauthor'  => 'View/Modify In-course Authoring permissions',
  437:                     );
  438:     } else {
  439:         %linktext = (
  440:                       'setquota'      => 'View quotas for group portfolio files, and for uploaded content',
  441:                       'setanon'       => 'View responders threshold for anonymous survey submissions display',
  442:                       'selfenroll'    => 'View Self-Enrollment configuration',
  443:                       'setpostsubmit' => 'View submit button behavior, post-submission',
  444:                       'setltiauth'    => 'View re-authentication requirement for LTI launch of deep-linked item',
  445:                       'setexttool'    => 'View External Tools permissions',
  446:                       'setcrsauthor'  => 'View In-course Authoring permissions',
  447:                     );
  448:     }
  449:     if ($type eq 'Community') {
  450:         if ($permission->{'setparms'} eq 'edit') {
  451:             $categorytitle = 'View/Modify Community Settings';
  452:             $linktext{'setparms'} = 'View/Modify community owner, self-enrollment and table lifetime';
  453:             $linktext{'catsettings'} = 'View/Modify catalog settings for community';
  454:         } else {
  455:             $categorytitle = 'View Community Settings';
  456:             $linktext{'setparms'} = 'View community owner, self-enrollment and table lifetime';
  457:             $linktext{'catsettings'} = 'View catalog settings for community';
  458:         }
  459:         $setquota_text = &mt('Total disk space allocated for storage of portfolio files in all groups in a community.');
  460:         $setuploadquota_text = &mt('Disk space allocated for storage of content uploaded directly to a community via Content Editor.');
  461:     } else {
  462:         if ($permission->{'setparms'} eq 'edit') {
  463:             $categorytitle = 'View/Modify Course Settings';
  464:             $linktext{'catsettings'} = 'View/Modify catalog settings for course';
  465:             if (($type ne 'Placement') && (&showcredits($dom))) {
  466:                 $linktext{'setparms'} = 'View/Modify course owner, institutional code, default authentication, credits, self-enrollment and table lifetime';
  467:             } else {
  468:                 $linktext{'setparms'} = 'View/Modify course owner, institutional code, default authentication, self-enrollment and table lifetime';
  469:             }
  470:         } else {
  471:             $categorytitle = 'View Course Settings';
  472:             $linktext{'catsettings'} = 'View catalog settings for course';
  473:             if (($type ne 'Placement') && (&showcredits($dom))) {
  474:                 $linktext{'setparms'} = 'View course owner, institutional code, default authentication, credits, self-enrollment and table lifetime';
  475:             } else {
  476:                 $linktext{'setparms'} = 'View course owner, institutional code, default authentication, self-enrollment and table lifetime';
  477:             }
  478:         }
  479:         $setquota_text = &mt('Total disk space allocated for storage of portfolio files in all groups in a course.');
  480:         $setuploadquota_text = &mt('Disk space allocated for storage of content uploaded directly to a course via Content Editor.');
  481:         my %settings = &Apache::lonnet::get('environment',['internal.coursecode','internal.textbook'],
  482:                                             $cdom,$cnum);
  483:         $extendedtype = ucfirst(&Apache::lonuserutils::get_extended_type($cdom,$cnum,$type,\%settings));
  484:     }
  485:     my $anon_text = &mt('Responder threshold required to display anonymous survey submissions.');
  486:     my $postsubmit_text = &mt('Override defaults for submit button behavior post-submission for this specific course.');
  487:     my $mysqltables_text = &mt('Override default for lifetime of "temporary" MySQL tables containing student performance data.');
  488:     my $ltiauth_text = &mt('Override default for requirement for re-authentication for LTI-limited launch of deep-linked item.');
  489:     my $exttool_text = &mt('Override default permissions for external tools use for this specific course.');
  490:     $linktext{'viewparms'} = 'Display current settings for automated enrollment';
  491: 
  492:     my %domconf = &Apache::lonnet::get_dom('configuration',['coursecategories'],$dom);
  493:     my @additional_params = &catalog_settable($domconf{'coursecategories'},$type);
  494: 
  495:     sub manage_selfenrollment {
  496:         my ($cdom,$cnum,$type,$coursehash,$permission) = @_;
  497:         if ($permission->{'selfenroll'}) {
  498:             my ($managed_by_cc,$managed_by_dc) = &Apache::lonuserutils::selfenrollment_administration($cdom,$cnum,$type,$coursehash);
  499:             if (ref($managed_by_dc) eq 'ARRAY') {
  500:                 if (@{$managed_by_dc}) {
  501:                     return 1;
  502:                 }
  503:             }
  504:         }
  505:         return 0;
  506:     }
  507: 
  508:     sub phaseurl {
  509:         my $phase = shift;
  510:         return "javascript:changePage(document.menu,'$phase')"
  511:     }
  512:     my @menu =
  513:         ({  categorytitle => $categorytitle,
  514:         items => [
  515:             {
  516:                 linktext => $linktext{'setparms'},
  517:                 url => &phaseurl('setparms'),
  518:                 permission => $permission->{'setparms'},
  519:                 #help => '',
  520:                 icon => 'crsconf.png',
  521:                 linktitle => ''
  522:             },
  523:             {
  524:                 linktext => $linktext{'setquota'},
  525:                 url => &phaseurl('setquota'),
  526:                 permission => $permission->{'setquota'},
  527:                 #help => '',
  528:                 icon => 'groupportfolioquota.png',
  529:                 linktitle => ''
  530:             },
  531:             {
  532:                 linktext => $linktext{'setanon'},
  533:                 url => &phaseurl('setanon'),
  534:                 permission => $permission->{'setanon'},
  535:                 #help => '',
  536:                 icon => 'anonsurveythreshold.png',
  537:                 linktitle => ''
  538:             },
  539:             {
  540:                 linktext => $linktext{'catsettings'},
  541:                 url => &phaseurl('catsettings'),
  542:                 permission => (($permission->{'catsettings'}) && (@additional_params > 0)),
  543:                 #help => '',
  544:                 icon => 'ccatconf.png',
  545:                 linktitle => ''
  546:             },
  547:             {
  548:                 linktext => $linktext{'viewparms'},
  549:                 url => &phaseurl('viewparms'),
  550:                 permission => ($permission->{'viewparms'} && ($type ne 'Community') && ($type ne 'Placement')),
  551:                 #help => '',
  552:                 icon => 'roles.png',
  553:                 linktitle => ''
  554:             },
  555:             {
  556:                 linktext => $linktext{'selfenroll'},
  557:                 icon => 'self_enroll.png',
  558:                 #help => 'Course_Self_Enrollment',
  559:                 url => &phaseurl('selfenroll'),
  560:                 permission => &manage_selfenrollment($cdom,$cnum,$type,$coursehash,$permission),
  561:                 linktitle => 'Configure user self-enrollment.',
  562:             },
  563:             {
  564:                 linktext => $linktext{'setpostsubmit'},
  565:                 icon => 'emblem-readonly.png',
  566:                 #help => '',
  567:                 url => &phaseurl('setpostsubmit'),
  568:                 permission => $permission->{'setpostsubmit'},
  569:                 linktitle => '',
  570:             },
  571:             {
  572:                 linktext => $linktext{'setltiauth'},
  573:                 icon => 'system-lock-screen.png',
  574:                 #help => '',
  575:                 url => &phaseurl('setltiauth'),
  576:                 permission => $permission->{'setltiauth'},
  577:                 linktitle => '',
  578:             },
  579:             {
  580:                 linktext => $linktext{'setexttool'},
  581:                 icon => 'exttool.png',
  582:                 #help => '',
  583:                 url => &phaseurl('setexttool'),
  584:                 permission => $permission->{'setexttool'},
  585:                 linktitle => '',
  586:             },
  587:             {
  588:                 linktext => $linktext{'setcrsauthor'},
  589:                 icon => 'crsauthor.png',
  590:                 #help => '',
  591:                 url => &phaseurl('setcrsauthor'),
  592:                 permission => $permission->{'setcrsauthor'},
  593:                 linktitle => '',
  594:             },
  595:         ]
  596:         },
  597:         );
  598: 
  599:     $r->print(
  600:         '<h3>'
  601:        .&mt($type).': <span class="LC_nobreak">'.$cdesc.'</span>'
  602:        .'</h3>'."\n");
  603:     if ($extendedtype) {
  604:         $r->print('<h4>'.&mt('Type').': '.&mt("$extendedtype $type").'</h4>');
  605:     }
  606:     $r->print(
  607:         '<form name="menu" method="post" action="/adm/modifycourse">'
  608:        ."\n"
  609:        .&hidden_form_elements()
  610:        .&Apache::lonhtmlcommon::generate_menu(@menu)
  611:        .'</form>');
  612:     return;
  613: }
  614: 
  615: sub print_adhocrole_selected {
  616:     my ($r,$type,$permission) = @_;
  617:     &print_header($r,$type);
  618:     my ($cdom,$cnum) = split(/_/,$env{'form.pickedcourse'});
  619:     my ($newrole,$selectrole);
  620:     if ($permission->{'adhocrole'} eq 'coord') {
  621:         if ($type eq 'Community') {
  622:             $newrole = "co./$cdom/$cnum";
  623:         } else {
  624:             $newrole = "cc./$cdom/$cnum";
  625:         }
  626:         $selectrole = 1;
  627:     } elsif ($permission->{'adhocrole'} eq 'custom') {
  628:         my ($okroles,$description) = &Apache::lonnet::get_my_adhocroles($env{'form.pickedcourse'},1);
  629:         if (ref($okroles) eq 'ARRAY') {
  630:             my $possrole = $env{'form.adhocrole'};
  631:             if (($possrole ne '') && (grep(/^\Q$possrole\E$/,@{$okroles}))) {
  632:                 my $confname = &Apache::lonnet::get_domainconfiguser($cdom);
  633:                 $newrole = "cr/$cdom/$confname/$possrole./$cdom/$cnum";
  634:                 $selectrole = 1;
  635:             }
  636:         }
  637:     }
  638:     if ($selectrole) {
  639:         $r->print('<form name="adhocrole" method="post" action="/adm/roles">
  640: <input type="hidden" name="selectrole" value="'.$selectrole.'" />
  641: <input type="hidden" name="newrole" value="'.$newrole.'" />
  642: </form>');
  643:     } else {
  644:         $r->print('<form name="ccrole" method="post" action="/adm/modifycourse">'.
  645:                   '</form>');
  646:     }
  647:     return;
  648: }
  649: 
  650: sub print_settings_display {
  651:     my ($r,$cdom,$cnum,$cdesc,$type,$permission) = @_;
  652:     my %enrollvar = &get_enrollment_settings($cdom,$cnum);
  653:     my %longtype = &course_settings_descrip($type);
  654:     my %lt = &Apache::lonlocal::texthash(
  655:             'valu' => 'Current value',
  656:             'cour' => 'Current settings are:',
  657:             'cose' => "Settings which control auto-enrollment using classlists from your institution's student information system fall into two groups:",
  658:             'dcon' => 'Modifiable only by Domain Coordinator',
  659:             'back' => 'Pick another action',
  660:     );
  661:     my $ccrole = 'cc';
  662:     if ($type eq 'Community') {
  663:        $ccrole = 'co';
  664:     }
  665:     my $cctitle = &Apache::lonnet::plaintext($ccrole,$type);
  666:     my $dctitle = &Apache::lonnet::plaintext('dc');
  667:     my @modifiable_params = &get_dc_settable($type,$cdom);
  668:     my ($internals,$accessdates) = &autoenroll_keys();
  669:     my @items;
  670:     if ((ref($internals) eq 'ARRAY') && (ref($accessdates) eq 'ARRAY')) {
  671:         @items =  (@{$internals},@{$accessdates});
  672:     }
  673:     my $disp_table = &Apache::loncommon::start_data_table()."\n".
  674:                      &Apache::loncommon::start_data_table_header_row()."\n".
  675:                      "<th>&nbsp;</th>\n".
  676:                      "<th>$lt{'valu'}</th>\n".
  677:                      "<th>$lt{'dcon'}</th>\n".
  678:                      &Apache::loncommon::end_data_table_header_row()."\n";
  679:     foreach my $item (@items) {
  680:         my $shown = $enrollvar{$item};
  681:         if ($item eq 'crosslistings') {
  682:             my (@xlists,@lcsecs);
  683:             foreach my $entry (split(/,/,$enrollvar{$item})) {
  684:                 my ($xlist,$lc_sec) = split(/:/,$entry);
  685:                 push(@xlists,$xlist);
  686:                 push(@lcsecs,$lc_sec);
  687:             }
  688:             if (@xlists) {
  689:                 my $crskey = $cnum.':'.$enrollvar{'coursecode'};
  690:                 my %reformatted =
  691:                     &Apache::lonnet::auto_instsec_reformat($cdom,'declutter',
  692:                                                            {$crskey => \@xlists});
  693:                 if (ref($reformatted{$crskey}) eq 'ARRAY') {
  694:                     my @show;
  695:                     my @xlcodes = @{$reformatted{$crskey}};
  696:                     for (my $i=0; $i<@xlcodes; $i++) {
  697:                         push(@show,$xlcodes[$i].':'.$lcsecs[$i]);
  698:                     }
  699:                     if (@show) {
  700:                         $shown = join(',',@show);
  701:                     }
  702:                 }
  703:             }
  704:         }
  705:         $disp_table .= &Apache::loncommon::start_data_table_row()."\n".
  706:                        "<td><b>$longtype{$item}</b></td>\n".
  707:                        "<td>$shown</td>\n";
  708:         if (grep(/^\Q$item\E$/,@modifiable_params)) {
  709:             $disp_table .= '<td align="right">'.&mt('Yes').'</td>'."\n";
  710:         } else {
  711:             $disp_table .= '<td align="right">'.&mt('No').'</td>'."\n";
  712:         }
  713:         $disp_table .= &Apache::loncommon::end_data_table_row()."\n";
  714:     }
  715:     $disp_table .= &Apache::loncommon::end_data_table()."\n";
  716:     &print_header($r,$type);
  717:     my ($enroll_link_start,$enroll_link_end,$setparms_link_start,$setparms_link_end);
  718:     if (&Apache::lonnet::allowed('ccc',$cdom)) {
  719:         my $newrole = $ccrole.'./'.$cdom.'/'.$cnum;
  720:         my $escuri = &HTML::Entities::encode('/adm/roles?selectrole=1&'.$newrole.
  721:                                              '=1&destinationurl=/adm/populate','&<>"');
  722:         $enroll_link_start = '<a href="'.$escuri.'">';
  723:         $enroll_link_end = '</a>';
  724:     }
  725:     if ($permission->{'setparms'}) {
  726:         $setparms_link_start = '<a href="javascript:changePage(document.viewparms,'."'setparms'".');">';
  727:         $setparms_link_end = '</a>';
  728:     }
  729:     $r->print('<h3>'.&mt('Current automated enrollment settings').'</h3>'."\n".
  730:               '<h4><span class="LC_nobreak">'.&mt($type).': '.$cdesc.'</span></h4>'."\n".
  731:               '<form action="/adm/modifycourse" method="post" name="viewparms">'."\n".
  732:               '<p>'.$lt{'cose'}.'</p><ul>'.
  733:               '<li>'.&mt('Settings modifiable by a [_1] via the [_2]Automated Enrollment Manager[_3] in a course.',
  734:                          $cctitle,$enroll_link_start,$enroll_link_end).'</li>');
  735:     if (&showcredits($cdom)) {
  736:         $r->print('<li>'.&mt('Settings modifiable by a [_1] via [_2]View/Modify course owner, institutional code, default authentication, credits, self-enrollment and table lifetime[_3].',$dctitle,$setparms_link_start,$setparms_link_end)."\n");
  737:     } else {
  738:         $r->print('<li>'.&mt('Settings modifiable by a [_1] via [_2]View/Modify course owner, institutional code, default authentication, self-enrollment and table lifetime[_3].',$dctitle,$setparms_link_start,$setparms_link_end)."\n");
  739:     }
  740:     $r->print('</li></ul><p>'.
  741:               $lt{'cour'}.'</p>'.$disp_table.'<p>'."\n".
  742:               &hidden_form_elements().'</p>'.
  743:               '</form>'."\n");
  744:     my @actions =
  745:         ('<a href="javascript:changePage(document.viewparms,'."'menu'".')">'.
  746:          $lt{'back'}.'</a>');
  747:     $r->print('<br />'.&Apache::lonhtmlcommon::actionbox(\@actions));
  748: }
  749: 
  750: sub print_setquota {
  751:     my ($r,$cdom,$cnum,$cdesc,$type,$readonly) = @_;
  752:     my $lctype = lc($type);
  753:     my $headline = '<h3>'.&mt("Set disk space quotas for $lctype").'</h3>'."\n".
  754:                    '<h4><span class="LC_nobreak">'.&mt($type).': '.$cdesc.'</span></h4>'."\n";
  755:     my %lt = &Apache::lonlocal::texthash(
  756:                 'gpqu' => 'Disk space for storage of group portfolio files',
  757:                 'upqu' => 'Disk space for storage of content directly uploaded to course via Content Editor',
  758:                 'modi' => 'Save',
  759:                 'back' => 'Pick another action',
  760:     );
  761:     my %staticdefaults = (
  762:                            coursequota   => 20,
  763:                            uploadquota   => 500,
  764:                          );
  765:     my %settings = &Apache::lonnet::get('environment',['internal.coursequota','internal.uploadquota','internal.coursecode'],
  766:                                         $cdom,$cnum);
  767:     my $coursequota = $settings{'internal.coursequota'};
  768:     my $uploadquota = $settings{'internal.uploadquota'};
  769:     if (($uploadquota eq '') || ($coursequota eq '')) {
  770:         my %domdefs = &Apache::lonnet::get_domain_defaults($cdom);
  771:         my $quotatype = &Apache::lonuserutils::get_extended_type($cdom,$cnum,$type,\%settings);
  772:         if ($uploadquota eq '') {
  773:             $uploadquota = $domdefs{$quotatype.'quota'};
  774:             if ($uploadquota eq '') {
  775:                 $uploadquota = $staticdefaults{'uploadquota'};
  776:             }
  777:         }
  778:         if ($coursequota eq '') {
  779:             $coursequota = $domdefs{$quotatype.'coursequota'};
  780:             if ($coursequota eq '') {
  781:                 $coursequota = $staticdefaults{'coursequota'};
  782:             }
  783:         }
  784:     }
  785:     &print_header($r,$type);
  786:     my $hidden_elements = &hidden_form_elements();
  787:     my $porthelpitem = &Apache::loncommon::help_open_topic('Modify_Course_Quota');
  788:     my $uploadhelpitem = &Apache::loncommon::help_open_topic('Modify_Course_Upload_Quota');
  789:     my ($disabled,$submit);
  790:     if ($readonly) {
  791:         $disabled = ' disabled="disabled"';
  792:     } else {
  793:         $submit = '<input type="submit" value="'.$lt{'modi'}.'" />';
  794:     }
  795:     $r->print(<<ENDDOCUMENT);
  796: $headline
  797: <form action="/adm/modifycourse" method="post" name="setquota" onsubmit="return verify_quota();">
  798: <p><span class="LC_nobreak">
  799: $porthelpitem $lt{'gpqu'}: <input type="text" size="4" name="coursequota" value="$coursequota" $disabled /> MB
  800: </span>
  801: <br />
  802: <span class="LC_nobreak">
  803: $uploadhelpitem $lt{'upqu'}: <input type="text" size="4" name="uploadquota" value="$uploadquota" $disabled /> MB
  804: </span>
  805: </p>
  806: <p>
  807: $submit
  808: </p>
  809: $hidden_elements
  810: </form>
  811: ENDDOCUMENT
  812:     my @actions =
  813:         ('<a href="javascript:changePage(document.setquota,'."'menu'".')">'.
  814:          $lt{'back'}.'</a>');
  815:     $r->print('<br />'.&Apache::lonhtmlcommon::actionbox(\@actions));
  816:     return;
  817: }
  818: 
  819: sub print_set_anonsurvey_threshold {
  820:     my ($r,$cdom,$cnum,$cdesc,$type,$readonly) = @_;
  821:     my %lt = &Apache::lonlocal::texthash(
  822:                 'resp' => 'Responder threshold for anonymous survey submissions display:',
  823:                 'sufa' => 'Anonymous survey submissions displayed when responders exceeds',
  824:                 'modi' => 'Save',
  825:                 'back' => 'Pick another action',
  826:     );
  827:     my %settings = &Apache::lonnet::get('environment',['internal.anonsurvey_threshold'],$cdom,$cnum);
  828:     my $threshold = $settings{'internal.anonsurvey_threshold'};
  829:     if ($threshold eq '') {
  830:         my %domconfig =
  831:             &Apache::lonnet::get_dom('configuration',['coursedefaults'],$cdom);
  832:         if (ref($domconfig{'coursedefaults'}) eq 'HASH') {
  833:             $threshold = $domconfig{'coursedefaults'}{'anonsurvey_threshold'};
  834:             if ($threshold eq '') {
  835:                 $threshold = 10;
  836:             }
  837:         } else {
  838:             $threshold = 10;
  839:         }
  840:     }
  841:     &print_header($r,$type);
  842:     my $hidden_elements = &hidden_form_elements();
  843:     my ($disabled,$submit);
  844:     if ($readonly) {
  845:         $disabled = ' disabled="disabled"';
  846:     } else {
  847:         $submit = '<input type="submit" value="'.$lt{'modi'}.'" />';
  848:     }
  849:     my $helpitem = &Apache::loncommon::help_open_topic('Modify_Anonsurvey_Threshold');
  850:     my $showtype = &mt($type);
  851:     $r->print(<<ENDDOCUMENT);
  852: <h3>$lt{'resp'}</h3>
  853: <h4><span class="LC_nobreak">$showtype: $cdesc</span></h4>
  854: <form action="/adm/modifycourse" method="post" name="setanon" onsubmit="return verify_anon_threshold();">
  855: <p>
  856: $helpitem $lt{'sufa'}: <input type="text" size="4" name="threshold" value="$threshold" $disabled /> &nbsp;&nbsp;&nbsp;&nbsp;</p>
  857: $submit
  858: $hidden_elements
  859: </form>
  860: ENDDOCUMENT
  861:     my @actions =
  862:         ('<a href="javascript:changePage(document.setanon,'."'menu'".')">'.
  863:          $lt{'back'}.'</a>');
  864:     $r->print('<br /><br />'.&Apache::lonhtmlcommon::actionbox(\@actions));
  865:     return;
  866: }
  867: 
  868: sub print_postsubmit_config {
  869:     my ($r,$cdom,$cnum,$cdesc,$type,$readonly) = @_;
  870:     my %lt = &Apache::lonlocal::texthash (
  871:                 'conf' => 'Configure submit button behavior after student makes a submission',
  872:                 'disa' => 'Disable submit button/keypress following student submission',
  873:                 'nums' => 'Number of seconds submit is disabled',
  874:                 'modi' => 'Save',
  875:                 'back' => 'Pick another action',
  876:                 'yes'  => 'Yes',
  877:                 'no'   => 'No',
  878:     );
  879:     my %settings = &Apache::lonnet::get('environment',['internal.postsubmit','internal.postsubtimeout',
  880:                                                        'internal.coursecode','internal.textbook'],$cdom,$cnum);
  881:     my $postsubmit = $settings{'internal.postsubmit'};
  882:     if ($postsubmit eq '') {
  883:         my %domconfig =
  884:             &Apache::lonnet::get_dom('configuration',['coursedefaults'],$cdom);
  885:         $postsubmit = 1;
  886:         if (ref($domconfig{'coursedefaults'}) eq 'HASH') {
  887:             if (ref($domconfig{'coursedefaults'}{'postsubmit'}) eq 'HASH') {
  888:                 if ($domconfig{'coursedefaults'}{'postsubmit'}{'client'} eq 'off') {
  889:                     $postsubmit = 0;
  890:                 }
  891:             }
  892:         }
  893:     }
  894:     my ($checkedon,$checkedoff,$display);
  895:     if ($postsubmit) {
  896:         $checkedon = 'checked="checked"';
  897:         $display = 'block';
  898:     } else {
  899:         $checkedoff = 'checked="checked"';
  900:         $display = 'none';
  901:     }
  902:     my $postsubtimeout = $settings{'internal.postsubtimeout'};
  903:     my $default = &domain_postsubtimeout($cdom,$type,\%settings);
  904:     my $zero = &mt('(Enter 0 to disable until next page reload, or leave blank to use the domain default: [_1])',$default);
  905:     if ($postsubtimeout eq '') {
  906:         $postsubtimeout = $default;
  907:     }
  908:     &print_header($r,$type);
  909:     my $hidden_elements = &hidden_form_elements();
  910:     my ($disabled,$submit);
  911:     if ($readonly) {
  912:         $disabled = ' disabled="disabled"';
  913:     } else {
  914:         $submit = '<input type="submit" value="'.$lt{'modi'}.'" />';
  915:     }
  916:     my $helpitem = &Apache::loncommon::help_open_topic('Modify_Postsubmit_Config');
  917:     my $showtype = &mt($type);
  918:     $r->print(<<ENDDOCUMENT);
  919: <h3>$lt{'conf'}</h3>
  920: <h4><span class="LC_nobreak">$showtype: $cdesc</span></h4>
  921: <form action="/adm/modifycourse" method="post" name="setpostsubmit" onsubmit="return verify_postsubmit();">
  922: <p>
  923: $helpitem $lt{'disa'}:
  924: <label><input type="radio" name="postsubmit" $checkedon onclick="togglePostsubmit('studentsubmission');" value="1" $disabled />
  925: $lt{'yes'}</label>&nbsp;&nbsp;
  926: <label><input type="radio" name="postsubmit" $checkedoff onclick="togglePostsubmit('studentsubmission');" value="0" $disabled />
  927: $lt{'no'}</label></p>
  928: <div id="studentsubmission" style="display: $display">
  929: $lt{'nums'} <input type="text" name="postsubtimeout" value="$postsubtimeout" $disabled /><br />
  930: $zero</div>
  931: <p>
  932: $submit
  933: </p>
  934: $hidden_elements
  935: </form>
  936: ENDDOCUMENT
  937:     my @actions =
  938:         ('<a href="javascript:changePage(document.setpostsubmit,'."'menu'".')">'.
  939:          $lt{'back'}.'</a>');
  940:     $r->print('<br />'.&Apache::lonhtmlcommon::actionbox(\@actions));
  941:     return;
  942: }
  943: 
  944: sub domain_postsubtimeout {
  945:     my ($cdom,$type,$settings) = @_;
  946:     return unless (ref($settings) eq 'HASH');
  947:     my $lctype = &get_lctype($type,$settings);
  948:     my %domconfig =
  949:         &Apache::lonnet::get_dom('configuration',['coursedefaults'],$cdom);
  950:     my $postsubtimeout = 60;
  951:     if (ref($domconfig{'coursedefaults'}) eq 'HASH') {
  952:         if (ref($domconfig{'coursedefaults'}{'postsubmit'}) eq 'HASH') {
  953:             if (ref($domconfig{'coursedefaults'}{'postsubmit'}{'timeout'}) eq 'HASH') {
  954:                 if ($domconfig{'coursedefaults'}{'postsubmit'}{'timeout'}{$lctype} ne '') {
  955:                     $postsubtimeout = $domconfig{'coursedefaults'}{'postsubmit'}{'timeout'}{$lctype};
  956:                 }
  957:             }
  958:         }
  959:     }
  960:     return $postsubtimeout;
  961: }
  962: 
  963: sub get_lctype {
  964:     my ($type,$settings) = @_;
  965:     my $lctype = lc($type);
  966:     unless (($type eq 'Community') || ($type eq 'Placement')) {
  967:         $lctype = 'unofficial';
  968:         if (ref($settings) eq 'HASH') {
  969:             if ($settings->{'internal.coursecode'}) {
  970:                 $lctype = 'official';
  971:             } elsif ($settings->{'internal.textbook'}) {
  972:                 $lctype = 'textbook';
  973:             }
  974:         }
  975:     }
  976:     return $lctype;
  977: }
  978: 
  979: sub print_catsettings {
  980:     my ($r,$cdom,$cnum,$cdesc,$type,$readonly) = @_;
  981:     &print_header($r,$type);
  982:     my %lt = &Apache::lonlocal::texthash(
  983:                                          'back'    => 'Pick another action',
  984:                                          'catset'  => 'Catalog Settings for Course',
  985:                                          'visi'    => 'Visibility in Course/Community Catalog',
  986:                                          'exclude' => 'Exclude from course catalog:',
  987:                                          'categ'   => 'Categorize Course',
  988:                                          'assi'    => 'Assign one or more categories and/or subcategories to this course.'
  989:                                         );
  990:     if ($type eq 'Community') {
  991:         $lt{'catset'} = &mt('Catalog Settings for Community');
  992:         $lt{'exclude'} = &mt('Exclude from course catalog');
  993:         $lt{'categ'} = &mt('Categorize Community');
  994:         $lt{'assi'} = &mt('Assign one or more subcategories to this community.');
  995:     }
  996:     $r->print('<h3>'.$lt{'catset'}.'</h3>'."\n".
  997:               '<h4><span class="LC_nobreak">'.&mt($type).': '.$cdesc.'</span></h4>'."\n".
  998:               '<form action="/adm/modifycourse" method="post" name="catsettings">'."\n");
  999:     my %domconf = &Apache::lonnet::get_dom('configuration',['coursecategories'],$cdom);
 1000:     my @cat_params = &catalog_settable($domconf{'coursecategories'},$type);
 1001:     if (@cat_params > 0) {
 1002:         my $disabled;
 1003:         if ($readonly) {
 1004:             $disabled = ' disabled="disabled"';
 1005:         }
 1006:         my %currsettings =
 1007:             &Apache::lonnet::get('environment',['hidefromcat','categories'],$cdom,$cnum);
 1008:         if (grep(/^togglecats$/,@cat_params)) {
 1009:             my $excludeon = '';
 1010:             my $excludeoff = ' checked="checked" ';
 1011:             if ($currsettings{'hidefromcat'} eq 'yes') {
 1012:                 $excludeon = $excludeoff;
 1013:                 $excludeoff = '';
 1014:             }
 1015:             $r->print('<br /><h4>'.$lt{'visi'}.'</h4>'.
 1016:                       '<p>'.
 1017:                       $lt{'exclude'}.
 1018:                       '&nbsp;<label><input name="hidefromcat" type="radio" value="yes" '.$excludeon.$disabled.' />'.&mt('Yes').'</label>&nbsp;&nbsp;&nbsp;<label><input name="hidefromcat" type="radio" value="" '.$excludeoff.$disabled.' />'.&mt('No').'</label></p><p>');
 1019:             if ($type eq 'Community') {
 1020:                 $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.").'</p>');
 1021:             } elsif ($type eq 'Placement') {
 1022:                 $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.").'</p>');
 1023:             } else {
 1024:                 $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").':</p><ul>'.
 1025:                           '<li>'.&mt('Auto-cataloging is enabled and the course is assigned an institutional code.').'</li>'.
 1026:                           '<li>'.&mt('The course has been categorized using at least one of the course categories defined for the domain.').'</li></ul>');
 1027:             }
 1028:         }
 1029:         my $savebutton;
 1030:         unless ($readonly) {
 1031:             $savebutton = '<p><br /><input type="button" name="chgcatsettings" value="'.
 1032:                           &mt('Save').'" onclick="javascript:changePage(document.catsettings,'.
 1033:                           "'processcat'".');" /></p>';
 1034:         }
 1035:         my $shownsave;
 1036:         if (grep(/^categorize$/,@cat_params)) {
 1037:             my $categheader = '<br /><h4>'.$lt{'categ'}.'</h4>';
 1038:             if (ref($domconf{'coursecategories'}) eq 'HASH') {
 1039:                 my $cathash = $domconf{'coursecategories'}{'cats'};
 1040:                 if (ref($cathash) eq 'HASH') {
 1041:                     $r->print($categheader.
 1042:                               '<p>'.$lt{'assi'}.'</p>'.
 1043:                               &Apache::loncommon::assign_categories_table($cathash,
 1044:                                                      $currsettings{'categories'},$type,$disabled));
 1045:                 } else {
 1046:                     $r->print($savebutton.$categheader.
 1047:                               '<p>'.&mt('No categories defined for this domain.'));
 1048:                     $shownsave = 1;
 1049:                 }
 1050:             } else {
 1051:                 $r->print($savebutton.$categheader.
 1052:                           '<p>'.&mt('No categories defined for this domain.'));
 1053:                 $shownsave = 1;
 1054:             }
 1055:             if (($type eq 'Community') || ($type eq 'Placement')) {
 1056:                 $r->print('</p>');
 1057:             } elsif ($shownsave) {
 1058:                 $r->print('<br />'.&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.').'</p>');
 1059:             } else {
 1060:                 $r->print('</p><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>');
 1061:             }
 1062:         }
 1063:         unless ($readonly || $shownsave) {
 1064:             $r->print($savebutton);
 1065:         }
 1066:     } else {
 1067:         $r->print('<span class="LC_warning">');
 1068:         if ($type eq 'Community') {
 1069:             $r->print(&mt('Catalog settings in this domain are set in community context via "Community Configuration".'));
 1070:         } else {
 1071:             $r->print(&mt('Catalog settings in this domain are set in course context via "Course Configuration".'));
 1072:         }
 1073:         $r->print('</span>'."\n");
 1074:     }
 1075:     $r->print(&hidden_form_elements().'</form>'."\n");
 1076:     my @actions =
 1077:         ('<a href="javascript:changePage(document.catsettings,'."'menu'".')">'.
 1078:          $lt{'back'}.'</a>');
 1079:     $r->print('<br />'.&Apache::lonhtmlcommon::actionbox(\@actions));
 1080:     return;
 1081: }
 1082: 
 1083: sub print_course_modification_page {
 1084:     my ($r,$cdom,$cnum,$cdesc,$crstype,$readonly) = @_;
 1085:     my %lt=&Apache::lonlocal::texthash(
 1086:             'actv' => "Active",
 1087:             'inac' => "Inactive",
 1088:             'ownr' => "Owner",
 1089:             'name' => "Name",
 1090:             'unme' => "Username:Domain",
 1091:             'stus' => "Status",
 1092:             'nocc' => 'There is currently no owner set for this course.',
 1093:             'gobt' => "Save",
 1094:             'sett' => 'Setting',
 1095:             'domd' => 'Domain default',
 1096:             'whom' => 'Who configures',
 1097:     );
 1098:     my ($ownertable,$ccrole,$javascript_validations,$authenitems,$ccname,$disabled);
 1099:     my %enrollvar = &get_enrollment_settings($cdom,$cnum);
 1100:     my %settings = &Apache::lonnet::get('environment',['internal.coursecode','internal.textbook',
 1101:                                                        'internal.selfenrollmgrdc','internal.selfenrollmgrcc',
 1102:                                                        'internal.mysqltables'],$cdom,$cnum);
 1103:     my $type = &Apache::lonuserutils::get_extended_type($cdom,$cnum,$crstype,\%settings);
 1104:     my @specific_managebydc = split(/,/,$settings{'internal.selfenrollmgrdc'});
 1105:     my @specific_managebycc = split(/,/,$settings{'internal.selfenrollmgrcc'});
 1106:     my %domdefaults = &Apache::lonnet::get_domain_defaults($cdom);
 1107:     my %passwdconf = &Apache::lonnet::get_passwdconf($cdom);
 1108:     my @default_managebydc = split(/,/,$domdefaults{$type.'selfenrolladmdc'});
 1109:     if ($crstype eq 'Community') {
 1110:         $ccrole = 'co';
 1111:         $lt{'nocc'} = &mt('There is currently no owner set for this community.');
 1112:     } else {
 1113:         $ccrole ='cc';
 1114:         ($javascript_validations,$authenitems) = &gather_authenitems($cdom,\%enrollvar,$readonly);
 1115:     }
 1116:     $ccname = &Apache::lonnet::plaintext($ccrole,$crstype);
 1117:     if ($readonly) {
 1118:        $disabled = ' disabled="disabled"';
 1119:     }
 1120:     my %roleshash = &Apache::lonnet::get_my_roles($cnum,$cdom,'','',[$ccrole]);
 1121:     my (@local_ccs,%cc_status,%pname);
 1122:     foreach my $item (keys(%roleshash)) {
 1123:         my ($uname,$udom) = split(/:/,$item);
 1124:         if (!grep(/^\Q$uname\E:\Q$udom\E$/,@local_ccs)) {
 1125:             push(@local_ccs,$uname.':'.$udom);
 1126:             $pname{$uname.':'.$udom} = &Apache::loncommon::plainname($uname,$udom);
 1127:             $cc_status{$uname.':'.$udom} = $lt{'actv'};
 1128:         }
 1129:     }
 1130:     if (($enrollvar{'courseowner'} ne '') &&
 1131:         (!grep(/^$enrollvar{'courseowner'}$/,@local_ccs))) {
 1132:         push(@local_ccs,$enrollvar{'courseowner'});
 1133:         my ($owneruname,$ownerdom) = split(/:/,$enrollvar{'courseowner'});
 1134:         $pname{$enrollvar{'courseowner'}} =
 1135:                          &Apache::loncommon::plainname($owneruname,$ownerdom);
 1136:         my $active_cc = &Apache::loncommon::check_user_status($ownerdom,$owneruname,
 1137:                                                               $cdom,$cnum,$ccrole);
 1138:         if ($active_cc eq 'active') {
 1139:             $cc_status{$enrollvar{'courseowner'}} = $lt{'actv'};
 1140:         } else {
 1141:             $cc_status{$enrollvar{'courseowner'}} = $lt{'inac'};
 1142:         }
 1143:     }
 1144:     @local_ccs = sort(@local_ccs);
 1145:     if (@local_ccs == 0) {
 1146:         $ownertable = $lt{'nocc'};
 1147:     } else {
 1148:         my $numlocalcc = scalar(@local_ccs);
 1149:         $ownertable = '<input type="hidden" name="numlocalcc" value="'.$numlocalcc.'" />'.
 1150:                       &Apache::loncommon::start_data_table()."\n".
 1151:                       &Apache::loncommon::start_data_table_header_row()."\n".
 1152:                       '<th>'.$lt{'ownr'}.'</th>'.
 1153:                       '<th>'.$lt{'name'}.'</th>'.
 1154:                       '<th>'.$lt{'unme'}.'</th>'.
 1155:                       '<th>'.$lt{'stus'}.'</th>'.
 1156:                       &Apache::loncommon::end_data_table_header_row()."\n";
 1157:         foreach my $cc (@local_ccs) {
 1158:             $ownertable .= &Apache::loncommon::start_data_table_row()."\n";
 1159:             if ($cc eq $enrollvar{'courseowner'}) {
 1160:                 $ownertable .= '<td><input type="radio" name="courseowner" value="'.$cc.'" checked="checked"'.$disabled.' /></td>'."\n";
 1161:             } else {
 1162:                 $ownertable .= '<td><input type="radio" name="courseowner" value="'.$cc.'"'.$disabled.' /></td>'."\n";
 1163:             }
 1164:             $ownertable .=
 1165:                  '<td>'.$pname{$cc}.'</td>'."\n".
 1166:                  '<td>'.$cc.'</td>'."\n".
 1167:                  '<td>'.$cc_status{$cc}.' '.$ccname.'</td>'."\n".
 1168:                  &Apache::loncommon::end_data_table_row()."\n";
 1169:         }
 1170:         $ownertable .= &Apache::loncommon::end_data_table();
 1171:     }
 1172:     &print_header($r,$crstype,$javascript_validations);
 1173:     my $dctitle = &Apache::lonnet::plaintext('dc');
 1174:     my $hidden_elements = &hidden_form_elements();
 1175:     my $showtype;
 1176:     if (($type eq 'official') || ($type eq 'unofficial') || ($type eq 'textbook')) {
 1177:         $showtype = ' ('.&mt($type).')';
 1178:     }
 1179:     $r->print('<h3>'.&modifiable_only_title($crstype).'</h3>'."\n".
 1180:               '<h4><span class="LC_nobreak">'.&mt($crstype).': '.$cdesc.$showtype.'</span></h4><br />'."\n".
 1181:               '<form action="/adm/modifycourse" method="post" name="'.$env{'form.phase'}.'">'."\n".
 1182:               &Apache::lonhtmlcommon::start_pick_box());
 1183:     if ($crstype eq 'Community') {
 1184:         $r->print(&Apache::lonhtmlcommon::row_title(
 1185:                   &Apache::loncommon::help_open_topic('Modify_Community_Owner').
 1186:                   '&nbsp;'.&mt('Community Owner'))."\n".
 1187:                   $ownertable."\n".&Apache::lonhtmlcommon::row_closure());
 1188:     } else {
 1189:         $r->print(&Apache::lonhtmlcommon::row_title(
 1190:                       &Apache::loncommon::help_open_topic('Modify_Course_Instcode').
 1191:                       '&nbsp;'.&mt('Course Code'))."\n".
 1192:                   '<input type="text" size="15" name="coursecode" value="'.$enrollvar{'coursecode'}.'"'.$disabled.' />'.
 1193:                   &Apache::lonhtmlcommon::row_closure());
 1194:         if (($crstype eq 'Course') && (&showcredits($cdom))) {
 1195:             $r->print(&Apache::lonhtmlcommon::row_title(
 1196:                           &Apache::loncommon::help_open_topic('Modify_Course_Credithours').
 1197:                           '&nbsp;'.&mt('Credits (students)'))."\n".
 1198:                       '<input type="text" size="3" name="defaultcredits" value="'.$enrollvar{'defaultcredits'}.'"'.$disabled.' />'.
 1199:                       &Apache::lonhtmlcommon::row_closure());
 1200:         }
 1201:         $r->print(&Apache::lonhtmlcommon::row_title(
 1202:                       &Apache::loncommon::help_open_topic('Modify_Course_Defaultauth').
 1203:                       '&nbsp;'.&mt('Default Authentication method'))."\n".
 1204:                   $authenitems."\n".
 1205:                   &Apache::lonhtmlcommon::row_closure().
 1206:                   &Apache::lonhtmlcommon::row_title(
 1207:                       &Apache::loncommon::help_open_topic('Modify_Course_Owner').
 1208:                       '&nbsp;'.&mt('Course Owner'))."\n".
 1209:                   $ownertable."\n".&Apache::lonhtmlcommon::row_closure());
 1210:         if (($passwdconf{'crsownerchg'}) && ($type ne 'Placement')) {
 1211:             my $checked;
 1212:             if ($enrollvar{'nopasswdchg'}) {
 1213:                 $checked = ' checked="checked"';
 1214:             }
 1215:             $r->print(&Apache::lonhtmlcommon::row_title(
 1216:                          &Apache::loncommon::help_open_topic('Modify_Course_Chgpasswd').
 1217:                          '&nbsp;'.&mt('Changing passwords (internal)'))."\n".
 1218:                          '<label><input type="checkbox" value="1" name="nopasswdchg"'.$checked.$disabled.' />'.
 1219:                          &mt('Disable changing password for users with student role by course owner').'</label>'."\n".
 1220:                          &Apache::lonhtmlcommon::row_closure());
 1221:         }
 1222:     }
 1223:     my ($cctitle,$rolename,$currmanages,$ccchecked,$dcchecked,$defaultchecked);
 1224:     my ($selfenrollrows,$selfenrolltitles) = &Apache::lonuserutils::get_selfenroll_titles();
 1225:     if ($type eq 'Community') {
 1226:         $cctitle = &mt('Community personnel');
 1227:     } else {
 1228:         $cctitle = &mt('Course personnel');
 1229:     }
 1230: 
 1231:     $r->print(&Apache::lonhtmlcommon::row_title(
 1232:               &Apache::loncommon::help_open_topic('Modify_Course_Selfenrolladmin').
 1233:                   '&nbsp;'.&mt('Self-enrollment configuration')).
 1234:               &Apache::loncommon::start_data_table()."\n".
 1235:               &Apache::loncommon::start_data_table_header_row()."\n".
 1236:               '<th>'.$lt{'sett'}.'</th>'.
 1237:               '<th>'.$lt{'domd'}.'</th>'.
 1238:               '<th>'.$lt{'whom'}.'</th>'.
 1239:               &Apache::loncommon::end_data_table_header_row()."\n");
 1240:     my %optionname;
 1241:     $optionname{''} = &mt('Use domain default');
 1242:     $optionname{'0'} = $dctitle;
 1243:     $optionname{'1'} = $cctitle;
 1244:     foreach my $item (@{$selfenrollrows}) {
 1245:         my %checked;
 1246:         my $default = $cctitle;
 1247:         if (grep(/^\Q$item\E$/,@default_managebydc)) {
 1248:             $default = $dctitle;
 1249:         }
 1250:         if (grep(/^\Q$item\E$/,@specific_managebydc)) {
 1251:             $checked{'0'} = ' checked="checked"';
 1252:         } elsif (grep(/^\Q$item\E$/,@specific_managebycc)) {
 1253:             $checked{'1'} = ' checked="checked"';
 1254:         } else {
 1255:             $checked{''} = ' checked="checked"';
 1256:         }
 1257:         $r->print(&Apache::loncommon::start_data_table_row()."\n".
 1258:                  '<td>'.$selfenrolltitles->{$item}.'</td>'."\n".
 1259:                  '<td>'.&mt('[_1] configures',$default).'</td>'."\n".
 1260:                  '<td>');
 1261:         foreach my $option ('','0','1') {
 1262:             $r->print('<span class="LC_nobreak"><label>'.
 1263:                       '<input type="radio" name="selfenrollmgr_'.$item.'" '.
 1264:                       'value="'.$option.'"'.$checked{$option}.$disabled.' />'.
 1265:                       $optionname{$option}.'</label></span><br />');
 1266:         }
 1267:         $r->print('</td>'."\n".
 1268:                   &Apache::loncommon::end_data_table_row()."\n");
 1269:     }
 1270:     $r->print(&Apache::loncommon::end_data_table()."\n".
 1271:               '<br />'.&Apache::lonhtmlcommon::row_closure().
 1272:               &Apache::lonhtmlcommon::row_title(
 1273:               &Apache::loncommon::help_open_topic('Modify_Course_Table_Lifetime').
 1274:               '&nbsp;'.&mt('"Temporary" Tables Lifetime (s)'))."\n".
 1275:               '<input type="text" size="10" name="mysqltables" value="'.$settings{'internal.mysqltables'}.'"'.$disabled.' />'.
 1276:               &Apache::lonhtmlcommon::row_closure(1).
 1277:               &Apache::lonhtmlcommon::end_pick_box().'<br />'.$hidden_elements);
 1278:     unless ($readonly) {
 1279:         $r->print('<input type="button" onclick="javascript:changePage(this.form,'."'processparms'".');');
 1280:         if ($crstype eq 'Community') {
 1281:             $r->print('this.form.submit();"');
 1282:         } else {
 1283:             $r->print('javascript:verify_message(this.form);"');
 1284:         }
 1285:         $r->print(' value="'.$lt{'gobt'}.'" />');
 1286:     }
 1287:     $r->print('</form>');
 1288:     my @actions =
 1289:         ('<a href="javascript:changePage(document.'.$env{'form.phase'}.','."'menu'".')">'.
 1290:          &mt('Pick another action').'</a>');
 1291:     $r->print('<br /><br />'.&Apache::lonhtmlcommon::actionbox(\@actions));
 1292:     return;
 1293: }
 1294: 
 1295: sub print_selfenrollconfig {
 1296:     my ($r,$type,$cdesc,$coursehash,$readonly) = @_;
 1297:     return unless(ref($coursehash) eq 'HASH');
 1298:     my $cnum = $coursehash->{'num'};
 1299:     my $cdom = $coursehash->{'domain'};
 1300:     my %currsettings = &get_selfenroll_settings($coursehash);
 1301:     &print_header($r,$type);
 1302:     $r->print('<h3>'.&mt('Self-enrollment with a student role').'</h3>'."\n".
 1303:               '<h4><span class="LC_nobreak">'.&mt($type).': '.$cdesc.'</span></h4>'."\n");
 1304:     &Apache::loncreateuser::print_selfenroll_menu($r,'domain',$env{'form.pickedcourse'},
 1305:                                                   $cdom,$cnum,\%currsettings,
 1306:                                                   &hidden_form_elements(),$readonly);
 1307:     my @actions =
 1308:         ('<a href="javascript:changePage(document.selfenroll,'."'menu'".')">'.
 1309:          &mt('Pick another action').'</a>');
 1310:     $r->print('<br /><br />'.&Apache::lonhtmlcommon::actionbox(\@actions));
 1311:     return;
 1312: }
 1313: 
 1314: sub print_default_overrides {
 1315:     my ($r,$cdom,$cnum,$cdesc,$type,$readonly,$item) = @_;
 1316:     my (%titles,$checkeddom,$checkedcrs,$divsty,$currcrsval,$crsdefault,%crschecked,
 1317:         $helpfile,$title,$crselements);
 1318:     %titles = &default_overrides_titles($type);
 1319:     my ($title,$domdefdisplay,$settings,$optiontext,$options) =
 1320:         &default_overrides_common($item,$cdom,$cnum,$type,\%titles);
 1321:     $checkeddom = ' checked="checked"';
 1322:     $divsty = 'display:none';
 1323:     if ($item eq 'ltiauth') {
 1324:         $helpfile = 'Modify_Course_LTI_Authen';
 1325:         $crsdefault = 0;
 1326:     } else {
 1327:         if ($item eq 'exttool') {
 1328:             $helpfile = 'Modify_Course_External_Tool';
 1329:             $crsdefault = 'both';
 1330:         } elsif ($item eq 'crsauthor') {
 1331:             $helpfile = 'Modify_Course_Crsauthor';
 1332:             $crsdefault = 1;
 1333:         }
 1334:     }
 1335:     $currcrsval = $settings->{'internal.'.$item};
 1336:     if ($currcrsval ne '') {
 1337:         $checkedcrs = $checkeddom;
 1338:         $checkeddom = '';
 1339:         $divsty = 'display:inline-block';
 1340:         foreach my $option (@{$options}) {
 1341:             if ($currcrsval eq $option) {
 1342:                 $crschecked{$option} = ' checked="checked"';
 1343:             } else {
 1344:                 $crschecked{$option} = '';
 1345:             }
 1346:         }
 1347:     } else {
 1348:         foreach my $option (@{$options}) {
 1349:             if ($crsdefault eq $option) {
 1350:                 $crschecked{$option} = ' checked="checked"';
 1351:             } else {
 1352:                 $crschecked{$option} = '';
 1353:             }
 1354:         }
 1355:     }
 1356:     my ($disabled,$submit);
 1357:     if ($readonly) {
 1358:         $disabled = ' disabled="disabled"';
 1359:     } else {
 1360:         $submit = '<input type="button" onclick="javascript:changePage(this.form,'."'process${item}'".');" value="'.$titles{'modi'}.'" />';
 1361:     }
 1362:     foreach my $option (@{$options}) {
 1363:         $crselements .= '<span class="LC_nobreak">'.
 1364:                         '<label><input type="radio" name="'.$item.'" value="'.$option.'"'.
 1365:                         $crschecked{$option}.$disabled.' />'.$optiontext->{$option}.'</label>'.
 1366:                         '</span><br />'."\n";
 1367:     }
 1368:     &print_header($r,$type);
 1369:     my $hidden_elements = &hidden_form_elements();
 1370:     my $helpitem = &Apache::loncommon::help_open_topic($helpfile);
 1371:     my $showtype = &mt($type);
 1372:     $r->print(<<ENDDOCUMENT);
 1373: <h3>$helpitem $title</h3>
 1374: <h4><span class="LC_nobreak">$showtype: $cdesc</span></h4>
 1375: <form action="/adm/modifycourse" method="post" name="set$item">
 1376: <p><span class="LC_nobreak">$titles{'curd'}: <span style="font-style:italic">$domdefdisplay</span></span></p>
 1377: <p><span class="LC_nobreak">
 1378: <label><input type="radio" name="${item}set" value="dom" onclick="toggleOptions(this.form,'set$item');"$checkeddom$disabled />$titles{'used'}</label></span><br />
 1379: <span class="LC_nobreak">
 1380: <label><input type="radio" name="${item}set" value="course" onclick="toggleOptions(this.form,'set$item');"$checkedcrs$disabled />$titles{'cour'}</label></span></p>
 1381: <fieldset id="crs$item" style="$divsty">
 1382: <legend>$titles{'valu'}</legend>
 1383: $crselements
 1384: </fieldset><p>
 1385: $submit
 1386: $hidden_elements
 1387: </p>
 1388: </form>
 1389: ENDDOCUMENT
 1390:     my @actions =
 1391:         ('<a href="javascript:changePage(document.set'.$item.','."'menu'".')">'.
 1392:          $titles{'back'}.'</a>');
 1393:     $r->print('<br />'.&Apache::lonhtmlcommon::actionbox(\@actions));
 1394:     return;
 1395: }
 1396: 
 1397: sub default_overrides_titles {
 1398:     my ($type) = @_;
 1399:     my %titles = &Apache::lonlocal::texthash(
 1400:                 'requ' => 'Requirement for re-authentication for student LTI-limited launch of deep-linked item',
 1401:                 'link' => 'Link protection can be set to accept username for an enrolled student (if sent by Consumer)',
 1402:                 'logi' => 'Login needed, regardless of user information sent by LTI Consumer in (signed) parameters',
 1403:                 'extt' => 'External Tool permissions',
 1404:                 'none' => 'Use of external tools not permitted',
 1405:                 'crs' => 'Only external tools defined in course may be used',
 1406:                 'dom' => 'Only external tools defined in domain may be used',
 1407:                 'both' => 'External tools defined/configured in either domain or course may be used',
 1408:                 'stan' => "'In-course' authoring of standard LON-CAPA problems",
 1409:                 'on'   => 'In-course authoring available',
 1410:                 'off'  => 'In-course authoring unavailable',
 1411:                 'used' => 'Use domain default',
 1412:                 'cour' => 'Use course-specific setting',
 1413:                 'curd' => 'Current domain default is',
 1414:                 'valu' => 'Value for this course',
 1415:                 'modi' => 'Save',
 1416:                 'back' => 'Pick another action',
 1417:     );
 1418:     if ($type eq 'Community') {
 1419:         $titles{'crs'} = &mt('Only external tools defined in community may be used');
 1420:         $titles{'both'} = &mt('External tools defined/configured in either domain or community may be used');
 1421:         $titles{'cour'} = &mt('Use community-specific setting');
 1422:         $titles{'valu'} = &mt('Value for this community');
 1423:     }
 1424:     return %titles;
 1425: }
 1426: 
 1427: sub default_overrides_common {
 1428:     my ($item,$cdom,$cnum,$type,$titles) = @_;
 1429:     my ($title,$domdef,$domdefdom,$domdefdisplay,%settings,%optiontext,@options);
 1430:     if ($item eq 'ltiauth') {
 1431:         %settings = &Apache::lonnet::get('environment',['internal.'.$item],$cdom,$cnum);
 1432:         $title = $titles->{'requ'};
 1433:         $domdef = 0;
 1434:         @options = ('0','1');
 1435:         %optiontext = ( 
 1436:                         0 => $titles->{'logi'},
 1437:                         1 => $titles->{'link'},
 1438:                       );
 1439:     } else {
 1440:         %settings =
 1441:             &Apache::lonnet::get('environment',['internal.'.$item,'internal.coursecode',
 1442:                                                 'internal.textbook'],$cdom,$cnum);
 1443:         if ($item eq 'exttool') {
 1444:             $title = $titles->{'extt'};
 1445:             $domdefdom = 1;
 1446:             $domdef = 0;
 1447:             @options = ('both','dom','crs','none');
 1448:             map { $optiontext{$_} = $titles->{$_}; } @options;
 1449:         } elsif ($item eq 'crsauthor') {
 1450:             $title = $titles->{'stan'};
 1451:             $domdef = 1;
 1452:             @options = ('1','0');
 1453:             %optiontext = ( 
 1454:                             1 => $titles->{'on'},
 1455:                             0 => $titles->{'off'},
 1456:                           );
 1457:         }
 1458:     }
 1459:     my %domconfig =
 1460:         &Apache::lonnet::get_dom('configuration',['coursedefaults'],$cdom);
 1461:     if (ref($domconfig{'coursedefaults'}) eq 'HASH') {
 1462:         if ($item eq 'ltiauth') {
 1463:             $domdef = $domconfig{'coursedefaults'}{$item};
 1464:         } else {
 1465:             my $lctype = &get_lctype($type,\%settings);
 1466:             if (ref($domconfig{'coursedefaults'}{$item}) eq 'HASH') {
 1467:                 if (exists($domconfig{'coursedefaults'}{$item}{$lctype})) {
 1468:                     $domdef = $domconfig{'coursedefaults'}{$item}{$lctype};
 1469:                 }
 1470:             }
 1471:             if ($item eq 'exttool') {
 1472:                 if (ref($domconfig{'coursedefaults'}{'domexttool'}) eq 'HASH') {
 1473:                     if (exists($domconfig{'coursedefaults'}{'domexttool'}{$lctype})) {
 1474:                         $domdefdom = $domconfig{'coursedefaults'}{'domexttool'}{$lctype};
 1475:                     }
 1476:                 }
 1477:             }
 1478:         }
 1479:     }
 1480:     if ($item eq 'ltiauth') {
 1481:         if ($domdef) {
 1482:             $domdefdisplay = $titles->{'link'};
 1483:         } else {
 1484:             $domdefdisplay = $titles->{'logi'};
 1485:         }
 1486:     } elsif ($item eq 'exttool') {
 1487:         if ($domdef && $domdefdom) {
 1488:             $domdefdisplay = $titles->{'both'};
 1489:         } elsif ($domdef) {
 1490:             $domdefdisplay = $titles->{'crs'};
 1491:         } elsif ($domdefdom) {
 1492:             $domdefdisplay = $titles->{'dom'};
 1493:         } else {
 1494:             $domdefdisplay = $titles->{'none'};
 1495:         }
 1496:     } elsif ($item eq 'crsauthor') {
 1497:         if ($domdef) {
 1498:             $domdefdisplay = $titles->{'on'};
 1499:         } else {
 1500:             $domdefdisplay = $titles->{'off'};
 1501:         }
 1502:     }
 1503:     return ($title,$domdefdisplay,\%settings,\%optiontext,\@options);
 1504: }
 1505: 
 1506: sub modify_selfenrollconfig {
 1507:     my ($r,$type,$cdesc,$coursehash) = @_;
 1508:     return unless(ref($coursehash) eq 'HASH');
 1509:     my $cnum = $coursehash->{'num'};
 1510:     my $cdom = $coursehash->{'domain'};
 1511:     my %currsettings = &get_selfenroll_settings($coursehash);
 1512:     &print_header($r,$type);
 1513:     $r->print('<h3>'.&mt('Self-enrollment with a student role').'</h3>'.
 1514:               '<h4><span class="LC_nobreak">'.&mt($type).': '.$cdesc.'</span></h4>'."\n".
 1515:               '<form action="/adm/modifycourse" method="post" name="selfenrollchg">'."\n".
 1516:               &hidden_form_elements().'<br />');
 1517:     &Apache::loncreateuser::update_selfenroll_config($r,$env{'form.pickedcourse'},
 1518:                                                      $cdom,$cnum,'domain',$type,\%currsettings);
 1519:     $r->print('</form>');
 1520:     my @actions =
 1521:         ('<a href="javascript:changePage(document.selfenrollchg,'."'menu'".')">'.
 1522:          &mt('Pick another action').'</a>');
 1523:     $r->print('<br /><br />'.&Apache::lonhtmlcommon::actionbox(\@actions));
 1524:     return;
 1525: }
 1526: 
 1527: sub get_selfenroll_settings {
 1528:     my ($coursehash) = @_;
 1529:     my %currsettings;
 1530:     if (ref($coursehash) eq 'HASH') {
 1531:         %currsettings = (
 1532:             selfenroll_types              => $coursehash->{'internal.selfenroll_types'},
 1533:             selfenroll_registered         => $coursehash->{'internal.selfenroll_registered'},
 1534:             selfenroll_section            => $coursehash->{'internal.selfenroll_section'},
 1535:             selfenroll_notifylist         => $coursehash->{'internal.selfenroll_notifylist'},
 1536:             selfenroll_approval           => $coursehash->{'internal.selfenroll_approval'},
 1537:             selfenroll_limit              => $coursehash->{'internal.selfenroll_limit'},
 1538:             selfenroll_cap                => $coursehash->{'internal.selfenroll_cap'},
 1539:             selfenroll_start_date         => $coursehash->{'internal.selfenroll_start_date'},
 1540:             selfenroll_end_date           => $coursehash->{'internal.selfenroll_end_date'},
 1541:             selfenroll_start_access       => $coursehash->{'internal.selfenroll_start_access'},
 1542:             selfenroll_end_access         => $coursehash->{'internal.selfenroll_end_access'},
 1543:             default_enrollment_start_date => $coursehash->{'default_enrollment_start_date'},
 1544:             default_enrollment_end_date   => $coursehash->{'default_enrollment_end_date'},
 1545:             uniquecode                    => $coursehash->{'internal.uniquecode'},
 1546:         );
 1547:     }
 1548:     return %currsettings;
 1549: }
 1550: 
 1551: sub modifiable_only_title {
 1552:     my ($type) = @_;
 1553:     my $dctitle = &Apache::lonnet::plaintext('dc');
 1554:     if ($type eq 'Community') {
 1555:         return &mt('Community settings modifiable only by [_1]',$dctitle);
 1556:     } else {
 1557:         return &mt('Course settings modifiable only by [_1]',$dctitle);
 1558:     }
 1559: }
 1560: 
 1561: sub gather_authenitems {
 1562:     my ($cdom,$enrollvar,$readonly) = @_;
 1563:     my ($krbdef,$krbdefdom)=&Apache::loncommon::get_kerberos_defaults($cdom);
 1564:     my $curr_authtype = '';
 1565:     my $curr_authfield = '';
 1566:     if (ref($enrollvar) eq 'HASH') {
 1567:         if ($enrollvar->{'authtype'} =~ /^krb/) {
 1568:             $curr_authtype = 'krb';
 1569:         } elsif ($enrollvar->{'authtype'} eq 'internal' ) {
 1570:             $curr_authtype = 'int';
 1571:         } elsif ($enrollvar->{'authtype'} eq 'localauth' ) {
 1572:             $curr_authtype = 'loc';
 1573:         } elsif ($enrollvar->{'authtype'} eq 'lti' ) {
 1574:             $curr_authtype = 'lti';
 1575:         }
 1576:     }
 1577:     unless ($curr_authtype eq '') {
 1578:         $curr_authfield = $curr_authtype.'arg';
 1579:     }
 1580:     my $javascript_validations =
 1581:         &Apache::lonuserutils::javascript_validations('modifycourse',$krbdefdom,
 1582:                                                       $curr_authtype,$curr_authfield);
 1583:     my %param = ( formname => 'document.'.$env{'form.phase'},
 1584:            kerb_def_dom => $krbdefdom,
 1585:            kerb_def_auth => $krbdef,
 1586:            mode => 'modifycourse',
 1587:            curr_authtype => $curr_authtype,
 1588:            curr_autharg => $enrollvar->{'autharg'},
 1589:            readonly => $readonly,
 1590:         );
 1591:     my (%authform,$authenitems);
 1592:     $authform{'krb'} = &Apache::loncommon::authform_kerberos(%param);
 1593:     $authform{'int'} = &Apache::loncommon::authform_internal(%param);
 1594:     $authform{'loc'} = &Apache::loncommon::authform_local(%param);
 1595:     $authform{'lti'} = &Apache::loncommon::authform_lti(%param);
 1596:     foreach my $item ('krb','int','loc','lti') {
 1597:         if ($authform{$item} ne '') {
 1598:             $authenitems .= $authform{$item}.'<br />';
 1599:         }
 1600:     }
 1601:     return($javascript_validations,$authenitems);
 1602: }
 1603: 
 1604: sub modify_course {
 1605:     my ($r,$cdom,$cnum,$cdesc,$domdesc,$type) = @_;
 1606:     my %longtype = &course_settings_descrip($type);
 1607:     my @items = ('internal.courseowner','description','internal.co-owners',
 1608:                  'internal.pendingco-owners','internal.selfenrollmgrdc',
 1609:                  'internal.selfenrollmgrcc','internal.mysqltables');
 1610:     my ($selfenrollrows,$selfenrolltitles) = &Apache::lonuserutils::get_selfenroll_titles();
 1611:     unless (($type eq 'Community') || ($type eq 'Placement')) {
 1612:         push(@items,('internal.coursecode','internal.authtype','internal.autharg',
 1613:                      'internal.sectionnums','internal.crosslistings'));
 1614:         if (&showcredits($cdom)) {
 1615:             push(@items,'internal.defaultcredits');
 1616:         }
 1617:         my %passwdconf = &Apache::lonnet::get_passwdconf($cdom);
 1618:         if ($passwdconf{'crsownerchg'}) {
 1619:             push(@items,'internal.nopasswdchg');
 1620:         }
 1621:     }
 1622:     my %settings = &Apache::lonnet::get('environment',\@items,$cdom,$cnum);
 1623:     my $description = $settings{'description'};
 1624:     my ($ccrole,$response,$chgresponse,$nochgresponse,$reply,%currattr,%newattr,
 1625:         %cenv,%changed,@changes,@nochanges,@sections,@xlists,@warnings);
 1626:     my @modifiable_params = &get_dc_settable($type,$cdom);
 1627:     foreach my $param (@modifiable_params) {
 1628:         $currattr{$param} = $settings{'internal.'.$param};
 1629:     }
 1630:     if ($type eq 'Community') {
 1631:         %changed = ( owner  => 0 );
 1632:         $ccrole = 'co';
 1633:     } else {
 1634:         %changed = ( code  => 0,
 1635:                      owner => 0,
 1636:                      passwd => 0,
 1637:                    );
 1638:         $ccrole = 'cc';
 1639:         unless ($settings{'internal.sectionnums'} eq '') {
 1640:             if ($settings{'internal.sectionnums'} =~ m/,/) {
 1641:                 @sections = split/,/,$settings{'internal.sectionnums'};
 1642:             } else {
 1643:                 $sections[0] = $settings{'internal.sectionnums'};
 1644:             }
 1645:         }
 1646:         unless ($settings{'internal.crosslistings'} eq '') {
 1647:             if ($settings{'internal.crosslistings'} =~ m/,/) {
 1648:                 @xlists = split/,/,$settings{'internal.crosslistings'};
 1649:             } else {
 1650:                 $xlists[0] = $settings{'internal.crosslistings'};
 1651:             }
 1652:         }
 1653:         if ($env{'form.login'} eq 'krb') {
 1654:             $newattr{'authtype'} = $env{'form.login'};
 1655:             $newattr{'authtype'} .= $env{'form.krbver'};
 1656:             $newattr{'autharg'} = $env{'form.krbarg'};
 1657:         } elsif ($env{'form.login'} eq 'int') {
 1658:             $newattr{'authtype'} ='internal';
 1659:             if ((defined($env{'form.intarg'})) && ($env{'form.intarg'})) {
 1660:                 $newattr{'autharg'} = $env{'form.intarg'};
 1661:             }
 1662:         } elsif ($env{'form.login'} eq 'loc') {
 1663:             $newattr{'authtype'} = 'localauth';
 1664:             if ((defined($env{'form.locarg'})) && ($env{'form.locarg'})) {
 1665:                 $newattr{'autharg'} = $env{'form.locarg'};
 1666:             }
 1667:         } elsif ($env{'form.login'} eq 'lti') {
 1668:             $newattr{'authtype'} = 'lti';
 1669:         }
 1670:         if ( $newattr{'authtype'}=~ /^krb/) {
 1671:             if ($newattr{'autharg'}  eq '') {
 1672:                 push(@warnings,
 1673:                            &mt('As you did not include the default Kerberos domain'
 1674:                           .' to be used for authentication in this class, the'
 1675:                           .' institutional data used by the automated'
 1676:                           .' enrollment process must include the Kerberos'
 1677:                           .' domain for each new student.'));
 1678:             }
 1679:         }
 1680: 
 1681:         if ( exists($env{'form.coursecode'}) ) {
 1682:             $newattr{'coursecode'}=$env{'form.coursecode'};
 1683:             unless ( $newattr{'coursecode'} eq $currattr{'coursecode'} ) {
 1684:                 $changed{'code'} = 1;
 1685:             }
 1686:         }
 1687:         if ( exists($env{'form.mysqltables'}) ) {
 1688:             $newattr{'mysqltables'} = $env{'form.mysqltables'};
 1689:             $newattr{'mysqltables'} =~ s/\D+//g;
 1690:         }
 1691:         if ($type ne 'Placement') {
 1692:             if (&showcredits($cdom) && exists($env{'form.defaultcredits'})) {
 1693:                 $newattr{'defaultcredits'}=$env{'form.defaultcredits'};
 1694:                 $newattr{'defaultcredits'} =~ s/[^\d\.]//g;
 1695:             }
 1696:             if (grep(/^nopasswdchg$/,@modifiable_params)) {
 1697:                 if ($env{'form.nopasswdchg'}) {
 1698:                     $newattr{'nopasswdchg'} = 1;
 1699:                     unless ($currattr{'nopasswdchg'}) {
 1700:                         $changed{'passwd'} = 1;
 1701:                     }
 1702:                 } elsif ($currattr{'nopasswdchg'}) {
 1703:                     $changed{'passwd'} = 1;
 1704:                 }
 1705:             }
 1706:         }
 1707:     }
 1708: 
 1709:     my @newmgrdc = ();
 1710:     my @newmgrcc = ();
 1711:     my @currmgrdc = split(/,/,$currattr{'selfenrollmgrdc'});
 1712:     my @currmgrcc = split(/,/,$currattr{'selfenrollmgrcc'});
 1713: 
 1714:     foreach my $item (@{$selfenrollrows}) {
 1715:         if ($env{'form.selfenrollmgr_'.$item} eq '0') {
 1716:             push(@newmgrdc,$item);
 1717:         } elsif ($env{'form.selfenrollmgr_'.$item} eq '1') {
 1718:             push(@newmgrcc,$item);
 1719:         }
 1720:     }
 1721: 
 1722:     $newattr{'selfenrollmgrdc'}=join(',',@newmgrdc);
 1723:     $newattr{'selfenrollmgrcc'}=join(',',@newmgrcc);
 1724: 
 1725:     my $cctitle;
 1726:     if ($type eq 'Community') {
 1727:         $cctitle = &mt('Community personnel');
 1728:     } else {
 1729:         $cctitle = &mt('Course personnel');
 1730:     }
 1731:     my $dctitle = &Apache::lonnet::plaintext('dc');
 1732: 
 1733:     if ( exists($env{'form.courseowner'}) ) {
 1734:         $newattr{'courseowner'}=$env{'form.courseowner'};
 1735:         unless ( $newattr{'courseowner'} eq $currattr{'courseowner'} ) {
 1736:             $changed{'owner'} = 1;
 1737:         }
 1738:     }
 1739: 
 1740:     if ($changed{'owner'} || $changed{'code'} || $changed{'passwd'}) {
 1741:         my %crsinfo = &Apache::lonnet::courseiddump($cdom,'.',1,'.','.',$cnum,
 1742:                                                     undef,undef,'.');
 1743:         if (ref($crsinfo{$env{'form.pickedcourse'}}) eq 'HASH') {
 1744:             if ($changed{'code'}) {
 1745:                 $crsinfo{$env{'form.pickedcourse'}}{'inst_code'} = $env{'form.coursecode'};
 1746:             }
 1747:             if ($changed{'owner'}) {
 1748:                 $crsinfo{$env{'form.pickedcourse'}}{'owner'} = $env{'form.courseowner'};
 1749:             }
 1750:             if ($changed{'passwd'}) {
 1751:                 if ($env{'form.nopasswdchg'}) {
 1752:                     $crsinfo{$env{'form.pickedcourse'}}{'nopasswdchg'} = 1;
 1753:                 } else {
 1754:                     delete($crsinfo{'nopasswdchg'});
 1755:                 }
 1756:             }
 1757:             my $chome = &Apache::lonnet::homeserver($cnum,$cdom);
 1758:             my $putres = &Apache::lonnet::courseidput($cdom,\%crsinfo,$chome,'notime');
 1759:             if (($putres eq 'ok') && (($changed{'owner'} || $changed{'code'}))) {
 1760:                 &update_coowners($cdom,$cnum,$chome,\%settings,\%newattr);
 1761:                 if ($changed{'code'}) {
 1762:                     &Apache::lonnet::devalidate_cache_new('instcats',$cdom);
 1763:                     # Update cache of self-cataloging courses on institution's server(s).
 1764:                     if (&Apache::lonnet::shared_institution($cdom)) {
 1765:                         unless ($registered_cleanup) {
 1766:                             my $handlers = $r->get_handlers('PerlCleanupHandler');
 1767:                             $r->set_handlers('PerlCleanupHandler' => [\&devalidate_remote_instcats,@{$handlers}]);
 1768:                             $registered_cleanup=1;
 1769:                             $modified_dom = $cdom;
 1770:                         }
 1771:                     }
 1772:                 }
 1773:             }
 1774:         }
 1775:     }
 1776:     foreach my $param (@modifiable_params) {
 1777:         if ($currattr{$param} eq $newattr{$param}) {
 1778:             push(@nochanges,$param);
 1779:         } else {
 1780:             $cenv{'internal.'.$param} = $newattr{$param};
 1781:             push(@changes,$param);
 1782:         }
 1783:     }
 1784:     if (@changes > 0) {
 1785:         $chgresponse = &mt('The following settings have been changed:').'<br/><ul>';
 1786:     }
 1787:     if (@nochanges > 0) {
 1788:         $nochgresponse = &mt('The following settings remain unchanged:').'<br/><ul>';
 1789:     }
 1790:     if (@changes > 0) {
 1791:         my $putreply = &Apache::lonnet::put('environment',\%cenv,$cdom,$cnum);
 1792:         if ($putreply !~ /^ok$/) {
 1793:             $response = '<p class="LC_error">'.
 1794:                         &mt('There was a problem processing your requested changes.').'<br />';
 1795:             if ($type eq 'Community') {
 1796:                 $response .= &mt('Settings for this community have been left unchanged.');
 1797:             } else {
 1798:                 $response .= &mt('Settings for this course have been left unchanged.');
 1799:             }
 1800:             $response .= '<br/>'.&mt('Error: ').$putreply.'</p>';
 1801:         } else {
 1802:             if ($env{'course.'.$cdom.'_'.$cnum.'.description'} ne '') {
 1803:                 my %newenv;
 1804:                 map { $newenv{'course.'.$cdom.'_'.$cnum.'.internal.'.$_} = $newattr{$_}; } @changes;
 1805:                 &Apache::lonnet::appenv(\%newenv);
 1806:             }
 1807:             foreach my $attr (@modifiable_params) {
 1808:                 if (grep/^\Q$attr\E$/,@changes) {
 1809:                     my $shown = $newattr{$attr};
 1810:                     if ($attr eq 'selfenrollmgrdc') {
 1811:                         $shown = &selfenroll_config_status(\@newmgrdc,$selfenrolltitles);
 1812:                     } elsif ($attr eq 'selfenrollmgrcc') {
 1813:                         $shown = &selfenroll_config_status(\@newmgrcc,$selfenrolltitles);
 1814:                     } elsif (($attr eq 'defaultcredits') && ($shown eq '')) {
 1815:                         $shown = &mt('None');
 1816:                     } elsif (($attr eq 'mysqltables') && ($shown eq '')) {
 1817:                         $shown = &mt('domain default');
 1818:                     } elsif ($attr eq 'nopasswdchg') {
 1819:                         if ($shown) {
 1820:                             $shown = &mt('Yes');
 1821:                         } else {
 1822:                             $shown = &mt('No');
 1823:                         }
 1824:                     }
 1825:                     $chgresponse .= '<li>'.&mt('[_1] now set to: [_2]',$longtype{$attr},$shown).'</li>';
 1826:                 } else {
 1827:                     my $shown = $currattr{$attr};
 1828:                     if ($attr eq 'selfenrollmgrdc') {
 1829:                         $shown = &selfenroll_config_status(\@currmgrdc,$selfenrolltitles);
 1830:                     } elsif ($attr eq 'selfenrollmgrcc') {
 1831:                         $shown = &selfenroll_config_status(\@currmgrcc,$selfenrolltitles);
 1832:                     } elsif (($attr eq 'defaultcredits') && ($shown eq '')) {
 1833:                         $shown = &mt('None');
 1834:                     } elsif (($attr eq 'mysqltables') && ($shown eq '')) {
 1835:                         $shown = &mt('domain default');
 1836:                     } elsif ($attr eq 'nopasswdchg') {
 1837:                         if ($shown) {
 1838:                             $shown = &mt('Yes');
 1839:                         } else {
 1840:                             $shown = &mt('No');
 1841:                         }
 1842:                     }
 1843:                     $nochgresponse .= '<li>'.&mt('[_1] still set to: [_2]',$longtype{$attr},$shown).'</li>';
 1844:                 }
 1845:             }
 1846:             if (($type ne 'Community') && ($type ne 'Placement') && ($changed{'code'} || $changed{'owner'})) {
 1847:                 if ( $newattr{'courseowner'} eq '') {
 1848: 	            push(@warnings,&mt('There is no owner associated with this LON-CAPA course.').
 1849:                                    '<br />'.&mt('If automated enrollment at your institution requires validation of course owners, automated enrollment will fail.'));
 1850:                 } else {
 1851:                     my %crsenv = &Apache::lonnet::get('environment',['internal.co-owners'],$cdom,$cnum);
 1852:                     my $coowners = $crsenv{'internal.co-owners'};
 1853: 	            if (@sections > 0) {
 1854:                         if ($changed{'code'}) {
 1855: 	                    foreach my $sec (@sections) {
 1856: 		                if ($sec =~ m/^(.+):/) {
 1857:                                     my $instsec = $1;
 1858: 		                    my $inst_course_id = $newattr{'coursecode'}.$1;
 1859:                                     my $course_check = &Apache::lonnet::auto_validate_courseID($cnum,$cdom,$inst_course_id);
 1860: 			            if ($course_check eq 'ok') {
 1861:                                         my $outcome = &Apache::lonnet::auto_new_course($cnum,$cdom,$inst_course_id,$newattr{'courseowner'},$coowners);
 1862: 			                unless ($outcome eq 'ok') {
 1863: 				            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/>');
 1864: 			                }
 1865: 			            } else {
 1866:                                         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));
 1867: 			            }
 1868: 		                } else {
 1869: 			            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));
 1870: 		                }
 1871: 		            }
 1872: 	                } elsif ($changed{'owner'}) {
 1873:                             foreach my $sec (@sections) {
 1874:                                 if ($sec =~ m/^(.+):/) {
 1875:                                     my $instsec = $1;
 1876:                                     my $inst_course_id = $newattr{'coursecode'}.$instsec;
 1877:                                     my $outcome = &Apache::lonnet::auto_new_course($cnum,$cdom,$inst_course_id,$newattr{'courseowner'},$coowners);
 1878:                                     unless ($outcome eq 'ok') {
 1879:                                         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));
 1880:                                     }
 1881:                                 } else {
 1882:                                     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));
 1883:                                 }
 1884:                             }
 1885:                         }
 1886: 	            } else {
 1887: 	                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'}));
 1888: 	            }
 1889: 	            if ( (@xlists > 0) && ($changed{'owner'}) ) {
 1890: 	                foreach my $xlist (@xlists) {
 1891: 		            if ($xlist =~ m/^(.+):/) {
 1892:                                 my $instxlist = $1;
 1893:                                 my $outcome = &Apache::lonnet::auto_new_course($cnum,$cdom,$instxlist,$newattr{'courseowner'},$coowners);
 1894: 		                unless ($outcome eq 'ok') {
 1895: 			            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));
 1896: 		                }
 1897: 		            }
 1898: 	                }
 1899: 	            }
 1900:                 }
 1901:             }
 1902:         }
 1903:     } else {
 1904:         foreach my $attr (@modifiable_params) {
 1905:             my $shown = $currattr{$attr};
 1906:             if ($attr eq 'selfenrollmgrdc') {
 1907:                 $shown = &selfenroll_config_status(\@currmgrdc,$selfenrolltitles);
 1908:             } elsif ($attr eq 'selfenrollmgrcc') {
 1909:                 $shown = &selfenroll_config_status(\@currmgrcc,$selfenrolltitles);
 1910:             } elsif (($attr eq 'defaultcredits') && ($shown eq '')) {
 1911:                 $shown = &mt('None');
 1912:             } elsif (($attr eq 'mysqltables') && ($shown eq '')) {
 1913:                 $shown = &mt('domain default');
 1914:             }
 1915:             $nochgresponse .= '<li>'.&mt('[_1] still set to: [_2]',$longtype{$attr},$shown).'</li>';
 1916:         }
 1917:     }
 1918: 
 1919:     if (@changes > 0) {
 1920:         $chgresponse .= "</ul><br/><br/>";
 1921:     }
 1922:     if (@nochanges > 0) {
 1923:         $nochgresponse .=  "</ul><br/><br/>";
 1924:     }
 1925:     my ($warning,$numwarnings);
 1926:     my $numwarnings = scalar(@warnings);
 1927:     if ($numwarnings) {
 1928:         $warning = &mt('The following [quant,_1,warning was,warnings were] generated when applying your changes to automated enrollment:',$numwarnings).'<p><ul>';
 1929:         foreach my $warn (@warnings) {
 1930:             $warning .= '<li><span class="LC_warning">'.$warn.'</span></li>';
 1931:         }
 1932:         $warning .= '</ul></p>';
 1933:     }
 1934:     if ($response) {
 1935:         $reply = $response;
 1936:     } else {
 1937:         $reply = $chgresponse.$nochgresponse.$warning;
 1938:     }
 1939:     &print_header($r,$type);
 1940:     $reply = '<h3>'.&modifiable_only_title($type).'</h3>'."\n".
 1941:              '<h4><span class="LC_nobreak">'.&mt($type).': '.$cdesc.'</span></h4>'."\n".
 1942:              '<p>'.$reply.'</p>'."\n".
 1943:              '<form action="/adm/modifycourse" method="post" name="processparms">'.
 1944:              &hidden_form_elements();
 1945:     my @actions =
 1946:         ('<a href="javascript:changePage(document.processparms,'."'menu'".')">'.
 1947:                  &mt('Pick another action').'</a>');
 1948:     if ($numwarnings) {
 1949:         my $newrole = $ccrole.'./'.$cdom.'/'.$cnum;
 1950:         my $escuri = &HTML::Entities::encode('/adm/roles?selectrole=1&'.$newrole.
 1951:                                              '=1&destinationurl=/adm/populate','&<>"');
 1952: 
 1953:         push(@actions, '<a href="'.$escuri.'">'.
 1954:                   &mt('Go to Automated Enrollment Manager for course').'</a>');
 1955:     }
 1956:     $reply .= '</form>'.
 1957:               '<br />'.&Apache::lonhtmlcommon::actionbox(\@actions);
 1958:     $r->print($reply);
 1959:     return;
 1960: }
 1961: 
 1962: sub selfenroll_config_status {
 1963:     my ($items,$selfenrolltitles) = @_;
 1964:     my $shown;
 1965:     if ((ref($items) eq 'ARRAY') && (ref($selfenrolltitles) eq 'HASH')) {
 1966:         if (@{$items} > 0) {
 1967:             $shown = '<ul>';
 1968:             foreach my $item (@{$items}) {
 1969:                 $shown .= '<li>'.$selfenrolltitles->{$item}.'</li>';
 1970:             }
 1971:             $shown .= '</ul>';
 1972:         } else {
 1973:             $shown = &mt('None');
 1974:         }
 1975:     }
 1976:     return $shown;
 1977: }
 1978: 
 1979: sub update_coowners {
 1980:     my ($cdom,$cnum,$chome,$settings,$newattr) = @_;
 1981:     return unless ((ref($settings) eq 'HASH') && (ref($newattr) eq 'HASH'));
 1982:     my %designhash = &Apache::loncommon::get_domainconf($cdom);
 1983:     my (%cchash,$autocoowners);
 1984:     if ($designhash{$cdom.'.autoassign.co-owners'}) {
 1985:         $autocoowners = 1;
 1986:         %cchash = &Apache::lonnet::get_my_roles($cnum,$cdom,undef,undef,['cc']);
 1987:     }
 1988:     if ($settings->{'internal.courseowner'} ne $newattr->{'courseowner'}) {
 1989:         my $oldowner_to_coowner;
 1990:         my @types = ('co-owners');
 1991:         if (($newattr->{'coursecode'}) && ($autocoowners)) {
 1992:             my $oldowner = $settings->{'internal.courseowner'};
 1993:             if ($cchash{$oldowner.':cc'}) {
 1994:                 my ($result,$desc) = &Apache::lonnet::auto_validate_instcode($cnum,$cdom,$newattr->{'coursecode'},$oldowner);
 1995:                 if ($result eq 'valid') {
 1996:                     if ($settings->{'internal.co-owner'}) {
 1997:                         my @current = split(',',$settings->{'internal.co-owners'});
 1998:                         unless (grep(/^\Q$oldowner\E$/,@current)) {
 1999:                             $oldowner_to_coowner = 1;
 2000:                         }
 2001:                     } else {
 2002:                         $oldowner_to_coowner = 1;
 2003:                     }
 2004:                 }
 2005:             }
 2006:         } else {
 2007:             push(@types,'pendingco-owners');
 2008:         }
 2009:         foreach my $type (@types) {
 2010:             if ($settings->{'internal.'.$type}) {
 2011:                 my @current = split(',',$settings->{'internal.'.$type});
 2012:                 my $newowner = $newattr->{'courseowner'};
 2013:                 my @newvalues = ();
 2014:                 if (($newowner ne '') && (grep(/^\Q$newowner\E$/,@current))) {
 2015:                     foreach my $person (@current) {
 2016:                         unless ($person eq $newowner) {
 2017:                             push(@newvalues,$person);
 2018:                         }
 2019:                     }
 2020:                 } else {
 2021:                     @newvalues = @current;
 2022:                 }
 2023:                 if ($oldowner_to_coowner) {
 2024:                     push(@newvalues,$settings->{'internal.courseowner'});
 2025:                     @newvalues = sort(@newvalues);
 2026:                 }
 2027:                 my $newownstr = join(',',@newvalues);
 2028:                 if ($newownstr ne $settings->{'internal.'.$type}) {
 2029:                     if ($type eq 'co-owners') {
 2030:                         my $deleted = '';
 2031:                         unless (@newvalues) {
 2032:                             $deleted = 1;
 2033:                         }
 2034:                         &Apache::lonnet::store_coowners($cdom,$cnum,$chome,
 2035:                                                         $deleted,@newvalues);
 2036:                     } else {
 2037:                         my $pendingcoowners;
 2038:                         my $cid = $cdom.'_'.$cnum;
 2039:                         if (@newvalues) {
 2040:                             $pendingcoowners = join(',',@newvalues);
 2041:                             my %pendinghash = (
 2042:                                 'internal.pendingco-owners' => $pendingcoowners,
 2043:                             );
 2044:                             my $putresult = &Apache::lonnet::put('environment',\%pendinghash,$cdom,$cnum);
 2045:                             if ($putresult eq 'ok') {
 2046:                                 if ($env{'course.'.$cid.'.num'} eq $cnum) {
 2047:                                     &Apache::lonnet::appenv({'course.'.$cid.'.internal.pendingco-owners' => $pendingcoowners});
 2048:                                 }
 2049:                             }
 2050:                         } else {
 2051:                             my $delresult = &Apache::lonnet::del('environment',['internal.pendingco-owners'],$cdom,$cnum);
 2052:                             if ($delresult eq 'ok') {
 2053:                                 if ($env{'course.'.$cid.'.internal.pendingco-owners'}) {
 2054:                                     &Apache::lonnet::delenv('course.'.$cid.'.internal.pendingco-owners');
 2055:                                 }
 2056:                             }
 2057:                         }
 2058:                     }
 2059:                 } elsif ($oldowner_to_coowner) {
 2060:                     &Apache::lonnet::store_coowners($cdom,$cnum,$chome,'',
 2061:                                          $settings->{'internal.courseowner'});
 2062: 
 2063:                 }
 2064:             } elsif ($oldowner_to_coowner) {
 2065:                 &Apache::lonnet::store_coowners($cdom,$cnum,$chome,'',
 2066:                                      $settings->{'internal.courseowner'});
 2067:             }
 2068:         }
 2069:     }
 2070:     if ($settings->{'internal.coursecode'} ne $newattr->{'coursecode'}) {
 2071:         if ($newattr->{'coursecode'} ne '') {
 2072:             my %designhash = &Apache::loncommon::get_domainconf($cdom);
 2073:             if ($designhash{$cdom.'.autoassign.co-owners'}) {
 2074:                 my @newcoowners = ();
 2075:                 if ($settings->{'internal.co-owners'}) {
 2076:                     my @currcoown = split(',',$settings->{'internal.co-owners'});
 2077:                     my ($updatecoowners,$delcoowners);
 2078:                     foreach my $person (@currcoown) {
 2079:                         my ($result,$desc) = &Apache::lonnet::auto_validate_instcode($cnum,$cdom,$newattr->{'coursecode'},$person);
 2080:                         if ($result eq 'valid') {
 2081:                             push(@newcoowners,$person);
 2082:                         }
 2083:                     }
 2084:                     foreach my $item (sort(keys(%cchash))) {
 2085:                         my ($uname,$udom,$urole) = split(':',$item);
 2086:                         next if ($uname.':'.$udom eq $newattr->{'courseowner'});
 2087:                         unless (grep(/^\Q$uname\E:\Q$udom\E$/,@newcoowners)) {
 2088:                             my ($result,$desc) = &Apache::lonnet::auto_validate_instcode($cnum,$cdom,$newattr->{'coursecode'},$uname.':'.$udom);
 2089:                             if ($result eq 'valid') {
 2090:                                 push(@newcoowners,$uname.':'.$udom);
 2091:                             }
 2092:                         }
 2093:                     }
 2094:                     if (@newcoowners) {
 2095:                         my $coowners = join(',',sort(@newcoowners));
 2096:                         unless ($coowners eq $settings->{'internal.co-owners'}) {
 2097:                             $updatecoowners = 1;
 2098:                         }
 2099:                     } else {
 2100:                         $delcoowners = 1;
 2101:                     }
 2102:                     if ($updatecoowners || $delcoowners) {
 2103:                         &Apache::lonnet::store_coowners($cdom,$cnum,$chome,
 2104:                                                         $delcoowners,@newcoowners);
 2105:                     }
 2106:                 } else {
 2107:                     foreach my $item (sort(keys(%cchash))) {
 2108:                         my ($uname,$udom,$urole) = split(':',$item);
 2109:                         push(@newcoowners,$uname.':'.$udom);
 2110:                     }
 2111:                     if (@newcoowners) {
 2112:                         &Apache::lonnet::store_coowners($cdom,$cnum,$chome,'',
 2113:                                                         @newcoowners);
 2114:                     }
 2115:                 }
 2116:             }
 2117:         }
 2118:     }
 2119:     return;
 2120: }
 2121: 
 2122: sub modify_quota {
 2123:     my ($r,$cdom,$cnum,$cdesc,$domdesc,$type) = @_;
 2124:     &print_header($r,$type);
 2125:     my $lctype = lc($type);
 2126:     $r->print('<h3>'.&mt("Disk space quotas for $lctype")."</h3>\n".
 2127:               '<h4><span class="LC_nobreak">'.&mt($type).' :'.$cdesc.'</span></h4>'."\n".
 2128:               '<form action="/adm/modifycourse" method="post" name="processquota">'."\n");
 2129:     my %oldsettings = &Apache::lonnet::get('environment',['internal.coursequota','internal.uploadquota'],$cdom,$cnum);
 2130:     my %staticdefaults = (
 2131:                            coursequota   => 20,
 2132:                            uploadquota   => 500,
 2133:                          );
 2134:     my %default;
 2135:     $default{'coursequota'} = $staticdefaults{'coursequota'};
 2136:     my %domdefs = &Apache::lonnet::get_domain_defaults($cdom);
 2137:     $default{'uploadquota'} = $domdefs{'uploadquota'};
 2138:     if ($default{'uploadquota'} eq '') {
 2139:         $default{'uploadquota'} = $staticdefaults{'uploadquota'};
 2140:     }
 2141:     my (%cenv,%showresult);
 2142:     foreach my $item ('coursequota','uploadquota') {
 2143:         if ($env{'form.'.$item} ne '') {
 2144:             my $newquota = $env{'form.'.$item};
 2145:             if ($newquota =~ /^\s*(\d+\.?\d*|\.\d+)\s*$/) {
 2146:                 $newquota = $1;
 2147:                 if ($oldsettings{'internal.'.$item} == $newquota) {
 2148:                     if ($item eq 'coursequota') {
 2149:                         $r->print(&mt('The disk space allocated for group portfolio files remains unchanged as [_1] MB.',$newquota).'<br />');
 2150:                     } else {
 2151:                         $r->print(&mt('The disk space allocated for files uploaded via the Content Editor remains unchanged as [_1] MB.',$newquota).'<br />');
 2152:                     }
 2153:                 } else {
 2154:                     $cenv{'internal.'.$item} = $newquota;
 2155:                     $showresult{$item} = 1;
 2156:                 }
 2157:             } else {
 2158:                 if ($item eq 'coursequota') {
 2159:                     $r->print(&mt('The proposed group portfolio quota contained invalid characters, so the quota is unchanged.').'<br />');
 2160:                 } else {
 2161:                     $r->print(&mt('The proposed quota for content uploaded via the Content Editor contained invalid characters, so the quota is unchanged.').'<br />');
 2162: 
 2163:                 }
 2164:             }
 2165:         }
 2166:     }
 2167:     if (keys(%cenv)) {
 2168:         my $putreply = &Apache::lonnet::put('environment',\%cenv,$cdom,
 2169:                                             $cnum);
 2170:         foreach my $key (sort(keys(%showresult))) {
 2171:             if (($oldsettings{'internal.'.$key} eq '') &&
 2172:                 ($env{'form.'.$key} == $default{$key})) {
 2173:                 if ($key eq 'uploadquota') {
 2174:                     if ($type eq 'Community') {
 2175:                         $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.',
 2176:                                       $default{$key}).'<br />');
 2177:                     } else {
 2178:                         $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.',
 2179:                                       $default{$key}).'<br />');
 2180:                     }
 2181:                 } else {
 2182:                     if ($type eq 'Community') {
 2183:                         $r->print(&mt('The disk space allocated for group portfolio files in this community is the default quota for this domain: [_1] MB.',
 2184:                                       $default{$key}).'<br />');
 2185:                     } else {
 2186:                         $r->print(&mt('The disk space allocated for group portfolio files in this course is the default quota for this domain: [_1] MB.',
 2187:                                       $default{$key}).'<br />');
 2188:                     }
 2189:                 }
 2190:                 delete($showresult{$key});
 2191:             }
 2192:         }
 2193:         if ($putreply eq 'ok') {
 2194:             my %updatedsettings = &Apache::lonnet::get('environment',['internal.coursequota','internal.uploadquota'],$cdom,$cnum);
 2195:             if ($showresult{'coursequota'}) {
 2196:                 $r->print(&mt('The disk space allocated for group portfolio files is now: [_1] MB.',
 2197:                               '<b>'.$updatedsettings{'internal.coursequota'}.'</b>').'<br />');
 2198:                 my $usage = &Apache::longroup::sum_quotas($cdom.'_'.$cnum);
 2199:                 if ($usage >= $updatedsettings{'internal.coursequota'}) {
 2200:                     my $newoverquota;
 2201:                     if ($usage < $oldsettings{'internal.coursequota'}) {
 2202:                         $newoverquota = 'now';
 2203:                     }
 2204:                     $r->print('<p>');
 2205:                     if ($type eq 'Community') {
 2206:                         $r->print(&mt("Disk usage $newoverquota exceeds the quota for this community.").' '.
 2207:                                   &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.'));
 2208:                     } else {
 2209:                         $r->print(&mt("Disk usage $newoverquota exceeds the quota for this course.").' '.
 2210:                                   &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.'));
 2211:                     }
 2212:                     $r->print('</p>');
 2213:                 }
 2214:             }
 2215:             if ($showresult{'uploadquota'}) {
 2216:                 $r->print(&mt('The disk space allocated for content uploaded directly via the Content Editor is now: [_1] MB.',
 2217:                               '<b>'.$updatedsettings{'internal.uploadquota'}.'</b>').'<br />');
 2218:             }
 2219:         } else {
 2220:             $r->print(&mt('An error occurred storing the quota(s) for group portfolio files and/or uploaded content: ').
 2221:                       $putreply);
 2222:         }
 2223:     }
 2224:     $r->print(&hidden_form_elements().'</form>');
 2225:     my @actions =
 2226:         ('<a href="javascript:changePage(document.processparms,'."'menu'".')">'.
 2227:          &mt('Pick another action').'</a>');
 2228:     $r->print('<br />'.&Apache::lonhtmlcommon::actionbox(\@actions));
 2229:     return;
 2230: }
 2231: 
 2232: sub modify_anonsurvey_threshold {
 2233:     my ($r,$cdom,$cnum,$cdesc,$domdesc,$type) = @_;
 2234:     &print_header($r,$type);
 2235:     $r->print('<h3>'.&mt('Responder threshold required for display of anonymous survey submissions').'</h3>'."\n".
 2236:               '<h4><span class="LC_nobreak">'.&mt($type).': '.$cdesc.'</span></h4>'."\n".
 2237:               '<form action="/adm/modifycourse" method="post" name="processthreshold">'."\n");
 2238:     my %oldsettings = &Apache::lonnet::get('environment',['internal.anonsurvey_threshold'],$cdom,$cnum);
 2239:     my %domconfig =
 2240:         &Apache::lonnet::get_dom('configuration',['coursedefaults'],$cdom);
 2241:     my $defaultthreshold;
 2242:     if (ref($domconfig{'coursedefaults'}) eq 'HASH') {
 2243:         $defaultthreshold = $domconfig{'coursedefaults'}{'anonsurvey_threshold'};
 2244:         if ($defaultthreshold eq '') {
 2245:             $defaultthreshold = 10;
 2246:         }
 2247:     } else {
 2248:         $defaultthreshold = 10;
 2249:     }
 2250:     if ($env{'form.threshold'} eq '') {
 2251:         $r->print(&mt('The proposed responder threshold for display of anonymous survey submissions was blank, so the threshold is unchanged.'));
 2252:     } else {
 2253:         my $newthreshold = $env{'form.threshold'};
 2254:         if ($newthreshold =~ /^\s*(\d+)\s*$/) {
 2255:             $newthreshold = $1;
 2256:             if ($oldsettings{'internal.anonsurvey_threshold'} eq $env{'form.threshold'}) {
 2257:                 $r->print(&mt('Responder threshold for anonymous survey submissions display remains unchanged: [_1].',$env{'form.threshold'}));
 2258:             } else {
 2259:                 my %cenv = (
 2260:                            'internal.anonsurvey_threshold' => $env{'form.threshold'},
 2261:                            );
 2262:                 my $putreply = &Apache::lonnet::put('environment',\%cenv,$cdom,
 2263:                                                     $cnum);
 2264:                 if ($putreply eq 'ok') {
 2265:                     if ($env{'course.'.$cdom.'_'.$cnum.'.description'} ne '') {
 2266:                         &Apache::lonnet::appenv(
 2267:                            {'course.'.$cdom.'_'.$cnum.'.internal.anonsurvey_threshold' => $env{'form.threshold'}});
 2268:                     }
 2269:                 }
 2270:                 if (($oldsettings{'internal.anonsurvey_threshold'} eq '') &&
 2271:                     ($env{'form.threshold'} == $defaultthreshold)) {
 2272:                     $r->print(&mt('The responder threshold for display of anonymous survey submissions is the default for this domain: [_1].',$defaultthreshold));
 2273:                 } else {
 2274:                     if ($putreply eq 'ok') {
 2275:                         my %updatedsettings = &Apache::lonnet::get('environment',['internal.anonsurvey_threshold'],$cdom,$cnum);
 2276:                         $r->print(&mt('The responder threshold for display of anonymous survey submissions is now: [_1].','<b>'.$updatedsettings{'internal.anonsurvey_threshold'}.'</b>'));
 2277:                     } else {
 2278:                         $r->print(&mt('An error occurred storing the responder threshold for anonymous submissions display: ').
 2279:                                   $putreply);
 2280:                     }
 2281:                 }
 2282:             }
 2283:         } else {
 2284:             $r->print(&mt('The proposed responder threshold for display of anonymous submissions contained invalid characters, so the threshold is unchanged.'));
 2285:         }
 2286:     }
 2287:     $r->print(&hidden_form_elements().'</form>');
 2288:     my @actions =
 2289:         ('<a href="javascript:changePage(document.processthreshold,'."'menu'".')">'.
 2290:          &mt('Pick another action').'</a>');
 2291:     $r->print('<br />'.&Apache::lonhtmlcommon::actionbox(\@actions));
 2292:     return;
 2293: }
 2294: 
 2295: sub modify_postsubmit_config {
 2296:     my ($r,$cdom,$cnum,$cdesc,$domdesc,$type) = @_;
 2297:     &print_header($r,$type);
 2298:     my %lt = &Apache::lonlocal::texthash(
 2299:                 subb => 'Submit button behavior after student makes a submission:',
 2300:                 unch => 'Post submission behavior of the Submit button is unchanged.',
 2301:                 erro => 'An error occurred when saving your proposed changes.',
 2302:                 inva => 'An invalid response was recorded.',
 2303:                 back => 'Pick another action',
 2304:              );
 2305:     $r->print('<h3>'.$lt{'subb'}.'</h3>'."\n".
 2306:               '<h4><span class="LC_nobreak">'.&mt($type).': '.$cdesc.'</span></h4>'."\n".
 2307:               '<form action="/adm/modifycourse" method="post" name="processpostsubmit"><p>'."\n");
 2308:     my %oldsettings =
 2309:         &Apache::lonnet::get('environment',['internal.postsubmit','internal.postsubtimeout','internal.coursecode','internal.textbook'],$cdom,$cnum);
 2310:     my $postsubmit = $env{'form.postsubmit'};
 2311:     if ($postsubmit eq '1') {
 2312:         my $postsubtimeout = $env{'form.postsubtimeout'};
 2313:         $postsubtimeout =~ s/[^\d\.]+//g;
 2314:         if (($oldsettings{'internal.postsubmit'} eq $postsubmit) && ($oldsettings{'internal.postsubtimeout'} eq $postsubtimeout)) {
 2315:             $r->print($lt{'unch'});
 2316:         } else {
 2317:             my %cenv = (
 2318:                          'internal.postsubmit' => $postsubmit,
 2319:                        );
 2320:             if ($postsubtimeout eq '') {
 2321:                 my $putreply = &Apache::lonnet::put('environment',\%cenv,$cdom,$cnum);
 2322:                 if ($putreply eq 'ok') {
 2323:                     my $defaulttimeout = &domain_postsubtimeout($cdom,$type,\%oldsettings);
 2324:                     $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));
 2325:                     if (exists($oldsettings{'internal.postsubtimeout'})) {
 2326:                         &Apache::lonnet::del('environment',['internal.postsubtimeout'],$cdom,$cnum);
 2327:                     }
 2328:                 } else {
 2329:                     $r->print($lt{'erro'});
 2330:                 }
 2331:             } else {
 2332:                 $cenv{'internal.postsubtimeout'} = $postsubtimeout;
 2333:                 my $putreply = &Apache::lonnet::put('environment',\%cenv,$cdom,$cnum);
 2334:                 if ($putreply eq 'ok') {
 2335:                     if ($postsubtimeout eq '0') {
 2336:                         $r->print(&mt('Submit button will be disabled after student submission until page is reloaded.'));
 2337:                     } else {
 2338:                         $r->print(&mt('Submit button will be disabled after student submission for [quant,_1,second].',$postsubtimeout));
 2339:                     }
 2340:                 } else {
 2341:                     $r->print($lt{'erro'});
 2342:                 }
 2343:             }
 2344:         }
 2345:     } elsif ($postsubmit eq '0') {
 2346:         if ($oldsettings{'internal.postsubmit'} eq $postsubmit) {
 2347:             $r->print($lt{'unch'});
 2348:         } else {
 2349:             if (exists($oldsettings{'internal.postsubtimeout'})) {
 2350:                 &Apache::lonnet::del('environment',['internal.postsubtimeout'],$cdom,$cnum);
 2351:             }
 2352:             my %cenv = (
 2353:                          'internal.postsubmit' => $postsubmit,
 2354:                        );
 2355:             my $putreply = &Apache::lonnet::put('environment',\%cenv,$cdom,$cnum);
 2356:             if ($putreply eq 'ok') {
 2357:                 $r->print(&mt('Submit button will not be disabled after student submission'));
 2358:             } else {
 2359:                 $r->print($lt{'erro'});
 2360:             }
 2361:         }
 2362:     } else {
 2363:         $r->print($lt{'inva'}.' '.$lt{'unch'});
 2364:     }
 2365:     $r->print('</p>'.&hidden_form_elements().'</form>');
 2366:     my @actions =
 2367:         ('<a href="javascript:changePage(document.processpostsubmit,'."'menu'".')">'.
 2368:          $lt{'back'}.'</a>');
 2369:     $r->print('<br />'.&Apache::lonhtmlcommon::actionbox(\@actions));
 2370:     return;
 2371: }
 2372: 
 2373: sub modify_catsettings {
 2374:     my ($r,$cdom,$cnum,$cdesc,$domdesc,$type) = @_;
 2375:     &print_header($r,$type);
 2376:     my ($ccrole,%desc);
 2377:     if ($type eq 'Community') {
 2378:         $desc{'hidefromcat'} = &mt('Excluded from community catalog');
 2379:         $desc{'categories'} = &mt('Assigned categories for this community');
 2380:         $ccrole = 'co';
 2381:     } else {
 2382:         $desc{'hidefromcat'} = &mt('Excluded from course catalog');
 2383:         $desc{'categories'} = &mt('Assigned categories for this course');
 2384:         $ccrole = 'cc';
 2385:     }
 2386:     $r->print('<h3>'.&mt('Category settings').'</h3>'."\n".
 2387:               '<h4><span class="LC_nobreak">'.&mt($type).': '.$cdesc.'</span></h4>'."\n".
 2388:               '<form action="/adm/modifycourse" method="post" name="processcat"><br />'."\n");
 2389:     my %domconf = &Apache::lonnet::get_dom('configuration',['coursecategories'],$cdom);
 2390:     my @cat_params = &catalog_settable($domconf{'coursecategories'},$type);
 2391:     if (@cat_params > 0) {
 2392:         my (%cenv,@changes,@nochanges);
 2393:         my %currsettings =
 2394:             &Apache::lonnet::get('environment',['hidefromcat','categories'],$cdom,$cnum);
 2395:         my (@newcategories,%showitem);
 2396:         if (grep(/^togglecats$/,@cat_params)) {
 2397:             if ($currsettings{'hidefromcat'} ne $env{'form.hidefromcat'}) {
 2398:                 push(@changes,'hidefromcat');
 2399:                 $cenv{'hidefromcat'} = $env{'form.hidefromcat'};
 2400:             } else {
 2401:                 push(@nochanges,'hidefromcat');
 2402:             }
 2403:             if ($env{'form.hidefromcat'} eq 'yes') {
 2404:                 $showitem{'hidefromcat'} = '"'.&mt('Yes')."'";
 2405:             } else {
 2406:                 $showitem{'hidefromcat'} = '"'.&mt('No').'"';
 2407:             }
 2408:         }
 2409:         if (grep(/^categorize$/,@cat_params)) {
 2410:             my (@cats,@trails,%allitems,%idx,@jsarray);
 2411:             if (ref($domconf{'coursecategories'}) eq 'HASH') {
 2412:                 my $cathash = $domconf{'coursecategories'}{'cats'};
 2413:                 if (ref($cathash) eq 'HASH') {
 2414:                     &Apache::loncommon::extract_categories($cathash,\@cats,\@trails,
 2415:                                                            \%allitems,\%idx,\@jsarray);
 2416:                 }
 2417:             }
 2418:             @newcategories =  &Apache::loncommon::get_env_multiple('form.usecategory');
 2419:             if (@newcategories == 0) {
 2420:                 $showitem{'categories'} = '"'.&mt('None').'"';
 2421:             } else {
 2422:                 $showitem{'categories'} = '<ul>';
 2423:                 foreach my $item (@newcategories) {
 2424:                     $showitem{'categories'} .= '<li>'.$trails[$allitems{$item}].'</li>';
 2425:                 }
 2426:                 $showitem{'categories'} .= '</ul>';
 2427:             }
 2428:             my $catchg = 0;
 2429:             if ($currsettings{'categories'} ne '') {
 2430:                 my @currcategories = split('&',$currsettings{'categories'});
 2431:                 foreach my $cat (@currcategories) {
 2432:                     if (!grep(/^\Q$cat\E$/,@newcategories)) {
 2433:                         $catchg = 1;
 2434:                         last;
 2435:                     }
 2436:                 }
 2437:                 if (!$catchg) {
 2438:                     foreach my $cat (@newcategories) {
 2439:                         if (!grep(/^\Q$cat\E$/,@currcategories)) {
 2440:                             $catchg = 1;
 2441:                             last;
 2442:                         }
 2443:                     }
 2444:                 }
 2445:             } else {
 2446:                 if (@newcategories > 0) {
 2447:                     $catchg = 1;
 2448:                 }
 2449:             }
 2450:             if ($catchg) {
 2451:                 $cenv{'categories'} = join('&',@newcategories);
 2452:                 push(@changes,'categories');
 2453:             } else {
 2454:                 push(@nochanges,'categories');
 2455:             }
 2456:             if (@changes > 0) {
 2457:                 my $putreply = &Apache::lonnet::put('environment',\%cenv,$cdom,$cnum);
 2458:                 if ($putreply eq 'ok') {
 2459:                     if ($env{'course.'.$cdom.'_'.$cnum.'.description'} ne '') {
 2460:                         my %newenvhash;
 2461:                         foreach my $item (@changes) {
 2462:                             $newenvhash{'course.'.$cdom.'_'.$cnum.'.'.$item} = $cenv{$item};
 2463:                         }
 2464:                         &Apache::lonnet::appenv(\%newenvhash);
 2465:                     }
 2466:                     my %crsinfo = &Apache::lonnet::courseiddump($cdom,'.',1,'.','.',
 2467:                                                                 $cnum,undef,undef,'.');
 2468:                     if (ref($crsinfo{$env{'form.pickedcourse'}}) eq 'HASH') {
 2469:                         if (grep(/^hidefromcat$/,@changes)) {
 2470:                             $crsinfo{$env{'form.pickedcourse'}}{'hidefromcat'} = $env{'form.hidefromcat'};
 2471:                         }
 2472:                         if (grep(/^categories$/,@changes)) {
 2473:                             $crsinfo{$env{'form.pickedcourse'}}{'categories'} = $cenv{'categories'};
 2474:                         }
 2475:                         my $chome = &Apache::lonnet::homeserver($cnum,$cdom);
 2476:                         my $putres = &Apache::lonnet::courseidput($cdom,\%crsinfo,$chome,'notime');
 2477:                     }
 2478:                     $r->print(&mt('The following changes occurred:').'<ul>');
 2479:                     foreach my $item (@changes) {
 2480:                         $r->print('<li>'.&mt('[_1] now set to: [_2]',$desc{$item},$showitem{$item}).'</li>');
 2481:                     }
 2482:                     $r->print('</ul><br />');
 2483:                 }
 2484:             }
 2485:             if (@nochanges > 0) {
 2486:                 $r->print(&mt('The following were unchanged:').'<ul>');
 2487:                 foreach my $item (@nochanges) {
 2488:                     $r->print('<li>'.&mt('[_1] still set to: [_2]',$desc{$item},$showitem{$item}).'</li>');
 2489:                 }
 2490:                 $r->print('</ul>');
 2491:             }
 2492:         }
 2493:     } else {
 2494:         my $newrole = $ccrole.'./'.$cdom.'/'.$cnum;
 2495:         my $escuri = &HTML::Entities::encode('/adm/roles?selectrole=1&'.$newrole.
 2496:                                              '=1&destinationurl=/adm/courseprefs','&<>"');
 2497:         if ($type eq 'Community') {
 2498:             $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 />');
 2499:         } else {
 2500:             $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 />');
 2501:         }
 2502:     }
 2503:     $r->print('<br />'.&hidden_form_elements().'</form>');
 2504:     my @actions =
 2505:         ('<a href="javascript:changePage(document.processcat,'."'menu'".')">'.
 2506:          &mt('Pick another action').'</a>');
 2507:     $r->print('<br />'.&Apache::lonhtmlcommon::actionbox(\@actions));
 2508:     return;
 2509: }
 2510: 
 2511: sub modify_default_overrides {
 2512:     my ($r,$cdom,$cnum,$cdesc,$domdesc,$type,$item) = @_;
 2513:     my (%titles,$oldcrsval,$newcrsval,%resulttext,$itemvalue,$nochange,$change,$status,$error);
 2514:     %titles = &default_overrides_titles($type);
 2515:     my ($title,$domdefdisplay,$oldsettings,$optiontext,$options) =
 2516:         &default_overrides_common($item,$cdom,$cnum,$type,\%titles);
 2517:     $oldcrsval = $oldsettings->{'internal.'.$item};
 2518:     if ($item eq 'ltiauth') {
 2519:         %resulttext =
 2520:             &Apache::lonlocal::texthash(
 2521:                                          chg   => 'Re-authentication requirement for LTI launch of deep-linked changed',
 2522:                                          nochg => 'Re-authentication requirement for LTI launch of deep-linked item is unchanged',
 2523:                                        );
 2524:     } elsif ($item eq 'exttool') {
 2525:         %resulttext =
 2526:             &Apache::lonlocal::texthash(
 2527:                                          chg   => 'External Tool permissions changed',
 2528:                                          nochg => 'External Tool permissions unchanged',
 2529:                                        );
 2530:     } elsif ($item eq 'crsauthor') {
 2531:         %resulttext =
 2532:             &Apache::lonlocal::texthash(
 2533:                                          chg   => 'In-course authoring permissions changed',
 2534:                                          nochg => 'In-course authoring permissions unchanged',
 2535:                                        );
 2536:     }
 2537:     &print_header($r,$type);
 2538:     $r->print('<h3>'.$title.'</h3>'."\n".
 2539:               '<h4><span class="LC_nobreak">'.&mt($type).': '.$cdesc.'</span></h4>'."\n".
 2540:               '<form action="/adm/modifycourse" method="post" name="process'.$item.'">'."\n");
 2541:     if ($env{'form.'.$item.'set'} eq 'dom') {
 2542:         if ($oldcrsval eq '') {
 2543:             $nochange = 1;
 2544:         } else {
 2545:             $change = 1;
 2546:         }
 2547:     } elsif ($env{'form.'.$item.'set'} eq 'course') {
 2548:         my $posscrsval = $env{'form.'.$item};
 2549:         if (grep(/^\Q$posscrsval\E$/,@{$options})) {
 2550:             $newcrsval = $posscrsval;
 2551:         }
 2552:         if ($oldcrsval eq $newcrsval) {
 2553:             $nochange = 1;
 2554:         } else {
 2555:             $change = 1;
 2556:         }
 2557:     }
 2558:     if ($change) {
 2559:         if ($newcrsval ne '') {
 2560:             my %cenv = (
 2561:                          'internal.'.$item => $newcrsval,
 2562:                        );
 2563:             if (&Apache::lonnet::put('environment',\%cenv,$cdom,$cnum) eq 'ok') {
 2564:                 if ($env{'course.'.$cdom.'_'.$cnum.'.description'} ne '') {
 2565:                     &Apache::lonnet::appenv(
 2566:                        {'course.'.$cdom.'_'.$cnum.'.internal.'.$item => $newcrsval});
 2567:                 }
 2568:             } else {
 2569:                 $error = 1;
 2570:             }
 2571:         } else {
 2572:             if (&Apache::lonnet::del('environment',['internal.'.$item],$cdom,$cnum) eq 'ok') {
 2573:                 if (exists($env{'course.'.$cdom.'_'.$cnum.'.internal.'.$item})) {
 2574:                     &Apache::lonnet::delenv('course.'.$cdom.'_'.$cnum.'.internal.'.$item);
 2575:                 }
 2576:             } else {
 2577:                 $error = 1;
 2578:             }
 2579:         }
 2580:     }
 2581:     if ($error) {
 2582:         $nochange = 1;
 2583:     }
 2584:     if ($nochange) {
 2585:         $itemvalue = $oldcrsval;
 2586:     } else {
 2587:         $itemvalue = $newcrsval;
 2588:     }
 2589:     if ($itemvalue eq '') {
 2590:         $status = $titles{'used'}.': '.
 2591:                   '<span style="font-style:italic">'.$domdefdisplay.'</span>';
 2592:     } else {
 2593:         $status = $titles{'cour'}.': '.
 2594:                   '<span style="font-style:italic">'.$optiontext->{$itemvalue}.'</span>';
 2595:     }
 2596:     if ($error) {
 2597:         $r->print('<p class="LC_warning">'.&mt('An error occurred when saving your changes').'</p>');
 2598:     }
 2599:     $r->print('<p>');
 2600:     if ($nochange) {
 2601:         $r->print($resulttext{'nochg'});
 2602:     } elsif ($change) {
 2603:         $r->print($resulttext{'chg'});
 2604:     }
 2605:     $r->print('<br />'.$status.'</p>'.
 2606:               &hidden_form_elements().'</form>');
 2607:     my @actions =
 2608:         ('<a href="javascript:changePage(document.process'.$item.','."'menu'".')">'.
 2609:          $titles{'back'}.'</a>');
 2610:     $r->print('<br />'.&Apache::lonhtmlcommon::actionbox(\@actions));
 2611:     return;
 2612: }
 2613: 
 2614: sub print_header {
 2615:     my ($r,$type,$javascript_validations) = @_;
 2616:     my $phase = "start";
 2617:     if ( exists($env{'form.phase'}) ) {
 2618:         $phase = $env{'form.phase'};
 2619:     }
 2620:     my $js = qq|
 2621: 
 2622: function changePage(formname,newphase) {
 2623:     formname.phase.value = newphase;
 2624:     if (newphase == 'processparms') {
 2625:         return;
 2626:     }
 2627:     formname.submit();
 2628: }
 2629: 
 2630: |;
 2631:     if ($phase eq 'setparms') {
 2632: 	$js .= $javascript_validations;
 2633:     } elsif ($phase eq 'courselist') {
 2634:         $js .= <<"ENDJS";
 2635: function hide_searching() {
 2636:     if (document.getElementById('searching')) {
 2637:         document.getElementById('searching').style.display = 'none';
 2638:     }
 2639:     return;
 2640: }
 2641: 
 2642: ENDJS
 2643:     } elsif ($phase eq 'setquota') {
 2644:         my $invalid = &mt('The quota you entered contained invalid characters.');
 2645:         my $alert = &mt('You must enter a number');
 2646:         &js_escape(\$invalid);
 2647:         &js_escape(\$alert);
 2648:         my $regexp = '/^\s*(\d+\.?\d*|\.\d+)\s*$/';
 2649:         $js .= <<"ENDSCRIPT";
 2650: 
 2651: function verify_quota() {
 2652:     var newcoursequota = document.setquota.coursequota.value;
 2653:     var newuploadquota = document.setquota.uploadquota.value;
 2654:     var num_reg = $regexp;
 2655:     if ((num_reg.test(newcoursequota)) && (num_reg.test(newuploadquota))) {
 2656:         changePage(document.setquota,'processquota');
 2657:     } else {
 2658:         alert("$invalid\\n$alert");
 2659:         return false;
 2660:     }
 2661:     return true;
 2662: }
 2663: 
 2664: ENDSCRIPT
 2665:     } elsif ($phase eq 'setanon') {
 2666:         my $invalid = &mt('The responder threshold you entered is invalid.');
 2667:         my $alert = &mt('You must enter a positive integer.');
 2668:         &js_escape(\$invalid);
 2669:         &js_escape(\$alert);
 2670:         my $regexp = ' /^\s*\d+\s*$/';
 2671:         $js .= <<"ENDSCRIPT";
 2672: 
 2673: function verify_anon_threshold() {
 2674:     var newthreshold = document.setanon.threshold.value;
 2675:     var num_reg = $regexp;
 2676:     if (num_reg.test(newthreshold)) {
 2677:         if (newthreshold > 0) {
 2678:             changePage(document.setanon,'processthreshold');
 2679:         } else {
 2680:             alert("$invalid\\n$alert");
 2681:             return false;
 2682:         }
 2683:     } else {
 2684:         alert("$invalid\\n$alert");
 2685:         return false;
 2686:     }
 2687:     return true;
 2688: }
 2689: 
 2690: ENDSCRIPT
 2691:     } elsif ($phase eq 'setpostsubmit') {
 2692:         my $invalid = &mt('The choice entered for disabling the submit button is invalid.');
 2693:         my $invalidtimeout = &mt('The timeout you entered for disabling the submit button is invalid.');
 2694:         my $alert = &mt('Enter one of: a positive integer, 0 (for no timeout), or leave blank to use domain default');
 2695:         &js_escape(\$invalid);
 2696:         &js_escape(\$invalidtimeout);
 2697:         &js_escape(\$alert);
 2698:         my $regexp = ' /^\s*\d+\s*$/';
 2699: 
 2700:         $js .= <<"ENDSCRIPT";
 2701: 
 2702: function verify_postsubmit() {
 2703:     var optionsElement = document.setpostsubmit.postsubmit;
 2704:     var verified = '';
 2705:     if (optionsElement.length) {
 2706:         var currval;
 2707:         for (var i=0; i<optionsElement.length; i++) {
 2708:             if (optionsElement[i].checked) {
 2709:                currval = optionsElement[i].value;
 2710:             }
 2711:         }
 2712:         if (currval == 1) {
 2713:             var newtimeout = document.setpostsubmit.postsubtimeout.value;
 2714:             if (newtimeout == '') {
 2715:                 verified = 'ok';
 2716:             } else {
 2717:                 var num_reg = $regexp;
 2718:                 if (num_reg.test(newtimeout)) {
 2719:                     if (newtimeout>= 0) {
 2720:                         verified = 'ok';
 2721:                     } else {
 2722:                         alert("$invalidtimeout\\n$alert");
 2723:                         return false;
 2724:                     }
 2725:                 } else {
 2726:                     alert("$invalid\\n$alert");
 2727:                     return false;
 2728:                 }
 2729:             }
 2730:         } else {
 2731:             if (currval == 0) {
 2732:                verified = 'ok';
 2733:             } else {
 2734:                alert('$invalid');
 2735:                return false;
 2736:             }
 2737:         }
 2738:         if (verified == 'ok') {
 2739:             changePage(document.setpostsubmit,'processpostsubmit');
 2740:             return true;
 2741:         }
 2742:     }
 2743:     return false;
 2744: }
 2745: 
 2746: function togglePostsubmit(caller) {
 2747:     var optionsElement = document.setpostsubmit.postsubmit;
 2748:     if (document.getElementById(caller)) {
 2749:         var divitem = document.getElementById(caller);
 2750:         var optionsElement = document.setpostsubmit.postsubmit;
 2751:         if (optionsElement.length) {
 2752:             var currval;
 2753:             for (var i=0; i<optionsElement.length; i++) {
 2754:                 if (optionsElement[i].checked) {
 2755:                    currval = optionsElement[i].value;
 2756:                 }
 2757:             }
 2758:             if (currval == 1) {
 2759:                 divitem.style.display = 'block';
 2760:             } else {
 2761:                 divitem.style.display = 'none';
 2762:             }
 2763:         }
 2764:     }
 2765:     return;
 2766: }
 2767: 
 2768: ENDSCRIPT
 2769: 
 2770:     } elsif (($phase eq 'setltiauth') || ($phase eq 'setexttool') || ($phase eq 'setcrsauthor')) {
 2771:         $js .= <<"ENDJS";
 2772: function toggleOptions(form,phase) {
 2773:     var radioname;
 2774:     var divid;
 2775:     if (phase == 'setltiauth') {
 2776:         radioname = 'ltiauthset';
 2777:         divid = 'crsltiauth';
 2778:     } else if (phase == 'setexttool') {
 2779:         radioname = 'exttoolset';
 2780:         divid = 'crsexttool';
 2781:     } else if (phase == 'setcrsauthor') {
 2782:         radioname = 'crsauthorset';
 2783:         divid = 'crscrsauthor';
 2784:     }
 2785:     var num = form.elements[radioname].length;
 2786:     if (num) {
 2787:         var setvis = '';
 2788:         for (var i=0; i<num; i++) {
 2789:             if (form.elements[radioname][i].checked) {
 2790:                 if (form.elements[radioname][i].value == 'course') {
 2791:                     if (document.getElementById(divid)) {
 2792:                         document.getElementById(divid).style.display = 'inline-block';
 2793:                     }
 2794:                     setvis = 1;
 2795:                 }
 2796:                 break;
 2797:             }
 2798:         }
 2799:         if (!setvis) {
 2800:             if (document.getElementById(divid)) {
 2801:                 document.getElementById(divid).style.display = 'none';
 2802:             }
 2803:         }
 2804:     }
 2805:     return;
 2806: }
 2807: 
 2808: ENDJS
 2809:     }
 2810:     my $starthash;
 2811:     if ($env{'form.phase'} eq 'adhocrole') {
 2812:         $starthash = {
 2813:            add_entries => {'onload' => "javascript:document.adhocrole.submit();"},
 2814:                      };
 2815:     } elsif ($phase eq 'courselist') {
 2816:         $starthash = {
 2817:            add_entries => {'onload' => "hide_searching(); courseSet(document.filterpicker.official, 'load');"},
 2818:                      };
 2819:     } elsif ($env{'form.phase'} =~ /^set(ltiauth|exttool|crsauthor)$/) {
 2820:         $starthash = {
 2821:            add_entries => {'onload' => "toggleOptions(document.$env{'form.phase'},'$env{'form.phase'}');"},
 2822:                      };
 2823:     }
 2824:     $r->print(&Apache::loncommon::start_page('View/Modify Course/Community Settings',
 2825: 					     &Apache::lonhtmlcommon::scripttag($js),
 2826:                                              $starthash));
 2827:     my $bread_text = "View/Modify Courses/Communities";
 2828:     if ($type eq 'Community') {
 2829:         $bread_text = 'Community Settings';
 2830:     } elsif ($type eq 'Placement') {
 2831:         $bread_text = 'Placement Test Settings';
 2832:     } else {
 2833:         $bread_text = 'Course Settings';
 2834:     }
 2835:     my $helpcomponent;
 2836:     if ($env{'form.phase'} eq 'menu') {
 2837:         if ($type eq 'Community') {
 2838:             $helpcomponent = 'Domain_Modify_Community';
 2839:         } else {
 2840:             $helpcomponent = 'Domain_Modify_Course';
 2841:         }
 2842:     }
 2843:     $r->print(&Apache::lonhtmlcommon::breadcrumbs($bread_text,$helpcomponent));
 2844:     return;
 2845: }
 2846: 
 2847: sub print_footer {
 2848:     my ($r) = @_;
 2849:     $r->print('<br />'.&Apache::loncommon::end_page());
 2850:     return;
 2851: }
 2852: 
 2853: sub check_course {
 2854:     my ($dom,$domdesc) = @_;
 2855:     my ($ok_course,$description,$instcode);
 2856:     my %coursehash;
 2857:     if ($env{'form.pickedcourse'} =~ /^$match_domain\_$match_courseid$/) {
 2858:         my %args;
 2859:         unless ($env{'course.'.$env{'form.pickedcourse'}.'.description'}) {
 2860:             %args = (
 2861:                       'one_time'      => 1,
 2862:                       'freshen_cache' => 1,
 2863:                     );
 2864:         }
 2865:         %coursehash =
 2866:            &Apache::lonnet::coursedescription($env{'form.pickedcourse'},\%args);
 2867:         my $cnum = $coursehash{'num'};
 2868:         my $cdom = $coursehash{'domain'};
 2869:         $description = $coursehash{'description'};
 2870:         $instcode = $coursehash{'internal.coursecode'};
 2871:         if ($instcode) {
 2872:             $description .= " ($instcode)";
 2873:         }
 2874:         if (($cdom eq $dom) && ($cnum =~ /^$match_courseid$/)) {
 2875:             my %courseIDs = &Apache::lonnet::courseiddump($cdom,'.',1,'.','.',
 2876:                                                           $cnum,undef,undef,'.');
 2877:             if ($courseIDs{$cdom.'_'.$cnum}) {
 2878:                 $ok_course = 'ok';
 2879:             }
 2880:         }
 2881:     }
 2882:     return ($ok_course,$description,\%coursehash);
 2883: }
 2884: 
 2885: sub course_settings_descrip {
 2886:     my ($type) = @_;
 2887:     my %longtype;
 2888:     if ($type eq 'Community') {
 2889:          %longtype = &Apache::lonlocal::texthash(
 2890:                       'courseowner'      => "Username:domain of community owner",
 2891:                       'co-owners'        => "Username:domain of each co-owner",
 2892:                       'selfenrollmgrdc'  => "Community-specific self-enrollment configuration by Domain Coordinator",
 2893:                       'selfenrollmgrcc'  => "Community-specific self-enrollment configuration by Community personnel",
 2894:                       'mysqltables'      => '"Temporary" student performance tables lifetime (seconds)',
 2895:          );
 2896:     } else {
 2897:          %longtype = &Apache::lonlocal::texthash(
 2898:                       'authtype' => 'Default authentication method',
 2899:                       'autharg'  => 'Default authentication parameter',
 2900:                       'autoadds' => 'Automated adds',
 2901:                       'autodrops' => 'Automated drops',
 2902:                       'autostart' => 'Date of first automated enrollment',
 2903:                       'autoend' => 'Date of last automated enrollment',
 2904:                       'default_enrollment_start_date' => 'Date of first student access',
 2905:                       'default_enrollment_end_date' => 'Date of last student access',
 2906:                       'coursecode' => 'Official course code',
 2907:                       'courseowner' => "Username:domain of course owner",
 2908:                       'co-owners'   => "Username:domain of each co-owner",
 2909:                       'notifylist' => 'Course Coordinators to be notified of enrollment changes',
 2910:                       'sectionnums' => 'Course section number:LON-CAPA section',
 2911:                       'crosslistings' => 'Crosslisted class:LON-CAPA section',
 2912:                       'defaultcredits' => 'Credits',
 2913:                       'autodropfailsafe' => "Failsafe section enrollment count",
 2914:                       'selfenrollmgrdc'  => "Course-specific self-enrollment configuration by Domain Coordinator",
 2915:                       'selfenrollmgrcc'  => "Course-specific self-enrollment configuration by Course personnel",
 2916:                       'mysqltables'      => '"Temporary" student performance tables lifetime (seconds)',
 2917:                       'nopasswdchg' => 'Disable changing password for users with student role by course owner',
 2918:          );
 2919:     }
 2920:     return %longtype;
 2921: }
 2922: 
 2923: sub hidden_form_elements {
 2924:     my $hidden_elements =
 2925:       &Apache::lonhtmlcommon::echo_form_input(['gosearch','updater','coursecode',
 2926:           'prevphase','numlocalcc','courseowner','login','coursequota','intarg',
 2927:           'locarg','krbarg','krbver','counter','hidefromcat','usecategory',
 2928:           'threshold','postsubmit','postsubtimeout','defaultcredits','uploadquota',
 2929:           'selfenrollmgrdc','selfenrollmgrcc','action','state','currsec_st',
 2930:           'sections','newsec','mysqltables','nopasswdchg','ltiauth','ltiauthset',
 2931:           'exttoolset','exttool','crsauthorset','crsauthor'],
 2932:            ['^selfenrollmgr_','^selfenroll_'])."\n".
 2933:           '<input type="hidden" name="prevphase" value="'.$env{'form.phase'}.'" />';
 2934:     return $hidden_elements;
 2935: }
 2936: 
 2937: sub showcredits {
 2938:     my ($dom) = @_;
 2939:     my %domdefaults = &Apache::lonnet::get_domain_defaults($dom);
 2940:     if ($domdefaults{'officialcredits'} || $domdefaults{'unofficialcredits'} || $domdefaults{'textbookcredits'}) {
 2941:         return 1;
 2942:     }
 2943: }
 2944: 
 2945: sub get_permission {
 2946:     my ($dom) = @_;
 2947:     my ($allowed,%permission);
 2948:     my %passwdconf = &Apache::lonnet::get_passwdconf($dom);
 2949:     if (&Apache::lonnet::allowed('ccc',$dom)) {
 2950:         $allowed = 1;
 2951:         %permission = (
 2952:             setquota          => 'edit',
 2953:             processquota      => 'edit',
 2954:             setanon           => 'edit',
 2955:             processthreshold  => 'edit',
 2956:             setpostsubmit     => 'edit',
 2957:             processpostsubmit => 'edit',
 2958:             viewparms         => 'view',
 2959:             setparms          => 'edit',
 2960:             processparms      => 'edit',
 2961:             catsettings       => 'edit',
 2962:             processcat        => 'edit',
 2963:             selfenroll        => 'edit',
 2964:             adhocrole         => 'coord',
 2965:             setltiauth        => 'edit',
 2966:             processltiauth    => 'edit',
 2967:             setexttool        => 'edit',
 2968:             processexttool    => 'edit',
 2969:             setcrsauthor      => 'edit',
 2970:             processcrsauthor  => 'edit',
 2971:         );
 2972:         if ($passwdconf{'crsownerchg'}) {
 2973:             $permission{passwdchg} = 'edit';
 2974:         }
 2975:     } elsif (&Apache::lonnet::allowed('rar',$dom)) {
 2976:         $allowed = 1;
 2977:         %permission = (
 2978:             setquota      => 'view',
 2979:             viewparms     => 'view',
 2980:             setanon       => 'view',
 2981:             setpostsubmit => 'view',
 2982:             setparms      => 'view',
 2983:             catsettings   => 'view',
 2984:             selfenroll    => 'view',
 2985:             adhocrole     => 'custom',
 2986:             setltiauth    => 'view',
 2987:             setexttool    => 'view',
 2988:             setcrsauthor  => 'view',
 2989:         );
 2990:         if ($passwdconf{'crsownerchg'}) {
 2991:             $permission{passwdchg} = 'view';
 2992:         }
 2993:     }
 2994:     return ($allowed,\%permission);
 2995: }
 2996: 
 2997: sub devalidate_remote_instcats {
 2998:     if ($modified_dom ne '') {
 2999:         my %servers = &Apache::lonnet::internet_dom_servers($modified_dom);
 3000:         my %thismachine;
 3001:         map { $thismachine{$_} = 1; } &Apache::lonnet::current_machine_ids();
 3002:         if (keys(%servers)) {
 3003:             foreach my $server (keys(%servers)) {
 3004:                 next if ($thismachine{$server});
 3005:                 &Apache::lonnet::remote_devalidate_cache($server,['instcats:'.$modified_dom]);
 3006:             }
 3007:         }
 3008:         $modified_dom = '';
 3009:     }
 3010:     return;
 3011: }
 3012: 
 3013: sub handler {
 3014:     my $r = shift;
 3015:     if ($r->header_only) {
 3016:         &Apache::loncommon::content_type($r,'text/html');
 3017:         $r->send_http_header;
 3018:         return OK;
 3019:     }
 3020: 
 3021:     $registered_cleanup=0;
 3022:     $modified_dom = '';
 3023: 
 3024:     my $dom = $env{'request.role.domain'};
 3025:     my $domdesc = &Apache::lonnet::domain($dom,'description');
 3026:     my ($allowed,$permission) = &get_permission($dom);
 3027:     if ($allowed) {
 3028:         &Apache::loncommon::content_type($r,'text/html');
 3029:         $r->send_http_header;
 3030: 
 3031:         &Apache::lonhtmlcommon::clear_breadcrumbs();
 3032: 
 3033:         my $phase = $env{'form.phase'};
 3034:         if ($env{'form.updater'}) {
 3035:             $phase = '';
 3036:         }
 3037:         if ($phase eq '') {
 3038:             &Apache::lonhtmlcommon::add_breadcrumb
 3039:             ({href=>"/adm/modifycourse",
 3040:               text=>"Course/Community search"});
 3041:             &print_course_search_page($r,$dom,$domdesc);
 3042:         } else {
 3043:             my $firstform = $phase;
 3044:             if ($phase eq 'courselist') {
 3045:                 $firstform = 'filterpicker';
 3046:             }
 3047:             my $choose_text;
 3048:             my $type = $env{'form.type'};
 3049:             if ($type eq '') {
 3050:                 $type = 'Course';
 3051:             }
 3052:             if ($type eq 'Community') {
 3053:                 $choose_text = "Choose a community";
 3054:             } elsif ($type eq 'Placement') {
 3055:                 $choose_text = "Choose a placement test";
 3056:             } else {
 3057:                 $choose_text = "Choose a course";
 3058:             }
 3059:             &Apache::lonhtmlcommon::add_breadcrumb
 3060:             ({href=>"javascript:changePage(document.$firstform,'')",
 3061:               text=>"Course/Community search"},
 3062:               {href=>"javascript:changePage(document.$phase,'courselist')",
 3063:               text=>$choose_text});
 3064:             if ($phase eq 'courselist') {
 3065:                 &print_course_selection_page($r,$dom,$domdesc,$permission);
 3066:             } else {
 3067:                 my ($checked,$cdesc,$coursehash) = &check_course($dom,$domdesc);
 3068:                 if ($checked eq 'ok') {
 3069:                     my $enter_text;
 3070:                     if ($type eq 'Community') {
 3071:                         $enter_text = 'Enter community';
 3072:                     } elsif ($type eq 'Placement') {
 3073:                         $enter_text = 'Enter placement test';
 3074:                     } else {
 3075:                         $enter_text = 'Enter course';
 3076:                     }
 3077:                     if ($phase eq 'menu') {
 3078:                         &Apache::lonhtmlcommon::add_breadcrumb
 3079:                         ({href=>"javascript:changePage(document.$phase,'menu')",
 3080:                           text=>"Pick action"});
 3081:                         &print_modification_menu($r,$cdesc,$domdesc,$dom,$type,
 3082:                                                  $env{'form.pickedcourse'},$coursehash,
 3083:                                                  $permission);
 3084:                     } elsif ($phase eq 'adhocrole') {
 3085:                         &Apache::lonhtmlcommon::add_breadcrumb
 3086:                          ({href=>"javascript:changePage(document.$phase,'adhocrole')",
 3087:                            text=>$enter_text});
 3088:                         &print_adhocrole_selected($r,$type,$permission);
 3089:                     } else {
 3090:                         &Apache::lonhtmlcommon::add_breadcrumb
 3091:                         ({href=>"javascript:changePage(document.$phase,'menu')",
 3092:                           text=>"Pick action"});
 3093:                         my ($cdom,$cnum) = split(/_/,$env{'form.pickedcourse'});
 3094:                         my ($readonly,$linktext);
 3095:                         if ($permission->{$phase} eq 'view') {
 3096:                            $readonly = 1;
 3097:                         }
 3098:                         if (($phase eq 'setquota') && ($permission->{'setquota'})) {
 3099:                             if ($permission->{'setquota'} eq 'view') {
 3100:                                 $linktext = 'Set quota';
 3101:                             } else {
 3102:                                 $linktext = 'Display quota';
 3103:                             }
 3104:                             &Apache::lonhtmlcommon::add_breadcrumb
 3105:                             ({href=>"javascript:changePage(document.$phase,'$phase')",
 3106:                               text=>$linktext});
 3107:                             &print_setquota($r,$cdom,$cnum,$cdesc,$type,$readonly);
 3108:                         } elsif (($phase eq 'processquota') && ($permission->{'processquota'})) {
 3109:                             &Apache::lonhtmlcommon::add_breadcrumb
 3110:                             ({href=>"javascript:changePage(document.$phase,'setquota')",
 3111:                               text=>"Set quota"});
 3112:                             &Apache::lonhtmlcommon::add_breadcrumb
 3113:                             ({href=>"javascript:changePage(document.$phase,'$phase')",
 3114:                               text=>"Result"});
 3115:                             &modify_quota($r,$cdom,$cnum,$cdesc,$domdesc,$type);
 3116:                         } elsif (($phase eq 'setanon') && ($permission->{'setanon'})) {
 3117:                             &Apache::lonhtmlcommon::add_breadcrumb
 3118:                             ({href=>"javascript:changePage(document.$phase,'$phase')",
 3119:                               text=>"Threshold for anonymous submissions display"});
 3120:                             &print_set_anonsurvey_threshold($r,$cdom,$cnum,$cdesc,$type,$readonly);
 3121:                         } elsif (($phase eq 'processthreshold') && ($permission->{'processthreshold'})) {
 3122:                             &Apache::lonhtmlcommon::add_breadcrumb
 3123:                             ({href=>"javascript:changePage(document.$phase,'setanon')",
 3124:                               text=>"Threshold for anonymous submissions display"});
 3125:                             &Apache::lonhtmlcommon::add_breadcrumb
 3126:                             ({href=>"javascript:changePage(document.$phase,'$phase')",
 3127:                               text=>"Result"});
 3128:                             &modify_anonsurvey_threshold($r,$cdom,$cnum,$cdesc,$domdesc,$type);
 3129:                         } elsif (($phase eq 'setpostsubmit') && ($permission->{'setpostsubmit'})) {
 3130:                             if ($permission->{'setpostsubmit'} eq 'view') {
 3131:                                 $linktext = 'Submit button behavior post-submission';
 3132:                             } else {
 3133:                                 $linktext = 'Configure submit button behavior post-submission';
 3134:                             }
 3135:                             &Apache::lonhtmlcommon::add_breadcrumb
 3136:                             ({href=>"javascript:changePage(document.$phase,'$phase')",
 3137:                               text=>$linktext});
 3138:                             &print_postsubmit_config($r,$cdom,$cnum,$cdesc,$type,$readonly);
 3139:                         } elsif (($phase eq 'processpostsubmit') && ($permission->{'processpostsubmit'})) {
 3140:                             &Apache::lonhtmlcommon::add_breadcrumb
 3141:                             ({href=>"javascript:changePage(document.$phase,'$phase')",
 3142:                               text=>"Result"});
 3143:                             &modify_postsubmit_config($r,$cdom,$cnum,$cdesc,$domdesc,$type);
 3144:                         } elsif (($phase eq 'viewparms') && ($permission->{'viewparms'})) {
 3145:                             &Apache::lonhtmlcommon::add_breadcrumb
 3146:                             ({href=>"javascript:changePage(document.$phase,'viewparms')",
 3147:                               text=>"Display settings"});
 3148:                             &print_settings_display($r,$cdom,$cnum,$cdesc,$type,$permission);
 3149:                         } elsif (($phase eq 'setparms') && ($permission->{'setparms'})) {
 3150:                             if ($permission->{'setparms'} eq 'view') {
 3151:                                 $linktext = 'Display settings';
 3152:                             } else {
 3153:                                 $linktext = 'Change settings';
 3154:                             }
 3155:                             &Apache::lonhtmlcommon::add_breadcrumb
 3156:                             ({href=>"javascript:changePage(document.$phase,'$phase')",
 3157:                               text=>$linktext});
 3158:                             &print_course_modification_page($r,$cdom,$cnum,$cdesc,$type,$readonly);
 3159:                         } elsif (($phase eq 'processparms') && ($permission->{'processparms'})) {
 3160:                             &Apache::lonhtmlcommon::add_breadcrumb
 3161:                             ({href=>"javascript:changePage(document.$phase,'setparms')",
 3162:                               text=>"Change settings"});
 3163:                             &Apache::lonhtmlcommon::add_breadcrumb
 3164:                             ({href=>"javascript:changePage(document.$phase,'$phase')",
 3165:                               text=>"Result"});
 3166:                             &modify_course($r,$cdom,$cnum,$cdesc,$domdesc,$type);
 3167:                         } elsif (($phase eq 'catsettings') && ($permission->{'catsettings'})) {
 3168:                             &Apache::lonhtmlcommon::add_breadcrumb
 3169:                             ({href=>"javascript:changePage(document.$phase,'$phase')",
 3170:                               text=>"Catalog settings"});
 3171:                             &print_catsettings($r,$cdom,$cnum,$cdesc,$type,$readonly);
 3172:                         } elsif (($phase eq 'processcat') && ($permission->{'processcat'})) {
 3173:                             &Apache::lonhtmlcommon::add_breadcrumb
 3174:                             ({href=>"javascript:changePage(document.$phase,'catsettings')",
 3175:                               text=>"Catalog settings"});
 3176:                             &Apache::lonhtmlcommon::add_breadcrumb
 3177:                             ({href=>"javascript:changePage(document.$phase,'$phase')",
 3178:                               text=>"Result"});
 3179:                             &modify_catsettings($r,$cdom,$cnum,$cdesc,$domdesc,$type);
 3180:                         } elsif (($phase eq 'selfenroll') && ($permission->{'selfenroll'})) {
 3181:                             &Apache::lonhtmlcommon::add_breadcrumb
 3182:                             ({href => "javascript:changePage(document.$phase,'$phase')",
 3183:                               text => "Self-enrollment settings"});
 3184:                             if (!exists($env{'form.state'})) {
 3185:                                 &print_selfenrollconfig($r,$type,$cdesc,$coursehash,$readonly);
 3186:                             } elsif ($env{'form.state'} eq 'done') {
 3187:                                 &Apache::lonhtmlcommon::add_breadcrumb
 3188:                                 ({href=>"javascript:changePage(document.$phase,'$phase')",
 3189:                                   text=>"Result"});
 3190:                                 &modify_selfenrollconfig($r,$type,$cdesc,$coursehash);
 3191:                             }
 3192:                         } elsif (($phase eq 'setltiauth') && ($permission->{'setltiauth'})) {
 3193:                             &Apache::lonhtmlcommon::add_breadcrumb
 3194:                             ({href=>"javascript:changePage(document.$phase,'$phase')",
 3195:                               text=>"Authentication post-LTI launch"});
 3196:                             &print_default_overrides($r,$cdom,$cnum,$cdesc,$type,$readonly,'ltiauth');
 3197:                         } elsif (($phase eq 'processltiauth') && ($permission->{'processltiauth'})) {
 3198:                             &Apache::lonhtmlcommon::add_breadcrumb
 3199:                             ({href=>"javascript:changePage(document.$phase,'setltiauth')",
 3200:                               text=>"Authentication post-LTI launch"},
 3201:                              {href=>"javascript:changePage(document.$phase,'$phase')",
 3202:                               text=>"Result"});
 3203:                             &modify_default_overrides($r,$cdom,$cnum,$cdesc,$domdesc,$type,'ltiauth');
 3204:                         } elsif (($phase eq 'setexttool') && ($permission->{'setexttool'})) {
 3205:                             &Apache::lonhtmlcommon::add_breadcrumb
 3206:                             ({href=>"javascript:changePage(document.$phase,'$phase')",
 3207:                               text=>"External Tool permission"});
 3208:                             &print_default_overrides($r,$cdom,$cnum,$cdesc,$type,$readonly,'exttool');
 3209:                         } elsif (($phase eq 'processexttool') && ($permission->{'processexttool'})) {
 3210:                             &Apache::lonhtmlcommon::add_breadcrumb
 3211:                             ({href=>"javascript:changePage(document.$phase,'setexttool')",
 3212:                               text=>"External Tool permission"},
 3213:                              {href=>"javascript:changePage(document.$phase,'$phase')",
 3214:                               text=>"Result"});
 3215:                             &modify_default_overrides($r,$cdom,$cnum,$cdesc,$domdesc,$type,'exttool');
 3216:                         } elsif (($phase eq 'setcrsauthor') && ($permission->{'setcrsauthor'})) {
 3217:                             &Apache::lonhtmlcommon::add_breadcrumb
 3218:                             ({href=>"javascript:changePage(document.$phase,'$phase')",
 3219:                               text=>"In-course authoring permission"});
 3220:                             &print_default_overrides($r,$cdom,$cnum,$cdesc,$type,$readonly,'crsauthor');
 3221:                         } elsif (($phase eq 'processcrsauthor') && ($permission->{'processcrsauthor'})) {
 3222:                             &Apache::lonhtmlcommon::add_breadcrumb
 3223:                             ({href=>"javascript:changePage(document.$phase,'setcrsauthor')",
 3224:                               text=>"In-course authoring permission"},
 3225:                              {href=>"javascript:changePage(document.$phase,'$phase')",
 3226:                               text=>"Result"});
 3227:                             &modify_default_overrides($r,$cdom,$cnum,$cdesc,$domdesc,$type,'crsauthor');
 3228:                         }
 3229:                     }
 3230:                 } else {
 3231:                     $r->print('<span class="LC_error">');
 3232:                     if ($type eq 'Community') {
 3233:                         $r->print(&mt('The community you selected is not a valid community in this domain'));
 3234:                     } elsif ($type eq 'Placement') {
 3235:                         $r->print(&mt('The course you selected is not a valid placement test in this domain'));
 3236:                     } else {
 3237:                         $r->print(&mt('The course you selected is not a valid course in this domain'));
 3238:                     }
 3239:                     $r->print(" ($domdesc)</span>");
 3240:                 }
 3241:             }
 3242:         }
 3243:         &print_footer($r);
 3244:     } else {
 3245:         $env{'user.error.msg'}=
 3246:         "/adm/modifycourse:ccc:0:0:Cannot modify course/community settings";
 3247:         return HTTP_NOT_ACCEPTABLE;
 3248:     }
 3249:     return OK;
 3250: }
 3251: 
 3252: 1;
 3253: __END__

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>