Diff for /loncom/interface/loncommon.pm between versions 1.232 and 1.233

version 1.232, 2004/11/19 19:31:51 version 1.233, 2004/11/21 04:24:49
Line 2683  sub get_users_function { Line 2683  sub get_users_function {
   
 ###############################################  ###############################################
   
   =pod
   
   =item get_sections
   
   Determines all the sections for a course including
   sections with students and sections containing other roles.
   Incoming parameters: domain, course number, reference to 
   section hash (keys to be section/group IDs), reference to 
   array containing roles for which sections should be gathered
   (optional). If the fourth argument is undefined, sections
   are gathered for any role.
    
   Returns number of sections.
   
   =cut
   
   ###############################################
   sub get_sections {
       my ($cdom,$cnum,$sectioncount,$possible_roles) = @_;
       my $cid = $cdom.'_'.$cnum;
       my $numsections = 0;
       if ($cdom && $cnum) {
           if (!defined($possible_roles) || (grep/^st$/,@$possible_roles)) {
               my ($classlist) = &Apache::loncoursedata::get_classlist($cid,$cdom,$cnum);
               my $sec_index = &Apache::loncoursedata::CL_SECTION();
               my $status_index = &Apache::loncoursedata::CL_STATUS();
               while (my ($student,$data) = each %$classlist) {
                   my ($section,$status) = ($data->[$sec_index],
                                            $data->[$status_index]);
                   unless ($section eq '' || $section =~ /^\s*$/) {
                       if (!defined($$sectioncount{$section})) {
                           $$sectioncount{$section} = 1;
                           $numsections ++;
                       } else {
                           $$sectioncount{$section} ++;
                       }
                   }
               }
           }
           my %courseroles = &Apache::lonnet::dump('nohist_userroles',$cdom,$cnum);
           foreach my $user (sort keys %courseroles) {
               if ($user =~ /^(\w{2})/) {
                   my $role = $1;
                   if (!defined($possible_roles) || (grep/^$role$/,@$possible_roles)) {
                       if ($role eq 'cr') {
                           if ($user =~ m-^$role/[^/]*/[^/]*/[^/]*:[^:]*:[^:]*:(\w+)-) {
                               if (!defined($$sectioncount{$1})) {
                                   $$sectioncount{$1} = 1;
                                   $numsections ++;
                               } else {
                                   $$sectioncount{$1} ++;
                               }
                           }
                       }
                       if ($user =~ /^$role:[^:]*:[^:]*:(\w+)/) {
                           if (!defined($$sectioncount{$1})) {
                               $$sectioncount{$1} = 1;
                               $numsections ++;
                           } else {
                               $$sectioncount{$1} ++;
                           }
                       }
                   }
               }
           }
       }
       return $numsections;
   }
   
   
 sub get_posted_cgi {  sub get_posted_cgi {
     my $r=shift;      my $r=shift;
   

Removed from v.1.232  
changed lines
  Added in v.1.233


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>