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

1.1       www         1: # The LearningOnline Network
                      2: # Create a course
1.5       albertel    3: #
1.35    ! www         4: # $Id: loncreatecourse.pm,v 1.34 2003/09/03 21:31: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.1       www        28: # (My Desk
                     29: #
                     30: # (Internal Server Error Handler
                     31: #
                     32: # (Login Screen
                     33: # 5/21/99,5/22,5/25,5/26,5/31,6/2,6/10,7/12,7/14,
                     34: # 1/14/00,5/29,5/30,6/1,6/29,7/1,11/9 Gerd Kortemeyer)
                     35: #
                     36: # 3/1/1 Gerd Kortemeyer)
                     37: #
                     38: # 3/1 Gerd Kortemeyer)
                     39: #
1.4       www        40: # 2/14,2/16,2/17,7/6 Gerd Kortemeyer
1.1       www        41: #
                     42: package Apache::loncreatecourse;
                     43: 
                     44: use strict;
                     45: use Apache::Constants qw(:common :http);
                     46: use Apache::lonnet;
1.12      www        47: use Apache::loncommon;
1.13      www        48: use Apache::lonratedt;
                     49: use Apache::londocs;
1.28      www        50: 
                     51: # -------------------------------------------- Return path to profile directory
                     52: 
                     53: sub propath {
                     54:     my ($udom,$uname)=@_;
                     55:     $udom=~s/\W//g;
                     56:     $uname=~s/\W//g;
                     57:     my $subdir=$uname.'__';
                     58:     $subdir =~ s/(.)(.)(.).*/$1\/$2\/$3/;
                     59:     my $proname="$Apache::lonnet::perlvar{'lonUsersDir'}/$udom/$subdir/$uname";
                     60:     return $proname;
                     61: } 
                     62: 
                     63: # ================================================ Get course directory listing
                     64: 
                     65: sub crsdirlist {
                     66:     my ($courseid,$which)=@_;
                     67:     unless ($which) { $which=''; }
                     68:     my %crsdata=&Apache::lonnet::coursedescription($courseid);
                     69:     my @listing=&Apache::lonnet::dirlist
                     70: 	($which,$crsdata{'domain'},$crsdata{'num'},
                     71: 	 &propath($crsdata{'domain'},$crsdata{'num'}));
                     72:     my @output=();
                     73:     foreach (@listing) {
                     74: 	unless ($_=~/^\./) {
                     75: 	    push (@output,(split(/\&/,$_))[0]);
                     76: 	}
                     77:     }
                     78:     return @output;
1.29      www        79: }
                     80: 
                     81: # ============================================================= Read a userfile
                     82: 
                     83: sub readfile {
                     84:     my ($courseid,$which)=@_;
                     85:     my %crsdata=&Apache::lonnet::coursedescription($courseid);
                     86:     return &Apache::lonnet::getfile('/uploaded/'.$crsdata{'domain'}.'/'.
                     87: 				    $crsdata{'num'}.'/'.$which);
                     88: }
                     89: 
                     90: # ============================================================ Write a userfile
                     91: 
                     92: sub writefile {
1.30      www        93:     (my $courseid, my $which,$ENV{'form.output'})=@_;
1.29      www        94:     my %crsdata=&Apache::lonnet::coursedescription($courseid);
                     95:     return &Apache::lonnet::finishuserfileupload(
                     96: 					  $crsdata{'num'},$crsdata{'domain'},
                     97: 					  $crsdata{'home'},
                     98: 					  'output',$which);
                     99: }
                    100: 
                    101: # ============================================================= Copy a userfile
                    102: 
                    103: sub copyfile {
                    104:     my ($origcrsid,$newcrsid,$which)=@_;
                    105:     return &writefile($newcrsid,$which,&readfile($origcrsid,$which));
1.30      www       106: }
                    107: 
                    108: # =============================================================== Copy a dbfile
                    109: 
                    110: sub copydb {
                    111:     my ($origcrsid,$newcrsid,$which)=@_;
                    112:     $which=~s/\.db$//;
                    113:     my %origcrsdata=&Apache::lonnet::coursedescription($origcrsid);
                    114:     my %newcrsdata= &Apache::lonnet::coursedescription($newcrsid);
                    115:     my %data=&Apache::lonnet::dump
                    116: 	($which,$origcrsdata{'domain'},$origcrsdata{'num'});
                    117:     return &Apache::lonnet::put
                    118: 	($which,\%data,$newcrsdata{'domain'},$newcrsdata{'num'});
                    119: }
                    120: 
