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

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

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