Annotation of loncom/interface/loncreatecourse.pm, revision 1.123

1.65      raeburn     1: # The LearningOnline Network
1.1       www         2: # Create a course
1.5       albertel    3: #
1.123   ! raeburn     4: # $Id: loncreatecourse.pm,v 1.122 2009/04/22 14:47:59 www Exp $
1.5       albertel    5: #
                      6: # Copyright Michigan State University Board of Trustees
                      7: #
                      8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
                      9: #
                     10: # LON-CAPA is free software; you can redistribute it and/or modify
                     11: # it under the terms of the GNU General Public License as published by
                     12: # the Free Software Foundation; either version 2 of the License, or
                     13: # (at your option) any later version.
                     14: #
                     15: # LON-CAPA is distributed in the hope that it will be useful,
                     16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
                     17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
                     18: # GNU General Public License for more details.
                     19: #
                     20: # You should have received a copy of the GNU General Public License
                     21: # along with LON-CAPA; if not, write to the Free Software
                     22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
                     23: #
                     24: # /home/httpd/html/adm/gpl.txt
                     25: #
                     26: # http://www.lon-capa.org/
                     27: #
1.48      www        28: ###
                     29: 
1.111     jms        30: =head1 NAME
                     31: 
                     32: Apache::loncreatecourse.pm
                     33: 
                     34: =head1 SYNOPSIS
                     35: 
                     36: Allows domain coordinators to create new
                     37: courses and assign course coordinators.
                     38: 
                     39: This is part of the LearningOnline Network with CAPA project
                     40: described at http://www.lon-capa.org.
                     41: 
1.112     jms        42: =head1 SUBROUTINES
1.111     jms        43: 
                     44: =over
                     45: 
1.112     jms        46: =item handler()
1.111     jms        47: 
1.112     jms        48: =item print_course_creation_page()
1.111     jms        49: 
1.112     jms        50: =item create_course()
1.111     jms        51: 
1.112     jms        52: =item print_intro_page()
1.111     jms        53: 
1.112     jms        54: =item upload_batchfile()
1.111     jms        55: 
1.112     jms        56: =item process_batchfile()
1.111     jms        57: 
                     58: =back
                     59: 
                     60: =cut
                     61: 
1.1       www        62: package Apache::loncreatecourse;
                     63: 
                     64: use strict;
                     65: use Apache::Constants qw(:common :http);
                     66: use Apache::lonnet;
1.12      www        67: use Apache::loncommon;
1.13      www        68: use Apache::londocs;
1.38      www        69: use Apache::lonlocal;
1.105     raeburn    70: use Apache::lonuserutils;
1.96      albertel   71: use Apache::lonclonecourse;
1.90      raeburn    72: use LONCAPA::batchcreatecourse;
1.89      www        73: use LONCAPA;
1.28      www        74: 
1.2       www        75: # ===================================================== Phase one: fill-in form
                     76: 