1.35    ! www       121: # ========================================================== Copy resourcesdata
        !           122: 
        !           123: sub copyresourcedb {
        !           124:     my ($origcrsid,$newcrsid)=@_;
        !           125:     my %origcrsdata=&Apache::lonnet::coursedescription($origcrsid);
        !           126:     my %newcrsdata= &Apache::lonnet::coursedescription($newcrsid);
        !           127:     my %data=&Apache::lonnet::dump
        !           128: 	('resourcedata',$origcrsdata{'domain'},$origcrsdata{'num'});
        !           129:     $origcrsid=~s/^\///;
        !           130:     $origcrsid=~s/\//\_/;
        !           131:     $newcrsid=~s/^\///;
        !           132:     $newcrsid=~s/\//\_/;
        !           133:     my %newdata=();
        !           134:     undef %newdata;
        !           135:     my $startdate=$data{$origcrsid.'.0.opendate'};
        !           136:     my $today=time;
        !           137:     my $delta=0;
        !           138:     if ($startdate) {
        !           139: 	my $oneday=60*60*24;
        !           140: 	$delta=$today-$startdate;
        !           141: 	$delta=int($delta/$oneday)*$oneday;
        !           142:     }
        !           143: # ugly retro fix for broken version of types
        !           144:     foreach (keys %data) {
        !           145: 	if ($_=~/\wtype$/) {
        !           146: 	    my $newkey=$_;
        !           147: 	    $newkey=~s/type$/\.type/;
        !           148: 	    $data{$newkey}=$data{$_};
        !           149: 	    delete $data{$_};
        !           150: 	}
        !           151:     }
        !           152: # adjust dates
        !           153:     foreach (keys %data) {
        !           154: 	my $thiskey=$_;
        !           155: 	$thiskey=~s/^$origcrsid/$newcrsid/;
        !           156: 	$newdata{$thiskey}=$data{$_};
        !           157: 	if ($data{$_.'.type'}=~/^date/) {
        !           158: 	    $newdata{$thiskey}=$newdata{$thiskey}+$delta;
        !           159: 	}
        !           160:     }
        !           161:     return &Apache::lonnet::put
        !           162: 	('resourcedata',\%newdata,$newcrsdata{'domain'},$newcrsdata{'num'});
        !           163: }
        !           164: 
1.30      www       165: # ========================================================== Copy all userfiles
                    166: 
                    167: sub copyuserfiles {
                    168:     my ($origcrsid,$newcrsid)=@_;
                    169:     foreach (&crsdirlist($origcrsid,'userfiles')) {
                    170: 	&copyfile($origcrsid,$newcrsid,$_);
                    171:     }
                    172: }
                    173: # ========================================================== Copy all userfiles
                    174: 
                    175: sub copydbfiles {
                    176:     my ($origcrsid,$newcrsid)=@_;
                    177:     foreach (&crsdirlist($origcrsid)) {
                    178: 	if ($_=~/\.db$/) {
                    179: 	    unless 
1.34      www       180:              ($_=~/^(nohist\_|discussiontimes|classlist|versionupdate|resourcedata)/) {
1.30      www       181: 		 &copydb($origcrsid,$newcrsid,$_);
                    182: 	     }
                    183: 	}
                    184:     }
1.31      www       185: }
                    186: 
                    187: # ======================================================= Copy all course files
                    188: 
                    189: sub copycoursefiles {
                    190:     my ($origcrsid,$newcrsid)=@_;
                    191:     &copyuserfiles($origcrsid,$newcrsid);
                    192:     &copydbfiles($origcrsid,$newcrsid);
1.35    ! www       193:     &copyresourcedb($origcrsid,$newcrsid);
1.28      www       194: }
1.13      www       195: 
1.2       www       196: # ===================================================== Phase one: fill-in form
                    197: 
