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

www lon-capa-cvs@mail.lon-capa.org
Sat, 30 Aug 2003 18:49:10 -0000


www		Sat Aug 30 14:49:10 2003 EDT

  Modified files:              
    /loncom/interface	loncreatecourse.pm 
  Log:
  More tiny steps toward cloning courses, bug #1144
  
  
Index: loncom/interface/loncreatecourse.pm
diff -u loncom/interface/loncreatecourse.pm:1.28 loncom/interface/loncreatecourse.pm:1.29
--- loncom/interface/loncreatecourse.pm:1.28	Sat Aug 30 10:36:24 2003
+++ loncom/interface/loncreatecourse.pm	Sat Aug 30 14:49:10 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Create a course
 #
-# $Id: loncreatecourse.pm,v 1.28 2003/08/30 14:36:24 www Exp $
+# $Id: loncreatecourse.pm,v 1.29 2003/08/30 18:49:10 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -76,6 +76,34 @@
 	}
     }
     return @output;
+}
+
+# ============================================================= Read a userfile
+
+sub readfile {
+    my ($courseid,$which)=@_;
+    my %crsdata=&Apache::lonnet::coursedescription($courseid);
+    return &Apache::lonnet::getfile('/uploaded/'.$crsdata{'domain'}.'/'.
+				    $crsdata{'num'}.'/'.$which);
+}
+
+# ============================================================ Write a userfile
+
+sub writefile {
+    my ($courseid,$which,$data)=@_;
+    my %crsdata=&Apache::lonnet::coursedescription($courseid);
+    $ENV{'form.output'}=$data;
+    return &Apache::lonnet::finishuserfileupload(
+					  $crsdata{'num'},$crsdata{'domain'},
+					  $crsdata{'home'},
+					  'output',$which);
+}
+
+# ============================================================= Copy a userfile
+
+sub copyfile {
+    my ($origcrsid,$newcrsid,$which)=@_;
+    return &writefile($newcrsid,$which,&readfile($origcrsid,$which));
 }
 
 # ===================================================== Phase one: fill-in form