1.10      matthew    77: sub print_course_creation_page {
1.2       www        78:     my $r=shift;
1.123   ! raeburn    79:     my $crstype = 'Community';
1.90      raeburn    80:     if ($env{'form.phase'} eq 'courseone') {
                     81:         $crstype = 'Course';
                     82:     }
1.78      albertel   83:     my $defdom=$env{'request.role.domain'};
1.101     albertel   84:     my %host_servers = &Apache::lonnet::get_servers($defdom,'library');
1.10      matthew    85:     my $course_home = '<select name="course_home" size="1">'."\n";
                     86:     foreach my $server (sort(keys(%host_servers))) {
1.14      matthew    87:         $course_home .= qq{<option value="$server"};
                     88:         if ($server eq $Apache::lonnet::perlvar{'lonHostID'}) {
                     89:             $course_home .= " selected ";
                     90:         }
                     91:         $course_home .= qq{>$server $host_servers{$server}</option>};
1.10      matthew    92:     }
                     93:     $course_home .= "\n</select>\n";
1.9       matthew    94:     my $domform = &Apache::loncommon::select_dom_form($defdom,'ccdomain');
1.32      www        95:     my $cloneform=&Apache::loncommon::select_dom_form
1.78      albertel   96: 	($env{'request.role.domain'},'clonedomain').
1.32      www        97: 		     &Apache::loncommon::selectcourse_link
1.90      raeburn    98: 	     ('ccrs','clonecourse','clonedomain',undef,undef,undef,$crstype);
1.78      albertel   99:     my $coursebrowserjs=&Apache::loncommon::coursebrowser_javascript($env{'request.role.domain'});
1.90      raeburn   100:     my ($enroll_table,$access_table,$krbdef,$krbdefdom,$krbform,$intform,$locform,
                    101:         $javascript_validations);
                    102:     if ($crstype eq 'Course') {
                    103:         my $starttime = time;
                    104:         my $endtime = time+(6*30*24*60*60); # 6 months from now, approx
1.105     raeburn   105:         $enroll_table = &Apache::lonuserutils::date_setting_table($starttime,
                    106:                                               $endtime,'create_enrolldates');
                    107:         $access_table = &Apache::lonuserutils::date_setting_table($starttime,
                    108:                                              $endtime,'create_defaultdates');
1.90      raeburn   109:         ($krbdef,$krbdefdom) =
                    110:         &Apache::loncommon::get_kerberos_defaults($defdom);
1.105     raeburn   111:         $javascript_validations=&Apache::lonuserutils::javascript_validations(
1.90      raeburn   112:                                                     'createcourse',$krbdefdom);
                    113:         my %param = ( formname      => 'document.ccrs',
                    114:                       kerb_def_dom  => $krbdefdom,
                    115:                       kerb_def_auth => $krbdef
                    116:                     );
                    117:         $krbform = &Apache::loncommon::authform_kerberos(%param);
                    118:         $intform = &Apache::loncommon::authform_internal(%param);
                    119:         $locform = &Apache::loncommon::authform_local(%param);
                    120:     } else {
1.123   ! raeburn   121:         my $title_alert = &mt('A Community title is required');
        !           122:         my $coord_alert = &mt('The username of the Coordinator is required');
1.90      raeburn   123:         $javascript_validations = qq|
                    124: function validate(formname) {
                    125:     if (formname.title == '') {
1.123   ! raeburn   126:         alert("$title_alert");
1.90      raeburn   127:         return;
                    128:     }
                    129:     if (formname.ccuname == '') {
1.123   ! raeburn   130:         alert("$coord_alert");
1.90      raeburn   131:     }
                    132:     formname.submit();
                    133: }
                    134:         |;
                    135:     }
1.46      sakharuk  136:     my %lt=&Apache::lonlocal::texthash(
                    137: 		    'cinf' => "Course Information",
                    138:                     'ctit' => "Course Title",
                    139:                     'chsr' => "Course Home Server",
                    140:                     'cidn' => "Course ID/Number",
                    141:                     'opt'  => "optional",
                    142:                     'iinf' => "Institutional Information",
                    143:                     'stat' => "The following entries will be used to identify the course according to the naming scheme adopted by your institution. Your choices will be used to map an internal LON-CAPA course ID to the corresponding course section ID(s) used by the office responsible for providing official class lists for courses at your institution. This mapping is required if you choose to employ automatic population of class lists.",
                    144:                     'ccod' => "Course Code",
                    145:                     'toin' => "to interface with institutional data, e.g., fs03glg231 for Fall 2003 Geology 231",
1.90      raeburn   146:                     'snid' => "Section Numbers and corresponding LON-CAPA section IDs",
                    147:                     'csli' => "a comma separated list of institutional section numbers, each separated by a colon from the (optional) corresponding section ID to be used in LON-CAPA e.g., 001:1,002:2",
1.46      sakharuk  148:                     'crcs' => "Crosslisted courses",
1.90      raeburn   149:                     'cscs' => "a comma separated list of course sections crosslisted with the current course, with each entry including the institutional course section name followed by a colon and then the (optional) sectionID to be used in LON-CAPA, e.g., fs03ent231001:ent1,fs03bot231001:bot1,fs03zol231002:zol2",
1.46      sakharuk  150:                     'crco' => "Course Content",
                    151:                     'cncr' => "Completely new course",
                    152:                     'cecr' => "Clone an existing course", 
                    153:                     'map'  => "Map",
                    154:                     'smap' => "Select Map",
                    155:                     'sacr' => "Do NOT generate as standard course",
                    156:                     'ocik' => "only check if you know what you are doing",
                    157:                     'fres' => "First Resource",
                    158:                     'stco' => "standard courses only",
                    159:                     'blnk' => "Blank",
                    160:                     'sllb' => "Syllabus",
1.116     bisitz    161:                     'navi' => "Navigate Contents",
1.46      sakharuk  162:                     'cid'  => "Course ID",
                    163:                     'dmn'  => "Domain",
1.110     bisitz    164:                     'dsh'  => "Date Shift",
1.46      sakharuk  165:                     'asov' => "Additional settings, if specified below, will override cloned settings",
1.106     www       166:                     'ncd'  => "Do not clone date parameters",
                    167:                     'prd'  => 'Clone date parameters as-is',
                    168:                     'shd'  => 'Shift date parameters by number of days',
1.46      sakharuk  169:                     'assp' => "Assessment Parameters",
                    170:                     'oaas' => "Open all assessments",
                    171:                     'mssg' => "Messaging",
                    172:                     'scpf' => "Set course policy feedback to Course Coordinator",
                    173:                     'scfc' => "Set content feedback to Course Coordinator",
                    174:                     'cmmn' => "Communication",
                    175:                     'dsrd' => "Disable student resource discussion",
1.117     hauer     176:                     'dsuc' => "Disable student use of chat rooms",
1.46      sakharuk  177:                     'acco' => "Access Control",
                    178:                     'snak' => "Students need access key to enter course",
1.56      www       179: 		    'kaut' => 
                    180: 		    'Key authority (<tt>id@domain</tt>) if other than course',
1.46      sakharuk  181:                     'cc'   => "Course Coordinator",
                    182:                     'user' => "Username",
                    183:                     'aens' => "Automated enrollment settings",
                    184:                     'aesc' => "The following settings control automatic enrollment of students in this class based on information available for this specific course from your institution's official classlists.",
                    185:                     'aadd' => "Automated adds",
                    186:                     'yes'  => "Yes",
                    187:                     'no'   => "No",
                    188:                     'audr' => "Automated drops",
                    189:                     'dacu' => "Duration of automated classlist updates",
1.119     bisitz    190:                     'dads' => 'Default Access Dates for Students',
1.60      raeburn   191:                     'dacc' => "Default start and end dates for student access",
1.109     bisitz    192:                     'psam' => "Please select the Authentication mechanism",
1.46      sakharuk  193:                     'pcda' => "Please choose the default authentication method to be used by new users added to this LON-CAPA domain by the automated enrollment process",
                    194:                     'nech' => "Notification of enrollment changes",
                    195:                     'nccl' => "Notification to course coordinator via LON-CAPA message when enrollment changes occur during the automated update?",
1.77      raeburn   196:                     'ndcl' => "Notification to domain coordinator via LON-CAPA message when enrollment changes occur during the automated update?",
1.46      sakharuk  197:                     'irsp' => "Include retrieval of student photographs?",
1.55      www       198: 		    'rshm' => 'Resource Space Home',
1.93      raeburn   199:                     'cgrs' => "Course Group Settings",
1.119     bisitz    200:                     'cgrq' => 'Set a quota for the total disk space available for storage of course group portfolio files',
1.90      raeburn   201:                     'opco' => "Open Course",
1.123   ! raeburn   202:                     'ginf' => "Community Information",
        !           203:                     'gtit' => "Community Title",
        !           204:                     'ghsr' => "Community Home Server",
        !           205:                     'gidn' => "Community ID/Number",
        !           206:                     'grco' => "Community Content",
        !           207:                     'cngr' => "Completely new community",
        !           208:                     'cegr' => "Clone an existing community",
        !           209:                     'sagr' => "Do NOT generate as standard community",
        !           210:                     'stgo' => "standard communities only",
        !           211:                     'sgpf' => "Set community policy feedback to Coordinator",
        !           212:                     'scfg' => "Set content feedback to Coordinator",
1.90      raeburn   213:                     'dmrd' => "Disable member resource discussion",
1.118     hauer     214:                     'dmuc' => "Disable member use of chat rooms",
1.123   ! raeburn   215:                     'mnak' => "Members need access key to enter community",
1.90      raeburn   216:                     'kaug' =>
1.123   ! raeburn   217:                     'Key authority (<tt>id@domain</tt>) if other than community',
        !           218:                     'gc'   => "Coordinator",
        !           219:                     'gid'  => "Community ID",
        !           220:                     'crgr' => "Create Community",
        !           221:                     'grts' => "Community Group Settings",
        !           222:                     'grtq' => "Set a quota for the total disk space available for storage of community group portfolio files.",
1.93      raeburn   223: 
1.46      sakharuk  224: 				       );
1.86      albertel  225:     my $js = <<END;
                    226: <script type="text/javascript">
1.6       matthew   227: var editbrowser = null;
                    228: function openbrowser(formname,elementname) {
                    229:     var url = '/res/?';
                    230:     if (editbrowser == null) {
                    231:         url += 'launch=1&';
                    232:     }
                    233:     url += 'catalogmode=interactive&';
                    234:     url += 'mode=edit&';
                    235:     url += 'form=' + formname + '&';
1.7       matthew   236:     url += 'element=' + elementname + '&';
                    237:     url += 'only=sequence' + '';
1.6       matthew   238:     var title = 'Browser';
                    239:     var options = 'scrollbars=1,resizable=1,menubar=0';
                    240:     options += ',width=700,height=600';
                    241:     editbrowser = open(url,title,options,'1');
                    242:     editbrowser.focus();
                    243: }
1.41      raeburn   244: $javascript_validations
1.6       matthew   245: </script>
1.32      www       246: $coursebrowserjs
1.86      albertel  247: END
                    248: 
1.90      raeburn   249:     my %titles = &Apache::lonlocal::texthash(
                    250:                   courseone => 'Create a New Course',
1.123   ! raeburn   251:                   groupone => 'Create a New Community',
1.90      raeburn   252:     );  
1.86      albertel  253:     my $start_page = 
1.90      raeburn   254:         &Apache::loncommon::start_page($titles{$env{'form.phase'}},$js);
1.86      albertel  255:     my $end_page = 
                    256:         &Apache::loncommon::end_page();
1.91      albertel  257:     my $crumbs = 
                    258: 	&Apache::lonhtmlcommon::breadcrumbs($crstype.' Information',
                    259: 					    'Create_Course',undef,
                    260: 					    'Create_Courses');
1.90      raeburn   261:     $r->print($start_page.$crumbs);
1.110     bisitz    262: 
1.90      raeburn   263:     if ($crstype eq 'Course') {
1.113     raeburn   264:         $r->print('<form action="/adm/createcourse" method="post" name="ccrs"><div class="LC_createcourse">'
1.109     bisitz    265:                  .&Apache::lonhtmlcommon::start_pick_box()
                    266: 
                    267:                  .&Apache::lonhtmlcommon::row_headline()
                    268:                  .'<h3>'.$lt{'cinf'}.'</h3>'
                    269:                  .&Apache::lonhtmlcommon::row_closure()
                    270: 
                    271:                  .&Apache::lonhtmlcommon::row_title($lt{'ctit'})
                    272:                  .'<input type="text" size="50" name="title" />'
                    273:                  .&Apache::lonhtmlcommon::row_closure()
                    274: 
                    275:                  .&Apache::lonhtmlcommon::row_title($lt{'chsr'})
                    276:                  .$course_home
                    277:                  .&Apache::lonhtmlcommon::row_closure()
                    278: 
                    279:                  .&Apache::lonhtmlcommon::row_title($lt{'cidn'}.' ('.$lt{'opt'}.')')
                    280:                  .'<input type="text" size="30" name="crsid" />'
                    281:                  .&Apache::lonhtmlcommon::row_closure()
                    282: 
                    283:                  .&Apache::lonhtmlcommon::row_headline()
                    284:                  .'<h3>'.$lt{'iinf'}.'</h3>'
                    285:                  .$lt{'stat'}
                    286:                  .&Apache::lonhtmlcommon::row_closure()
                    287: 
                    288:                  .&Apache::lonhtmlcommon::row_title($lt{'ccod'})
                    289:                  .'<input type="text" size="30" name="crscode" />'
                    290:                  .'<br />('.$lt{'toin'}.')'
                    291:                  .&Apache::lonhtmlcommon::row_closure()
                    292: 
                    293:                  .&Apache::lonhtmlcommon::row_title($lt{'snid'})
                    294:                  .'<input type="text" size="30" name="crssections" />'
                    295:                  .'<br />('.$lt{'csli'}.')'
                    296:                  .&Apache::lonhtmlcommon::row_closure()
                    297: 
                    298:                  .&Apache::lonhtmlcommon::row_title($lt{'crcs'})
                    299:                  .'<input type="text" size="30" name="crsxlist" />'
                    300:                  .'<br />('.$lt{'cscs'}.')'
                    301:                  .&Apache::lonhtmlcommon::row_closure()
1.110     bisitz    302:         );
1.109     bisitz    303: 
1.110     bisitz    304:         # Table: New Course / Clone Course
                    305:         $r->print(&Apache::lonhtmlcommon::row_headline()
1.109     bisitz    306:                  .'<h3>'.$lt{'crco'}.'</h3>'
1.110     bisitz    307:                  .&Apache::loncommon::start_data_table()
                    308:                  .&Apache::loncommon::start_data_table_header_row()
                    309:                  .'<th>'.$lt{'cncr'}.'</th>'
                    310:                  .'<th>&nbsp;'.&mt('or').'&nbsp;</th>'
                    311:                  .'<th>'.$lt{'cecr'}.'</th>'
                    312:                  .&Apache::loncommon::end_data_table_header_row()
                    313:                  .&Apache::loncommon::start_data_table_row()
                    314: 
                    315:                  # New Course:
                    316:                  .'<td>'
                    317:                  .&Apache::lonhtmlcommon::start_pick_box()
                    318:                  .&Apache::lonhtmlcommon::row_title($lt{'map'})
                    319:                  .'<input type="text" size="50" name="topmap" />'
                    320:                  .'<a href="javascript:openbrowser(\'ccrs\',\'topmap\')">'.$lt{'smap'}.'</a>'
                    321:                  .&Apache::lonhtmlcommon::row_closure()
                    322:                  .&Apache::lonhtmlcommon::row_title('<label for="nonstd">'.$lt{'sacr'}.'</label>')
                    323:                  .'<input id="nonstd" type="checkbox" name="nonstandard" />'
                    324:                  .'<br />('.$lt{'ocik'}.')'
                    325:                  .&Apache::lonhtmlcommon::row_closure()
                    326:                  .&Apache::lonhtmlcommon::row_title($lt{'fres'})
                    327:                  .'<label>'
                    328:                  .'<input type="radio" name="firstres" value="blank" />'.$lt{'blnk'}
                    329:                  .'</label>'
                    330:                  .'&nbsp;'
                    331:                  .'<label>'
                    332:                  .'<input type="radio" name="firstres" value="syl" checked="checked" />'.$lt{'sllb'}
                    333:                  .'</label>'
                    334:                  .'&nbsp;'
                    335:                  .'<label>'
                    336:                  .'<input type="radio" name="firstres" value="nav" />'.$lt{'navi'}
                    337:                  .'</label>'
                    338:                  .'<br />('.$lt{'stco'}.')'
                    339:                  .&Apache::lonhtmlcommon::row_closure(1)
                    340:                  .&Apache::lonhtmlcommon::end_pick_box()
1.109     bisitz    341: 
1.110     bisitz    342:                  .'<td>&nbsp;</td>'
1.109     bisitz    343: 
1.110     bisitz    344:                  # Clone Course:
                    345:                  .'<td>'
                    346:                  .&Apache::lonhtmlcommon::start_pick_box()
                    347:                  .&Apache::lonhtmlcommon::row_title($lt{'cid'})
                    348:                  .'<label>'
                    349:                  .'<input type="text" size="25" name="clonecourse" value="" />'
                    350:                  .'</label>'
                    351:                  .&Apache::lonhtmlcommon::row_closure(1)
                    352:                  .&Apache::lonhtmlcommon::row_title($lt{'dmn'})
                    353:                  .'<label>'
                    354:                  .$cloneform
                    355:                  .'</label>'
                    356:                  .&Apache::lonhtmlcommon::row_closure()
                    357:                  .&Apache::lonhtmlcommon::row_title($lt{'dsh'})
                    358:                  .'<label>'
                    359:                  .'<input type="radio" name="datemode" value="delete" /> '.$lt{'ncd'}
                    360:                  .'</label><br />'
                    361:                  .'<label>'
                    362:                  .'<input type="radio" name="datemode" value="preserve" /> '.$lt{'prd'}
                    363:                  .'</label><br />'
                    364:                  .'<label>'
                    365:                  .'<input type="radio" name="datemode" value="shift" checked="checked" /> '.$lt{'shd'}
                    366:                  .'</label>'
                    367:                  .' <input type="text" size="5" name="dateshift" value="365" />'
                    368:                  .&Apache::lonhtmlcommon::row_closure()
                    369:                  .&Apache::lonhtmlcommon::row_headline()
                    370:                  .$lt{'asov'}
                    371:                  .&Apache::lonhtmlcommon::row_closure(1)
                    372:                  .&Apache::lonhtmlcommon::end_pick_box()
                    373:                  .'</td>'
                    374:                  .&Apache::loncommon::end_data_table_row()
                    375:                  .&Apache::loncommon::end_data_table()
1.109     bisitz    376:                  .&Apache::lonhtmlcommon::row_closure()
1.110     bisitz    377:         );
1.109     bisitz    378: 
1.110     bisitz    379:         $r->print(&Apache::lonhtmlcommon::row_headline()
1.119     bisitz    380:                  .'<h3>'.$lt{'dads'}.'</h3>'
                    381:                  .&Apache::lonhtmlcommon::row_closure()
                    382:                  .&Apache::lonhtmlcommon::row_title($lt{'dacc'})
                    383:                  .$access_table
                    384:                  .&Apache::lonhtmlcommon::row_closure()
                    385:         );
                    386: 
                    387:         $r->print(&Apache::lonhtmlcommon::row_headline()
1.109     bisitz    388:                  .'<h3>'.$lt{'assp'}.'</h3>'
                    389:                  .&Apache::lonhtmlcommon::row_closure()
                    390: 
                    391:                  .&Apache::lonhtmlcommon::row_title($lt{'oaas'})
                    392:                  .'<input type="checkbox" name="openall" />'
                    393:                  .&Apache::lonhtmlcommon::row_closure()
                    394: 
                    395:                  .&Apache::lonhtmlcommon::row_headline()
                    396:                  .'<h3>'.$lt{'mssg'}.'</h3>'
                    397:                  .&Apache::lonhtmlcommon::row_closure()
                    398: 
                    399:                  .&Apache::lonhtmlcommon::row_title($lt{'scpf'})
                    400:                  .'<input type="checkbox" name="setpolicy" checked="checked" />'
                    401:                  .&Apache::lonhtmlcommon::row_closure()
                    402: 
                    403:                  .&Apache::lonhtmlcommon::row_title($lt{'scfc'})
                    404:                  .'<input type="checkbox" name="setcontent" checked="checked" />'
                    405:                  .&Apache::lonhtmlcommon::row_closure()
                    406: 
                    407:                  .&Apache::lonhtmlcommon::row_headline()
                    408:                  .'<h3>'.$lt{'cmmn'}.'</h3>'
                    409:                  .&Apache::lonhtmlcommon::row_closure()
                    410: 
                    411:                  .&Apache::lonhtmlcommon::row_title($lt{'dsrd'})
                    412:                  .'<input type="checkbox" name="disresdis" />'
                    413:                  .&Apache::lonhtmlcommon::row_closure()
                    414: 
                    415:                  .&Apache::lonhtmlcommon::row_title($lt{'dsuc'})
1.120     bisitz    416:                  .'<input type="checkbox" name="disablechat" />'
1.109     bisitz    417:                  .&Apache::lonhtmlcommon::row_closure()
                    418: 
                    419:                  .&Apache::lonhtmlcommon::row_headline()
                    420:                  .'<h3>'.$lt{'acco'}.'</h3>'
                    421:                  .&Apache::lonhtmlcommon::row_closure()
                    422: 
                    423:                  .&Apache::lonhtmlcommon::row_title($lt{'snak'})
                    424:                  .'<input type="checkbox" name="setkeys" />'
                    425:                  .&Apache::lonhtmlcommon::row_closure()
                    426: 
                    427:                  .&Apache::lonhtmlcommon::row_title($lt{'kaut'})
                    428:                  .'<input type="text" size="30" name="keyauth" />'
                    429:                  .&Apache::lonhtmlcommon::row_closure()
                    430: 
                    431:                  .&Apache::lonhtmlcommon::row_headline()
                    432:                  .'<h3>'.$lt{'rshm'}.'</h3>'
                    433:                  .&Apache::lonhtmlcommon::row_closure()
                    434: 
                    435:                  .&Apache::lonhtmlcommon::row_title($lt{'rshm'})
                    436:                  .'<input type="text" name="reshome" size="30" value="/res/'.$defdom.'/" />'
                    437:                  .&Apache::lonhtmlcommon::row_closure()
                    438: 
                    439:                  .&Apache::lonhtmlcommon::row_headline()
                    440:                  .'<h3>'.$lt{'aens'}.'</h3>'
                    441:                  .&Apache::lonhtmlcommon::row_closure()
                    442: 
                    443:                  .&Apache::lonhtmlcommon::row_title($lt{'aadd'})
                    444:                  .'<label><input type="radio" name="autoadds" value="1" />'.$lt{'yes'}.'</label>'
                    445:                  .'<label><input type="radio" name="autoadds" value="0" checked="checked" />'.$lt{'no'}.'</label>'
                    446:                  .&Apache::lonhtmlcommon::row_closure()
                    447: 
                    448:                  .&Apache::lonhtmlcommon::row_title($lt{'audr'})
                    449:                  .'<label><input type="radio" name="autodrops" value="1" />'.$lt{'yes'}.'</label>'
                    450:                  .'<label><input type="radio" name="autodrops" value="0" checked="checked" />'.$lt{'no'}.'</label>'
                    451:                  .&Apache::lonhtmlcommon::row_closure()
                    452: 
                    453:                  .&Apache::lonhtmlcommon::row_title($lt{'dacu'})
                    454:                  .$enroll_table
                    455:                  .&Apache::lonhtmlcommon::row_closure()
                    456: 
                    457:                  .&Apache::lonhtmlcommon::row_title($lt{'psam'})
                    458:                  .$lt{'pcda'}.'<br />'
                    459:                  .$krbform.'<br />'
                    460:                  .$intform.'<br />'
                    461:                  .$locform
                    462:                  .&Apache::lonhtmlcommon::row_closure()
                    463: 
                    464:                  .&Apache::lonhtmlcommon::row_title($lt{'nech'})
                    465:                  .$lt{'nccl'}.'<br/>'
                    466:                  .'<label><input type="radio" name="notify_owner" value="1" />'.$lt{'yes'}.'</label>'
                    467:                  .'<label><input type="radio" name="notify_owner" value="0" checked="checked" />'.$lt{'no'}.'</label>'
                    468:                  .'<br />'
                    469:                  .$lt{'ndcl'}.'<br/>'
                    470:                  .'<label><input type="radio" name="notify_dc" value="1" />'.$lt{'yes'}.'</label>'
                    471:                  .'<label><input type="radio" name="notify_dc" value="0" checked="checked" />'.$lt{'no'}.'</label>'
                    472:                  .&Apache::lonhtmlcommon::row_closure()
                    473: 
                    474:                  .&Apache::lonhtmlcommon::row_title($lt{'irsp'})
                    475:                  .'<label>'
                    476:                  .'<input type="radio" name="showphotos" value="1" />'.$lt{'yes'}
                    477:                  .'</label> '
                    478:                  .'<label>'
                    479:                  .'<input type="radio" name="showphotos" value="0" checked="checked" />'.$lt{'no'}
                    480:                  .'</label> '
                    481:                  .&Apache::lonhtmlcommon::row_closure()
                    482: 
                    483:                  .&Apache::lonhtmlcommon::row_headline()
                    484:                  .'<h3>'.$lt{'cgrs'}.'</h3>'
                    485:                  .&Apache::lonhtmlcommon::row_closure()
                    486: 
                    487:                  .&Apache::lonhtmlcommon::row_title($lt{'cgrq'})
                    488:                  .'<input type="text" name="crsquota" value="20" size="6" />Mb'
                    489:                  .&Apache::lonhtmlcommon::row_closure()
                    490: 
                    491:                  .&Apache::lonhtmlcommon::row_headline()
                    492:                  .'<h3>'.$lt{'cc'}.'</h3>'
                    493:                  .&Apache::lonhtmlcommon::row_closure()
                    494: 
                    495:                  .&Apache::lonhtmlcommon::row_title($lt{'user'})
                    496:                  .'<input type="text" size="15" name="ccuname" />'
1.122     www       497:                  .&Apache::loncommon::studentbrowser_javascript()
                    498:                  .&Apache::loncommon::selectstudent_link('ccrs','ccuname','ccdomain')
1.109     bisitz    499:                  .&Apache::lonhtmlcommon::row_closure()
                    500: 
                    501:                  .&Apache::lonhtmlcommon::row_title($lt{'dmn'},"","LC_odd_row_value")
                    502:                  .$domform
                    503:                  .&Apache::lonhtmlcommon::row_closure(1)
                    504: 
                    505:                  .&Apache::lonhtmlcommon::end_pick_box()
1.110     bisitz    506:         );
1.109     bisitz    507:         $r->print(<<ENDDOCUMENT);
1.113     raeburn   508: </div>
1.55      www       509: <p>
1.90      raeburn   510: <input type="hidden" name="prevphase" value="courseone" />
                    511: <input type="hidden" name="phase" value="coursetwo" />
1.68      matthew   512: <input type="button" onClick="verify_message(this.form)" value="$lt{'opco'}" />
1.10      matthew   513: </p>
1.2       www       514: </form>
                    515: ENDDOCUMENT
1.109     bisitz    516: 
1.123   ! raeburn   517:     } elsif ($crstype eq 'Community') {
1.90      raeburn   518:         $r->print(<<ENDDOCUMENT);
                    519: <form action="/adm/createcourse" method="post" name="ccrs">
                    520: <h2>$lt{'ginf'}</h2>
                    521: <p>
                    522: <label><b>$lt{'gtit'}:</b>
                    523: <input type="text" size="50" name="title" /></label>
                    524: </p><p>
                    525: <label>
                    526:     <b>$lt{'ghsr'}:</b>$course_home
                    527: </label>
                    528: </p><p>
                    529: <label>
                    530:     <b>$lt{'gidn'} ($lt{'opt'})</b>
                    531:     <input type="text" size="30" name="crsid" />
                    532: </label>
                    533: </p>
                    534: <h2>$lt{'grco'}</h2>
                    535: <table border="2">
                    536: <tr><th>$lt{'cngr'}</th><th>$lt{'cegr'}</th></tr>
                    537: <tr><td>
                    538: <p>
                    539: <label>
                    540:     <b>$lt{'map'}:</b>
                    541:     <input type="text" size="50" name="topmap" />
                    542: </label>
                    543: <a href="javascript:openbrowser('ccrs','topmap')">$lt{'smap'}</a>
                    544: </p><p>
                    545: <label for="nonstd"><b>$lt{'sagr'}</b></label>
                    546: <br />
                    547: ($lt{'ocik'}):
                    548: <input id="nonstd" type="checkbox" name="nonstandard" />
                    549: </p><p>
                    550: <b>$lt{'fres'}</b><br />($lt{'stgo'}):
                    551: <label>
                    552:     <input type="radio" name="firstres" value="blank" />$lt{'blnk'}
                    553: </label>
                    554: &nbsp;
                    555: <label>
1.109     bisitz    556:     <input type="radio" name="firstres" value="syl" checked="checked" />$lt{'sllb'}
1.90      raeburn   557: </label>
                    558: &nbsp;
                    559: <label>
                    560:     <input type="radio" name="firstres" value="nav" />$lt{'navi'}
                    561: </label>
                    562: </p>
                    563: </td><td>
                    564: <label>
                    565:     $lt{'gid'}: <input type="text" size="25" name="clonecourse" value="" />
                    566: </label>
                    567: <br />
                    568: <label>
                    569:     $lt{'dmn'}: $cloneform
                    570: </label>
                    571: <br />
1.106     www       572:  <label><input type="radio" name="datemode" value="delete" /> $lt{'ncd'}</label><br />
                    573:  <label><input type="radio" name="datemode" value="preserve" /> $lt{'prd'}</label><br />
                    574:  <label><input type="radio" name="datemode" value="shift" checked="checked" /> $lt{'shd'}</label>
                    575:  <input type="text" size="5" name="dateshift" value="365" /><br />&nbsp;<br />
1.90      raeburn   576: $lt{'asov'}.
                    577: </td></tr>
                    578: </table>
                    579: </p>
                    580: <p>
                    581: <h2>$lt{'mssg'}</h2>
                    582: <p>
                    583: <label>
                    584:     <b>$lt{'sgpf'}: </b>
1.109     bisitz    585:     <input type="checkbox" name="setpolicy" checked="checked" />
1.90      raeburn   586: </label>
                    587: <br />
                    588: <label>
                    589:     <b>$lt{'scfg'}: </b>
1.109     bisitz    590:     <input type="checkbox" name="setcontent" checked="checked" />
1.90      raeburn   591: </label>
                    592: </p>
                    593: <h2>$lt{'cmmn'}</h2>
                    594: <p>
                    595: <label>
                    596:     <b>$lt{'dmrd'}: </b>
                    597:     <input type="checkbox" name="disresdis" />
                    598: </label>
                    599: <br />
                    600: <label>
                    601:     <b>$lt{'dmuc'}: </b>
                    602:     <input type="checkbox" name="disablechat" />
                    603: </label>
                    604: </p>
                    605: <h2>$lt{'acco'}</h2>
                    606: <p>
                    607: <label>
                    608:     <b>$lt{'mnak'}: </b>
                    609:     <input type="checkbox" name="setkeys" />
                    610: </label>
                    611: <br />
                    612: <label>
                    613:     <b>$lt{'kaug'}: </b>
                    614:     <input type="text" size="30" name="keyauth" />
                    615: </label>
                    616: </p>
                    617: <h2>$lt{'rshm'}</h2>
                    618: <p>
                    619: <label>
                    620:     <b>$lt{'rshm'}: </b>
                    621:     <input type="text" name="reshome" size="30" value="/res/$defdom/" />
                    622: </label>
                    623: </p>
1.93      raeburn   624: <p>
                    625: <h2>$lt{'grts'}</h2>
                    626: $lt{'grtq'}
                    627: <input type="text" name="crsquota" value="20" />Mb
                    628: </p>
1.90      raeburn   629: <hr />
                    630: <h2>$lt{'gc'}</h2>
                    631: <p>
                    632: <label>
                    633:     <b>$lt{'user'}:</b> <input type="text" size="15" name="ccuname" />
                    634: </label>
                    635: </p><p>
                    636: <label>
                    637:     <b>$lt{'dmn'}:</b> $domform
                    638: </label>
                    639: </p>
                    640: <p>
                    641: <input type="hidden" name="prevphase" value="groupone" />
                    642: <input type="hidden" name="phase" value="grouptwo" />
                    643: <input type="button" onClick="validate(this.form)" value="$lt{'crgr'}" />
                    644: </p>
                    645: </form>
                    646: ENDDOCUMENT
                    647:     }
                    648:     $r->print($end_page);
1.40      raeburn   649: }
                    650: 
