');
$rowNum ++;
}
}
$r->print('');
$r->print(&Apache::lonhtmlcommon::end_pick_box());
+ $r->print('');
+ if ($action eq 'view') {
+ if (!defined($state)) {
+ $state = 'view';
+ }
+ $r->print('');
+ }
} else {
$r->print($lt{'nogr'});
if ($manage_permission) {
@@ -267,15 +295,15 @@ END
my @coursegroups = split(/:/,$env{'request.course.groups'});
if (@coursegroups > 0) {
$r->print('
');
- my %curr_groups;
- if (&Apache::loncommon::coursegroups(\%curr_groups,$cdom,$cnum)) {
+ my %curr_groups = &Apache::longroup::coursegroups($cdom,$cnum);
+ if (%curr_groups) {
foreach my $group (@coursegroups) {
- my %group_info = &Apache::loncommon::get_group_settings(
+ my %group_info = &Apache::longroup::get_group_settings(
$curr_groups{$group});
my $description = &Apache::lonnet::unescape(
$group_info{description});
my ($uname,$udom) = split(/:/,$group_info{creator});
- $r->print(''.$group,' '.$description.'
');
}
}
} else {
@@ -287,7 +315,7 @@ END
}
sub group_administration {
- my ($r,$action,$cdom,$cnum,$function,$tabcol,$functions,$idx,
+ my ($r,$action,$state,$cdom,$cnum,$function,$tabcol,$functions,$idx,
$view_permission,$manage_permission,$rowColor1,$rowColor2) = @_;
my %sectioncount = ();
my @tools = ();
@@ -302,7 +330,6 @@ sub group_administration {
my %memchg;
my @member_changes = ('deletion','expire','activate','reenable',
'changefunc','changepriv');
- my $state = $env{'form.state'};
my ($groupname,$description,$startdate,$enddate,$granularity,$specificity);
if (defined($env{'form.groupname'})) {
@@ -341,7 +368,11 @@ sub group_administration {
if ($action eq 'modify') {
if ($state eq '') {
- $state = 'pick_group';
+ if (defined($env{'form.groupname'})) {
+ $state = 'pick_task';
+ } else {
+ $state = 'pick_group';
+ }
} else {
%stored = &retrieve_settings($cdom,$cnum,$groupname);
if (ref($stored{'types'}) eq 'ARRAY') {
@@ -433,7 +464,10 @@ sub group_administration {
);
if (ref($stored{'autorole'}) eq 'ARRAY') {
foreach my $role (@{$stored{'autorole'}}) {
- $elements{'modify'}{'change_settings'}{'sec_'.$role} = 'selectbox';
+ unless ($role eq 'cc') {
+ $elements{'modify'}{'change_settings'}{'sec_'.$role} =
+ 'selectbox';
+ }
}
}
%{$elements{'create'}{'pick_members'}} = (
@@ -454,9 +488,8 @@ sub group_administration {
(($state eq 'pick_name') || ($state eq 'pick_privs'))) ||
(($action eq 'modify') && (($state eq 'change_settings') ||
($state eq 'add_members')))) {
- my $numsections = &Apache::loncommon::get_sections($cdom,$cnum,
- \%sectioncount);
- if ($numsections > 0) {
+ %sectioncount = &Apache::loncommon::get_sections($cdom,$cnum);
+ if (%sectioncount) {
$elements{'create'}{'pick_name'}{'sectionpick'} = 'selectbox';
$elements{'modify'}{'change_mapping'}{'sectionpick'} = 'selectbox';
$elements{'modify'}{'add_members'}{'sectionpick'} = 'selectbox';
@@ -473,7 +506,7 @@ sub group_administration {
}
if (defined($env{'form.sectionpick'})) {
@sections=&Apache::loncommon::get_env_multiple('form.sectionpick');
- if (grep/^_all$/,@sections) {
+ if (grep/^all$/,@sections) {
@sections = sort {$a cmp $b} keys(%sectioncount);
}
}
@@ -557,11 +590,17 @@ sub group_administration {
}
if (($state eq 'pick_privs') || ($state eq 'change_privs') ||
- (($specificity eq 'No') &&
- (($state eq 'result') || ($state eq 'memresult')))) {
+ (($specificity eq 'No') &&
+ ($state eq 'memresult' || $state eq 'result' || $state eq 'addresult'))) {
foreach my $tool (@tools) {
my @values = &Apache::loncommon::get_env_multiple('form.user_'.$tool);
foreach my $user (@values) {
+ if ($state eq 'pick_privs' || $state eq 'result'
+ || $state eq 'addresult') {
+ if (!grep(/^\Q$user\E$/,@members)) {
+ next;
+ }
+ }
unless(exists($usertools{$user}{$tool})) {
$usertools{$user}{$tool} = 1;
}
@@ -688,7 +727,7 @@ function changeSort(caller) {
document.$state.sortby.value = caller;
document.$state.submit();
}
-
+
|;
$jscript .= &Apache::lonhtmlcommon::set_form_elements(
\%{$elements{$action}{$state}},\%stored);
@@ -702,7 +741,7 @@ function changeSort(caller) {
@{$branchstates{'members'}} = ('change_members','change_privs','memresult');
@{$branchstates{'adds'}} = ('add_members','pick_members','pick_privs',
'addresult');
-
+
if (defined($env{'form.branch'})) {
push (@{$states{$action}},@{$branchstates{$env{'form.branch'}}});
}
@@ -798,7 +837,7 @@ function changeSort(caller) {
$r->print(&Apache::lonhtmlcommon::breadcrumbs
('Course Groups Manager'));
&display_groups($r,$cdom,$cnum,$function,$tabcol,$functions,$idx,
- $view_permission,$manage_permission,$action,
+ $view_permission,$manage_permission,$action,$state,
$rowColor1,$rowColor2);
}
@@ -808,55 +847,57 @@ function changeSort(caller) {
sub retrieve_settings {
my ($cdom,$cnum,$groupname) = @_;
- my %groupinfo;
+ my %curr_groups = &Apache::longroup::coursegroups($cdom,$cnum,$groupname);
+
+ return if (!%curr_groups);
+
+ my %groupinfo =
+ &Apache::longroup::get_group_settings($curr_groups{$groupname});
+
my %stored;
- my %curr_groups;
- my $numgroups = &Apache::loncommon::coursegroups(\%curr_groups,$cdom,
- $cnum,$groupname);
- if ($numgroups > 0) {
- %groupinfo = &Apache::loncommon::get_group_settings(
- $curr_groups{$groupname});
- $stored{'description'} = &Apache::lonnet::unescape(
- $groupinfo{'description'});
- $stored{'startdate'} = $groupinfo{'startdate'};
- $stored{'enddate'} = $groupinfo{'enddate'};
- if ($stored{'enddate'} == 0) {
- $stored{'no_end_date'} = 1;
- }
- $stored{'granularity'} = $groupinfo{'granularity'};
- $stored{'specificity'} = $groupinfo{'specificity'};
- $stored{'creation'} = $groupinfo{'creation'};
- $stored{'creator'} = $groupinfo{'creator'};
-
- foreach my $tool (sort(keys(%{$groupinfo{'functions'}}))) {
- if ($groupinfo{functions}{$tool} eq 'on') {
- push(@{$stored{tool}},$tool);
- }
- }
- foreach my $role (@{$groupinfo{'roles'}}) {
- push(@{$stored{roles}},$role);
- }
- foreach my $type (@{$groupinfo{'types'}}) {
- push(@{$stored{types}},$type);
- }
- foreach my $section (@{$groupinfo{'sectionpick'}}) {
- push(@{$stored{sectionpick}},$section);
- }
- foreach my $defpriv (@{$groupinfo{'defpriv'}}) {
- push(@{$stored{defpriv}},$defpriv);
- }
- $stored{'autoadd'} = $groupinfo{'autoadd'};
- $stored{'autodrop'} = $groupinfo{'autodrop'};
- if (exists($groupinfo{'autosec'})) {
- foreach my $role (sort(keys(%{$groupinfo{'autosec'}}))) {
- foreach my $section (@{$groupinfo{'autosec'}{$role}}) {
- push (@{$stored{'sec_'.$role}},$section);
- }
- if (@{$groupinfo{'autosec'}{$role}} > 0) {
- push(@{$stored{'autorole'}},$role);
- }
+
+ $stored{'description'} =
+ &Apache::lonnet::unescape($groupinfo{'description'});
+ $stored{'startdate'} = $groupinfo{'startdate'};
+ $stored{'enddate'} = $groupinfo{'enddate'};
+ if ($stored{'enddate'} == 0) {
+ $stored{'no_end_date'} = 1;
+ }
+ $stored{'granularity'} = $groupinfo{'granularity'};
+ $stored{'specificity'} = $groupinfo{'specificity'};
+ $stored{'creation'} = $groupinfo{'creation'};
+ $stored{'creator'} = $groupinfo{'creator'};
+
+ foreach my $tool (sort(keys(%{$groupinfo{'functions'}}))) {
+ if ($groupinfo{functions}{$tool} eq 'on') {
+ push(@{$stored{tool}},$tool);
+ }
+ }
+ foreach my $role (@{$groupinfo{'roles'}}) {
+ push(@{$stored{roles}},$role);
+ }
+ foreach my $type (@{$groupinfo{'types'}}) {
+ push(@{$stored{types}},$type);
+ }
+ foreach my $section (@{$groupinfo{'sectionpick'}}) {
+ push(@{$stored{sectionpick}},$section);
+ }
+ foreach my $defpriv (@{$groupinfo{'defpriv'}}) {
+ push(@{$stored{defpriv}},$defpriv);
+ }
+ $stored{'autoadd'} = $groupinfo{'autoadd'};
+ $stored{'autodrop'} = $groupinfo{'autodrop'};
+ if (exists($groupinfo{'autosec'})) {
+ foreach my $role (sort(keys(%{$groupinfo{'autosec'}}))) {
+ if (ref($groupinfo{'autosec'}{$role}) eq 'ARRAY') {
+ foreach my $section (@{$groupinfo{'autosec'}{$role}}) {
+ push (@{$stored{'sec_'.$role}},$section);
+ }
+ if (@{$groupinfo{'autosec'}{$role}} > 0) {
+ push(@{$stored{'autorole'}},$role);
+ }
}
- }
+ }
}
return %stored;
}
@@ -898,7 +939,7 @@ sub display_control {
my $groupname = $env{'form.groupname'};
if ($state eq 'pick_group') {
&display_groups($r,$cdom,$cnum,$function,$tabcol,$functions,$idx,
- $view_permission,$manage_permission,$action,
+ $view_permission,$manage_permission,$action,$state,
$rowColor1,$rowColor2);
} elsif ($state eq 'pick_task') {
&modify_menu($r,$groupname,$page);
@@ -1202,7 +1243,8 @@ sub membership_options {
'meof' => 'members of the new group.',
'admg' => 'additional members of the group.',
'ifno' => 'If you do not wish to add members when you first '.
- 'create the group, do not make any selections',
+ 'create the group, do not make any selections.',
+ 'asub' => 'A subsequent step will also allow you to specify automatic adding/dropping of group members triggered by specified role and section changes.',
'acty' => 'Access types',
'coro' => 'Course roles',
'cose' => 'Course sections',
@@ -1212,7 +1254,7 @@ sub membership_options {
previous => &mt('Previously had access'),
future => &mt('Will have future access'),
);
-
+
my @roles = ('st','cc','in','ta','ep','cr');
my @sections = keys(%{$sectioncount});
@@ -1224,7 +1266,7 @@ sub membership_options {
'.$lt{'gmem'}.' '.$lt{'picr'});
if ($action eq 'create') {
- $r->print($lt{'meof'}.' '.$lt{'ifno'});
+ $r->print($lt{'meof'}.' '.$lt{'ifno'}.' '.$lt{'asub'});
} else {
$r->print($lt{'admg'});
}
@@ -1248,8 +1290,8 @@ sub membership_options {
$r->print(&Apache::lonhtmlcommon::role_select_row(\@roles));
if (@sections > 0) {
@sections = sort {$a cmp $b} @sections;
- unshift(@sections,'_all'); # Put 'all' at the front of the list
- unshift(@sections,'_nosec'); # Put 'no sections' next
+ unshift(@sections,'all'); # Put 'all' at the front of the list
+ unshift(@sections,'none'); # Put 'no sections' next
$r->print('