--- loncom/interface/loncreatecourse.pm	2005/11/04 21:48:30	1.83
+++ loncom/interface/loncreatecourse.pm	2006/01/16 23:11:50	1.85
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Create a course
 #
-# $Id: loncreatecourse.pm,v 1.83 2005/11/04 21:48:30 albertel Exp $
+# $Id: loncreatecourse.pm,v 1.85 2006/01/16 23:11:50 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
@@ -220,7 +234,7 @@ sub copydbfiles {
     foreach (&crsdirlist($origcrsid)) {
 	if ($_=~/\.db$/) {
 	    unless 
-             ($_=~/^(nohist\_|discussiontimes|classlist|versionupdate|resourcedata|\Q$origcrs_discussion\E|slots|slot_reservations|(grading|review)queue)/) {
+             ($_=~/^(nohist\_|discussiontimes|classlist|versionupdate|resourcedata|\Q$origcrs_discussion\E|slots|slot_reservations|(grading|review)queue|CODEs)/) {
 		 &copydb($origcrsid,$newcrsid,$_);
 		 my $histfile=$_;
 		 $histfile=~s/\.db$/\.hist/;