Diff for /loncom/interface/loncommon.pm between versions 1.239 and 1.240

version 1.239, 2004/12/02 18:58:30 version 1.240, 2004/12/02 21:30:16
Line 2719  Returns number of sections. Line 2719  Returns number of sections.
 ###############################################  ###############################################
 sub get_sections {  sub get_sections {
     my ($cdom,$cnum,$sectioncount,$possible_roles) = @_;      my ($cdom,$cnum,$sectioncount,$possible_roles) = @_;
       if (!($cdom && $cnum)) { return 0; }
     my $cid = $cdom.'_'.$cnum;      my $cid = $cdom.'_'.$cnum;
     my $numsections = 0;      my $numsections = 0;
     if ($cdom && $cnum) {  
         if (!defined($possible_roles) || (grep/^st$/,@$possible_roles)) {      if (!defined($possible_roles) || (grep/^st$/,@$possible_roles)) {
             my ($classlist) = &Apache::loncoursedata::get_classlist($cid,$cdom,$cnum);   my ($classlist) = &Apache::loncoursedata::get_classlist($cid,$cdom,$cnum);
             my $sec_index = &Apache::loncoursedata::CL_SECTION();   my $sec_index = &Apache::loncoursedata::CL_SECTION();
             my $status_index = &Apache::loncoursedata::CL_STATUS();   my $status_index = &Apache::loncoursedata::CL_STATUS();
             while (my ($student,$data) = each %$classlist) {   while (my ($student,$data) = each %$classlist) {
                 my ($section,$status) = ($data->[$sec_index],      my ($section,$status) = ($data->[$sec_index],
                                          $data->[$status_index]);       $data->[$status_index]);
                 unless ($section eq '' || $section =~ /^\s*$/) {      unless ($section eq '-1' || $section =~ /^\s*$/) {
                     if (!defined($$sectioncount{$section})) {   if (!defined($$sectioncount{$section})) { $numsections++; }
                         $$sectioncount{$section} = 1;   $$sectioncount{$section}++;
                         $numsections ++;      }
                     } else {   }
                         $$sectioncount{$section} ++;      }
                     }      my %courseroles = &Apache::lonnet::dump('nohist_userroles',$cdom,$cnum);
                 }      foreach my $user (sort(keys(%courseroles))) {
             }   if ($user !~ /^(\w{2})/) { next; }
         }   my ($role) = ($user =~ /^(\w{2})/);
         my %courseroles = &Apache::lonnet::dump('nohist_userroles',$cdom,$cnum);   if ($possible_roles && !(grep(/^$role$/,@$possible_roles))) { next; }
         foreach my $user (sort keys %courseroles) {   my $section;
             if ($user =~ /^(\w{2})/) {   if ($role eq 'cr' &&
                 my $role = $1;      $user =~ m-^$role/[^/]*/[^/]*/[^/]*:[^:]*:[^:]*:(\w+)-) {
                 if (!defined($possible_roles) || (grep/^$role$/,@$possible_roles)) {      $section=$1;
                     if ($role eq 'cr') {   }
                         if ($user =~ m-^$role/[^/]*/[^/]*/[^/]*:[^:]*:[^:]*:(\w+)-) {   if ($user =~ /^$role:[^:]*:[^:]*:(\w+)/) { $section=$1; }
                             if (!defined($$sectioncount{$1})) {   if (!defined($section) || $section eq '-1') { next; }
                                 $$sectioncount{$1} = 1;   if (!defined($$sectioncount{$section})) { $numsections++; } 
                                 $numsections ++;   $$sectioncount{$section}++;
                             } else {  
                                 $$sectioncount{$1} ++;  
                             }  
                         }  
                     }  
                     if ($user =~ /^$role:[^:]*:[^:]*:(\w+)/) {  
                         if (!defined($$sectioncount{$1})) {  
                             $$sectioncount{$1} = 1;  
                             $numsections ++;  
                         } else {  
                             $$sectioncount{$1} ++;  
                         }  
                     }  
                 }  
             }  
         }  
     }      }
     return $numsections;      return $numsections;
 }  }

Removed from v.1.239  
changed lines
  Added in v.1.240


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