version 1.7.12.1, 2010/02/26 22:45:03
|
version 1.10, 2014/12/11 01:14:40
|
Line 30
|
Line 30
|
package Apache::lonclonecourse; |
package Apache::lonclonecourse; |
use LONCAPA; |
use LONCAPA; |
use Apache::lonnet; |
use Apache::lonnet; |
use Apache::loncoursedata; |
|
|
|
# ================================================ Get course directory listing |
# ================================================ Get course directory listing |
|
|
Line 49 sub innercrsdirlist {
|
Line 48 sub innercrsdirlist {
|
unless ($path) { $path=''; } else { $path.='/'; } |
unless ($path) { $path=''; } else { $path.='/'; } |
my %crsdata=&Apache::lonnet::coursedescription($courseid); |
my %crsdata=&Apache::lonnet::coursedescription($courseid); |
my $getpropath = 1; |
my $getpropath = 1; |
my @listing=&Apache::lonnet::dirlist |
my ($dirlistref,$listerror) = |
($which,$crsdata{'domain'},$crsdata{'num'},$getpropath); |
&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 164 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 my $key (keys %data) { |
foreach my $key (keys(%data)) { |
if ($key=~/\wtype$/) { |
if ($key=~/\wtype$/) { |
my $newkey=$key; |
my $newkey=$key; |
$newkey=~s/type$/\.type/; |
$newkey=~s/type$/\.type/; |
Line 175 sub copyresourcedb {
|
Line 177 sub copyresourcedb {
|
# 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 my $key (keys %data) { |
foreach my $key (keys(%data)) { |
if ($key=~/\Q$pattern\E/) { |
if ($key=~/\Q$pattern\E/) { |
my $newkey=$key; |
my $newkey=$key; |
$newkey=~s/\Q$pattern\E/$new/; |
$newkey=~s/\Q$pattern\E/$new/; |
Line 184 sub copyresourcedb {
|
Line 186 sub copyresourcedb {
|
} |
} |
} |
} |
# transfer hash |
# transfer hash |
foreach my $key (keys %data) { |
foreach my $key (keys(%data)) { |
my $thiskey=$key; |
my $thiskey=$key; |
$thiskey=~s/^$origcrsid/$newcrsid/; |
$thiskey=~s/^$origcrsid/$newcrsid/; |
$newdata{$thiskey}=$data{$key}; |
$newdata{$thiskey}=$data{$key}; |
Line 226 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 242 sub copycoursefiles {
|
Line 244 sub copycoursefiles {
|
©resourcedb($origcrsid,$newcrsid,$date_mode,$date_shift); |
©resourcedb($origcrsid,$newcrsid,$date_mode,$date_shift); |
} |
} |
|
|
sub copyroster { |
|
my ($origcrsid,$newcrsid,$accessstart,$accessend) = @_; |
|
my %origcrsdata=&Apache::lonnet::coursedescription($origcrsid); |
|
my $newcrsiddata=&Apache::lonnet::coursedescription($newcrsid); |
|
|
|
my $classlist = |
|
&Apache::loncoursedata::get_classlist($origcrsdata{'domain'},$origcrsdata{'num'}); |
|
my %origdate = &Apache::lonnet::get('environment', |
|
['default_enrollment_end_date'], |
|
$origcrsdata{'domain'},$origcrsdata{'num'}); |
|
|
|
my $enddate = $origdate{'default_enrollment_end_date'}; |
|
|
|
my $sec_idx = &Apache::loncoursedata::CL_SECTION(); |
|
my $status_idx = &Apache::loncoursedata::CL_STATUS(); |
|
my $end_idx = &Apache::loncoursedata::CL_END(); |
|
my $start_idx = &Apache::loncoursedata::CL_START(); |
|
|
|
my (%newstudents,%rolesadded,$numadded); |
|
my $numadded = 0; |
|
my $classlist = &Apache::loncoursedata::get_classlist(); |
|
if (ref($classlist) eq 'HASH') { |
|
foreach my $student (sort(keys(%{$classlist}))) { |
|
my ($sname,$sdom) = split(/:/,$student); |
|
next if ($classlist->{$student}->[$end_idx] eq '-1' |
|
|| ($classlist->{$student}->[$start_idx] eq '-1')); |
|
if (($classlist->{$student}->[$status_idx] eq 'Active') || |
|
($classlist->{$student}->[$end_idx] >= $enddate)) { |
|
if (ref($classlist->{$student}) eq 'ARRAY') { |
|
my @info = @{$classlist->{$student}}; |
|
$info[$end_idx] = $accessend; |
|
$info[$start_idx] = $accessstart; |
|
$newstudents{$student}{'info'} = join(':',@info); |
|
$newstudents{$student}{'section'} = |
|
$classlist->{$student}->[$sec_idx]; |
|
} |
|
} |
|
} |
|
} |
|
if (keys(%newstudents)) { |
|
my $uurl='/'.$newcrsid; |
|
$uurl=~s/\_/\//g; |
|
foreach my $student (sort(keys(%newstudents))) { |
|
my $surl = $uurl; |
|
if ($newstudents{$student}{'section'}) { |
|
$surl.='/'.$newstudents{$student}{'section'}; |
|
} |
|
if (&assignrole($sdom,$sname,$uurl,'st',$accessend,$accessstart,undef,undef,'requestcourses') eq 'ok') { |
|
$rolesadded{$student} = $newstudents{$student}; |
|
$numadded ++ ; |
|
} |
|
} |
|
} |
|
my $clisterror; |
|
if (keys(%rolesadded) > 0) { |
|
my $reply=cput('classlist',\%rolesadded,$newcrsdata{'domain'},$newcrsdata{'num'}); |
|
unless (($reply eq 'ok') || ($reply eq 'delayed')) { |
|
$clisterror = 'error: '.$reply; |
|
} |
|
} |
|
return ($numadded,$clisterror); |
|
} |
|
|
|
1; |
1; |