1.2       www       651: # ====================================================== Phase two: make course
                    652: 
1.10      matthew   653: sub create_course {
1.2       www       654:     my $r=shift;
1.99      albertel  655:     my $ccuname =&LONCAPA::clean_username($env{'form.ccuname'});
                    656:     my $ccdomain=&LONCAPA::clean_domain($env{'form.ccdomain'});
1.123   ! raeburn   657:     my $crstype = 'Community';
1.90      raeburn   658:     my ($enrollstart,$enrollend,$startaccess,$endaccess);
1.74      raeburn   659: 
1.90      raeburn   660:     if ($env{'form.phase'} eq 'coursetwo') {
                    661:         $crstype='Course';
                    662:         $enrollstart=&Apache::lonhtmlcommon::get_date_from_form('startenroll');
                    663:         $enrollend=&Apache::lonhtmlcommon::get_date_from_form('endenroll');
                    664:     }
                    665:     $startaccess = &Apache::lonhtmlcommon::get_date_from_form('startaccess');
                    666:     $endaccess   = &Apache::lonhtmlcommon::get_date_from_form('endaccess');
1.74      raeburn   667: 
                    668:     my $autharg;
                    669:     my $authtype;
                    670: 
1.78      albertel  671:     if ($env{'form.login'} eq 'krb') {
1.74      raeburn   672:         $authtype = 'krb';
1.78      albertel  673:         $authtype .=$env{'form.krbver'};
                    674:         $autharg = $env{'form.krbarg'};
                    675:     } elsif ($env{'form.login'} eq 'int') {
1.74      raeburn   676:         $authtype ='internal';
1.78      albertel  677:         if ((defined($env{'form.intarg'})) && ($env{'form.intarg'})) {
                    678:             $autharg = $env{'form.intarg'};
1.74      raeburn   679:         }
1.78      albertel  680:     } elsif ($env{'form.login'} eq 'loc') {
1.74      raeburn   681:         $authtype = 'localauth';
1.78      albertel  682:         if ((defined($env{'form.locarg'})) && ($env{'form.locarg'})) {
                    683:             $autharg = $env{'form.locarg'};
1.74      raeburn   684:         }
                    685:     }
1.90      raeburn   686:     my $logmsg;
1.91      albertel  687:     my $start_page=&Apache::loncommon::start_page('Create a New '.$crstype);
1.90      raeburn   688:     my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Creation Outcome','Create_Course',undef,'Create_Courses');
1.74      raeburn   689: 
1.90      raeburn   690:     $r->print($start_page.$crumbs);
1.74      raeburn   691: 
                    692:     my $args = {
1.90      raeburn   693:                crstype => $crstype,
1.74      raeburn   694:                ccuname => $ccuname,
                    695:                ccdomain => $ccdomain,
1.78      albertel  696:                cdescr => $env{'form.title'},
                    697:                curl => $env{'form.topmap'},
                    698:                course_domain => $env{'request.role.domain'},
                    699:                course_home =>  $env{'form.course_home'},
                    700:                nonstandard => $env{'form.nonstandard'},
                    701:                crscode => $env{'form.crscode'},
1.93      raeburn   702:                crsquota => $env{'form.crsquota'},
1.103     raeburn   703:                clonecourse => $env{'form.clonecourse'},
                    704:                clonedomain => $env{'form.clonedomain'},
1.106     www       705:                datemode => $env{'form.datemode'},
                    706:                dateshift => $env{'form.dateshift'},
1.78      albertel  707:                crsid => $env{'form.crsid'},
1.94      raeburn   708:                curruser => $env{'user.name'}.':'.$env{'user.domain'},
1.78      albertel  709:                crssections => $env{'form.crssections'},
                    710:                crsxlist => $env{'form.crsxlist'},
                    711:                autoadds => $env{'form.autoadds'},
                    712:                autodrops => $env{'form.autodrops'},
                    713:                notify_owner => $env{'form.notify_owner'},
                    714:                notify_dc => $env{'form.notify_dc'},
                    715:                no_end_date => $env{'form.no_end_date'},
                    716:                showphotos => $env{'form.showphotos'},
1.74      raeburn   717:                authtype => $authtype,
                    718:                autharg => $autharg,
                    719:                enrollstart => $enrollstart,
                    720:                enrollend => $enrollend,
                    721:                startaccess => $startaccess,
                    722:                endaccess => $endaccess,
1.78      albertel  723:                setpolicy => $env{'form.setpolicy'},
                    724:                setcontent => $env{'form.setcontent'},
                    725:                reshome => $env{'form.reshome'},
                    726:                setkeys => $env{'form.setkeys'},
                    727:                keyauth => $env{'form.keyauth'},
                    728:                disresdis => $env{'form.disresdis'},
                    729:                disablechat => $env{'form.disablechat'},
                    730:                openall => $env{'form.openall'},
                    731:                firstres => $env{'form.firstres'}
1.74      raeburn   732:                };
                    733: 
1.10      matthew   734:     #
                    735:     # Verify data
                    736:     #
                    737:     # Check the veracity of the course coordinator
1.2       www       738:     if (&Apache::lonnet::homeserver($ccuname,$ccdomain) eq 'no_host') {
1.52      albertel  739: 	$r->print('<form action="/adm/createuser" method="post" name="crtuser">');
1.108     bisitz    740:         $r->print('<div class="LC_warning">'
                    741:                   .&mt('No such user [_1] at domain [_2].','<tt>'.$ccuname.'</tt>','<tt>'.$ccdomain.'</tt>')
                    742:                  .'</div>');
                    743: 	$r->print(&mt('Please click Back on your browser and select another user, or [_1]Create User[_2]'
                    744: 	             , '<input type="hidden" name="phase" value="get_user_info" />'
                    745:                       .'<input type="hidden" name="ccuname" value="'.$ccuname.'" />'
                    746:                       .'<input type="hidden" name="ccdomain" value="'.$ccdomain.'" />'
                    747:                       .'<input name="userrole" type="submit" value="'
                    748:                      , '" />'
                    749:                      )
                    750:                  .'</form>'.&Apache::loncommon::end_page()
                    751:                  );
1.2       www       752: 	return;
                    753:     }
1.10      matthew   754:     # Check the proposed home server for the course
1.101     albertel  755:     my %host_servers = 
                    756: 	&Apache::lonnet::get_servers($env{'request.role.domain'},'library');
1.78      albertel  757:     if (! exists($host_servers{$env{'form.course_home'}})) {
1.108     bisitz    758:         $r->print(&mt('Invalid home server for course: [_1]'
                    759:                      ,$env{'form.course_home'}.&Apache::loncommon::end_page()));
1.10      matthew   760:         return;
                    761:     }
1.74      raeburn   762:     my ($courseid,$crsudom,$crsunum);
1.104     albertel  763:     my ($success,$output) = 
                    764: 	&Apache::loncommon::construct_course($args,\$logmsg,\$courseid,
                    765: 					     \$crsudom,\$crsunum,
                    766: 					     $env{'user.domain'},
                    767: 					     $env{'user.name'});
                    768:     $r->print($output);
                    769:     if ($success) {
                    770:         #
                    771: 	# Make the requested user a course coordinator or group coordinator
                    772:         #
                    773: 	if (($ccdomain) && ($ccuname)) {
1.114     bisitz    774: 	    $r->print(&mt('Assigning role of '.$crstype.' Coordinator to [_1]:',
                    775: 			 ,'<i>'.$ccuname.':'.$ccdomain.'</i>')
                    776: 		      .&Apache::lonnet::assignrole($ccdomain,$ccuname,$courseid,
1.107     raeburn   777: 						  'cc','','','','','createcourse').'<p>');
1.104     albertel  778: 	}
                    779: 	if ($env{'form.setkeys'}) {
                    780: 	    $r->print(
                    781: 		      '<p><a href="/adm/managekeys?cid='.$crsudom.'_'.$crsunum.'">'.&mt('Manage Access Keys').'</a></p>');
                    782: 	}
                    783:         # Flush the course logs so reverse user roles immediately updated
                    784: 	&Apache::lonnet::flushcourselogs();
                    785: 	$r->print('<p>'.&mt('Roles will be active at next login').'.</p>');
                    786:     }
                    787:     $r->print('<p><a href="/adm/createcourse?phase='.lc($crstype).'one">'.
1.114     bisitz    788: 	      &mt("Create Another $crstype").'</a></p>'.
1.86      albertel  789: 	      &Apache::loncommon::end_page());
1.74      raeburn   790: }
                    791: 
