version 1.165, 2006/04/29 18:00:17
|
version 1.166, 2006/05/01 05:27:28
|
Line 2874 sub get_classlist {
|
Line 2874 sub get_classlist {
|
} |
} |
} |
} |
|
|
|
sub get_group_memberships { |
|
my ($classlist,$cdom,$cnum) = @_; |
|
my $cid = $cdom.'_'.$cnum; |
|
if (!defined($cdom) || !defined($cnum)) { |
|
$cid = $env{'request.course.id'}; |
|
$cdom = $env{'course.'.$cid.'.domain'}; |
|
$cnum = $env{'course.'.$cid.'.num'}; |
|
} |
|
my (%classgroups,%studentgroups); |
|
my $now = time; |
|
my $access_end = $env{'course.'.$cid.'.default_enrollment_end_date'}; |
|
my (%curr_groups,%groupmemberhash); |
|
my $numgroups = &Apache::loncommon::coursegroups(\%curr_groups,$cdom, |
|
$cnum); |
|
if ($numgroups) { |
|
%groupmemberhash = &Apache::lonnet::get_group_membership($cdom,$cnum); |
|
foreach my $student (keys(%{$classlist})) { |
|
%{$classgroups{$student}} = (); |
|
my $hasgroup = 0; |
|
foreach my $status ('previous','future','active','aftercourse') { |
|
%{$classgroups{$student}{$status}} = (); |
|
} |
|
foreach my $group (keys(%curr_groups)) { |
|
if (defined($groupmemberhash{$group.':'.$student})) { |
|
my ($end,$start) = split(/:/,$groupmemberhash{$group.':'. |
|
$student}); |
|
if ($start == -1) { |
|
next; |
|
} else { |
|
$studentgroups{$group} ++; |
|
$hasgroup = 1; |
|
if ($end && $end < $now) { |
|
$classgroups{$student}{'previous'}{$group} = |
|
$groupmemberhash{$group.':'.$student}; |
|
if ($classlist->{$student}[&CL_STATUS()] eq 'Expired') { |
|
if ($access_end && $access_end < $now) { |
|
if ($access_end - $end < 86400) { |
|
$classgroups{$student}{'aftercourse'}{$group} = $groupmemberhash{$group.':'.$student}; |
|
} |
|
} |
|
} |
|
} elsif ($now > $start) { |
|
if (!$end || $end > $now) { |
|
$classgroups{$student}{'active'}{$group} = |
|
$groupmemberhash{$group.':'.$student}; |
|
} |
|
} else { |
|
$classgroups{$student}{'future'}{$group} = |
|
$groupmemberhash{$group.':'.$student}; |
|
} |
|
} |
|
} |
|
} |
|
if (!$hasgroup) { |
|
$studentgroups{'none'} ++; |
|
} |
|
} |
|
} |
|
return (\%classgroups,\%studentgroups); |
|
} |
|
|
|
sub get_students_groups { |
|
my ($student,$enrollment_status,$classgroups) = @_; |
|
my @studentsgroups = (); |
|
if (ref($$classgroups{$student}{'active'}) eq 'HASH') { |
|
push(@studentsgroups,keys(%{$$classgroups{$student}{'active'}})); |
|
} |
|
if ($enrollment_status eq 'Any') { |
|
foreach my $status ('previous','future') { |
|
if (ref($$classgroups{$student}{$status}) eq 'HASH') { |
|
push(@studentsgroups,keys(%{$$classgroups{$student}{$status}})); |
|
} |
|
} |
|
} else { |
|
if (ref($$classgroups{$student}{'aftercourse'}) eq 'HASH') { |
|
push(@studentsgroups,keys(%{$$classgroups{$student}{'aftercourse'}})); |
|
} |
|
} |
|
return @studentsgroups; |
|
} |
|
|
|
|
# ----- END HELPER FUNCTIONS -------------------------------------------- |
# ----- END HELPER FUNCTIONS -------------------------------------------- |
|
|
1; |
1; |
__END__ |
__END__ |
|
|
|
|