version 1.5, 2008/01/21 17:47:21
|
version 1.9, 2012/03/10 02:45:35
|
Line 47 sub innercrsdirlist {
|
Line 47 sub innercrsdirlist {
|
unless ($which) { $which=''; } else { $which.='/'; } |
unless ($which) { $which=''; } else { $which.='/'; } |
unless ($path) { $path=''; } else { $path.='/'; } |
unless ($path) { $path=''; } else { $path.='/'; } |
my %crsdata=&Apache::lonnet::coursedescription($courseid); |
my %crsdata=&Apache::lonnet::coursedescription($courseid); |
my @listing=&Apache::lonnet::dirlist |
my $getpropath = 1; |
($which,$crsdata{'domain'},$crsdata{'num'}, |
my ($dirlistref,$listerror) = |
&propath($crsdata{'domain'},$crsdata{'num'})); |
&Apache::lonnet::dirlist($which,$crsdata{'domain'}, |
foreach (@listing) { |
$crsdata{'num'},$getpropath); |
unless ($_=~/^\./) { |
if (ref($dirlistref) eq 'ARRAY') { |
my @unpackline = split (/\&/,$_); |
foreach (@{$dirlistref}) { |
if ($unpackline[3]&$dirptr) { |
unless ($_=~/^\./) { |
|
my @unpackline = split (/\&/,$_); |
|
if ($unpackline[3]&$dirptr) { |
# is a directory, recurse |
# is a directory, recurse |
&innercrsdirlist($courseid,$which.$unpackline[0], |
&innercrsdirlist($courseid,$which.$unpackline[0], |
$path.$unpackline[0]); |
$path.$unpackline[0]); |
} else { |
} else { |
# is a file, put into output |
# is a file, put into output |
push (@output,$path.$unpackline[0]); |
push (@output,$path.$unpackline[0]); |
|
} |
} |
} |
} |
} |
} |
} |
return @output; |
return @output; |
} |
} |
Line 141 sub copydb {
|
Line 144 sub copydb {
|
# ========================================================== Copy resourcesdata |
# ========================================================== Copy resourcesdata |
|
|
sub copyresourcedb { |
sub copyresourcedb { |
my ($origcrsid,$newcrsid)=@_; |
my ($origcrsid,$newcrsid,$date_mode,$date_shift)=@_; |
|
my $delta=$date_shift*60*60*24; |
my %origcrsdata=&Apache::lonnet::coursedescription($origcrsid); |
my %origcrsdata=&Apache::lonnet::coursedescription($origcrsid); |
my %newcrsdata= &Apache::lonnet::coursedescription($newcrsid); |
my %newcrsdata= &Apache::lonnet::coursedescription($newcrsid); |
my %data=&Apache::lonnet::dump |
my %data=&Apache::lonnet::dump |
Line 162 sub copyresourcedb {
|
Line 166 sub copyresourcedb {
|
$startdate = $start{'default_enrollment_start_date'}; |
$startdate = $start{'default_enrollment_start_date'}; |
} |
} |
# ugly retro fix for broken version of types |
# ugly retro fix for broken version of types |
foreach (keys %data) { |
foreach my $key (keys %data) { |
if ($_=~/\wtype$/) { |
if ($key=~/\wtype$/) { |
my $newkey=$_; |
my $newkey=$key; |
$newkey=~s/type$/\.type/; |
$newkey=~s/type$/\.type/; |
$data{$newkey}=$data{$_}; |
$data{$newkey}=$data{$key}; |
delete $data{$_}; |
delete $data{$key}; |
} |
} |
} |
} |
# adjust symbs |
# adjust symbs |
my $pattern='uploaded/'.$origcrsdata{'domain'}.'/'.$origcrsdata{'num'}.'/'; |
my $pattern='uploaded/'.$origcrsdata{'domain'}.'/'.$origcrsdata{'num'}.'/'; |
my $new= 'uploaded/'. $newcrsdata{'domain'}.'/'. $newcrsdata{'num'}.'/'; |
my $new= 'uploaded/'. $newcrsdata{'domain'}.'/'. $newcrsdata{'num'}.'/'; |
foreach (keys %data) { |
foreach my $key (keys %data) { |
if ($_=~/\Q$pattern\E/) { |
if ($key=~/\Q$pattern\E/) { |
my $newkey=$_; |
my $newkey=$key; |
$newkey=~s/\Q$pattern\E/$new/; |
$newkey=~s/\Q$pattern\E/$new/; |
$data{$newkey}=$data{$_}; |
$data{$newkey}=$data{$key}; |
delete $data{$_}; |
delete $data{$key}; |
|
} |
|
} |
|
# transfer hash |
|
foreach my $key (keys %data) { |
|
my $thiskey=$key; |
|
$thiskey=~s/^$origcrsid/$newcrsid/; |
|
$newdata{$thiskey}=$data{$key}; |
|
# date_mode empty or "preserve": transfer dates one-to-one |
|
# date_mode "shift": shift dates by date_shift days |
|
# date_mode other: do not transfer dates |
|
if (($date_mode) && ($date_mode ne 'preserve')) { |
|
if ($data{$key.'.type'}=~/^date_(start|end)$/) { |
|
if ($date_mode eq 'shift') { |
|
$newdata{$thiskey}=$newdata{$thiskey}+$delta; |
|
} else { |
|
delete($newdata{$thiskey}); |
|
delete($newdata{$thiskey.'.type'}); |
|
} |
|
} |
} |
} |
} |
} |
return &Apache::lonnet::put |
return &Apache::lonnet::put |
Line 205 sub copydbfiles {
|
Line 228 sub copydbfiles {
|
foreach (&crsdirlist($origcrsid)) { |
foreach (&crsdirlist($origcrsid)) { |
if ($_=~/\.db$/) { |
if ($_=~/\.db$/) { |
unless |
unless |
($_=~/^(nohist\_|discussiontimes|classlist|versionupdate|resourcedata|\Q$origcrs_discussion\E|slots|slot_reservations|gradingqueue|reviewqueue|CODEs|groupmembership)/) { |
($_=~/^(nohist\_|disclikes|discussiontimes|classlist|versionupdate|resourcedata|\Q$origcrs_discussion\E|slots|slot_reservations|gradingqueue|reviewqueue|CODEs|groupmembership)/) { |
©db($origcrsid,$newcrsid,$_); |
©db($origcrsid,$newcrsid,$_); |
} |
} |
} |
} |
Line 215 sub copydbfiles {
|
Line 238 sub copydbfiles {
|
# ======================================================= Copy all course files |
# ======================================================= Copy all course files |
|
|
sub copycoursefiles { |
sub copycoursefiles { |
my ($origcrsid,$newcrsid)=@_; |
my ($origcrsid,$newcrsid,$date_mode,$date_shift)=@_; |
©userfiles($origcrsid,$newcrsid); |
©userfiles($origcrsid,$newcrsid); |
©dbfiles($origcrsid,$newcrsid); |
©dbfiles($origcrsid,$newcrsid); |
©resourcedb($origcrsid,$newcrsid); |
©resourcedb($origcrsid,$newcrsid,$date_mode,$date_shift); |
} |
} |
|
|
1; |
1; |