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

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.28    ! raeburn     4: # $Id: lonmodifycourse.pm,v 1.27 2006/07/18 21:52:01 albertel 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.28    ! raeburn    70:             } elsif ($type eq "sectionums") {
        !            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'};
        !           141:     my $action = '/adm/modifycourse';
        !           142:     my $dctitle = &Apache::lonnet::plaintext('dc');
        !           143:     $r->print(&mt('Revise your search criteria for this domain').' ('.$domdesc.').<br /><br />');
        !           144:     $r->print(&Apache::lonpickcourse::build_filters($filterlist,$type,
        !           145:                                        undef,undef,\%filter,$action));
        !           146:     $filter{'domainfilter'} = $dom;
        !           147:     my %courses = &Apache::lonpickcourse::search_courses($r,$type,0,
        !           148:                                                          \%filter);
        !           149:     if (keys(%courses) > 0) {
        !           150:         $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 />');
        !           151:     }
        !           152: 
        !           153:     &Apache::lonpickcourse::display_matched_courses($r,$type,0,$action,
        !           154:                                                     %courses);
1.1       raeburn   155:     return;
                    156: }
                    157: 
1.28    ! raeburn   158: sub print_modification_menu {
        !           159:     my ($r,$cdesc) = @_;
        !           160:     &print_header($r,$cdesc);
        !           161:     my @menu =
        !           162:         (
        !           163:           { text  => 'Modify quota for group portfolio files',
        !           164:             phase => 'setquota',
        !           165:             },
        !           166:           { text  => 'Display current settings for automated enrollment',
        !           167:             phase => 'viewparms',
        !           168:             },
        !           169:           { text => 'Modify institutional code, course owner and/or default authentication',
        !           170:             phase => 'setparms',
        !           171:             }
        !           172:          );
        !           173:     my $menu_html = '<h3>'.&mt('View/Modify settings for: ').$cdesc.'</h3>'."\n".
        !           174:                     '<form name="menu" method="post" action="/adm/modifycourse" />'."\n".
        !           175:                      &hidden_form_elements();
        !           176:     foreach my $menu_item (@menu) {
        !           177:         $menu_html.='<p>';
        !           178:         $menu_html.='<font size="+1">';
        !           179:         $menu_html.=
        !           180:                 qq|<a href="javascript:changePage(document.menu,'$menu_item->{'phase'}')">|;
        !           181:         $menu_html.= &mt($menu_item->{'text'}).'</a></font>';
        !           182:         $menu_html.='</p>';
1.3       raeburn   183:     }
1.28    ! raeburn   184:     
        !           185:     $r->print($menu_html);
        !           186:     return;
        !           187: }
        !           188: 
        !           189: sub print_settings_display {
        !           190:     my ($r,$cdom,$cnum,$cdesc,$type) = @_;
        !           191:     my %enrollvar = &get_enrollment_settings($cdom,$cnum);
        !           192:     my %longtype = &course_settings_descrip();
        !           193:     my %lt = &Apache::lonlocal::texthash(
        !           194:             'cset' => "Course setting",
        !           195:             'valu' => "Current value",
        !           196:             'caes' => 'Current automated enrollment settings for ',
        !           197:             'cour' => "Course settings that control automated enrollment in this LON-CAPA course are currently:",
        !           198:             '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:",
        !           199:             'dcon' => "Modifiable by DC only",
        !           200:             'back' => "Back to options page",
        !           201:     );
        !           202: 
        !           203:     my @bgcolors = ('#eeeeee','#cccccc');
        !           204:     my $cctitle = &Apache::lonnet::plaintext('cc',$type);
        !           205:     my $dctitle = &Apache::lonnet::plaintext('dc');
        !           206:     my @modifiable_params = &get_dc_settable();
        !           207: 
        !           208:     my $disp_table = &Apache::loncommon::start_data_table()."\n".
        !           209:                      &Apache::loncommon::start_data_table_header_row()."\n".
        !           210:                      "<th>$lt{'cset'}</th>\n".
        !           211:                      "<th>$lt{'valu'}</th>\n".
        !           212:                      "<th>$lt{'dcon'}</th>\n".
        !           213:                      &Apache::loncommon::end_data_table_header_row()."\n";
        !           214:     foreach my $key (sort(keys(%enrollvar))) {
        !           215:         $disp_table .= &Apache::loncommon::start_data_table_row()."\n".
        !           216:                  "<td>$longtype{$key}</td>\n".
        !           217:                  "<td>$enrollvar{$key}</td>\n";
        !           218:         if (grep(/^\Q$key\E$/,@modifiable_params)) {
        !           219:             $disp_table .= '<td>'.&mt('Yes').'</td>'."\n"; 
        !           220:         } else {
        !           221:             $disp_table .= '<td>'.&mt('No').'</td>'."\n";
        !           222:         }
        !           223:         $disp_table .= &Apache::loncommon::end_data_table_row()."\n";
1.3       raeburn   224:     }
1.28    ! raeburn   225:     $disp_table .= &Apache::loncommon::end_data_table()."\n";
        !           226:     &print_header($r,$cdesc);
        !           227:     $r->print('
        !           228: <h3>'.$lt{'caes'}.'</h3>
        !           229: <p>
        !           230: <form action="/adm/modifycourse" method="post" name="viewparms">
        !           231: '.$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>
        !           232: </p><p>
        !           233: '.$lt{'cour'}.'
        !           234: </p><p>
        !           235: '.$disp_table.'
        !           236: </p><p>
        !           237: <a href="javascript:changePage(document.viewparms,'."'menu'".')">'.$lt{'back'}.'</a>&nbsp;&nbsp;&nbsp;&nbsp;
        !           238: <a href="javascript:changePage(document.viewparms,'."'setparms'".')">'.&mt('Modify [_1]-only settings',$dctitle).'</a>'."\n".
        !           239: &hidden_form_elements().    
        !           240: '</form>');
        !           241: }
