Annotation of loncom/interface/lonmodifycourse.pm, revision 1.35

1.20      albertel    1: # The LearningOnline Network with CAPA
1.28      raeburn     2: # handler for DC-only modifiable course settings
1.20      albertel    3: #
1.35    ! raeburn     4: # $Id: lonmodifycourse.pm,v 1.34 2007/10/06 04:32:49 raeburn Exp $
1.20      albertel    5: #
1.3       raeburn     6: # Copyright Michigan State University Board of Trustees
                      7: #
                      8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
                      9: #
                     10: # LON-CAPA is free software; you can redistribute it and/or modify
                     11: # it under the terms of the GNU General Public License as published by
                     12: # the Free Software Foundation; either version 2 of the License, or
                     13: # (at your option) any later version.
                     14: #
                     15: # LON-CAPA is distributed in the hope that it will be useful,
                     16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
                     17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
                     18: # GNU General Public License for more details.
                     19: #
                     20: # You should have received a copy of the GNU General Public License
                     21: # along with LON-CAPA; if not, write to the Free Software
                     22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
                     23: #
                     24: # /home/httpd/html/adm/gpl.txt
                     25: #
                     26: # http://www.lon-capa.org/
                     27: #
1.1       raeburn    28: package Apache::lonmodifycourse;
                     29: 
                     30: use strict;
                     31: use Apache::Constants qw(:common :http);
                     32: use Apache::lonnet;
                     33: use Apache::loncommon;
1.28      raeburn    34: use Apache::lonhtmlcommon;
1.1       raeburn    35: use Apache::lonlocal;
                     36: use Apache::londropadd;
1.28      raeburn    37: use Apache::lonpickcourse;
1.1       raeburn    38: use LONCAPA::Enrollment;
                     39: use lib '/home/httpd/lib/perl';
