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

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

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