1.3       raeburn   242: 
1.28    ! raeburn   243: sub print_setquota {
        !           244:     my ($r,$cdom,$cnum,$cdesc,$type) = @_;
        !           245:     my $dctitle = &Apache::lonnet::plaintext('dc');
        !           246:     my $cctitle = &Apache::lonnet::plaintext('cc',$type);
        !           247:     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);
        !           248:     my %lt = &Apache::lonlocal::texthash(
        !           249:                 'cquo' => 'Disk space for storage of group portfolio files',
        !           250:                 'gpqu' => 'Course portfolio files disk space',
        !           251:                 'each' => 'Each course group can be assigned a quota for portfolio files uploaded to the group.',
        !           252:                 'modi' => 'Modify quota',
        !           253:                 'back' => "Back to options page",
        !           254:     );
        !           255:     my %settings = &Apache::lonnet::get('environment',['internal.coursequota'],$cdom,$cnum);
        !           256:     my $coursequota = $settings{'internal.coursequota'};
        !           257:     if ($coursequota eq '') {
        !           258:         $coursequota = 20;
1.3       raeburn   259:     }
1.28    ! raeburn   260:     &print_header($r,$cdesc);
        !           261:     my $hidden_elements = &hidden_form_elements();
        !           262:     $r->print(<<ENDDOCUMENT);
        !           263: <form action="/adm/modifycourse" method="post" name="setquota">
        !           264: <h3>$lt{'cquo'}.</h3>
        !           265: <p>
        !           266: $lt{'each'}<br />
        !           267: $subdiv
        !           268: </p><p>
        !           269: $lt{'gpqu'}: <input type="text" size="4" name="coursequota" value="$coursequota" /> Mb &nbsp;&nbsp;&nbsp;&nbsp;
        !           270: <input type="button" onClick="javascript:verify_quota(this.form)" value="$lt{'modi'}" />
        !           271: </p>
        !           272: $hidden_elements
        !           273: <a href="javascript:changePage(document.setquota,'menu')">$lt{'back'}</a>
        !           274: </form>
        !           275: ENDDOCUMENT
        !           276:     return;
        !           277: }
1.3       raeburn   278: 
1.28    ! raeburn   279: sub print_course_modification_page {
        !           280:     my ($r,$cdom,$cnum,$cdesc,$domdesc) = @_;
        !           281:     my %longtype = &course_settings_descrip();
        !           282:     my %enrollvar = &get_enrollment_settings($cdom,$cnum);
1.1       raeburn   283:     my $ownertable;
1.2       raeburn   284:     my %lt=&Apache::lonlocal::texthash(
                    285:             'actv' => "Active",
                    286:             'inac' => "Inactive",
                    287:             'ccor' => "Course Coordinator",
                    288:             'noen' => "No end date",
                    289:             'ownr' => "Owner",
                    290:             'name' => "Name",
1.26      raeburn   291:             'unme' => "Username:Domain",
1.2       raeburn   292:             'stus' => "Status",
1.28    ! raeburn   293:             'cquo' => "Disk space for storage of group portfolio files",
        !           294:             'gpqu' => "Course portfolio files disk space",
        !           295:             'each' => "Each course group can be assigned a quota for portfolio files uploaded to the group.",
1.2       raeburn   296:             '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 ",
                    297:             'aenm' => "Automated Enrollment Manager",
                    298:             'andb' => " and (b) settings that may only be modified by a Domain Coordinator via this page.",
                    299:             'caes' => 'Current automated enrollment settings',
                    300:             'cour' => "Course settings that control automated enrollment in this LON-CAPA course
                    301: are currently:",
                    302:             '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.",    
                    303:             'ccus' => "A course coordinator can use the 'Automated Enrollment Manager' to change
                    304: 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).",
                    305:             'ccod' => "Course Code",
                    306:             '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.",
                    307:             'cown' => "Course Owner",
                    308:             '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.",
                    309:             'tabl' => 'The table below contains a list of active course coordinators in this course, who are from this domain',
                    310:             'usrd' => 'Use the radio buttons to select a different course owner.',
                    311:             'deam' => "Default Authentication method",
                    312:             '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.",
                    313:             'gobt' => "Modify settings",
                    314:     );
1.28    ! raeburn   315:     my @bgcolors = ('#eeeeee','#cccccc');
1.2       raeburn   316: 
1.28    ! raeburn   317:     my @coursepersonnel = &Apache::lonnet::getkeys('nohist_userroles',$cdom,$cnum);
1.1       raeburn   318:     my @local_ccs = ();
                    319:     my %cc_status = ();
                    320:     my %pname = ();
                    321:     my $active_cc;
1.26      raeburn   322:     foreach my $person (@coursepersonnel) {
                    323:         my ($role,$user) = split(/:/,$person,2);
                    324:         $user =~ s/:$//;
                    325:         if (($role eq 'cc') && ($user ne ''))  {
                    326:             if (!grep(/^\Q$user\E$/,@local_ccs)) {
                    327:                 my ($ccname,$ccdom) = split(/:/,$user);
                    328:                 $active_cc = 
1.28    ! raeburn   329:                    &Apache::loncommon::check_user_status($ccdom,$ccname,$cdom,
        !           330:                                                          $cnum,'cc');
1.19      raeburn   331:                 if ($active_cc eq 'active') {
1.26      raeburn   332:                     push(@local_ccs,$user);
                    333:                     $pname{$user} = &Apache::loncommon::plainname($ccname,$ccdom);
                    334:                     $cc_status{$user} = $lt{'actv'};
1.1       raeburn   335:                 }
                    336:             }
                    337:         }
                    338:     }