1.25      www        40: use LONCAPA;
1.1       raeburn    41: 
1.28      raeburn    42: sub get_dc_settable {
                     43:     return ('courseowner','coursecode','authtype','autharg');
                     44: }
                     45: 
                     46: sub get_enrollment_settings {
                     47:     my ($cdom,$cnum) = @_;
                     48:     my %settings = &Apache::lonnet::dump('environment',$cdom,$cnum);
                     49:     my %enrollvar;
                     50:     $enrollvar{'autharg'} = '';
                     51:     $enrollvar{'authtype'} = '';
1.1       raeburn    52:     my %lt=&Apache::lonlocal::texthash(
1.28      raeburn    53:             'noen' => "No end date",
1.1       raeburn    54:     );
1.28      raeburn    55:     foreach my $item (keys %settings) {
                     56:         if ($item =~ m/^internal\.(.+)$/) {
                     57:             my $type = $1;
                     58:             if ( ($type eq "autoadds") || ($type eq "autodrops") ) {
                     59:                 if ($settings{$item} == 1) {
                     60:                     $enrollvar{$type} = "ON";
                     61:                 } else {
                     62:                     $enrollvar{$type} = "OFF";
1.10      raeburn    63:                 }
1.28      raeburn    64:             } elsif ( ($type eq "autostart") || ($type eq "autoend") ) {
                     65:                 if ( ($type eq "autoend") && ($settings{$item} == 0) ) {
                     66:                     $enrollvar{$type} = $lt{'noen'};
                     67:                 } else {
                     68:                     $enrollvar{$type} = localtime($settings{$item});
1.14      raeburn    69:                 }
1.30      raeburn    70:             } elsif ($type eq "sectionnums") {
1.28      raeburn    71:                 $enrollvar{$type} = $settings{$item};
                     72:                 $enrollvar{$type} =~ s/,/, /g;
                     73:             } elsif ($type eq "authtype"
                     74:                      || $type eq "autharg"    || $type eq "coursecode"
                     75:                      || $type eq "crosslistings") {
                     76:                 $enrollvar{$type} = $settings{$item};
                     77:             } elsif ($type eq 'courseowner') {
                     78:                 if ($settings{$item} =~ /^[^:]+:[^:]+$/) {
                     79:                     $enrollvar{$type} = $settings{$item};
                     80:                 } else {
                     81:                     if ($settings{$item} ne '') {
                     82:                         $enrollvar{$type} = $settings{$item}.':'.$cdom;
1.26      raeburn    83:                     }
1.1       raeburn    84:                 }
1.28      raeburn    85:             }
                     86:         } elsif ($item =~ m/^default_enrollment_(start|end)_date$/) {
                     87:             my $type = $1;
                     88:             if ( ($type eq 'end') && ($settings{$item} == 0) ) {
                     89:                 $enrollvar{$item} = $lt{'noen'};
                     90:             } elsif ( ($type eq 'start') && ($settings{$item} eq '') ) {
                     91:                 $enrollvar{$item} = 'When enrolled';
                     92:             } else {
                     93:                 $enrollvar{$item} = localtime($settings{$item});
1.1       raeburn    94:             }
                     95:         }
                     96:     }
1.28      raeburn    97:     return %enrollvar;
                     98: }
                     99: 
                    100: sub print_course_search_page {
                    101:     my ($r,$dom,$domdesc) = @_;
                    102:     &print_header($r);
                    103:     my $filterlist = ['descriptfilter',
                    104:                       'instcodefilter','ownerfilter',
                    105:                       'ownerdomfilter','coursefilter'];
                    106:     my $filter = {};
                    107:     my $type = 'Course';
                    108:     my $action = '/adm/modifycourse';
                    109:     my $cctitle = &Apache::lonnet::plaintext('cc',$type);
                    110:     my $dctitle = &Apache::lonnet::plaintext('dc');
                    111:     my %lt=&Apache::lonlocal::texthash(
                    112:                     'some' => "Certain settings which control auto-enrollment of students from your institution's student information system.",
                    113:                     'crqo' => 'The total disk space allocated for storage of portfolio files in all groups in a course.',
                    114:                     'tmod' => 'To view or modify these settings use the criteria below to select a course from this domain.',
                    115:     );
                    116:     $r->print('<h3>'.
                    117:               &mt('Course settings which only a [_1] may modify.'
                    118:                   ,$dctitle).'</h3>'.
                    119:               &mt('Although almost all course settings can be modified by a [_1], a number of settings exist which only a [_2] may change:',$cctitle,$dctitle).'
                    120: <ul>
                    121:   <li>'.$lt{'some'}.'</li>
                    122:   <li>'.$lt{'crqo'}.'</li>
                    123: </ul>'.
                    124: $lt{'tmod'}.' ('.$domdesc.')
                    125: <br /><br />
                    126:     ');
                    127:     $r->print(&Apache::lonpickcourse::build_filters($filterlist,$type,
                    128:                              undef,undef,$filter,$action,'modifycourse'));
                    129: }
                    130: 
                    131: sub print_course_selection_page {
                    132:     my ($r,$dom,$domdesc) = @_;
                    133:     &print_header($r);
                    134: 
                    135: # Criteria for course search 
                    136:     my $filterlist = ['descriptfilter',
                    137:                       'instcodefilter','ownerfilter',
                    138:                       'ownerdomfilter','coursefilter'];
                    139:     my %filter;
                    140:     my $type = $env{'form.type'};
1.29      raeburn   141:     if ($type eq '') {
                    142:         $type = 'Course';
                    143:     }
1.28      raeburn   144:     my $action = '/adm/modifycourse';
                    145:     my $dctitle = &Apache::lonnet::plaintext('dc');
                    146:     $r->print(&mt('Revise your search criteria for this domain').' ('.$domdesc.').<br /><br />');
                    147:     $r->print(&Apache::lonpickcourse::build_filters($filterlist,$type,
                    148:                                        undef,undef,\%filter,$action));
                    149:     $filter{'domainfilter'} = $dom;
                    150:     my %courses = &Apache::lonpickcourse::search_courses($r,$type,0,
                    151:                                                          \%filter);
                    152:     if (keys(%courses) > 0) {
                    153:         $r->print(&mt("Click a 'Select' button to view or modify settings for a [_1] which may only be modified by a [_2] in this domain.",lc($type),$dctitle).'<br /><br />');
                    154:     }
                    155: 
                    156:     &Apache::lonpickcourse::display_matched_courses($r,$type,0,$action,
                    157:                                                     %courses);
1.1       raeburn   158:     return;
                    159: }
                    160: 
1.28      raeburn   161: sub print_modification_menu {
                    162:     my ($r,$cdesc) = @_;
                    163:     &print_header($r,$cdesc);
                    164:     my @menu =
                    165:         (
                    166:           { text  => 'Modify quota for group portfolio files',
                    167:             phase => 'setquota',
                    168:             },
                    169:           { text  => 'Display current settings for automated enrollment',
                    170:             phase => 'viewparms',
                    171:             },
                    172:           { text => 'Modify institutional code, course owner and/or default authentication',
                    173:             phase => 'setparms',
                    174:             }
                    175:          );
                    176:     my $menu_html = '<h3>'.&mt('View/Modify settings for: ').$cdesc.'</h3>'."\n".
                    177:                     '<form name="menu" method="post" action="/adm/modifycourse" />'."\n".
                    178:                      &hidden_form_elements();
                    179:     foreach my $menu_item (@menu) {
                    180:         $menu_html.='<p>';
                    181:         $menu_html.='<font size="+1">';
                    182:         $menu_html.=
                    183:                 qq|<a href="javascript:changePage(document.menu,'$menu_item->{'phase'}')">|;
                    184:         $menu_html.= &mt($menu_item->{'text'}).'</a></font>';
                    185:         $menu_html.='</p>';
1.3       raeburn   186:     }
1.28      raeburn   187:     
                    188:     $r->print($menu_html);
                    189:     return;
                    190: }
                    191: 
                    192: sub print_settings_display {
                    193:     my ($r,$cdom,$cnum,$cdesc,$type) = @_;
                    194:     my %enrollvar = &get_enrollment_settings($cdom,$cnum);
                    195:     my %longtype = &course_settings_descrip();
                    196:     my %lt = &Apache::lonlocal::texthash(
                    197:             'cset' => "Course setting",
                    198:             'valu' => "Current value",
                    199:             'caes' => 'Current automated enrollment settings for ',
                    200:             'cour' => "Course settings that control automated enrollment in this LON-CAPA course are currently:",
                    201:             'cose' => "Course settings for LON-CAPA courses that control auto-enrollment based on classlist data available from your institution's student information system fall into two groups:",
                    202:             'dcon' => "Modifiable by DC only",
                    203:             'back' => "Back to options page",
                    204:     );
                    205: 
                    206:     my @bgcolors = ('#eeeeee','#cccccc');
                    207:     my $cctitle = &Apache::lonnet::plaintext('cc',$type);
                    208:     my $dctitle = &Apache::lonnet::plaintext('dc');
                    209:     my @modifiable_params = &get_dc_settable();
                    210: 
                    211:     my $disp_table = &Apache::loncommon::start_data_table()."\n".
                    212:                      &Apache::loncommon::start_data_table_header_row()."\n".
                    213:                      "<th>$lt{'cset'}</th>\n".
                    214:                      "<th>$lt{'valu'}</th>\n".
                    215:                      "<th>$lt{'dcon'}</th>\n".
                    216:                      &Apache::loncommon::end_data_table_header_row()."\n";
                    217:     foreach my $key (sort(keys(%enrollvar))) {
                    218:         $disp_table .= &Apache::loncommon::start_data_table_row()."\n".
                    219:                  "<td>$longtype{$key}</td>\n".
                    220:                  "<td>$enrollvar{$key}</td>\n";
                    221:         if (grep(/^\Q$key\E$/,@modifiable_params)) {
                    222:             $disp_table .= '<td>'.&mt('Yes').'</td>'."\n"; 
                    223:         } else {
                    224:             $disp_table .= '<td>'.&mt('No').'</td>'."\n";
                    225:         }
                    226:         $disp_table .= &Apache::loncommon::end_data_table_row()."\n";
1.3       raeburn   227:     }
1.28      raeburn   228:     $disp_table .= &Apache::loncommon::end_data_table()."\n";
                    229:     &print_header($r,$cdesc);
                    230:     $r->print('
                    231: <h3>'.$lt{'caes'}.'</h3>
                    232: <p>
                    233: <form action="/adm/modifycourse" method="post" name="viewparms">
                    234: '.$lt{'cose'}.'<ul><li>'.&mt('Settings that can be modified by a [_1] using the <a href="/adm/populate">Automated Enrollment Manager</a>.',$cctitle).'</li><li>'.&mt('Settings that may only be modified by a [_1] from this menu.',$dctitle).'</li></ul>
                    235: </p><p>
                    236: '.$lt{'cour'}.'
                    237: </p><p>
                    238: '.$disp_table.'
                    239: </p><p>
                    240: <a href="javascript:changePage(document.viewparms,'."'menu'".')">'.$lt{'back'}.'</a>&nbsp;&nbsp;&nbsp;&nbsp;
                    241: <a href="javascript:changePage(document.viewparms,'."'setparms'".')">'.&mt('Modify [_1]-only settings',$dctitle).'</a>'."\n".
                    242: &hidden_form_elements().    
                    243: '</form>');
                    244: }
1.3       raeburn   245: 
1.28      raeburn   246: sub print_setquota {
                    247:     my ($r,$cdom,$cnum,$cdesc,$type) = @_;
                    248:     my $dctitle = &Apache::lonnet::plaintext('dc');
                    249:     my $cctitle = &Apache::lonnet::plaintext('cc',$type);
                    250:     my $subdiv = &mt('Although a [_1] will assign the disk quota for each individual group, the size of the quota is constrained by the total disk space allocated by the [_2] for portfolio files in a course.',$cctitle,$dctitle);
                    251:     my %lt = &Apache::lonlocal::texthash(
                    252:                 'cquo' => 'Disk space for storage of group portfolio files',
                    253:                 'gpqu' => 'Course portfolio files disk space',
                    254:                 'each' => 'Each course group can be assigned a quota for portfolio files uploaded to the group.',
                    255:                 'modi' => 'Modify quota',
                    256:                 'back' => "Back to options page",
                    257:     );
                    258:     my %settings = &Apache::lonnet::get('environment',['internal.coursequota'],$cdom,$cnum);
                    259:     my $coursequota = $settings{'internal.coursequota'};
                    260:     if ($coursequota eq '') {
                    261:         $coursequota = 20;
1.3       raeburn   262:     }
1.28      raeburn   263:     &print_header($r,$cdesc);
                    264:     my $hidden_elements = &hidden_form_elements();
                    265:     $r->print(<<ENDDOCUMENT);
                    266: <form action="/adm/modifycourse" method="post" name="setquota">
                    267: <h3>$lt{'cquo'}.</h3>
                    268: <p>
                    269: $lt{'each'}<br />
                    270: $subdiv
                    271: </p><p>
                    272: $lt{'gpqu'}: <input type="text" size="4" name="coursequota" value="$coursequota" /> Mb &nbsp;&nbsp;&nbsp;&nbsp;
                    273: <input type="button" onClick="javascript:verify_quota(this.form)" value="$lt{'modi'}" />
                    274: </p>
                    275: $hidden_elements
                    276: <a href="javascript:changePage(document.setquota,'menu')">$lt{'back'}</a>
                    277: </form>
                    278: ENDDOCUMENT
                    279:     return;
                    280: }
1.3       raeburn   281: 
1.28      raeburn   282: sub print_course_modification_page {
                    283:     my ($r,$cdom,$cnum,$cdesc,$domdesc) = @_;
                    284:     my %longtype = &course_settings_descrip();
                    285:     my %enrollvar = &get_enrollment_settings($cdom,$cnum);
1.1       raeburn   286:     my $ownertable;
1.2       raeburn   287:     my %lt=&Apache::lonlocal::texthash(
                    288:             'actv' => "Active",
                    289:             'inac' => "Inactive",
                    290:             'ccor' => "Course Coordinator",
                    291:             'noen' => "No end date",
                    292:             'ownr' => "Owner",
                    293:             'name' => "Name",
1.26      raeburn   294:             'unme' => "Username:Domain",
1.2       raeburn   295:             'stus' => "Status",
1.28      raeburn   296:             'cquo' => "Disk space for storage of group portfolio files",
                    297:             'gpqu' => "Course portfolio files disk space",
                    298:             'each' => "Each course group can be assigned a quota for portfolio files uploaded to the group.",
1.2       raeburn   299:             'cose' => "Course settings for LON-CAPA courses that control automated student enrollment based on classlist data available from your institution's student information system fall into two groups: (a) settings that can be modified by a Course Coordinator using the ",
                    300:             'aenm' => "Automated Enrollment Manager",
                    301:             'andb' => " and (b) settings that may only be modified by a Domain Coordinator via this page.",
                    302:             'caes' => 'Current automated enrollment settings',
                    303:             'cour' => "Course settings that control automated enrollment in this LON-CAPA course
                    304: are currently:",
                    305:             'nocc' => "There is currently no course owner set for this course. In addition, no active course coordinators from this LON-CAPA domain were found, so you will not be able assign a course owner.  If you wish to assign a course owner, it is recommended that you use the 'User Roles' screen to add a course coordinator with a LON-CAPA account in this domain to the course.",    
                    306:             'ccus' => "A course coordinator can use the 'Automated Enrollment Manager' to change
                    307: all settings except course code, course owner, and default authentication method for students added to your course (who are also new to the LON-CAPA system at this domain).",
                    308:             'ccod' => "Course Code",
                    309:             'ccus' => "The course code is used during automated enrollment to map the internal LON-CAPA course ID for this course to the corresponding course section ID(s) used by the office responsible for providing official class lists for courses at your institution.",
                    310:             'cown' => "Course Owner",
                    311:             'cous' => "The course owner is used in the retrieval of class lists from your institution's student information system when access to class lists data incorporates validation of instructor status.",
                    312:             'tabl' => 'The table below contains a list of active course coordinators in this course, who are from this domain',
                    313:             'usrd' => 'Use the radio buttons to select a different course owner.',
                    314:             'deam' => "Default Authentication method",
                    315:             'deus' => "The default authentication method, and default authentication parameter (domain, initial password or argument) are used when automatic enrollment of students in a course requires addition of new user accounts in your domain, and the class list file contains empty entries for the &lt;authtype&gt; and &lt;autharg&gt; properties for the new student. If you choose 'internally authenticated', and leave the initial password field empty, the automated enrollment process will create a randomized password for each new student account that it adds to your LON-CAPA domain.",
1.32      raeburn   316:             'gobt' => "Save",
1.2       raeburn   317:     );
1.28      raeburn   318:     my @bgcolors = ('#eeeeee','#cccccc');
1.2       raeburn   319: 
1.28      raeburn   320:     my @coursepersonnel = &Apache::lonnet::getkeys('nohist_userroles',$cdom,$cnum);
1.1       raeburn   321:     my @local_ccs = ();
                    322:     my %cc_status = ();
                    323:     my %pname = ();
                    324:     my $active_cc;
1.26      raeburn   325:     foreach my $person (@coursepersonnel) {
                    326:         my ($role,$user) = split(/:/,$person,2);
                    327:         $user =~ s/:$//;
                    328:         if (($role eq 'cc') && ($user ne ''))  {
                    329:             if (!grep(/^\Q$user\E$/,@local_ccs)) {
                    330:                 my ($ccname,$ccdom) = split(/:/,$user);
                    331:                 $active_cc = 
1.28      raeburn   332:                    &Apache::loncommon::check_user_status($ccdom,$ccname,$cdom,
                    333:                                                          $cnum,'cc');
1.19      raeburn   334:                 if ($active_cc eq 'active') {
1.26      raeburn   335:                     push(@local_ccs,$user);
                    336:                     $pname{$user} = &Apache::loncommon::plainname($ccname,$ccdom);
                    337:                     $cc_status{$user} = $lt{'actv'};
1.1       raeburn   338:                 }
                    339:             }
                    340:         }
                    341:     }
1.26      raeburn   342:     if ( (!grep(/^$enrollvar{'courseowner'}$/,@local_ccs)) && 
                    343:              ($enrollvar{'courseowner'} ne '') )  {
                    344:         my ($owneruname,$ownerdom) = split(/:/,$enrollvar{'courseowner'});
                    345:         push(@local_ccs,$enrollvar{'courseowner'});
                    346:         $pname{$enrollvar{'courseowner'}} = 
                    347:                          &Apache::loncommon::plainname($owneruname,$ownerdom);
                    348:         $active_cc = &Apache::loncommon::check_user_status($ownerdom,$owneruname,
1.28      raeburn   349:                                                            $cdom,$cnum,'cc');
1.19      raeburn   350:         if ($active_cc eq 'active') {
1.2       raeburn   351:             $cc_status{$enrollvar{'courseowner'}} = $lt{'actv'};
1.1       raeburn   352:         } else {
1.2       raeburn   353:             $cc_status{$enrollvar{'courseowner'}} = $lt{'inac'};
1.1       raeburn   354:         }
                    355:     }
                    356:     my $numlocalcc = @local_ccs;
1.24      albertel  357: 
1.2       raeburn   358:     my $helplink=&Apache::loncommon::help_open_topic('Modify_Course',&mt("Help on Modifying Courses"));
1.28      raeburn   359:     my ($krbdef,$krbdefdom)=&Apache::loncommon::get_kerberos_defaults($cdom);
1.2       raeburn   360:     my $curr_authtype = '';
                    361:     my $curr_authfield = '';
                    362:     if ($enrollvar{'authtype'} =~ /^krb/) {
                    363:         $curr_authtype = 'krb';
                    364:     } elsif ($enrollvar{'authtype'} eq 'internal' ) {
                    365:         $curr_authtype = 'int';
                    366:     } elsif ($enrollvar{'authtype'} eq 'localauth' ) {
                    367:         $curr_authtype = 'loc';
                    368:     }
                    369:     unless ($curr_authtype eq '') {
                    370:         $curr_authfield = $curr_authtype.'arg';
1.33      raeburn   371:     }
1.28      raeburn   372:     my $javascript_validations=&Apache::londropadd::javascript_validations('modifycourse',$krbdefdom,$curr_authtype,$curr_authfield);
1.35    ! raeburn   373:     my %param = ( formname => 'document.'.$env{'form.phase'},
1.1       raeburn   374: 	   kerb_def_dom => $krbdefdom,
1.2       raeburn   375: 	   kerb_def_auth => $krbdef,
                    376:            mode => 'modifycourse',
                    377:            curr_authtype => $curr_authtype,
                    378:            curr_autharg => $enrollvar{'autharg'} 
1.1       raeburn   379: 	);
1.32      raeburn   380:     my (%authform,$authenitems);
                    381:     $authform{'krb'} = &Apache::loncommon::authform_kerberos(%param);
                    382:     $authform{'int'} = &Apache::loncommon::authform_internal(%param);
                    383:     $authform{'loc'} = &Apache::loncommon::authform_local(%param);
                    384:     foreach my $item ('krb','int','loc') {
                    385:         if ($authform{$item} ne '') {
                    386:             $authenitems .= $authform{$item}.'<br />';
                    387:         }
                    388:     } 
1.1       raeburn   389:     if ($numlocalcc == 0) {
1.2       raeburn   390:         $ownertable = $lt{'nocc'};
1.1       raeburn   391:     }
1.2       raeburn   392: 
1.1       raeburn   393:     if ($numlocalcc > 0) {
                    394:         @local_ccs = sort @local_ccs;
                    395:         $ownertable = qq(
                    396:             <input type="hidden" name="numlocalcc" value="$numlocalcc" />
                    397:             <table>
                    398:              <tr>
1.28      raeburn   399:                <td>$lt{'tabl'} - $cdom ($domdesc). $lt{'usrd'}
1.1       raeburn   400:               </td>
                    401:              </tr>
                    402:              <tr><td>&nbsp;</td></tr>
                    403:              <tr>
1.28      raeburn   404:               <td>).
                    405:             &Apache::loncommon::start_data_table()."\n".
                    406:             &Apache::loncommon::start_data_table_header_row()."\n".
                    407:                        "<th>$lt{'ownr'}</th>\n".
                    408:                        "<th>$lt{'name'}</th>\n".
                    409:                        "<th>$lt{'unme'}</th>\n".
                    410:                        "<th>$lt{'stus'}</th>\n".
                    411:             &Apache::loncommon::end_data_table_header_row()."\n";
                    412:         foreach my $cc (@local_ccs) {
                    413:             $ownertable .= &Apache::loncommon::start_data_table_row()."\n";
                    414:             if ($cc eq $enrollvar{'courseowner'}) {
                    415:                   $ownertable .= '<td><input type="radio" name="courseowner" value="'.$cc.'" checked="checked" /></td>'."\n";
1.1       raeburn   416:             } else {
1.28      raeburn   417:                 $ownertable .= '<td><input type="radio" name="courseowner" value="'.$cc.'" /></td>'."\n";
1.1       raeburn   418:             }
1.28      raeburn   419:             $ownertable .= 
                    420:                  '<td>'.$pname{$cc}.'</td>'."\n".
                    421:                  '<td>'.$cc.'</td>'."\n".
                    422:                  '<td>'.$cc_status{$cc}.' '.$lt{'ccor'}.'</td>'."\n".
                    423:                  &Apache::loncommon::end_data_table_row()."\n";
                    424:         }
                    425:         $ownertable .= &Apache::loncommon::end_data_table()."
1.1       raeburn   426:               </td>
                    427:              </tr>
                    428:             </table>";
                    429:     }
1.28      raeburn   430:     &print_header($r,$cdesc,$javascript_validations);
                    431:     my $type = $env{'form.type'};
1.29      raeburn   432:     if ($type eq '') {
                    433:         $type = 'Course';
                    434:     }
1.28      raeburn   435:     my $dctitle = &Apache::lonnet::plaintext('dc');
                    436:     my $cctitle = &Apache::lonnet::plaintext('cc',$type);
                    437:     my $mainheader = &mt('Course settings modifiable by [_1] only.',$dctitle);
                    438:     my $hidden_elements = &hidden_form_elements();
1.1       raeburn   439:     $r->print(<<ENDDOCUMENT);
1.35    ! raeburn   440: <form action="/adm/modifycourse" method="post" name="$env{'form.phase'}">
1.28      raeburn   441: <h3>$mainheader</h3>
1.1       raeburn   442: </p><p>
1.2       raeburn   443: <table width="100%" cellspacing="6" cellpadding="6">
                    444:  <tr>
1.32      raeburn   445:   <td colspan="2">Use the appropriate text boxes and radio buttons below to change some or all of the four automated enrollment settings that may only be changed by a Domain Coordinator.
1.2       raeburn   446:  </tr>
1.1       raeburn   447:  <tr>
                    448:   <td width="50%" valign="top">
1.2       raeburn   449:    <b>$lt{'ccod'}:</b>&nbsp;&nbsp;
1.1       raeburn   450:     <input type="text" size="10" name="coursecode" value="$enrollvar{'coursecode'}"/><br/><br/>
                    451:     $lt{'ccus'}
                    452:   </td>
                    453:   <td width="50%" valign="top" rowspan="2">
1.2       raeburn   454:    <b>$lt{'cown'}:</b><br/><br/>
                    455:    $ownertable
                    456:    <br/><br/>
1.1       raeburn   457:    $lt{'cous'}
                    458:   </td>
                    459:  </tr>
                    460:  <tr>
                    461:   <td width="50%" valign="top">
1.2       raeburn   462:    <b>$lt{'deam'}:</b><br/><br/>
1.32      raeburn   463:    $authenitems
1.2       raeburn   464:    <br/>
1.1       raeburn   465:    $lt{'deus'}.
                    466:    </td>
                    467:    <td width="50%">&nbsp;</td>
                    468:  </tr>
                    469: </table>
                    470: <table width="90%" cellpadding="5" cellspacing="0">
                    471:  <tr>
1.28      raeburn   472:   <td align="left">
                    473:    $hidden_elements
                    474:    <input type="button" onClick="javascript:changePage(this.form,'processparms');javascript:verify_message(this.form)" value="$lt{'gobt'}" />
1.1       raeburn   475:   </td>
                    476:  </tr>
                    477: </table>
                    478: </form>
                    479: <br/>
                    480: <br/>
                    481: ENDDOCUMENT
1.5       raeburn   482:     return;
1.1       raeburn   483: }
                    484: 
                    485: sub modify_course {
1.30      raeburn   486:     my ($r,$cdom,$cnum,$cdesc,$domdesc,$type) = @_;
1.28      raeburn   487:     my %longtype = &course_settings_descrip();
                    488:     my %settings = &Apache::lonnet::get('environment',['internal.courseowner','internal.coursecode','internal.authtype','internal.autharg','internal.sectionnums','internal.crosslistings','description'],$cdom,$cnum);
1.1       raeburn   489:     my %currattr = ();
                    490:     my %newattr = ();
                    491:     my %cenv = ();
                    492:     my $response;
                    493:     my $chgresponse;
                    494:     my $nochgresponse;
                    495:     my $warning;
                    496:     my $reply;
                    497:     my @changes = ();
                    498:     my @nochanges = ();
                    499:     my @sections = ();
                    500:     my @xlists = ();
                    501:     my $changecode = 0;
                    502:     my $changeowner = 0;
1.28      raeburn   503:     unless ($settings{'internal.sectionnums'} eq '') {
1.1       raeburn   504:         if ($settings{'internal.sectionnums'} =~ m/,/) {
                    505:             @sections = split/,/,$settings{'internal.sectionnums'};
                    506:         } else {
                    507:             $sections[0] = $settings{'internal.sectionnums'};
                    508:         }
                    509:     }
                    510:     unless ($settings{'internal.crosslistings'} eq'') {
                    511:         if ($settings{'internal.crosslistings'} =~ m/,/) {
                    512:             @xlists = split/,/,$settings{'internal.crosslistings'};
                    513:         } else {
                    514:             $xlists[0] = $settings{'internal.crosslistings'};
                    515:         }
                    516:     }
                    517: 
1.28      raeburn   518:     my @modifiable_params = &get_dc_settable();
                    519:     foreach my $param (@modifiable_params) {
                    520:         my $attr = 'internal.'.$param;
                    521:         $currattr{$param} = $settings{$attr};
1.1       raeburn   522:     }
                    523: 
                    524:     my $description = $settings{'description'};
                    525:     my %cenv = ();
                    526: 
1.16      albertel  527:     if ($env{'form.login'} eq 'krb') {
                    528:         $newattr{'authtype'} = $env{'form.login'};
                    529:         $newattr{'authtype'} .= $env{'form.krbver'};
                    530:         $newattr{'autharg'} = $env{'form.krbarg'};
                    531:     } elsif ($env{'form.login'} eq 'int') {
1.1       raeburn   532:         $newattr{'authtype'} ='internal';
1.16      albertel  533:         if ((defined($env{'form.intarg'})) && ($env{'form.intarg'})) {
                    534:             $newattr{'autharg'} = $env{'form.intarg'};
1.1       raeburn   535:         }
1.16      albertel  536:     } elsif ($env{'form.login'} eq 'loc') {
1.1       raeburn   537:         $newattr{'authtype'} = 'localauth';
1.16      albertel  538:         if ((defined($env{'form.locarg'})) && ($env{'form.locarg'})) {
                    539:             $newattr{'autharg'} = $env{'form.locarg'};
1.1       raeburn   540:         }
                    541:     }
                    542:     if ( $newattr{'authtype'}=~ /^krb/) {
                    543:         if ($newattr{'autharg'}  eq '') {
1.2       raeburn   544:             $warning = qq(<font color="red" size="+1">).
                    545: 	    &mt("As you did not include the default Kerberos domain to be used for authentication in this class, the institutional data used by the automated enrollment process must include the Kerberos domain for each new student").qq(</font></p>);
1.1       raeburn   546:         }
                    547:     }
                    548: 
1.16      albertel  549:     if ( exists($env{'form.courseowner'}) ) {
                    550:         $newattr{'courseowner'}=$env{'form.courseowner'};
1.14      raeburn   551:         unless ( $newattr{'courseowner'} eq $currattr{'courseowner'} ) {
                    552:             $changeowner = 1;
1.1       raeburn   553:         } 
                    554:     }
                    555: 													      
1.16      albertel  556:     if ( exists($env{'form.coursecode'}) ) {
                    557:         $newattr{'coursecode'}=$env{'form.coursecode'};
1.1       raeburn   558:         unless ( $newattr{'coursecode'} eq $currattr{'coursecode'} ) {
                    559:             $changecode = 1;
                    560:         }
                    561:     }
1.14      raeburn   562:     if ($changeowner == 1 || $changecode == 1) {
1.30      raeburn   563:         my $courseid_entry = &escape($cdom.'_'.$cnum).'='.&escape($description).':'.&escape($env{'form.coursecode'}).':'.&escape($env{'form.courseowner'}).':'.&escape($type);
1.33      raeburn   564:         my %courseid_entry = (
                    565:              $cdom.'_'.$cnum => {
1.34      raeburn   566:                                 description => $description,
                    567:                                 inst_code   => $env{'form.coursecode'},
                    568:                                 owner       => $env{'form.courseowner'},
                    569:                                 type        => $type,
1.33      raeburn   570:                                },
                    571:         );
                    572:         &Apache::lonnet::courseidput($cdom,\%courseid_entry,
1.34      raeburn   573:                                      &Apache::lonnet::homeserver($cnum,$cdom),'notime');
1.14      raeburn   574:     }
1.28      raeburn   575:     foreach my $param (@modifiable_params) {
                    576:         if ($currattr{$param} eq $newattr{$param}) {
                    577:             push(@nochanges,$param);
1.1       raeburn   578:         } else {
1.28      raeburn   579:             my $attr = 'internal.'.$param;
                    580:             $cenv{$attr} = $newattr{$param};
                    581:             push(@changes,$param);
1.1       raeburn   582:         }
                    583:     }
                    584:     if (@changes > 0) {
1.2       raeburn   585:         $chgresponse = &mt("The following automated enrollment parameters have been changed:<br/><ul>");
1.1       raeburn   586:     }
                    587:     if (@nochanges > 0) { 
1.2       raeburn   588:         $nochgresponse = &mt("The following automated enrollment parameters remain unchanged:<br/><ul>");
1.1       raeburn   589:     }
1.33      raeburn   590:     if (@changes > 0) {
1.28      raeburn   591:         my $putreply = &Apache::lonnet::put('environment',\%cenv,$cdom,$cnum);
1.1       raeburn   592:         if ($putreply !~ /^ok$/) {
1.33      raeburn   593:             $response = &mt("There was a problem processing your requested changes. The automated enrollment settings for this course have been left unchanged.<br/>").&mt('Error: ').$putreply;
1.1       raeburn   594:         } else {
1.28      raeburn   595:             foreach my $attr (@modifiable_params) {
1.1       raeburn   596:                 if (grep/^$attr$/,@changes) {
1.28      raeburn   597: 	            $chgresponse .= "<li>$longtype{$attr} ".&mt("now set to \"").$newattr{$attr}."\".</li>";
1.1       raeburn   598:                 } else {
1.28      raeburn   599: 	            $nochgresponse .= "<li>$longtype{$attr} ".&mt("still set to \"").$currattr{$attr}."\".</li>";
1.1       raeburn   600:                 }
                    601:             }
                    602:             if ($changecode || $changeowner) {
                    603:                 if ( $newattr{'courseowner'} eq '') {
1.2       raeburn   604: 	            $warning .= &mt("There is no owner associated with this LON-CAPA course.  If automated enrollment in LON-CAPA courses at your institution requires validation of course owners, automated enrollment will fail for this course.<br/>");
1.1       raeburn   605:                 } else {
                    606: 	            if (@sections > 0) {
1.2       raeburn   607:                         if ($changecode) {
                    608: 	                    foreach my $sec (@sections) {
                    609: 		                if ($sec =~ m/^(.+):/) {
1.8       raeburn   610: 		                    my $inst_course_id = $newattr{'coursecode'}.$1;
1.28      raeburn   611:                                     my $course_check = &Apache::lonnet::auto_validate_courseID($cnum,$cdom,$inst_course_id);
1.7       raeburn   612: 			            if ($course_check eq 'ok') {
1.28      raeburn   613:                                         my $outcome = &Apache::lonnet::auto_new_course($cnum,$cdom,$inst_course_id,$newattr{'courseowner'});
1.1       raeburn   614: 			                unless ($outcome eq 'ok') { 
1.2       raeburn   615: 				            $warning .= &mt("If automatic enrollment is enabled for LON-CAPA course: ").$description.&mt(", automated enrollment may fail for ").$newattr{'coursecode'}.&mt(" - section $1 for the following reason: $outcome.<br/>");
1.1       raeburn   616: 			                }
                    617: 			            } else {
1.2       raeburn   618: 			                $warning .= &mt("If automatic enrollment is enabled for LON-CAPA course: ").$description.&mt(", automated enrollment may fail for ").$newattr{'coursecode'}.&mt(" - section $1 for the following reason: $course_check.<br/>");
1.1       raeburn   619: 			            }
                    620: 		                } else {
1.2       raeburn   621: 			            $warning .= &mt("If automatic enrollment is enabled for LON-CAPA course: ").$description.&mt(", automated enrollment may fail for ").$newattr{'coursecode'}.&mt(" - section $sec because this is not a valid section entry.<br/>");
1.1       raeburn   622: 		                }
                    623: 		            }
1.4       raeburn   624: 	                } elsif ($changeowner) {
                    625:                             foreach my $sec (@sections) {
                    626:                                 if ($sec =~ m/^(.+):/) {
1.8       raeburn   627:                                     my $inst_course_id = $newattr{'coursecode'}.$1;
1.28      raeburn   628:                                     my $outcome = &Apache::lonnet::auto_new_course($cnum,$cdom,$inst_course_id,$newattr{'courseowner'});
1.4       raeburn   629:                                     unless ($outcome eq 'ok') {
                    630:                                         $warning .= &mt("If automatic enrollment is enabled for LON-CAPA course: ").$description.&mt(", automated enrollment may fail for ").$newattr{'coursecode'}.&mt(" - section $1 for the following reason: $outcome.<br/>");
                    631:                                     }
                    632:                                 } else {
                    633:                                     $warning .= &mt("If automatic enrollment is enabled for LON-CAPA course: ").$description.&mt(", automated enrollment may fail for ").$newattr{'coursecode'}.&mt(" - section $sec because this is not a valid section entry.<br/>");
                    634:                                 }
                    635:                             }
                    636:                         }
1.1       raeburn   637: 	            } else {
1.2       raeburn   638: 	                $warning .= &mt("As no section numbers are currently listed for LON-CAPA course: ").$description.&mt(", automated enrollment will not occur for any sections of coursecode: ").$newattr{'coursecode'}."<br/>";
1.1       raeburn   639: 	            }
                    640: 	            if ( (@xlists > 0) && ($changeowner) ) {
                    641: 	                foreach my $xlist (@xlists) {
                    642: 		            if ($xlist =~ m/^(.+):/) {
1.28      raeburn   643:                                 my $outcome = &Apache::lonnet::auto_new_course($cnum,$cdom,$1,$newattr{'courseowner'});
1.1       raeburn   644: 		                unless ($outcome eq 'ok') {
1.2       raeburn   645: 			            $warning .= &mt("If automatic enrollment is enabled for LON-CAPA course: ").$description.&mt(", automated enrollment may fail for crosslisted class: ").$1.&mt(" for the following reason: $outcome.<br/>");
1.1       raeburn   646: 		                }
1.28      raeburn   647: 		            }
1.1       raeburn   648: 	                }
                    649: 	            }
                    650:                 }
                    651:             }
                    652:         }
1.2       raeburn   653:     } else {
1.28      raeburn   654:         foreach my $attr (@modifiable_params) {
                    655:             $nochgresponse .= "<li>$longtype{$attr} ".&mt("still set to")." \"".$currattr{$attr}."\".</li>";
1.2       raeburn   656:         }
1.1       raeburn   657:     }
                    658: 
                    659:     if (@changes > 0) {
                    660:         $chgresponse .= "</ul><br/><br/>";
                    661:     }
                    662:     if (@nochanges > 0) {
                    663:         $nochgresponse .=  "</ul><br/><br/>";
                    664:     }
                    665:     unless ($warning eq '') {
1.2       raeburn   666:         $warning = &mt("The following warning messages were generated as a result of applying the changes you specified to course settings that can affect the automated enrollment process:<br/><br/>").$warning;
1.1       raeburn   667:     }
                    668:     if ($response eq '') {
                    669:         $reply = $chgresponse.$nochgresponse.$warning;
                    670:     } else {
                    671:         $reply = $response;
                    672:     }
1.28      raeburn   673:     &print_header($r,$cdesc);
                    674:     $reply = '<h3>'.
                    675:               &mt('Result of Changes to Automated Enrollment Settings.').
                    676:              '</h3>'."\n".
                    677:              '<table><tr><td>'.$reply.'</td></tr></table>'.
                    678:              '<form action="/adm/modifycourse" method="post" name="processparms">'.
                    679:              &hidden_form_elements().
                    680:              '<a href="javascript:changePage(document.processparms,'."'menu'".')">'.&mt('Back to options page').'</a>
                    681:              </form>';
1.3       raeburn   682:     $r->print($reply);
1.28      raeburn   683:     return;
                    684: }
                    685: 
                    686: sub modify_quota {
                    687:     my ($r,$cdom,$cnum,$cdesc,$domdesc) = @_;
                    688:     &print_header($r,$cdesc);
                    689: 
                    690:     my %lt = &Apache::lonlocal::texthash(
                    691:                                          'back' => 'Back to options page',
                    692:                                         );
                    693:     $r->print('
                    694: <form action="/adm/modifycourse" method="post" name="processquota">
                    695: <h3>'.&mt('Disk space for storage of group portfolio files for [_1]',$cdesc).
                    696:              '</h3>');
                    697:     my %oldsettings = &Apache::lonnet::get('environment',['internal.coursequota'],$cdom,$cnum);
                    698:     my $defaultquota = 20;
                    699:     if ($env{'form.coursequota'} ne '') {
                    700:         my $newquota = $env{'form.coursequota'};
                    701:         if ($newquota =~ /^\s*(\d+\.?\d*|\.\d+)\s*$/) {
                    702:             $newquota = $1;
                    703:             if ($oldsettings{'internal.coursequota'} eq $env{'form.coursequota'}) {
                    704:                 $r->print(&mt('The disk space allocated for group portfolio files remains unchanged as ').$env{'form.coursequota'}.' Mb');
                    705:             } else {
                    706:                 my %cenv = (
                    707:                            'internal.coursequota' => $env{'form.coursequota'},
                    708:                            );
                    709:                 my $putreply = &Apache::lonnet::put('environment',\%cenv,$cdom,
                    710:                                                     $cnum);
                    711:                 if (($oldsettings{'internal.coursequota'} eq '') && 
                    712:                     ($env{'form.coursequota'} == $defaultquota)) {
                    713:                     $r->print(&mt('The disk space allocated for group portfolio files in this course is the default quota for this domain:').' '.$defaultquota.' Mb');
                    714:                 } else {
                    715:                     if ($putreply eq 'ok') {
                    716:                         my %updatedsettings = &Apache::lonnet::get('environment',['internal.coursequota'],$cdom,$cnum);
                    717:                         $r->print(&mt('The disk space allocated for group portfolio files is now:').' '.$updatedsettings{'internal.coursequota'}.' Mb.');
                    718:                         my $usage = &Apache::longroup::sum_quotas($cdom.'_'.$cnum);
                    719:                         if ($usage >= $updatedsettings{'internal.coursequota'}) {
                    720:                             my $newoverquota;
                    721:                             if ($usage < $oldsettings{'internal.coursequota'}) {
                    722:                                 $newoverquota = 'now';
                    723:                             }
                    724:                             $r->print('<br /><br />'.
                    725:       &mt('Disk usage [_1] exceeds the quota for this course.',$newoverquota).' '.
                    726:       &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.'));
                    727:                         }
                    728:                     } else {
                    729:                         $r->print(&mt('There was an error'));
                    730:                     }
                    731:                 }
                    732:             }
                    733:         } else {
                    734:             $r->print(&mt('The new quota requested contained invalid characters, so the quota is unchanged.'));
                    735:         }
                    736:     }
                    737:     $r->print(qq|<br /><br />
                    738: <a href="javascript:changePage(document.processquota,'menu')">$lt{'back'}</a>|);
                    739:     $r->print(&hidden_form_elements().'</form>');
                    740:     return;
1.1       raeburn   741: }
                    742: 
                    743: sub print_header {
1.28      raeburn   744:     my ($r,$cdesc,$javascript_validations) = @_;
                    745:     my $phase = "start";
                    746:     if ( exists($env{'form.phase'}) ) {
                    747:         $phase = $env{'form.phase'};
                    748:     }
                    749:     my $js = qq|
                    750: <script type="text/javascript">
                    751: function changePage(formname,newphase) {
                    752:     formname.phase.value = newphase;
                    753:     if (newphase == 'processparms') {
                    754:         return;
1.1       raeburn   755:     }
1.28      raeburn   756:     formname.submit();
                    757: }
                    758: </script>
                    759: |;
                    760:     if ($phase eq 'setparms') {
                    761: 	$js .= qq|
                    762: <script  type="text/javascript">
                    763: $javascript_validations
                    764: </script>
                    765: |;
                    766:     } elsif ($phase eq 'courselist') {
                    767:         $js .= qq|
                    768: <script type="text/javascript">
                    769: function gochoose(cname,cdom,cdesc) {
                    770:     document.courselist.pickedcourse.value = cdom+'_'+cname;
                    771:     document.courselist.submit();
                    772: }
                    773: </script>
                    774: |;
                    775:     } elsif ($phase eq 'setquota') {
                    776:         $js .= <<'ENDSCRIPT';
                    777: <script type="text/javascript">
                    778: function verify_quota(formname) {
                    779:     var newquota = formname.coursequota.value; 
                    780:     var num_reg = /^\s*(\d+\.?\d*|\.\d+)\s*$/;
                    781:     if (num_reg.test(newquota)) {
                    782:         changePage(formname,'processquota');
1.1       raeburn   783:     } else {
1.28      raeburn   784:         alert("The quota you entered contained invalid characters.\nYou must enter a number");
1.1       raeburn   785:     }
1.28      raeburn   786:     return;
                    787: }
                    788: </script>
                    789: ENDSCRIPT
1.1       raeburn   790:     }
1.23      albertel  791:     $r->print(&Apache::loncommon::start_page('View/Modify Course Settings',
                    792: 					     $js));
1.28      raeburn   793:     my $bread_text = "View/Modify Courses";
                    794:     if ($cdesc ne '') {
                    795:         $bread_text = "Course Settings: $cdesc"; 
                    796:     } 
                    797:     $r->print(&Apache::lonhtmlcommon::breadcrumbs($bread_text));
1.5       raeburn   798:     return;
1.1       raeburn   799: }
                    800: 
                    801: sub print_footer {
1.23      albertel  802:     my ($r) = @_;
                    803:     $r->print('<br />'.&Apache::loncommon::end_page());
1.5       raeburn   804:     return;
1.3       raeburn   805: }
                    806: 
                    807: sub check_course {
1.28      raeburn   808:     my ($r,$dom,$domdesc) = @_;
                    809:     my ($ok_course,$description,$instcode,$owner);
1.35    ! raeburn   810:     my %args = (
        !           811:                  one_time => 1,
        !           812:                );
        !           813:     my %coursehash = 
        !           814:         &Apache::lonnet::coursedescription($env{'form.pickedcourse'},\%args);
        !           815:     my $cnum = $coursehash{'num'};
        !           816:     my $cdom = $coursehash{'domain'};
        !           817:     if ($cdom eq $dom) {
        !           818:         my $description;
        !           819:         my %courseIDs = &Apache::lonnet::courseiddump($cdom,'.',1,'.','.',
        !           820:                                            $cnum,undef,undef,'.');
        !           821:         if (keys(%courseIDs) > 0) {
        !           822:             $ok_course = 'ok';
        !           823:             my ($instcode,$owner);
        !           824:             if (ref($courseIDs{$cdom.'_'.$cnum}) eq 'HASH') {
        !           825:                 $description = $courseIDs{$cdom.'_'.$cnum}{'description'};
        !           826:                 $instcode = $courseIDs{$cdom.'_'.$cnum}{'inst_code'};
        !           827:                 $owner = $courseIDs{$cdom.'_'.$cnum}{'owner'};          
        !           828:             } else {
        !           829:                 ($description,$instcode,$owner) = 
        !           830:                                    split(/:/,$courseIDs{$cdom.'_'.$cnum});
        !           831:             }
        !           832:             $description = &unescape($description);
        !           833:             $instcode = &unescape($instcode);
        !           834:             if ($instcode) {
        !           835:                 $description .= " ($instcode)";
1.5       raeburn   836:             }
1.35    ! raeburn   837:             return ($ok_course,$description);
1.3       raeburn   838:         }
                    839:     }
1.1       raeburn   840: }
                    841: 
1.28      raeburn   842: sub course_settings_descrip {
                    843:     my %longtype = &Apache::lonlocal::texthash(
                    844:                       'authtype' => 'Default authentication method',
                    845:                       'autharg'  => 'Default authentication parameter',
                    846:                       'autoadds' => 'Automated adds',
                    847:                       'autodrops' => 'Automated drops',
                    848:                       'autostart' => 'Date of first automated enrollment',
                    849:                       'autoend' => 'Date of last automated enrollment',
                    850:                       'default_enrollment_start_date' => 'Date of first student access',
                    851:                       'default_enrollment_end_date' => 'Date of last student access',
                    852:                       'coursecode' => 'Official course code',
                    853:                       'courseowner' => "Username:domain of course owner",
                    854:                       'notifylist' => 'Course Coordinators to be notified of enrollment changes',
                    855:                       'sectionnums' => 'Course section number(:LON-CAPA section)',
                    856:                       'crosslistings' => 'Crosslisted class(:LON-CAPA section)',
                    857:                    );
                    858:     return %longtype;
                    859: }
                    860: 
                    861: sub hidden_form_elements {
                    862:     my $hidden_elements = 
                    863:       &Apache::lonhtmlcommon::echo_form_input(['gosearch','coursecode',
                    864:                                                'numlocalcc','courseowner',
                    865:                                                'login','coursequota','intarg',                                               'locarg','krbarg','krbver']);
                    866:     return $hidden_elements;
                    867: }
1.1       raeburn   868: 
                    869: sub handler {
                    870:     my $r = shift;
                    871:     if ($r->header_only) {
                    872:         &Apache::loncommon::content_type($r,'text/html');
                    873:         $r->send_http_header;
                    874:         return OK;
                    875:     }
1.28      raeburn   876:     my $dom = $env{'request.role.domain'};
1.31      albertel  877:     my $domdesc = &Apache::lonnet::domain($dom,'description');
1.28      raeburn   878:     if (&Apache::lonnet::allowed('ccc',$dom)) {
1.1       raeburn   879:         &Apache::loncommon::content_type($r,'text/html');
                    880:         $r->send_http_header;
                    881: 
1.28      raeburn   882:         &Apache::lonhtmlcommon::clear_breadcrumbs();
                    883: 
                    884:         my $phase = $env{'form.phase'};
                    885:         &Apache::lonhtmlcommon::add_breadcrumb
                    886:             ({href=>"/adm/modifycourse",
                    887:               text=>"Course search"});
                    888:         if ($phase eq '') {
                    889:             &print_course_search_page($r,$dom,$domdesc);
1.1       raeburn   890:         } else {
1.28      raeburn   891:             &Apache::lonhtmlcommon::add_breadcrumb
                    892:             ({href=>"javascript:changePage(document.$phase,'courselist')",
                    893:               text=>"Choose a course"});
                    894:             if ($phase eq 'courselist') {
                    895:                 &print_course_selection_page($r,$dom,$domdesc);
                    896:             } else {
                    897:                 &Apache::lonhtmlcommon::add_breadcrumb
                    898:                 ({href=>"javascript:changePage(document.$phase,'menu')",
                    899:                   text=>"Pick action"});
                    900:                 my ($checked,$cdesc) = &check_course($r,$dom,$domdesc);
                    901:                 my $type = $env{'form.type'};
1.29      raeburn   902:                 if ($type eq '') {
                    903:                     $type = 'Course';
                    904:                 }
1.28      raeburn   905:                 if ($checked eq 'ok') {
                    906:                     if ($phase eq 'menu') {
                    907:                         &print_modification_menu($r,$cdesc);
                    908:                     } else {
                    909:                         my ($cdom,$cnum) = split(/_/,$env{'form.pickedcourse'});
                    910:                         if ($phase eq 'setquota') {
                    911:                             &Apache::lonhtmlcommon::add_breadcrumb
                    912:                             ({href=>"javascript:changePage(document.$phase,'$phase')",
                    913:                               text=>"Set quota"});
                    914:                             &print_setquota($r,$cdom,$cnum,$cdesc,$type)
                    915:                         } elsif ($phase eq 'processquota') { 
                    916:                             &Apache::lonhtmlcommon::add_breadcrumb
                    917:                             ({href=>"javascript:changePage(document.$phase,'setquota')",
                    918:                               text=>"Set quota"});
                    919:                             &Apache::lonhtmlcommon::add_breadcrumb
                    920:                             ({href=>"javascript:changePage(document.$phase,'$phase')",
                    921:                               text=>"Result"});
                    922:                             &modify_quota($r,$cdom,$cnum,$cdesc,$domdesc);
                    923:                         } elsif ($phase eq 'viewparms') {  
                    924:                             &Apache::lonhtmlcommon::add_breadcrumb
                    925:                             ({href=>"javascript:changePage(document.$phase,'viewparms')",
                    926:                               text=>"Display settings"});
                    927:                             &print_settings_display($r,$cdom,$cnum,$cdesc,$type);
                    928:                         } elsif ($phase eq 'setparms') {
                    929:                             &Apache::lonhtmlcommon::add_breadcrumb
                    930:                             ({href=>"javascript:changePage(document.$phase,'$phase')",
                    931:                               text=>"Change settings"});
                    932:                             &print_course_modification_page($r,$cdom,$cnum,$cdesc,$domdesc);
                    933:                         } elsif ($phase eq 'processparms') {
                    934:                             &Apache::lonhtmlcommon::add_breadcrumb
                    935:                             ({href=>"javascript:changePage(document.$phase,'setparms')",
                    936:                               text=>"Change settings"});
                    937:                             &Apache::lonhtmlcommon::add_breadcrumb
                    938:                             ({href=>"javascript:changePage(document.$phase,'$phase')",
                    939:                               text=>"Result"});
1.30      raeburn   940:                             &modify_course($r,$cdom,$cnum,$cdesc,$domdesc,$type);
1.28      raeburn   941:                         }
                    942:                     }
                    943:                 } else {
1.33      raeburn   944:                     $r->print('<span class="LC_error">'.&mt('The course you selected is not a valid course in this domain')." ($domdesc)".'</span>'); 
1.28      raeburn   945:                 }
                    946:             }
1.1       raeburn   947:         }
1.28      raeburn   948:         &print_footer($r);
1.1       raeburn   949:     } else {
1.16      albertel  950:         $env{'user.error.msg'}=
1.2       raeburn   951:         "/adm/modifycourse:ccc:0:0:Cannot modify course settings";
1.1       raeburn   952:         return HTTP_NOT_ACCEPTABLE;
                    953:     }
                    954:     return OK;
                    955: }
                    956: 
                    957: 1;
                    958: __END__

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