1.10      matthew   198: sub print_course_creation_page {
1.2       www       199:     my $r=shift;
1.10      matthew   200:     my $defdom=$ENV{'request.role.domain'};
                    201:     my %host_servers = &Apache::loncommon::get_library_servers($defdom);
                    202:     my $course_home = '<select name="course_home" size="1">'."\n";
                    203:     foreach my $server (sort(keys(%host_servers))) {
1.14      matthew   204:         $course_home .= qq{<option value="$server"};
                    205:         if ($server eq $Apache::lonnet::perlvar{'lonHostID'}) {
                    206:             $course_home .= " selected ";
                    207:         }
                    208:         $course_home .= qq{>$server $host_servers{$server}</option>};
1.10      matthew   209:     }
                    210:     $course_home .= "\n</select>\n";
1.9       matthew   211:     my $domform = &Apache::loncommon::select_dom_form($defdom,'ccdomain');
1.12      www       212:     my $bodytag=&Apache::loncommon::bodytag('Create a New Course');
1.17      www       213:     my $helplink=&Apache::loncommon::help_open_topic('Create_Course','Help on Creating Courses');
1.32      www       214:     my $cloneform=&Apache::loncommon::select_dom_form
                    215: 	($ENV{'request.role.domain'},'clonedomain').
                    216: 		     &Apache::loncommon::selectcourse_link
                    217: 		     ('ccrs','clonecourse','clonedomain');
                    218:     my $coursebrowserjs=&Apache::loncommon::coursebrowser_javascript();
1.2       www       219:     $r->print(<<ENDDOCUMENT);
                    220: <html>
1.6       matthew   221: <script language="JavaScript" type="text/javascript">
                    222: var editbrowser = null;
                    223: function openbrowser(formname,elementname) {
                    224:     var url = '/res/?';
                    225:     if (editbrowser == null) {
                    226:         url += 'launch=1&';
                    227:     }
                    228:     url += 'catalogmode=interactive&';
                    229:     url += 'mode=edit&';
                    230:     url += 'form=' + formname + '&';
1.7       matthew   231:     url += 'element=' + elementname + '&';
                    232:     url += 'only=sequence' + '';
1.6       matthew   233:     var title = 'Browser';
                    234:     var options = 'scrollbars=1,resizable=1,menubar=0';
                    235:     options += ',width=700,height=600';
                    236:     editbrowser = open(url,title,options,'1');
                    237:     editbrowser.focus();
                    238: }
                    239: </script>
1.32      www       240: $coursebrowserjs
1.2       www       241: <head>
                    242: <title>The LearningOnline Network with CAPA</title>
                    243: </head>
1.12      www       244: $bodytag
1.17      www       245: $helplink
1.6       matthew   246: <form action="/adm/createcourse" method="post" name="ccrs">
1.10      matthew   247: <h2>Course Information</h2>
                    248: <p>
                    249: <b>Course Title:</b>
1.6       matthew   250: <input type="text" size="50" name="title">
1.10      matthew   251: </p><p>
1.13      www       252: <b>Course Home Server:</b>$course_home
                    253: </p><p>
                    254: <b>Course ID/Number (optional)</b>
                    255: <input type="text" size="30" name="crsid">
                    256: </p>
                    257: <h2>Course Content</h2>
1.32      www       258: <table border="2">
                    259: <tr><th>Completely new course</th><th>Clone an existing course</th></tr>
                    260: <tr><td>
1.13      www       261: <p>
1.11      www       262: <b>Map:</b>
1.6       matthew   263: <input type="text" size="50" name="topmap">
1.24      www       264: <a href="javascript:openbrowser('ccrs','topmap')">Select Map</a>
1.10      matthew   265: </p><p>
1.32      www       266: <b>Do NOT generate as standard course</b><br /> 
1.11      www       267: (only check if you know what you are doing):
                    268: <input type="checkbox" name="nonstandard">
1.13      www       269: </p>
                    270: <p>
1.32      www       271: <b>First Resource</b><br />(standard courses only):
1.17      www       272: <input type="radio" name="firstres" value="blank">Blank
1.13      www       273: &nbsp;
1.17      www       274: <input type="radio" name="firstres" value="syl" checked>Syllabus
1.13      www       275: &nbsp;
                    276: <input type="radio" name="firstres" value="nav">Navigate
                    277: </p>
1.32      www       278: </td><td>
                    279: Course ID: <input input type="text" size="25" name="clonecourse" value="" />
                    280: <br />
                    281: Domain: 
                    282: $cloneform<br />&nbsp;<br />
                    283: Additional settings, if specified below, will override cloned settings.
                    284: </td></tr>
                    285: </table>
1.13      www       286: <h2>Assessment Parameters</h2>
                    287: <p>
1.11      www       288: <b>Open all assessments: </b>
                    289: <input type="checkbox" name="openall" checked>
1.13      www       290: </p>
                    291: <h2>Messaging</h2>
                    292: <p>
1.11      www       293: <b>Set course policy feedback to Course Coordinator: </b>
                    294: <input type="checkbox" name="setpolicy" checked>
                    295: </p><p>
                    296: <b>Set content feedback to Course Coordinator: </b>
                    297: <input type="checkbox" name="setcontent" checked>
                    298: </p>
1.16      www       299: <h2>Communication</h2>
                    300: <p>
                    301: <b>Disable student resource discussion: </b>
1.26      matthew   302: <input type="checkbox" name="disresdis" /> <br />
                    303: <b>Disable student use of chatrooms: </b>
                    304: <input type="checkbox" name="disablechat" />
1.16      www       305: </p>
1.18      www       306: <h2>Access Control</h2>
                    307: <p>
                    308: <b>Students need access key to enter course: </b>
                    309: <input type="checkbox" name="setkeys" />
                    310: </p>
1.10      matthew   311: <h2>Course Coordinator</h2>
                    312: <p>
1.11      www       313: <b>Username:</b> <input type="text" size="15" name="ccuname" />
                    314: </p><p>
                    315: <b>Domain:</b> $domform
1.10      matthew   316: </p><p>
1.11      www       317: <b>Immediately expire own role as Course Coordinator:</b>
                    318: <input type="checkbox" name="expireown" checked>
1.10      matthew   319: </p><p>
                    320: <input type="hidden" name="phase" value="two" />
1.6       matthew   321: <input type="submit" value="Open Course">
1.10      matthew   322: </p>
1.2       www       323: </form>
                    324: </body>
                    325: </html>
                    326: ENDDOCUMENT
                    327: }
                    328: 
                    329: # ====================================================== Phase two: make course
                    330: 