1.26      raeburn   339:     if ( (!grep(/^$enrollvar{'courseowner'}$/,@local_ccs)) && 
                    340:              ($enrollvar{'courseowner'} ne '') )  {
                    341:         my ($owneruname,$ownerdom) = split(/:/,$enrollvar{'courseowner'});
                    342:         push(@local_ccs,$enrollvar{'courseowner'});
                    343:         $pname{$enrollvar{'courseowner'}} = 
                    344:                          &Apache::loncommon::plainname($owneruname,$ownerdom);
                    345:         $active_cc = &Apache::loncommon::check_user_status($ownerdom,$owneruname,
1.28    ! raeburn   346:                                                            $cdom,$cnum,'cc');
1.19      raeburn   347:         if ($active_cc eq 'active') {
1.2       raeburn   348:             $cc_status{$enrollvar{'courseowner'}} = $lt{'actv'};
1.1       raeburn   349:         } else {
1.2       raeburn   350:             $cc_status{$enrollvar{'courseowner'}} = $lt{'inac'};
1.1       raeburn   351:         }
                    352:     }
                    353:     my $numlocalcc = @local_ccs;
1.24      albertel  354: 
1.2       raeburn   355:     my $helplink=&Apache::loncommon::help_open_topic('Modify_Course',&mt("Help on Modifying Courses"));
1.28    ! raeburn   356:     my ($krbdef,$krbdefdom)=&Apache::loncommon::get_kerberos_defaults($cdom);
1.2       raeburn   357:     my $curr_authtype = '';
                    358:     my $curr_authfield = '';
                    359:     if ($enrollvar{'authtype'} =~ /^krb/) {
                    360:         $curr_authtype = 'krb';
                    361:     } elsif ($enrollvar{'authtype'} eq 'internal' ) {
                    362:         $curr_authtype = 'int';
                    363:     } elsif ($enrollvar{'authtype'} eq 'localauth' ) {
                    364:         $curr_authtype = 'loc';
                    365:     }
                    366:     unless ($curr_authtype eq '') {
                    367:         $curr_authfield = $curr_authtype.'arg';
                    368:     } 
1.28    ! raeburn   369:     my $javascript_validations=&Apache::londropadd::javascript_validations('modifycourse',$krbdefdom,$curr_authtype,$curr_authfield);
1.2       raeburn   370:     my %param = ( formname => 'document.cmod',
1.1       raeburn   371: 	   kerb_def_dom => $krbdefdom,
1.2       raeburn   372: 	   kerb_def_auth => $krbdef,
                    373:            mode => 'modifycourse',
                    374:            curr_authtype => $curr_authtype,
                    375:            curr_autharg => $enrollvar{'autharg'} 
1.1       raeburn   376: 	);
                    377:     my $krbform = &Apache::loncommon::authform_kerberos(%param);
                    378:     my $intform = &Apache::loncommon::authform_internal(%param);
                    379:     my $locform = &Apache::loncommon::authform_local(%param);
                    380: 
                    381:     if ($numlocalcc == 0) {
1.2       raeburn   382:         $ownertable = $lt{'nocc'};
1.1       raeburn   383:     }
1.2       raeburn   384: 
1.1       raeburn   385:     if ($numlocalcc > 0) {
                    386:         @local_ccs = sort @local_ccs;
                    387:         $ownertable = qq(
                    388:             <input type="hidden" name="numlocalcc" value="$numlocalcc" />
                    389:             <table>
                    390:              <tr>
1.28    ! raeburn   391:                <td>$lt{'tabl'} - $cdom ($domdesc). $lt{'usrd'}
1.1       raeburn   392:               </td>
                    393:              </tr>
                    394:              <tr><td>&nbsp;</td></tr>
                    395:              <tr>
1.28    ! raeburn   396:               <td>).
        !           397:             &Apache::loncommon::start_data_table()."\n".
        !           398:             &Apache::loncommon::start_data_table_header_row()."\n".
        !           399:                        "<th>$lt{'ownr'}</th>\n".
        !           400:                        "<th>$lt{'name'}</th>\n".
        !           401:                        "<th>$lt{'unme'}</th>\n".
        !           402:                        "<th>$lt{'stus'}</th>\n".
        !           403:             &Apache::loncommon::end_data_table_header_row()."\n";
        !           404:         foreach my $cc (@local_ccs) {
        !           405:             $ownertable .= &Apache::loncommon::start_data_table_row()."\n";
        !           406:             if ($cc eq $enrollvar{'courseowner'}) {
        !           407:                   $ownertable .= '<td><input type="radio" name="courseowner" value="'.$cc.'" checked="checked" /></td>'."\n";
1.1       raeburn   408:             } else {
1.28    ! raeburn   409:                 $ownertable .= '<td><input type="radio" name="courseowner" value="'.$cc.'" /></td>'."\n";
1.1       raeburn   410:             }
1.28    ! raeburn   411:             $ownertable .= 
        !           412:                  '<td>'.$pname{$cc}.'</td>'."\n".
        !           413:                  '<td>'.$cc.'</td>'."\n".
        !           414:                  '<td>'.$cc_status{$cc}.' '.$lt{'ccor'}.'</td>'."\n".
        !           415:                  &Apache::loncommon::end_data_table_row()."\n";
        !           416:         }
        !           417:         $ownertable .= &Apache::loncommon::end_data_table()."
1.1       raeburn   418:               </td>
                    419:              </tr>
                    420:             </table>";
                    421:     }
