--- loncom/interface/loncreatecourse.pm 2005/07/08 14:27:14 1.80 +++ loncom/interface/loncreatecourse.pm 2006/03/21 18:34:23 1.86 @@ -1,7 +1,7 @@ # The LearningOnline Network # Create a course # -# $Id: loncreatecourse.pm,v 1.80 2005/07/08 14:27:14 www Exp $ +# $Id: loncreatecourse.pm,v 1.86 2006/03/21 18:34:23 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -159,6 +159,14 @@ sub copyresourcedb { my %newdata=(); undef %newdata; my $startdate=$data{$origcrsid.'.0.opendate'}; + if (!$startdate) { + # now global start date for assements try the enrollment start + my %start=&Apache::lonnet::get('environment', + ['default_enrollment_start_date'], + $origcrsdata{'domain'},$origcrsdata{'num'}); + + $startdate = $start{'default_enrollment_start_date'}; + } my $today=time; my $delta=0; if ($startdate) { @@ -193,7 +201,13 @@ sub copyresourcedb { $thiskey=~s/^$origcrsid/$newcrsid/; $newdata{$thiskey}=$data{$_}; if ($data{$_.'.type'}=~/^date_(start|end)$/) { - $newdata{$thiskey}=$newdata{$thiskey}+$delta; + if ($delta > 0) { + $newdata{$thiskey}=$newdata{$thiskey}+$delta; + } else { + # no delta, it's unlikely we want the old dates and times + delete($newdata{$thiskey}); + delete($newdata{$thiskey.'.type'}); + } } } return &Apache::lonnet::put @@ -214,10 +228,13 @@ sub copyuserfiles { sub copydbfiles { my ($origcrsid,$newcrsid)=@_; + + my ($origcrs_discussion) = ($origcrsid=~m|^/(.*)|); + $origcrs_discussion=~s|/|_|g; foreach (&crsdirlist($origcrsid)) { if ($_=~/\.db$/) { unless - ($_=~/^(nohist\_|discussiontimes|classlist|versionupdate|resourcedata)/) { + ($_=~/^(nohist\_|discussiontimes|classlist|versionupdate|resourcedata|\Q$origcrs_discussion\E|slots|slot_reservations|(grading|review)queue|CODEs)/) { ©db($origcrsid,$newcrsid,$_); my $histfile=$_; $histfile=~s/\.db$/\.hist/; @@ -252,7 +269,6 @@ sub print_course_creation_page { } $course_home .= "\n\n"; my $domform = &Apache::loncommon::select_dom_form($defdom,'ccdomain'); - my $bodytag=&Apache::loncommon::bodytag('Create a New Course'); my $helplink=&Apache::loncommon::help_open_topic('Create_Course',&mt('Help on Creating Courses')); my $cloneform=&Apache::loncommon::select_dom_form ($env{'request.role.domain'},'clonedomain'). @@ -334,11 +350,8 @@ sub print_course_creation_page { 'rshm' => 'Resource Space Home', 'opco' => "Open Course" ); - my $html=&Apache::lonxml::xmlbegin(); - $r->print(< - $coursebrowserjs -The LearningOnline Network with CAPA - -$bodytag +END + + my $start_page = + &Apache::loncommon::start_page('Create a New Course',$js); + my $end_page = + &Apache::loncommon::end_page(); + + $r->print(<

$lt{'cinf'}

@@ -565,8 +584,7 @@ $lt{'ndcl'}

- - +$end_page ENDDOCUMENT } @@ -604,15 +622,8 @@ sub create_course { } my $logmsg; - my $html=&Apache::lonxml::xmlbegin(); - my $bodytag=&Apache::loncommon::bodytag('Create a New Course'); - $r->print(< -The LearningOnline Network with CAPA - -$bodytag -ENDENHEAD + my $start_page=&Apache::loncommon::start_page('Create a New Course'); + $r->print($start_page); my $args = { ccuname => $ccuname, @@ -666,7 +677,7 @@ ENDENHEAD - '); + '.&Apache::loncommon::end_page()); return; } # Check the proposed home server for the course @@ -674,7 +685,7 @@ ENDENHEAD ($env{'request.role.domain'}); if (! exists($host_servers{$env{'form.course_home'}})) { $r->print(&mt('Invalid home server for course').': '. - $env{'form.course_home'}.''); + $env{'form.course_home'}.&Apache::loncommon::end_page()); return; } my ($courseid,$crsudom,$crsunum); @@ -694,7 +705,8 @@ ENDENHEAD } # Flush the course logs so reverse user roles immediately updated &Apache::lonnet::flushcourselogs(); - $r->print('

'.&mt('Roles will be active at next login').'.

'); + $r->print('

'.&mt('Roles will be active at next login').'.

'. + &Apache::loncommon::end_page()); } sub construct_course { @@ -784,7 +796,7 @@ sub construct_course { foreach my $item (@sections) { my ($sec,$gp) = split/:/,$item; my $class = $args->{'crscode'}.$sec; - my $addcheck = &Apache::lonnet::auto_new_course($crsunum,$crsudom,$class,$cenv{'internal.courseowner'}); + my $addcheck = &Apache::lonnet::auto_new_course($$crsunum,$$crsudom,$class,$cenv{'internal.courseowner'}); $cenv{'internal.sectionnums'} .= $item.','; unless ($addcheck eq 'ok') { push @badclasses, $class;