Diff for /loncom/interface/loncoursegroups.pm between versions 1.57 and 1.58

version 1.57, 2006/07/21 02:51:31 version 1.58, 2006/07/28 18:44:27
Line 965  sub retrieve_settings { Line 965  sub retrieve_settings {
  foreach my $role (sort(keys(%{$groupinfo{'autosec'}}))) {   foreach my $role (sort(keys(%{$groupinfo{'autosec'}}))) {
             if (ref($groupinfo{'autosec'}{$role}) eq 'ARRAY') {              if (ref($groupinfo{'autosec'}{$role}) eq 'ARRAY') {
         foreach my $section (@{$groupinfo{'autosec'}{$role}}) {          foreach my $section (@{$groupinfo{'autosec'}{$role}}) {
   
             push (@{$stored{'sec_'.$role}},$section);              push (@{$stored{'sec_'.$role}},$section);
         }          }
         if (@{$groupinfo{'autosec'}{$role}} > 0) {          if (@{$groupinfo{'autosec'}{$role}} > 0) {
Line 1206  sub general_settings_form { Line 1207  sub general_settings_form {
        $gpterm,$ucgpterm);         $gpterm,$ucgpterm);
         &mapping_options($r,$action,$formname,$page,$sectioncount,          &mapping_options($r,$action,$formname,$page,$sectioncount,
                          $states,$stored,$navbuttons,4,5,                           $states,$stored,$navbuttons,4,5,
  $gpterm,$ucgpterm,$crstype);   $gpterm,$ucgpterm,$crstype,$cdom,$cnum);
         $nexttext = $$navbuttons{'mose'};          $nexttext = $$navbuttons{'mose'};
     }      }
     $prevtext = $$navbuttons{'gtpp'};      $prevtext = $$navbuttons{'gtpp'};
Line 2413  sub choose_privs_form { Line 2414  sub choose_privs_form {
         my $img2 = 8;          my $img2 = 8;
         &mapping_options($r,$action,$formname,$page,$sectioncount,          &mapping_options($r,$action,$formname,$page,$sectioncount,
                          $states,$stored,$navbuttons,$img1,$img2,                           $states,$stored,$navbuttons,$img1,$img2,
                          $gpterm,$ucgpterm,$crstype);                           $gpterm,$ucgpterm,$crstype,$cdom,$cnum);
     }      }
     my $prevtext = $$navbuttons{'gtps'};      my $prevtext = $$navbuttons{'gtps'};
     &display_navbuttons($r,$formname,$$states{$action}[$page-1],$prevtext,      &display_navbuttons($r,$formname,$$states{$action}[$page-1],$prevtext,
Line 3077  sub process_membership { Line 3078  sub process_membership {
   
 sub mapping_options {  sub mapping_options {
     my ($r,$action,$formname,$page,$sectioncount,$states,$stored,      my ($r,$action,$formname,$page,$sectioncount,$states,$stored,
         $navbuttons,$img1,$img2,$gpterm,$ucgpterm,$crstype) = @_;          $navbuttons,$img1,$img2,$gpterm,$ucgpterm,$crstype,$cdom,$cnum) = @_;
     my %lt = &Apache::lonlocal::texthash(      my %lt = &Apache::lonlocal::texthash(
         'auto' => "Settings for automatic $gpterm enrollment",          'auto' => "Settings for automatic $gpterm enrollment",
         'gmma' => "$ucgpterm membership mapping to specific sections/roles",          'gmma' => "$ucgpterm membership mapping to specific sections/roles",
Line 3094  sub mapping_options { Line 3095  sub mapping_options {
         'mapr' => "Mapping of roles and sections affected by automatic $gpterm enrollment/disenrollment follows scheme chosen below.",          'mapr' => "Mapping of roles and sections affected by automatic $gpterm enrollment/disenrollment follows scheme chosen below.",
     );      );
     &automapping($r,$action,$stored,\%lt,$img1);      &automapping($r,$action,$stored,\%lt,$img1);
     &mapping_settings($r,$sectioncount,\%lt,$stored,$img2,$crstype);      &mapping_settings($r,$sectioncount,\%lt,$stored,$img2,$crstype,$cdom,$cnum,
                         $action);
     return;      return;
 }  }
   
Line 3127  sub automapping { Line 3129  sub automapping {
 }  }
   
 sub mapping_settings {  sub mapping_settings {
     my ($r,$sectioncount,$lt,$stored,$image,$crstype) = @_;      my ($r,$sectioncount,$lt,$stored,$image,$crstype,$cdom,$cnum,$action) = @_;
     my @sections = keys(%{$sectioncount});      my @sections = keys(%{$sectioncount});
     if (@sections > 0) {      if (@sections > 0) {
         @sections = sort {$a cmp $b} @sections;          @sections = sort {$a cmp $b} @sections;
Line 3138  sub mapping_settings { Line 3140  sub mapping_settings {
     }      }
     &topic_bar($r,$image,$$lt{'pirs'});      &topic_bar($r,$image,$$lt{'pirs'});
     my @roles = &standard_roles();      my @roles = &standard_roles();
     my %customroles = &my_custom_roles();      my %customroles = &course_custom_roles($cdom,$cnum);
     $r->print(&Apache::loncommon::start_data_table().      $r->print(&Apache::loncommon::start_data_table().
       &Apache::loncommon::start_data_table_header_row());        &Apache::loncommon::start_data_table_header_row());
     $r->print('      $r->print('
Line 3149  sub mapping_settings { Line 3151  sub mapping_settings {
     }      }
     $r->print(&Apache::loncommon::end_data_table_header_row()."\n");      $r->print(&Apache::loncommon::end_data_table_header_row()."\n");
     foreach my $role (@roles) {      foreach my $role (@roles) {
         my $plrole=&Apache::lonnet::plaintext($role,$crstype);          my $roletitle=&Apache::lonnet::plaintext($role,$crstype);
         my $sections_sel;          $r->print(&print_autorole_item($role,$roletitle,\@sections));
         if (@sections > 0) {  
             if ($role eq 'cc') {  
                 $sections_sel = '<td align="right">'.  
                                 &mt('all sections').'<input type="hidden" '.   
                                 'name="sec_cc" value="all" /></td>';  
             } else {   
                 $sections_sel='<td align="right">'.  
                               &sections_selection(\@sections,'sec_'.$role).  
                               '</td>';  
             }  
         }  
         $r->print(&Apache::loncommon::start_data_table_row().  
   '<td><input type="checkbox" '.  
                   'name="autorole" value="'.$role.'" /></td><td>'.$plrole.  
                   '</td>'.$sections_sel.  
   &Apache::loncommon::end_data_table_row());  
     }      }
       my @customs;
     foreach my $role (sort(keys(%customroles))) {      foreach my $role (sort(keys(%customroles))) {
         my $sections_sel;          my ($roletitle) = ($role =~ m|^cr/[^/]+/[^/]+/(.+)$|);
         if (@sections > 0) {          $role =~ s/\//_/g;
             $sections_sel =           push (@customs,$role);
  '<td>'.&sections_selection(\@sections,'sec_'.$role).'</td>';          $r->print(&print_autorole_item($role,$roletitle,\@sections));
         }      }
         $r->print(&Apache::loncommon::start_data_table_row().      if ($action eq 'modify') {
   '<td><input type="checkbox" '.          foreach my $role (@{$$stored{'autorole'}}) {
                   'value="'.$role.'" /></td><td>'.&mt('Custom role: ').              if ((!grep(/^\Q$role\E$/,@customs)) && 
                   '<i>'.$role.'</i></td>'.$sections_sel.                  (!grep(/^\Q$role\E$/,@roles))) {
   &Apache::loncommon::end_data_table_row());                  my $roletitle;
                   if ($role =~ /^cr/) {
                       ($roletitle) = ($role =~ m|_([^_]+)$|);
                   } else {
                       $roletitle = &Apache::lonnet::plaintext($role,$crstype);
                   }
                   $r->print(&print_autorole_item($role,$roletitle,\@sections));
               }
           }
     }      }
     $r->print(&Apache::loncommon::end_data_table());      $r->print(&Apache::loncommon::end_data_table());
     return;      return;
 }  }
   
   sub print_autorole_item {
       my ($role,$roletitle,$sections) = @_;
       my $sections_sel;
       if (@{$sections} > 0) {
           if ($role eq 'cc') {
               $sections_sel = '<td align="right">'.
                               &mt('all sections').'<input type="hidden" '.
                               'name="sec_cc" value="all" /></td>';
           } else {
               $sections_sel='<td align="right">'.
                             &sections_selection($sections,'sec_'.$role).
                             '</td>';
           }
       }
       my $output = &Apache::loncommon::start_data_table_row().
                    '<td><input type="checkbox" '.
                    'name="autorole" value="'.$role.'" />'.
                    '</td><td>'.$roletitle.'</td>'.$sections_sel.
                    &Apache::loncommon::end_data_table_row();
       return $output;
   } 
   
 sub standard_roles {  sub standard_roles {
     my @roles = ('cc','in','ta','ep','st');      my @roles = ('cc','in','ta','ep','st');
     return @roles;      return @roles;
 }  }
   
 sub my_custom_roles {  sub course_custom_roles {
       my ($cdom,$cnum) = @_;
     my %returnhash=();      my %returnhash=();
     my %rolehash=&Apache::lonnet::dump('roles');      my %coursepersonnel=&Apache::lonnet::dump('nohist_userroles',$cdom,$cnum);
     foreach (keys %rolehash) {      foreach my $person (sort(keys(%coursepersonnel))) {
         if ($_=~/^rolesdef\_(\w+)$/) {          my ($role) = ($person =~ /^([^:]+):/);
             $returnhash{$1}=$1;          my ($end,$start) = split(/:/,$coursepersonnel{$person});
           if ($end == -1 && $start == -1) {
               next;
           }
           if ($role =~ m|^cr/[^/]+/[^/]+/[^/]|) {
               $returnhash{$role} ++;
         }          }
     }      }
     return %returnhash;      return %returnhash;

Removed from v.1.57  
changed lines
  Added in v.1.58


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