1.28    ! raeburn   422:     &print_header($r,$cdesc,$javascript_validations);
        !           423:     my $type = $env{'form.type'};
        !           424:     my $dctitle = &Apache::lonnet::plaintext('dc');
        !           425:     my $cctitle = &Apache::lonnet::plaintext('cc',$type);
        !           426:     my $mainheader = &mt('Course settings modifiable by [_1] only.',$dctitle);
        !           427:     my $hidden_elements = &hidden_form_elements();
1.1       raeburn   428:     $r->print(<<ENDDOCUMENT);
1.28    ! raeburn   429: <form action="/adm/modifycourse" method="post" name="setparms">
        !           430: <h3>$mainheader</h3>
1.1       raeburn   431: </p><p>
1.2       raeburn   432: <table width="100%" cellspacing="6" cellpadding="6">
                    433:  <tr>
                    434:   <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. Click the <b>"$lt{'gobt'}"</b> button to save your changes.</td>
                    435:  </tr>
1.1       raeburn   436:  <tr>
                    437:   <td width="50%" valign="top">
1.2       raeburn   438:    <b>$lt{'ccod'}:</b>&nbsp;&nbsp;
1.1       raeburn   439:     <input type="text" size="10" name="coursecode" value="$enrollvar{'coursecode'}"/><br/><br/>
                    440:     $lt{'ccus'}
                    441:   </td>
                    442:   <td width="50%" valign="top" rowspan="2">
1.2       raeburn   443:    <b>$lt{'cown'}:</b><br/><br/>
                    444:    $ownertable
                    445:    <br/><br/>
1.1       raeburn   446:    $lt{'cous'}
                    447:   </td>
                    448:  </tr>
                    449:  <tr>
                    450:   <td width="50%" valign="top">
1.2       raeburn   451:    <b>$lt{'deam'}:</b><br/><br/>
                    452:    $krbform
                    453:    <br/>
                    454:    $intform
                    455:    <br/>
                    456:    $locform
                    457:    <br/>
                    458:    <br/>
1.1       raeburn   459:    $lt{'deus'}.
                    460:    </td>
                    461:    <td width="50%">&nbsp;</td>
                    462:  </tr>
                    463: </table>
                    464: <table width="90%" cellpadding="5" cellspacing="0">
                    465:  <tr>
1.28    ! raeburn   466:   <td align="left">
        !           467:    $hidden_elements
        !           468:    <input type="button" onClick="javascript:changePage(this.form,'processparms');javascript:verify_message(this.form)" value="$lt{'gobt'}" />
1.1       raeburn   469:   </td>
                    470:  </tr>
                    471: </table>
                    472: </form>
                    473: <br/>
                    474: <br/>
                    475: ENDDOCUMENT
