File:  [LON-CAPA] / loncom / interface / lonmodifycourse.pm
Revision 1.83: download - view: text, annotated - select for diffs
Wed Apr 6 17:41:52 2016 UTC (8 years, 1 month ago) by raeburn
Branches: MAIN
CVS tags: HEAD
- Bug 6808. New course container -- "Placement" for Placement Tests.
  - Placement Tests can have an instituional course code, so that
    auto-enrollment can be supported.

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

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