1.10      matthew   331: sub create_course {
1.2       www       332:     my $r=shift;
                    333:     my $topurl='/res/'.&Apache::lonnet::declutter($ENV{'form.topmap'});
                    334:     my $ccuname=$ENV{'form.ccuname'};
                    335:     my $ccdomain=$ENV{'form.ccdomain'};
                    336:     $ccuname=~s/\W//g;
                    337:     $ccdomain=~s/\W//g;
                    338:     my $cdescr=$ENV{'form.title'};
                    339:     my $curl=$ENV{'form.topmap'};
1.12      www       340:     my $bodytag=&Apache::loncommon::bodytag('Create a New Course');
1.2       www       341:     $r->print(<<ENDENHEAD);
                    342: <html>
                    343: <head>
                    344: <title>The LearningOnline Network with CAPA</title>
                    345: </head>
1.12      www       346: $bodytag
1.2       www       347: ENDENHEAD
1.10      matthew   348:     #
                    349:     # Verify data
                    350:     #
                    351:     # Check the veracity of the course coordinator
1.2       www       352:     if (&Apache::lonnet::homeserver($ccuname,$ccdomain) eq 'no_host') {
1.3       www       353:         $r->print('No such user '.$ccuname.' at '.$ccdomain.'</body></html>');
1.2       www       354: 	return;
                    355:     }
1.10      matthew   356:     # Check the proposed home server for the course
                    357:     my %host_servers = &Apache::loncommon::get_library_servers
                    358:         ($ENV{'request.role.domain'});
                    359:     if (! exists($host_servers{$ENV{'form.course_home'}})) {
                    360:         $r->print('Invalid home server for course: '.
                    361:                   $ENV{'form.course_home'}.'</body></html>');
                    362:         return;
                    363:     }
1.2       www       364: #
                    365: # Open course
                    366: #
1.32      www       367:     my %cenv=();
1.10      matthew   368:     my $courseid=&Apache::lonnet::createcourse($ENV{'request.role.domain'},
                    369:                                                $cdescr,$curl,
1.11      www       370:                                                $ENV{'form.course_home'},
                    371:                                                $ENV{'form.nonstandard'});
1.2       www       372: 
1.27      bowersj2  373:     # Note: The testing routines depend on this being output; see 
                    374:     # Utils::Course. This needs to at least be output as a comment
                    375:     # if anyone ever decides to not show this, and Utils::Course::new
                    376:     # will need to be suitably modified.
1.4       www       377:     $r->print('New LON-CAPA Course ID: '.$courseid.'<br>');
                    378: #
1.12      www       379: # Check if created correctly
1.4       www       380: #
                    381:     my ($crsudom,$crsunum)=($courseid=~/^\/(\w+)\/(\w+)$/);
                    382:     my $crsuhome=&Apache::lonnet::homeserver($crsunum,$crsudom);
                    383:     $r->print('Created on: '.$crsuhome.'<br>');
1.12      www       384: #
1.32      www       385: # Are we cloning?
                    386: #
                    387:     my $cloneid='';
                    388:     if (($ENV{'form.clonecourse'}) && ($ENV{'form.clonedomain'})) {
                    389: 	$cloneid='/'.$ENV{'form.clonedomain'}.'/'.$ENV{'form.clonecourse'};
                    390:         my ($clonecrsudom,$clonecrsunum)=($cloneid=~/^\/(\w+)\/(\w+)$/);
                    391: 	my $clonehome=&Apache::lonnet::homeserver($clonecrsunum,$clonecrsudom);
                    392: 	if ($clonehome eq 'no_host') {
                    393: 	    $r->print(
                    394:     '<br /><font color="red">Attempting to clone non-existing course '.$cloneid.'</font>');
                    395: 	} else {
                    396: 	    $r->print(
                    397:     '<br /><font color="green">Cloning course from '.$clonehome.'</font>');
                    398: # Copy all files
                    399: 	    &copycoursefiles($cloneid,$courseid);
                    400: # Restore title
                    401: 	    $cenv{'description'}=$cdescr;
1.35    ! www       402: 	    $cenv{'clonedfrom'}=$cloneid;
1.32      www       403: 	}
                    404:     }
                    405: #
                    406: # Set environment (will override cloned, if existing)
1.12      www       407: #
1.4       www       408:     if ($ENV{'form.crsid'}) {
1.12      www       409:         $cenv{'courseid'}=$ENV{'form.crsid'};
                    410:     }
                    411:     if (($ccdomain) && ($ccuname)) {
                    412:        if ($ENV{'form.setpolicy'}) {
                    413:            $cenv{'policy.email'}=$ccuname.':'.$ccdomain;
                    414:        }
                    415:        if ($ENV{'form.setcontent'}) {
1.18      www       416:            $cenv{'question.email'}=$ccuname.':'.$ccdomain;
                    417:        }
                    418:     }
                    419:     if ($ENV{'form.setkeys'}) {
                    420:        $cenv{'keyaccess'}='yes';
1.16      www       421:     }
                    422:     if ($ENV{'form.disresdis'}) {
                    423:         $cenv{'pch.roles.denied'}='st';
1.26      matthew   424:     }
                    425:     if ($ENV{'form.disablechat'}) {
                    426:         $cenv{'plc.roles.denied'}='st';
1.21      albertel  427:     }
1.23      bowersj2  428: 
1.32      www       429:     # Record we've not yet viewed the Course Initialization Helper for this 
                    430:     # course
1.23      bowersj2  431:     $cenv{'course.helper.not.run'} = 1;
1.21      albertel  432:     #
                    433:     # Use new Randomseed
                    434:     #
1.22      albertel  435:     $cenv{'rndseed'}=&Apache::lonnet::latest_rnd_algorithm_id();;
1.25      matthew   436:     #
                    437:     # By default, use standard grading
                    438:     $cenv{'grading'} = 'standard';
1.22      albertel  439: 
1.32      www       440:     $r->print('<br />Setting environment: '.                 
1.12      www       441:           &Apache::lonnet::put('environment',\%cenv,$crsudom,$crsunum).'<br>');
                    442: #
                    443: # Open all assignments
                    444: #
                    445:     if ($ENV{'form.openall'}) {
                    446:        my $storeunder=$crsudom.'_'.$crsunum.'.0.opendate';
1.33      www       447:        my %storecontent = ($storeunder         => time,
                    448:                            $storeunder.'.type' => 'date_start');
1.12      www       449:        
                    450:        $r->print('Opening all assignments: '.&Apache::lonnet::cput
                    451:                  ('resourcedata',\%storecontent,$crsudom,$crsunum).'<br>');
                    452:    }
1.13      www       453: #
                    454: # Set first page
                    455: #
                    456:     unless (($ENV{'form.nonstandard'}) || ($ENV{'form.firstres'} eq 'blank')) {
                    457: 	$r->print('Setting first resource: ');
                    458:         my ($errtext,$fatal)=
                    459:            &Apache::londocs::mapread($crsunum,$crsudom,'default.sequence');
                    460:         $r->print(($fatal?$errtext:'read ok').' - ');
                    461:         my $title; my $url;
                    462:         if ($ENV{'form.firstres'} eq 'syl') {
                    463: 	    $title='Syllabus';
                    464:             $url='/public/'.$crsudom.'/'.$crsunum.'/syllabus';
                    465:         } else {
                    466:             $title='Navigate Contents';
                    467:             $url='/adm/navmaps';
                    468:         }
                    469:         $Apache::lonratedt::resources[1]=$title.':'.$url.':false:start:res';
1.15      albertel  470:         ($errtext,$fatal)=
1.13      www       471:            &Apache::londocs::storemap($crsunum,$crsudom,'default.sequence');
                    472:         $r->print(($fatal?$errtext:'write ok').'<br>');
                    473:   }
1.2       www       474: #
                    475: # Make current user course adminstrator
                    476: #
1.12      www       477:     my $end=undef;
                    478:     my $addition='';
                    479:     if ($ENV{'form.expireown'}) { $end=time+5; $addition='expired'; }
                    480:     $r->print('Assigning '.$addition.' role of course coordinator to self: '.
1.2       www       481:     &Apache::lonnet::assignrole(
1.12      www       482:      $ENV{'user.domain'},$ENV{'user.name'},$courseid,'cc',$end).'<br>');
1.2       www       483: #
                    484: # Make additional user course administrator
                    485: #
1.12      www       486:    if (($ccdomain) && ($ccuname)) {
1.2       www       487:     $r->print('Assigning role of course coordinator to '.
                    488:                $ccuname.' at '.$ccdomain.': '.
1.3       www       489:     &Apache::lonnet::assignrole($ccdomain,$ccuname,$courseid,'cc').'<p>');
1.12      www       490:    }
1.20      www       491:     if ($ENV{'form.setkeys'}) {
                    492: 	$r->print(
                    493:  '<p><a href="/adm/managekeys?cid='.$crsudom.'_'.$crsunum.'">Manage Access Keys</a></p>');
                    494:     }
                    495:     $r->print('<p>Roles will be active at next login.</p></body></html>');
1.2       www       496: }
                    497: 
                    498: # ===================================================================== Handler
1.1       www       499: sub handler {
                    500:     my $r = shift;
                    501: 
                    502:     if ($r->header_only) {
                    503:        $r->content_type('text/html');
                    504:        $r->send_http_header;
                    505:        return OK;
                    506:     }
                    507: 
1.10      matthew   508:     if (&Apache::lonnet::allowed('ccc',$ENV{'request.role.domain'})) {
1.1       www       509:        $r->content_type('text/html');
                    510:        $r->send_http_header;
                    511: 
1.2       www       512:        if ($ENV{'form.phase'} eq 'two') {
1.10      matthew   513:            &create_course($r);
1.2       www       514:        } else {
1.10      matthew   515: 	   &print_course_creation_page($r);
1.2       www       516:        }
1.1       www       517:    } else {
                    518:       $ENV{'user.error.msg'}=
                    519:         "/adm/createcourse:ccc:0:0:Cannot create courses";
                    520:       return HTTP_NOT_ACCEPTABLE; 
                    521:    }
                    522:    return OK;
                    523: } 
                    524: 
                    525: 1;
                    526: __END__

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