version 1.2, 2006/12/05 01:36:13
|
version 1.6, 2008/01/22 22:37:18
|
Line 84 sub writefile {
|
Line 84 sub writefile {
|
my $data = &Apache::lonnet::finishuserfileupload( |
my $data = &Apache::lonnet::finishuserfileupload( |
$crsdata{'num'},$crsdata{'domain'}, |
$crsdata{'num'},$crsdata{'domain'}, |
'output',$which); |
'output',$which); |
&Apache::lonnet::logthis("gor $data $crsdata{'num'} $crsdata{'domain'}"); |
|
return $data; |
return $data; |
} |
} |
|
|
Line 116 sub copyfile {
|
Line 115 sub copyfile {
|
'/uploaded/'.$origcrsdata{'domain'}.'/'.$origcrsdata{'num'}.'/' |
'/uploaded/'.$origcrsdata{'domain'}.'/'.$origcrsdata{'num'}.'/' |
=> '/uploaded/'. $newcrsdata{'domain'}.'/'. $newcrsdata{'num'}.'/', |
=> '/uploaded/'. $newcrsdata{'domain'}.'/'. $newcrsdata{'num'}.'/', |
'/public/'.$origcrsdata{'domain'}.'/'.$origcrsdata{'num'}.'/' |
'/public/'.$origcrsdata{'domain'}.'/'.$origcrsdata{'num'}.'/' |
=> '/public/'. $newcrsdata{'domain'}.'/'. $newcrsdata{'num'}.'/' |
=> '/public/'. $newcrsdata{'domain'}.'/'. $newcrsdata{'num'}.'/', |
|
'/adm/'.$origcrsdata{'domain'}.'/'.$origcrsdata{'num'}.'/' |
|
=> '/adm/'.$newcrsdata{'domain'}.'/'.$newcrsdata{'num'}.'/', |
))); |
))); |
} |
} |
} |
} |
Line 140 sub copydb {
|
Line 141 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 160 sub copyresourcedb {
|
Line 162 sub copyresourcedb {
|
|
|
$startdate = $start{'default_enrollment_start_date'}; |
$startdate = $start{'default_enrollment_start_date'}; |
} |
} |
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 |
# 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}; |
} |
} |
} |
} |
# adjust dates |
# transfer hash |
foreach (keys %data) { |
foreach my $key (keys %data) { |
my $thiskey=$_; |
my $thiskey=$key; |
$thiskey=~s/^$origcrsid/$newcrsid/; |
$thiskey=~s/^$origcrsid/$newcrsid/; |
$newdata{$thiskey}=$data{$_}; |
$newdata{$thiskey}=$data{$key}; |
if ($data{$_.'.type'}=~/^date_(start|end)$/) { |
# date_mode empty or "preserve": transfer dates one-to-one |
if ($delta > 0) { |
# date_mode "shift": shift dates by date_shift days |
$newdata{$thiskey}=$newdata{$thiskey}+$delta; |
# date_mode other: do not transfer dates |
} else { |
if (($date_mode) && ($date_mode ne 'preserve')) { |
# no delta, it's unlikely we want the old dates and times |
if ($data{$key.'.type'}=~/^date_(start|end)$/) { |
delete($newdata{$thiskey}); |
if ($date_mode eq 'shift') { |
delete($newdata{$thiskey.'.type'}); |
$newdata{$thiskey}=$newdata{$thiskey}+$delta; |
} |
} else { |
|
delete($newdata{$thiskey}); |
|
delete($newdata{$thiskey.'.type'}); |
|
} |
|
} |
} |
} |
} |
} |
return &Apache::lonnet::put |
return &Apache::lonnet::put |
Line 236 sub copydbfiles {
|
Line 235 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; |