1.90      raeburn   792: sub print_intro_page {
                    793:     my $r = shift;
                    794:     my $start_page =
1.123   ! raeburn   795:         &Apache::loncommon::start_page('Create a New Course or Community');
1.90      raeburn   796:     my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Creation Options','Create_Course',undef,'Create_Courses');
                    797:     my $end_page =
                    798:         &Apache::loncommon::end_page();
1.123   ! raeburn   799:     my $helplink=&Apache::loncommon::help_open_topic('Create_Course_Community',&mt('Help on Creating Courses and Communities'));
1.90      raeburn   800: 
                    801:     my @choices = ({ internal_name => 'courseone',
                    802:                      name => &mt('Create a single course'),
                    803:                      short_description =>
                    804:     &mt('Create a new course by completing an online form.'),
                    805:                  },
                    806:                    { internal_name => 'groupone',
1.123   ! raeburn   807:                      name => &mt('Create a single collaborative "community"'),
1.90      raeburn   808:                      short_description =>
1.123   ! raeburn   809:     &mt('Create a new collaborative community by completing an online form.'),
1.90      raeburn   810:                  },
                    811:                    { internal_name => 'batchone',
1.123   ! raeburn   812:                      name => &mt('Create courses/communities by uploading an attributes file'),
1.90      raeburn   813:                      short_description =>
1.123   ! raeburn   814:     &mt('Upload an attributes file containing specifications for one or more courses or communities in XML format.'),
1.97      raeburn   815:                      help => 'Batch_Creation',
1.90      raeburn   816:                  },
                    817:     );
                    818:     my $options;
                    819:     foreach my $choice (@choices) {
                    820:         $options .='    <h3><a href="/adm/createcourse?phase='.
                    821:             $choice->{'internal_name'}.'" >'.
1.97      raeburn   822:             $choice->{'name'}.'</a>';
                    823:         if (exists($choice->{'help'})) {
                    824:             $options .= &Apache::loncommon::help_open_topic($choice->{'help'});
                    825:         }
                    826:         $options .= "</h3>\n".'    '.('&nbsp;'x8).$choice->{'short_description'}.
1.90      raeburn   827:             "\n";
                    828:     }
                    829: 
                    830:     $r->print(<<ENDDOCUMENT);
                    831: $start_page
                    832: $crumbs
                    833: $options
                    834: $end_page
                    835: ENDDOCUMENT
                    836: }
                    837: 
                    838: sub upload_batchfile {
                    839:     my $r = shift;
                    840:     my $start_page =
1.123   ! raeburn   841:         &Apache::loncommon::start_page('Create a New Course or Community');
        !           842:     my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Upload Course/Community Attributes File','Create_Course',undef,'Create_Courses');
1.90      raeburn   843:     my $end_page =
                    844:         &Apache::loncommon::end_page();
                    845:     $r->print($start_page.$crumbs);
                    846:     $r->print('<h3>'.&mt('Upload a courses or groups attributes file').'</h3>');
                    847:     $r->print('<form name="batchcreate" method="post" '.
                    848:                 'enctype="multipart/form-data" action="/adm/createcourse">'.
                    849:               '<input type="file" name="coursecreatorxml" />'.
1.121     bisitz    850:               '<input type="hidden" name="phase" value="batchtwo" /><br /><br />'.
1.90      raeburn   851:               '<input type="submit" name="batchsubmit" '.
1.123   ! raeburn   852:               'value="Create Courses/Communities" /></form>');
1.90      raeburn   853:     $r->print($end_page);
                    854:     return;
                    855: }
                    856: 
                    857: sub process_batchfile {
                    858:     my $r = shift;
                    859:     my $start_page =
1.123   ! raeburn   860:         &Apache::loncommon::start_page('Create a New Course or Community');
1.90      raeburn   861:     my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Creation Outcome','Create_Course',undef,'Create_Courses');
                    862:     my $end_page =
                    863:         &Apache::loncommon::end_page();
                    864:     my $defdom=$env{'request.role.domain'};
                    865:     my $batchfilepath=&Apache::lonnet::userfileupload('coursecreatorxml',undef,
                    866:                                                       'batchupload',undef,undef,
                    867:                                                        undef,undef,$defdom);
                    868:     my ($batchdir,$filename) = ($batchfilepath =~ m-^(.+)/pending/([^/]+)$-);
                    869:     my ($result,$logmsg);
                    870:     if (-e "$batchfilepath") {
                    871:         open(FILE,"<$batchfilepath");
                    872:         my @buffer = <FILE>;
                    873:         close(FILE);
                    874:         if ((defined($filename)) && (defined($batchdir))) {
                    875:             my @requests = ($filename);
                    876:             my %courseids = ();
                    877:             ($result,$logmsg) = &LONCAPA::batchcreatecourse::create_courses(
                    878:                                         \@requests,\%courseids,'web',$defdom,
                    879:                                         $env{'user.name'},$env{'user.domain'});
                    880:             if ($result) {
                    881:                 if (!-e "$batchdir/processed") {
                    882:                     mkdir("$batchdir/processed", 0755);
                    883:                     open(FILE,">$batchdir/processed/$filename");
                    884:                     print FILE @buffer;
                    885:                     close(FILE);
                    886:                     if (-e "$batchdir/processed/$filename") {
                    887:                         unlink("$batchdir/pending/$filename");
                    888:                     }
                    889:                 }
                    890:             }
                    891:         }
                    892:     }
1.103     raeburn   893:     $r->print($start_page.$crumbs.$logmsg.$result.'<br /><a href="/adm/createcourse">'.
                    894:               &mt('Creation options menu').'</a>'.$end_page);
1.90      raeburn   895:  
                    896: }
                    897: 
