version 1.276, 2005/10/04 18:27:32
|
version 1.279, 2005/10/13 22:37:40
|
Line 3061 Retrieves usernames:domains for users in
|
Line 3061 Retrieves usernames:domains for users in
|
with specific role(s), and access status. |
with specific role(s), and access status. |
|
|
Incoming parameters: |
Incoming parameters: |
1. course_id |
1. course domain |
2. course domain |
2. course number |
3. course number |
3. access status: users must have - either active, |
4. access status: users must have - either active, |
|
previous, future, or all. |
previous, future, or all. |
5. reference to array of permissible roles |
4. reference to array of permissible roles |
6. reference to results object (hash of hashes). |
5. reference to results object (hash of hashes). |
Keys of top level hash are roles. |
Keys of top level hash are roles. |
Keys of inner hashes are username:domain, with |
Keys of inner hashes are username:domain, with |
values set to access type. |
values set to access type. |
Line 3077 values set to access type.
|
Line 3076 values set to access type.
|
############################################### |
############################################### |
|
|
sub get_course_users { |
sub get_course_users { |
my ($course_id,$cdom,$cnum,$types,$roles,$users) = @_; |
my ($cdom,$cnum,$types,$roles,$users) = @_; |
if (grep/^st$/,@{$roles}) { |
if (grep/^st$/,@{$roles}) { |
my $statusidx = &Apache::loncoursedata::CL_STATUS; |
my $statusidx = &Apache::loncoursedata::CL_STATUS(); |
my $startidx = &Apache::loncoursedata::CL_START; |
my $startidx = &Apache::loncoursedata::CL_START(); |
my $endidx = &Apache::loncoursedata::CL_END; |
my $endidx = &Apache::loncoursedata::CL_END(); |
my ($classlist,$keylist)=&Apache::loncoursedata::get_classlist($cdom,$cnum); |
my ($classlist,$keylist)=&Apache::loncoursedata::get_classlist($cdom,$cnum); |
foreach my $student (keys (%{$classlist})) { |
my $now = time; |
|
foreach my $student (keys(%{$classlist})) { |
if (defined($$types{'active'})) { |
if (defined($$types{'active'})) { |
if ($$classlist{$student}[$statusidx] eq 'Active') { |
if ($$classlist{$student}[$statusidx] eq 'Active') { |
push(@{$$users{st}{$student}},'active'); |
push(@{$$users{st}{$student}},'active'); |
} |
} |
} |
} |
if (defined($$types{'previous'})) { |
if (defined($$types{'previous'})) { |
if ($$classlist{$student}[$endidx] <= time) { |
if ($$classlist{$student}[$endidx] <= $now) { |
push(@{$$users{st}{$student}},'previous'); |
push(@{$$users{st}{$student}},'previous'); |
} |
} |
} |
} |
if (defined($$types{'future'})) { |
if (defined($$types{'future'})) { |
if (($$classlist{$student}[$startidx] > 0) && ($$classlist{$student}[$endidx] > time) || ($$classlist{$student}[$endidx] == 0) || ($$classlist{$student}[$endidx] eq '')) { |
if (($$classlist{$student}[$startidx] > $now) && ($$classlist{$student}[$endidx] > $now) || ($$classlist{$student}[$endidx] == 0) || ($$classlist{$student}[$endidx] eq '')) { |
push(@{$$users{st}{$student}},'future'); |
push(@{$$users{st}{$student}},'future'); |
} |
} |
} |
} |
} |
} |
} |
} |
if ((@{$roles} > 0) && (@{$roles} ne "st")) { |
if ((@{$roles} > 0) && (@{$roles} ne "st")) { |
my ($cdom,$cnum) = split/_/,$course_id; |
|
my @coursepersonnel = &Apache::lonnet::getkeys('nohist_userroles',$cdom,$cnum); |
my @coursepersonnel = &Apache::lonnet::getkeys('nohist_userroles',$cdom,$cnum); |
foreach my $person (@coursepersonnel) { |
foreach my $person (@coursepersonnel) { |
my ($role,$user) = ($person =~ /^([^:]*):([^:]+:[^:]+)/); |
my ($role,$user) = ($person =~ /^([^:]*):([^:]+:[^:]+)/); |
$user =~ s/:$//; |
$user =~ s/:$//; |
if (($role) && (grep/^$role$/,@{$roles})) { |
if (($role) && (grep(/^$role$/,@{$roles}))) { |
my ($uname,$udom) = split/:/,$user; |
my ($uname,$udom) = split(/:/,$user); |
if ($uname ne '' && $udom ne '') { |
if ($uname ne '' && $udom ne '') { |
my $status = &check_user_status($udom,$uname,$cdom,$cnum,$role); |
my $status = &check_user_status($udom,$uname,$cdom,$cnum,$role); |
foreach my $type (keys %{$types}) { |
foreach my $type (keys(%{$types})) { |
if ($status eq $type) { |
if ($status eq $type) { |
$$users{$role}{$user} = $type; |
$$users{$role}{$user} = $type; |
} |
} |
Line 3119 sub get_course_users {
|
Line 3118 sub get_course_users {
|
} |
} |
} |
} |
} |
} |
|
if (grep/^ow$/,@{$roles}) { |
|
if ((defined($cdom)) && (defined($cnum))) { |
|
my %csettings = &Apache::lonnet::get('environment',['internal.courseowner'],$cdom,$cnum); |
|
if ( defined($csettings{'internal.courseowner'}) ) { |
|
my $owner = $csettings{'internal.courseowner'}; |
|
$$users{'ow'}{$owner.':'.$cdom} = 'any'; |
|
} |
|
} |
|
} |
} |
} |
return; |
return; |
} |
} |