version 1.7.12.1, 2010/02/26 22:45:03
|
version 1.7.12.2, 2010/03/01 20:11:03
|
Line 245 sub copycoursefiles {
|
Line 245 sub copycoursefiles {
|
sub copyroster { |
sub copyroster { |
my ($origcrsid,$newcrsid,$accessstart,$accessend) = @_; |
my ($origcrsid,$newcrsid,$accessstart,$accessend) = @_; |
my %origcrsdata=&Apache::lonnet::coursedescription($origcrsid); |
my %origcrsdata=&Apache::lonnet::coursedescription($origcrsid); |
my $newcrsiddata=&Apache::lonnet::coursedescription($newcrsid); |
my %newcrsdata=&Apache::lonnet::coursedescription($newcrsid); |
|
|
my $classlist = |
my $classlist = |
&Apache::loncoursedata::get_classlist($origcrsdata{'domain'},$origcrsdata{'num'}); |
&Apache::loncoursedata::get_classlist($origcrsdata{'domain'},$origcrsdata{'num'}); |
my %origdate = &Apache::lonnet::get('environment', |
my %origdate = &Apache::lonnet::get('environment', |
Line 255 sub copyroster {
|
Line 254 sub copyroster {
|
|
|
my $enddate = $origdate{'default_enrollment_end_date'}; |
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 $end_idx = &Apache::loncoursedata::CL_END(); |
my $start_idx = &Apache::loncoursedata::CL_START(); |
my $start_idx = &Apache::loncoursedata::CL_START(); |
|
my $id_idx = &Apache::loncoursedata::CL_ID(); |
|
my $sec_idx = &Apache::loncoursedata::CL_SECTION(); |
|
my $name_idx = &Apache::loncoursedata::CL_FULLNAME(); |
|
my $status_idx = &Apache::loncoursedata::CL_STATUS(); |
|
my $type_idx = &Apache::loncoursedata::CL_TYPE(); |
|
my $locktype_idx = &Apache::loncoursedata::CL_LOCKEDTYPE(); |
|
|
my (%newstudents,%rolesadded,$numadded); |
my (%newstudents,%rolesadded,$numadded); |
my $numadded = 0; |
my $numadded = 0; |
my $classlist = &Apache::loncoursedata::get_classlist(); |
|
if (ref($classlist) eq 'HASH') { |
if (ref($classlist) eq 'HASH') { |
foreach my $student (sort(keys(%{$classlist}))) { |
foreach my $student (sort(keys(%{$classlist}))) { |
my ($sname,$sdom) = split(/:/,$student); |
my ($sname,$sdom) = split(/:/,$student); |
Line 271 sub copyroster {
|
Line 273 sub copyroster {
|
if (($classlist->{$student}->[$status_idx] eq 'Active') || |
if (($classlist->{$student}->[$status_idx] eq 'Active') || |
($classlist->{$student}->[$end_idx] >= $enddate)) { |
($classlist->{$student}->[$end_idx] >= $enddate)) { |
if (ref($classlist->{$student}) eq 'ARRAY') { |
if (ref($classlist->{$student}) eq 'ARRAY') { |
my @info = @{$classlist->{$student}}; |
my $sec = $classlist->{$student}->[$sec_idx]; |
$info[$end_idx] = $accessend; |
$newstudents{$student}{'section'} = $sec; |
$info[$start_idx] = $accessstart; |
$newstudents{$student}{'info'} = |
$newstudents{$student}{'info'} = join(':',@info); |
$accessend.':'. |
$newstudents{$student}{'section'} = |
$accessstart.':'. |
$classlist->{$student}->[$sec_idx]; |
$classlist->{$student}->[$id_idx].':'. |
|
$sec.':'. |
|
$classlist->{$student}->[$name_idx].':'. |
|
$classlist->{$student}->[$type_idx].':'. |
|
$classlist->{$student}->[$locktype_idx]; |
} |
} |
} |
} |
} |
} |
} |
} |
if (keys(%newstudents)) { |
if (keys(%newstudents)) { |
my $uurl='/'.$newcrsid; |
my $uurl=$newcrsid; |
$uurl=~s/\_/\//g; |
$uurl=~s/\_/\//g; |
foreach my $student (sort(keys(%newstudents))) { |
foreach my $student (sort(keys(%newstudents))) { |
my $surl = $uurl; |
my $surl = $uurl; |
if ($newstudents{$student}{'section'}) { |
if ($newstudents{$student}{'section'}) { |
$surl.='/'.$newstudents{$student}{'section'}; |
$surl.='/'.$newstudents{$student}{'section'}; |
} |
} |
if (&assignrole($sdom,$sname,$uurl,'st',$accessend,$accessstart,undef,undef,'requestcourses') eq 'ok') { |
my ($sname,$sdom) = split(/:/,$student); |
$rolesadded{$student} = $newstudents{$student}; |
if (&Apache::lonnet::assignrole($sdom,$sname,$uurl,'st',$accessend,$accessstart,undef,undef,'requestcourses') eq 'ok') { |
|
$rolesadded{$student} = $newstudents{$student}{'info'}; |
$numadded ++ ; |
$numadded ++ ; |
} |
} |
} |
} |
} |
} |
my $clisterror; |
my $clisterror; |
if (keys(%rolesadded) > 0) { |
if (keys(%rolesadded) > 0) { |
my $reply=cput('classlist',\%rolesadded,$newcrsdata{'domain'},$newcrsdata{'num'}); |
my $reply = &Apache::lonnet::cput('classlist',\%rolesadded,$newcrsdata{'domain'},$newcrsdata{'num'}); |
unless (($reply eq 'ok') || ($reply eq 'delayed')) { |
unless (($reply eq 'ok') || ($reply eq 'delayed')) { |
$clisterror = 'error: '.$reply; |
$clisterror = 'error: '.$reply; |
} |
} |