1.2       www       898: # ===================================================================== Handler
1.1       www       899: sub handler {
                    900:     my $r = shift;
                    901: 
                    902:     if ($r->header_only) {
1.38      www       903:        &Apache::loncommon::content_type($r,'text/html');
1.1       www       904:        $r->send_http_header;
                    905:        return OK;
                    906:     }
                    907: 
1.78      albertel  908:     if (&Apache::lonnet::allowed('ccc',$env{'request.role.domain'})) {
1.38      www       909:        &Apache::loncommon::content_type($r,'text/html');
1.1       www       910:        $r->send_http_header;
                    911: 
1.90      raeburn   912:        &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
                    913:                                             ['phase']);
                    914:        &Apache::lonhtmlcommon::clear_breadcrumbs();
                    915:        &Apache::lonhtmlcommon::add_breadcrumb
                    916:           ({href=>"/adm/createcourse",
                    917:             text=>"Creation Options",
                    918:             faq=>79,bug=>'Dom Coord Interface',});
                    919:        if (($env{'form.phase'} eq 'coursetwo') ||
                    920:            ($env{'form.phase'} eq 'grouptwo')) {
                    921:            &Apache::lonhtmlcommon::add_breadcrumb
                    922:                  ({href=>"/adm/createcourse?phase=$env{'form.prevphase'}",
                    923:                    text=>&mt('[_1] Creation Settings',),
                    924:                    faq=>9,bug=>'Dom Coord Interface',});
                    925:           &Apache::lonhtmlcommon::add_breadcrumb
                    926:                  ({href=>"/adm/createcourse?phase=$env{'form.phase'}",
                    927:                    text=>"Creation Outcome",
                    928:                    faq=>9,bug=>'Dom Coord Interface',});
1.10      matthew   929:            &create_course($r);
1.90      raeburn   930:        } elsif (($env{'form.phase'} eq 'courseone') || 
                    931:                 ($env{'form.phase'} eq 'groupone')) {
                    932:            &Apache::lonhtmlcommon::add_breadcrumb
                    933:                  ({href=>"/adm/createcourse?phase=$env{'form.phase'}",
                    934:                    text=>&mt('[_1] Creation Settings',),
                    935:                    faq=>9,bug=>'Dom Coord Interface',});
                    936: 	   &print_course_creation_page($r);
                    937:        } elsif ($env{'form.phase'} eq 'batchone') {
                    938:            &Apache::lonhtmlcommon::add_breadcrumb
                    939:                  ({href=>"/adm/createcourse?phase=$env{'form.phase'}",
                    940:                    text=>"Upload Description File",
                    941:                    faq=>9,bug=>'Dom Coord Interface',});
                    942:            &upload_batchfile($r);
                    943:        } elsif ($env{'form.phase'} eq 'batchtwo') {
                    944:            &Apache::lonhtmlcommon::add_breadcrumb
                    945:                  ({href=>"/adm/createcourse?phase=$env{'form.prevphase'}",
                    946:                    text=>"Upload Description File",
                    947:                    faq=>9,bug=>'Dom Coord Interface',});
                    948:            &Apache::lonhtmlcommon::add_breadcrumb
                    949:                  ({href=>"/adm/createcourse?phase=$env{'form.phase'}",
                    950:                    text=>"Creation Outcome",
                    951:                    faq=>9,bug=>'Dom Coord Interface',});
                    952:            &process_batchfile($r);
1.2       www       953:        } else {
1.90      raeburn   954:            &print_intro_page($r);
1.2       www       955:        }
1.1       www       956:    } else {
1.78      albertel  957:       $env{'user.error.msg'}=
1.90      raeburn   958:         "/adm/createcourse:ccc:0:0:Cannot create courses or groups";
1.1       www       959:       return HTTP_NOT_ACCEPTABLE; 
                    960:    }
                    961:    return OK;
1.90      raeburn   962: }
1.1       www       963: 
                    964: 1;
                    965: __END__

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