[LON-CAPA-cvs] cvs: loncom /interface loncreatecourse.pm

www lon-capa-cvs@mail.lon-capa.org
Tue, 02 Sep 2003 15:21:42 -0000


www		Tue Sep  2 11:21:42 2003 EDT

  Modified files:              
    /loncom/interface	loncreatecourse.pm 
  Log:
  Saving my work on Bug #1144 to work on other bugs for now.
  
  
Index: loncom/interface/loncreatecourse.pm
diff -u loncom/interface/loncreatecourse.pm:1.29 loncom/interface/loncreatecourse.pm:1.30
--- loncom/interface/loncreatecourse.pm:1.29	Sat Aug 30 14:49:10 2003
+++ loncom/interface/loncreatecourse.pm	Tue Sep  2 11:21:42 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Create a course
 #
-# $Id: loncreatecourse.pm,v 1.29 2003/08/30 18:49:10 www Exp $
+# $Id: loncreatecourse.pm,v 1.30 2003/09/02 15:21:42 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -90,9 +90,8 @@
 # ============================================================ Write a userfile
 
 sub writefile {
-    my ($courseid,$which,$data)=@_;
+    (my $courseid, my $which,$ENV{'form.output'})=@_;
     my %crsdata=&Apache::lonnet::coursedescription($courseid);
-    $ENV{'form.output'}=$data;
     return &Apache::lonnet::finishuserfileupload(
 					  $crsdata{'num'},$crsdata{'domain'},
 					  $crsdata{'home'},
@@ -104,6 +103,41 @@
 sub copyfile {
     my ($origcrsid,$newcrsid,$which)=@_;
     return &writefile($newcrsid,$which,&readfile($origcrsid,$which));
+}
+
+# =============================================================== Copy a dbfile
+
+sub copydb {
+    my ($origcrsid,$newcrsid,$which)=@_;
+    $which=~s/\.db$//;
+    my %origcrsdata=&Apache::lonnet::coursedescription($origcrsid);
+    my %newcrsdata= &Apache::lonnet::coursedescription($newcrsid);
+    my %data=&Apache::lonnet::dump
+	($which,$origcrsdata{'domain'},$origcrsdata{'num'});
+    return &Apache::lonnet::put
+	($which,\%data,$newcrsdata{'domain'},$newcrsdata{'num'});
+}
+
+# ========================================================== Copy all userfiles
+
+sub copyuserfiles {
+    my ($origcrsid,$newcrsid)=@_;
+    foreach (&crsdirlist($origcrsid,'userfiles')) {
+	&copyfile($origcrsid,$newcrsid,$_);
+    }
+}
+# ========================================================== Copy all userfiles
+
+sub copydbfiles {
+    my ($origcrsid,$newcrsid)=@_;
+    foreach (&crsdirlist($origcrsid)) {
+	if ($_=~/\.db$/) {
+	    unless 
+             ($_=~/^(nohist\_|discussiontimes|classlist|versionupdate)/) {
+		 &copydb($origcrsid,$newcrsid,$_);
+	     }
+	}
+    }
 }
 
 # ===================================================== Phase one: fill-in form