1.5       raeburn   476:     return;
1.1       raeburn   477: }
                    478: 
                    479: sub modify_course {
1.28    ! raeburn   480:     my ($r,$cdom,$cnum,$cdesc,$domdesc) = @_;
        !           481:     my %longtype = &course_settings_descrip();
        !           482:     my %settings = &Apache::lonnet::get('environment',['internal.courseowner','internal.coursecode','internal.authtype','internal.autharg','internal.sectionnums','internal.crosslistings','description'],$cdom,$cnum);
1.1       raeburn   483:     my %currattr = ();
                    484:     my %newattr = ();
                    485:     my %cenv = ();
                    486:     my $response;
                    487:     my $chgresponse;
                    488:     my $nochgresponse;
                    489:     my $warning;
                    490:     my $reply;
                    491:     my @changes = ();
                    492:     my @nochanges = ();
                    493:     my @sections = ();
                    494:     my @xlists = ();
                    495:     my $changecode = 0;
                    496:     my $changeowner = 0;
1.28    ! raeburn   497:     unless ($settings{'internal.sectionnums'} eq '') {
1.1       raeburn   498:         if ($settings{'internal.sectionnums'} =~ m/,/) {
                    499:             @sections = split/,/,$settings{'internal.sectionnums'};
                    500:         } else {
                    501:             $sections[0] = $settings{'internal.sectionnums'};
                    502:         }
                    503:     }
                    504:     unless ($settings{'internal.crosslistings'} eq'') {
                    505:         if ($settings{'internal.crosslistings'} =~ m/,/) {
                    506:             @xlists = split/,/,$settings{'internal.crosslistings'};
                    507:         } else {
                    508:             $xlists[0] = $settings{'internal.crosslistings'};
                    509:         }
                    510:     }
                    511: 
1.28    ! raeburn   512:     my @modifiable_params = &get_dc_settable();
        !           513:     foreach my $param (@modifiable_params) {
        !           514:         my $attr = 'internal.'.$param;
        !           515:         $currattr{$param} = $settings{$attr};
1.1       raeburn   516:     }
                    517: 
                    518:     my $description = $settings{'description'};
                    519:     my %cenv = ();
                    520: 
1.16      albertel  521:     if ($env{'form.login'} eq 'krb') {
                    522:         $newattr{'authtype'} = $env{'form.login'};
                    523:         $newattr{'authtype'} .= $env{'form.krbver'};
                    524:         $newattr{'autharg'} = $env{'form.krbarg'};
                    525:     } elsif ($env{'form.login'} eq 'int') {
1.1       raeburn   526:         $newattr{'authtype'} ='internal';
1.16      albertel  527:         if ((defined($env{'form.intarg'})) && ($env{'form.intarg'})) {
                    528:             $newattr{'autharg'} = $env{'form.intarg'};
1.1       raeburn   529:         }
1.16      albertel  530:     } elsif ($env{'form.login'} eq 'loc') {
1.1       raeburn   531:         $newattr{'authtype'} = 'localauth';
1.16      albertel  532:         if ((defined($env{'form.locarg'})) && ($env{'form.locarg'})) {
                    533:             $newattr{'autharg'} = $env{'form.locarg'};
1.1       raeburn   534:         }
                    535:     }
                    536:     if ( $newattr{'authtype'}=~ /^krb/) {
                    537:         if ($newattr{'autharg'}  eq '') {
1.2       raeburn   538:             $warning = qq(<font color="red" size="+1">).
                    539: 	    &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   540:         }
                    541:     }
                    542: 
1.16      albertel  543:     if ( exists($env{'form.courseowner'}) ) {
                    544:         $newattr{'courseowner'}=$env{'form.courseowner'};
1.14      raeburn   545:         unless ( $newattr{'courseowner'} eq $currattr{'courseowner'} ) {
                    546:             $changeowner = 1;
1.1       raeburn   547:         } 
                    548:     }
                    549: 													      
1.16      albertel  550:     if ( exists($env{'form.coursecode'}) ) {
                    551:         $newattr{'coursecode'}=$env{'form.coursecode'};
1.1       raeburn   552:         unless ( $newattr{'coursecode'} eq $currattr{'coursecode'} ) {
                    553:             $changecode = 1;
                    554:         }
                    555:     }
1.14      raeburn   556:     if ($changeowner == 1 || $changecode == 1) {
1.28    ! raeburn   557:         my $courseid_entry = &escape($cdom.'_'.$cnum).'='.&escape($description).':'.&escape($env{'form.coursecode'}).':'.&escape($env{'form.courseowner'});
        !           558:         &Apache::lonnet::courseidput($cdom,$courseid_entry,&Apache::lonnet::homeserver($cnum,$cdom));
1.14      raeburn   559:     }
1.1       raeburn   560: 
1.28    ! raeburn   561:     foreach my $param (@modifiable_params) {
        !           562:         if ($currattr{$param} eq $newattr{$param}) {
        !           563:             push(@nochanges,$param);
1.1       raeburn   564:         } else {
1.28    ! raeburn   565:             my $attr = 'internal.'.$param;
        !           566:             $cenv{$attr} = $newattr{$param};
        !           567:             push(@changes,$param);
1.1       raeburn   568:         }
                    569:     }
                    570: 
                    571:     if (@changes > 0) {
1.2       raeburn   572:         $chgresponse = &mt("The following automated enrollment parameters have been changed:<br/><ul>");
1.1       raeburn   573:     }
                    574:     if (@nochanges > 0) { 
1.2       raeburn   575:         $nochgresponse = &mt("The following automated enrollment parameters remain unchanged:<br/><ul>");
1.1       raeburn   576:     }
                    577:     if (@changes > 0) { 
1.28    ! raeburn   578:         my $putreply = &Apache::lonnet::put('environment',\%cenv,$cdom,$cnum);
1.1       raeburn   579:         if ($putreply !~ /^ok$/) {
1.2       raeburn   580:             $response = &mt("There was a problem processing your requested changes. The automated enrollment settings for this course have been left unchanged.<br/>");
1.1       raeburn   581:         } else {
1.28    ! raeburn   582:             foreach my $attr (@modifiable_params) {
1.1       raeburn   583:                 if (grep/^$attr$/,@changes) {
1.28    ! raeburn   584: 	            $chgresponse .= "<li>$longtype{$attr} ".&mt("now set to \"").$newattr{$attr}."\".</li>";
1.1       raeburn   585:                 } else {
1.28    ! raeburn   586: 	            $nochgresponse .= "<li>$longtype{$attr} ".&mt("still set to \"").$currattr{$attr}."\".</li>";
1.1       raeburn   587:                 }
                    588:             }
                    589:             if ($changecode || $changeowner) {
                    590:                 if ( $newattr{'courseowner'} eq '') {
1.2       raeburn   591: 	            $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   592:                 } else {
                    593: 	            if (@sections > 0) {
1.2       raeburn   594:                         if ($changecode) {
                    595: 	                    foreach my $sec (@sections) {
                    596: 		                if ($sec =~ m/^(.+):/) {
1.8       raeburn   597: 		                    my $inst_course_id = $newattr{'coursecode'}.$1;
1.28    ! raeburn   598:                                     my $course_check = &Apache::lonnet::auto_validate_courseID($cnum,$cdom,$inst_course_id);
1.7       raeburn   599: 			            if ($course_check eq 'ok') {
1.28    ! raeburn   600:                                         my $outcome = &Apache::lonnet::auto_new_course($cnum,$cdom,$inst_course_id,$newattr{'courseowner'});
1.1       raeburn   601: 			                unless ($outcome eq 'ok') { 
1.2       raeburn   602: 				            $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   603: 			                }
                    604: 			            } else {
1.2       raeburn   605: 			                $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   606: 			            }
                    607: 		                } else {
1.2       raeburn   608: 			            $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   609: 		                }
                    610: 		            }
1.4       raeburn   611: 	                } elsif ($changeowner) {
                    612:                             foreach my $sec (@sections) {
                    613:                                 if ($sec =~ m/^(.+):/) {
1.8       raeburn   614:                                     my $inst_course_id = $newattr{'coursecode'}.$1;
1.28    ! raeburn   615:                                     my $outcome = &Apache::lonnet::auto_new_course($cnum,$cdom,$inst_course_id,$newattr{'courseowner'});
1.4       raeburn   616:                                     unless ($outcome eq 'ok') {
                    617:                                         $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/>");
                    618:                                     }
                    619:                                 } else {
                    620:                                     $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/>");
                    621:                                 }
                    622:                             }
                    623:                         }
1.1       raeburn   624: 	            } else {
1.2       raeburn   625: 	                $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   626: 	            }
                    627: 	            if ( (@xlists > 0) && ($changeowner) ) {
                    628: 	                foreach my $xlist (@xlists) {
                    629: 		            if ($xlist =~ m/^(.+):/) {
1.28    ! raeburn   630:                                 my $outcome = &Apache::lonnet::auto_new_course($cnum,$cdom,$1,$newattr{'courseowner'});
1.1       raeburn   631: 		                unless ($outcome eq 'ok') {
1.2       raeburn   632: 			            $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   633: 		                }
1.28    ! raeburn   634: 		            }
1.1       raeburn   635: 	                }
                    636: 	            }
                    637:                 }
                    638:             }
                    639:         }
1.2       raeburn   640:     } else {
1.28    ! raeburn   641:         foreach my $attr (@modifiable_params) {
        !           642:             $nochgresponse .= "<li>$longtype{$attr} ".&mt("still set to")." \"".$currattr{$attr}."\".</li>";
1.2       raeburn   643:         }
1.1       raeburn   644:     }
                    645: 
                    646:     if (@changes > 0) {
                    647:         $chgresponse .= "</ul><br/><br/>";
                    648:     }
                    649:     if (@nochanges > 0) {
                    650:         $nochgresponse .=  "</ul><br/><br/>";
                    651:     }
                    652:     unless ($warning eq '') {
1.2       raeburn   653:         $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   654:     }
                    655:     if ($response eq '') {
                    656:         $reply = $chgresponse.$nochgresponse.$warning;
                    657:     } else {
                    658:         $reply = $response;
                    659:     }
1.28    ! raeburn   660:     &print_header($r,$cdesc);
        !           661:     $reply = '<h3>'.
        !           662:               &mt('Result of Changes to Automated Enrollment Settings.').
        !           663:              '</h3>'."\n".
        !           664:              '<table><tr><td>'.$reply.'</td></tr></table>'.
        !           665:              '<form action="/adm/modifycourse" method="post" name="processparms">'.
        !           666:              &hidden_form_elements().
        !           667:              '<a href="javascript:changePage(document.processparms,'."'menu'".')">'.&mt('Back to options page').'</a>
        !           668:              </form>';
1.3       raeburn   669:     $r->print($reply);
1.28    ! raeburn   670:     return;
        !           671: }
        !           672: 
        !           673: sub modify_quota {
        !           674:     my ($r,$cdom,$cnum,$cdesc,$domdesc) = @_;
        !           675:     &print_header($r,$cdesc);
        !           676: 
        !           677:     my %lt = &Apache::lonlocal::texthash(
        !           678:                                          'back' => 'Back to options page',
        !           679:                                         );
        !           680:     $r->print('
        !           681: <form action="/adm/modifycourse" method="post" name="processquota">
        !           682: <h3>'.&mt('Disk space for storage of group portfolio files for [_1]',$cdesc).
        !           683:              '</h3>');
        !           684:     my %oldsettings = &Apache::lonnet::get('environment',['internal.coursequota'],$cdom,$cnum);
        !           685:     my $defaultquota = 20;
        !           686:     if ($env{'form.coursequota'} ne '') {
        !           687:         my $newquota = $env{'form.coursequota'};
        !           688:         if ($newquota =~ /^\s*(\d+\.?\d*|\.\d+)\s*$/) {
        !           689:             $newquota = $1;
        !           690:             if ($oldsettings{'internal.coursequota'} eq $env{'form.coursequota'}) {
        !           691:                 $r->print(&mt('The disk space allocated for group portfolio files remains unchanged as ').$env{'form.coursequota'}.' Mb');
        !           692:             } else {
        !           693:                 my %cenv = (
        !           694:                            'internal.coursequota' => $env{'form.coursequota'},
        !           695:                            );
        !           696:                 my $putreply = &Apache::lonnet::put('environment',\%cenv,$cdom,
        !           697:                                                     $cnum);
        !           698:                 if (($oldsettings{'internal.coursequota'} eq '') && 
        !           699:                     ($env{'form.coursequota'} == $defaultquota)) {
        !           700:                     $r->print(&mt('The disk space allocated for group portfolio files in this course is the default quota for this domain:').' '.$defaultquota.' Mb');
        !           701:                 } else {
        !           702:                     if ($putreply eq 'ok') {
        !           703:                         my %updatedsettings = &Apache::lonnet::get('environment',['internal.coursequota'],$cdom,$cnum);
        !           704:                         $r->print(&mt('The disk space allocated for group portfolio files is now:').' '.$updatedsettings{'internal.coursequota'}.' Mb.');
        !           705:                         my $usage = &Apache::longroup::sum_quotas($cdom.'_'.$cnum);
        !           706:                         if ($usage >= $updatedsettings{'internal.coursequota'}) {
        !           707:                             my $newoverquota;
        !           708:                             if ($usage < $oldsettings{'internal.coursequota'}) {
        !           709:                                 $newoverquota = 'now';
        !           710:                             }
        !           711:                             $r->print('<br /><br />'.
        !           712:       &mt('Disk usage [_1] exceeds the quota for this course.',$newoverquota).' '.
        !           713:       &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.'));
        !           714:                         }
        !           715:                     } else {
        !           716:                         $r->print(&mt('There was an error'));
        !           717:                     }
        !           718:                 }
        !           719:             }
        !           720:         } else {
        !           721:             $r->print(&mt('The new quota requested contained invalid characters, so the quota is unchanged.'));
        !           722:         }
        !           723:     }
        !           724:     $r->print(qq|<br /><br />
        !           725: <a href="javascript:changePage(document.processquota,'menu')">$lt{'back'}</a>|);
        !           726:     $r->print(&hidden_form_elements().'</form>');
        !           727:     return;
1.1       raeburn   728: }
                    729: 
                    730: sub print_header {
1.28    ! raeburn   731:     my ($r,$cdesc,$javascript_validations) = @_;
        !           732:     my $phase = "start";
        !           733:     if ( exists($env{'form.phase'}) ) {
        !           734:         $phase = $env{'form.phase'};
        !           735:     }
        !           736:     my $js = qq|
        !           737: <script type="text/javascript">
        !           738: function changePage(formname,newphase) {
        !           739:     formname.phase.value = newphase;
        !           740:     if (newphase == 'processparms') {
        !           741:         return;
1.1       raeburn   742:     }
1.28    ! raeburn   743:     formname.submit();
        !           744: }
        !           745: </script>
        !           746: |;
        !           747:     if ($phase eq 'setparms') {
        !           748: 	$js .= qq|
        !           749: <script  type="text/javascript">
        !           750: $javascript_validations
        !           751: </script>
        !           752: |;
        !           753:     } elsif ($phase eq 'courselist') {
        !           754:         $js .= qq|
        !           755: <script type="text/javascript">
        !           756: function gochoose(cname,cdom,cdesc) {
        !           757:     document.courselist.pickedcourse.value = cdom+'_'+cname;
        !           758:     document.courselist.submit();
        !           759: }
        !           760: </script>
        !           761: |;
        !           762:     } elsif ($phase eq 'setquota') {
        !           763:         $js .= <<'ENDSCRIPT';
        !           764: <script type="text/javascript">
        !           765: function verify_quota(formname) {
        !           766:     var newquota = formname.coursequota.value; 
        !           767:     var num_reg = /^\s*(\d+\.?\d*|\.\d+)\s*$/;
        !           768:     if (num_reg.test(newquota)) {
        !           769:         changePage(formname,'processquota');
1.1       raeburn   770:     } else {
1.28    ! raeburn   771:         alert("The quota you entered contained invalid characters.\nYou must enter a number");
1.1       raeburn   772:     }
1.28    ! raeburn   773:     return;
        !           774: }
        !           775: </script>
        !           776: ENDSCRIPT
1.1       raeburn   777:     }
1.23      albertel  778:     $r->print(&Apache::loncommon::start_page('View/Modify Course Settings',
                    779: 					     $js));
1.28    ! raeburn   780:     my $bread_text = "View/Modify Courses";
        !           781:     if ($cdesc ne '') {
        !           782:         $bread_text = "Course Settings: $cdesc"; 
        !           783:     } 
        !           784:     $r->print(&Apache::lonhtmlcommon::breadcrumbs($bread_text));
1.5       raeburn   785:     return;
1.1       raeburn   786: }
                    787: 
                    788: sub print_footer {
1.23      albertel  789:     my ($r) = @_;
                    790:     $r->print('<br />'.&Apache::loncommon::end_page());
1.5       raeburn   791:     return;
1.3       raeburn   792: }
                    793: 
                    794: sub check_course {
1.28    ! raeburn   795:     my ($r,$dom,$domdesc) = @_;
        !           796:     my ($ok_course,$description,$instcode,$owner);
        !           797:     if (defined($env{'form.pickedcourse'})) {
        !           798:         my ($cdom,$cnum) = split(/_/,$env{'form.pickedcourse'});
        !           799:         if ($cdom eq $dom) {
        !           800:             my %courseIDs = &Apache::lonnet::courseiddump($cdom,'.',1,'.','.',
        !           801:                                                           $cnum,undef,undef,'.');
        !           802:             if (keys(%courseIDs) > 0) {
        !           803:                 $ok_course = 'ok';
        !           804:                 ($description,$instcode,$owner) = 
        !           805:                                        split(/:/,$courseIDs{$cdom.'_'.$cnum});
        !           806:                 $description = &unescape($description);
        !           807:                 $instcode = &unescape($instcode);
        !           808:                 if ($instcode) {
        !           809:                     $description .= " ($instcode)";
        !           810:                 } 
1.5       raeburn   811:             }
1.3       raeburn   812:         }
                    813:     }
1.28    ! raeburn   814: 
        !           815:     if ($ok_course ne 'ok') {
        !           816:         $r->print('<br/>'.&mt('The LON-CAPA course selected was not a valid course for the [_1] domain',$domdesc));
        !           817:     }
        !           818:     return ($ok_course,$description);
1.1       raeburn   819: }
                    820: 
1.28    ! raeburn   821: sub course_settings_descrip {
        !           822:     my %longtype = &Apache::lonlocal::texthash(
        !           823:                       'authtype' => 'Default authentication method',
        !           824:                       'autharg'  => 'Default authentication parameter',
        !           825:                       'autoadds' => 'Automated adds',
        !           826:                       'autodrops' => 'Automated drops',
        !           827:                       'autostart' => 'Date of first automated enrollment',
        !           828:                       'autoend' => 'Date of last automated enrollment',
        !           829:                       'default_enrollment_start_date' => 'Date of first student access',
        !           830:                       'default_enrollment_end_date' => 'Date of last student access',
        !           831:                       'coursecode' => 'Official course code',
        !           832:                       'courseowner' => "Username:domain of course owner",
        !           833:                       'notifylist' => 'Course Coordinators to be notified of enrollment changes',
        !           834:                       'sectionnums' => 'Course section number(:LON-CAPA section)',
        !           835:                       'crosslistings' => 'Crosslisted class(:LON-CAPA section)',
        !           836:                    );
        !           837:     return %longtype;
        !           838: }
        !           839: 
        !           840: sub hidden_form_elements {
        !           841:     my $hidden_elements = 
        !           842:       &Apache::lonhtmlcommon::echo_form_input(['gosearch','coursecode',
        !           843:                                                'numlocalcc','courseowner',
        !           844:                                                'login','coursequota','intarg',                                               'locarg','krbarg','krbver']);
        !           845:     return $hidden_elements;
        !           846: }
1.1       raeburn   847: 
                    848: sub handler {
                    849:     my $r = shift;
                    850:     if ($r->header_only) {
                    851:         &Apache::loncommon::content_type($r,'text/html');
                    852:         $r->send_http_header;
                    853:         return OK;
                    854:     }
1.28    ! raeburn   855:     my $dom = $env{'request.role.domain'};
        !           856:     my $domdesc = $Apache::lonnet::domaindescription{$dom}; 
        !           857:     if (&Apache::lonnet::allowed('ccc',$dom)) {
1.1       raeburn   858:         &Apache::loncommon::content_type($r,'text/html');
                    859:         $r->send_http_header;
                    860: 
1.28    ! raeburn   861:         &Apache::lonhtmlcommon::clear_breadcrumbs();
        !           862: 
        !           863:         my $phase = $env{'form.phase'};
        !           864:         &Apache::lonhtmlcommon::add_breadcrumb
        !           865:             ({href=>"/adm/modifycourse",
        !           866:               text=>"Course search"});
        !           867:         if ($phase eq '') {
        !           868:             &print_course_search_page($r,$dom,$domdesc);
1.1       raeburn   869:         } else {
1.28    ! raeburn   870:             &Apache::lonhtmlcommon::add_breadcrumb
        !           871:             ({href=>"javascript:changePage(document.$phase,'courselist')",
        !           872:               text=>"Choose a course"});
        !           873:             if ($phase eq 'courselist') {
        !           874:                 &print_course_selection_page($r,$dom,$domdesc);
        !           875:             } else {
        !           876:                 &Apache::lonhtmlcommon::add_breadcrumb
        !           877:                 ({href=>"javascript:changePage(document.$phase,'menu')",
        !           878:                   text=>"Pick action"});
        !           879:                 my ($checked,$cdesc) = &check_course($r,$dom,$domdesc);
        !           880:                 my $type = $env{'form.type'};
        !           881:                 if ($checked eq 'ok') {
        !           882:                     if ($phase eq 'menu') {
        !           883:                         &print_modification_menu($r,$cdesc);
        !           884:                     } else {
        !           885:                         my ($cdom,$cnum) = split(/_/,$env{'form.pickedcourse'});
        !           886:                         if ($phase eq 'setquota') {
        !           887:                             &Apache::lonhtmlcommon::add_breadcrumb
        !           888:                             ({href=>"javascript:changePage(document.$phase,'$phase')",
        !           889:                               text=>"Set quota"});
        !           890:                             &print_setquota($r,$cdom,$cnum,$cdesc,$type)
        !           891:                         } elsif ($phase eq 'processquota') { 
        !           892:                             &Apache::lonhtmlcommon::add_breadcrumb
        !           893:                             ({href=>"javascript:changePage(document.$phase,'setquota')",
        !           894:                               text=>"Set quota"});
        !           895:                             &Apache::lonhtmlcommon::add_breadcrumb
        !           896:                             ({href=>"javascript:changePage(document.$phase,'$phase')",
        !           897:                               text=>"Result"});
        !           898:                             &modify_quota($r,$cdom,$cnum,$cdesc,$domdesc);
        !           899:                         } elsif ($phase eq 'viewparms') {  
        !           900:                             &Apache::lonhtmlcommon::add_breadcrumb
        !           901:                             ({href=>"javascript:changePage(document.$phase,'viewparms')",
        !           902:                               text=>"Display settings"});
        !           903:                             &print_settings_display($r,$cdom,$cnum,$cdesc,$type);
        !           904:                         } elsif ($phase eq 'setparms') {
        !           905:                             &Apache::lonhtmlcommon::add_breadcrumb
        !           906:                             ({href=>"javascript:changePage(document.$phase,'$phase')",
        !           907:                               text=>"Change settings"});
        !           908:                             &print_course_modification_page($r,$cdom,$cnum,$cdesc,$domdesc);
        !           909:                         } elsif ($phase eq 'processparms') {
        !           910:                             &Apache::lonhtmlcommon::add_breadcrumb
        !           911:                             ({href=>"javascript:changePage(document.$phase,'setparms')",
        !           912:                               text=>"Change settings"});
        !           913:                             &Apache::lonhtmlcommon::add_breadcrumb
        !           914:                             ({href=>"javascript:changePage(document.$phase,'$phase')",
        !           915:                               text=>"Result"});
        !           916:                             &modify_course($r,$cdom,$cnum,$cdesc,$domdesc);
        !           917:                         }
        !           918:                     }
        !           919:                 } else {
        !           920:                     $r->print(&mt('The course you selected is not a valid course in this domain')." ($domdesc)"); 
        !           921:                 }
        !           922:             }
1.1       raeburn   923:         }
1.28    ! raeburn   924:         &print_footer($r);
1.1       raeburn   925:     } else {
1.16      albertel  926:         $env{'user.error.msg'}=
1.2       raeburn   927:         "/adm/modifycourse:ccc:0:0:Cannot modify course settings";
1.1       raeburn   928:         return HTTP_NOT_ACCEPTABLE;
                    929:     }
                    930:     return OK;
                    931: }
                    932: 
                    933: 1;
                    934: __END__

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