[LON-CAPA-cvs] cvs: loncom /interface loncreatecourse.pm
www
lon-capa-cvs@mail.lon-capa.org
Wed, 03 Sep 2003 23:15:28 -0000
www Wed Sep 3 19:15:28 2003 EDT
Modified files:
/loncom/interface loncreatecourse.pm
Log:
No matter what some broken version of this said in the past: it is
parameter.type
not
parametertype
Aargh.
Index: loncom/interface/loncreatecourse.pm
diff -u loncom/interface/loncreatecourse.pm:1.34 loncom/interface/loncreatecourse.pm:1.35
--- loncom/interface/loncreatecourse.pm:1.34 Wed Sep 3 17:31:59 2003
+++ loncom/interface/loncreatecourse.pm Wed Sep 3 19:15:27 2003
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Create a course
#
-# $Id: loncreatecourse.pm,v 1.34 2003/09/03 21:31:59 www Exp $
+# $Id: loncreatecourse.pm,v 1.35 2003/09/03 23:15:27 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -118,6 +118,50 @@
($which,\%data,$newcrsdata{'domain'},$newcrsdata{'num'});
}
+# ========================================================== Copy resourcesdata
+
+sub copyresourcedb {
+ my ($origcrsid,$newcrsid)=@_;
+ my %origcrsdata=&Apache::lonnet::coursedescription($origcrsid);
+ my %newcrsdata= &Apache::lonnet::coursedescription($newcrsid);
+ my %data=&Apache::lonnet::dump
+ ('resourcedata',$origcrsdata{'domain'},$origcrsdata{'num'});
+ $origcrsid=~s/^\///;
+ $origcrsid=~s/\//\_/;
+ $newcrsid=~s/^\///;
+ $newcrsid=~s/\//\_/;
+ my %newdata=();
+ undef %newdata;
+ my $startdate=$data{$origcrsid.'.0.opendate'};
+ my $today=time;
+ my $delta=0;
+ if ($startdate) {
+ my $oneday=60*60*24;
+ $delta=$today-$startdate;
+ $delta=int($delta/$oneday)*$oneday;
+ }
+# ugly retro fix for broken version of types
+ foreach (keys %data) {
+ if ($_=~/\wtype$/) {
+ my $newkey=$_;
+ $newkey=~s/type$/\.type/;
+ $data{$newkey}=$data{$_};
+ delete $data{$_};
+ }
+ }
+# adjust dates
+ foreach (keys %data) {
+ my $thiskey=$_;
+ $thiskey=~s/^$origcrsid/$newcrsid/;
+ $newdata{$thiskey}=$data{$_};
+ if ($data{$_.'.type'}=~/^date/) {
+ $newdata{$thiskey}=$newdata{$thiskey}+$delta;
+ }
+ }
+ return &Apache::lonnet::put
+ ('resourcedata',\%newdata,$newcrsdata{'domain'},$newcrsdata{'num'});
+}
+
# ========================================================== Copy all userfiles
sub copyuserfiles {
@@ -146,6 +190,7 @@
my ($origcrsid,$newcrsid)=@_;
©userfiles($origcrsid,$newcrsid);
©dbfiles($origcrsid,$newcrsid);
+ ©resourcedb($origcrsid,$newcrsid);
}
# ===================================================== Phase one: fill-in form
@@ -354,6 +399,7 @@
©coursefiles($cloneid,$courseid);
# Restore title
$cenv{'description'}=$cdescr;
+ $cenv{'clonedfrom'}=$cloneid;
}
}
#