[LON-CAPA-cvs] cvs: loncom /interface loncoursegroups.pm
raeburn
lon-capa-cvs@mail.lon-capa.org
Mon, 22 May 2006 22:35:49 -0000
This is a MIME encoded message
--raeburn1148337349
Content-Type: text/plain
raeburn Mon May 22 18:35:49 2006 EDT
Modified files:
/loncom/interface loncoursegroups.pm
Log:
Enabling sorting by column in tabular display of course groups. This table now includes links for both viewing and modifying a specific group, if a user has appropriate privileges. Group access dates no longer reset when enabling new functionality or changing privileges for existing users. Fixes so addition of new members sets group privileges for only these users.
--raeburn1148337349
Content-Type: text/plain
Content-Disposition: attachment; filename="raeburn-20060522183549.txt"
Index: loncom/interface/loncoursegroups.pm
diff -u loncom/interface/loncoursegroups.pm:1.20 loncom/interface/loncoursegroups.pm:1.21
--- loncom/interface/loncoursegroups.pm:1.20 Thu May 18 18:13:48 2006
+++ loncom/interface/loncoursegroups.pm Mon May 22 18:35:46 2006
@@ -83,10 +83,16 @@
my $rowColor2 = "#eeeeee";
my $action = $env{'form.action'};
+ my $state = $env{'form.state'};
+ if ((!defined($action)) || ($action eq 'view')) {
+ if (!defined($state)) {
+ $state = 'view';
+ }
+ }
if ($action eq 'create' || $action eq 'modify' || $action eq 'view') {
if ($view_permission || $manage_permission) {
- &group_administration($r,$action,$cdom,$cnum,$function,$tabcol,
- \%functions,\%idx,$view_permission,
+ &group_administration($r,$action,$state,$cdom,$cnum,$function,
+ $tabcol,\%functions,\%idx,$view_permission,
$manage_permission,$rowColor1,$rowColor2);
} else {
$r->print(&mt('You do not have group administration '.
@@ -94,7 +100,7 @@
}
} else {
&print_main_menu($r,$cdom,$cnum,$function,$tabcol,\%functions,\%idx,
- $view_permission,$manage_permission,$action,
+ $view_permission,$manage_permission,$action,$state,
$rowColor1,$rowColor2);
}
return OK;
@@ -102,31 +108,36 @@
sub print_main_menu {
my ($r,$cdom,$cnum,$function,$tabcol,$functions,$idx,$view_permission,
- $manage_permission,$action,$rowColor1,$rowColor2) = @_;
- $r->print(&header('Course Groups',undef,undef,undef,undef,$function));
+ $manage_permission,$action,$state,$rowColor1,$rowColor2) = @_;
+ my $jscript = qq|
+function changeSort(caller) {
+ document.$state.sortby.value = caller;
+ document.$state.submit();
+}\n|;
+ $r->print(&header('Course Groups',$jscript,$action,$state,
+ undef,$function));
&Apache::lonhtmlcommon::add_breadcrumb
({href=>"/adm/coursegroups",
text=>"Course Groups",});
$r->print(&Apache::lonhtmlcommon::breadcrumbs('Course Groups'));
&display_groups($r,$cdom,$cnum,$function,$tabcol,$functions,$idx,
- $view_permission,$manage_permission,$action,$rowColor1,
- $rowColor2);
+ $view_permission,$manage_permission,$action,$state,
+ $rowColor1,$rowColor2);
$r->print(&footer());
return;
}
sub display_groups {
my ($r,$cdom,$cnum,$function,$tabcol,$functions,$idx,$view_permission,
- $manage_permission,$action,$rowColor1,$rowColor2) = @_;
+ $manage_permission,$action,$state,$rowColor1,$rowColor2) = @_;
my %curr_groups = ();
my %grp_info = ();
-
my %actionlinks = (
- modify => '<a href="/adm/coursegroups?action=modify&state=pick_task&refpage='.
- $env{'form.refpage'}.'&groupname=',
+ modify => '<a href="/adm/coursegroups?action=modify&refpage='.
+ $env{'form.refpage'}.'&groupname=',
view => '<a href="/adm/'.$cdom.'/'.$cnum.'/',
delete => '<a href="/adm/coursegroups?action=delete&refpage='.
- $env{'form.refpage'}.'&groupname=',
+ $env{'form.refpage'}.'&groupname=',
);
my %lt = &Apache::lonlocal::texthash(
modify => 'Modify',
@@ -174,7 +185,7 @@
<td><b>$lt{'func'}</b>
</td>
<td><b><a href="javascript:changeSort('quota')">$lt{'quot'}</a></b></td>
- <td><b><a href="javascript:changeSort('totalmembers)">$lt{'memb'}</a></b></td>
+ <td><b><a href="javascript:changeSort('totalmembers')">$lt{'memb'}</a></b></td>
<td><b><a href="javascript:changeSort('totalfiles')">$lt{'file'}</a></b></td>
<td><b><a href="javascript:changeSort('boards')">$lt{'dibd'}</a></b></td>
<td><b><a href="javascript:changeSort('diskuse')">$lt{'dius'}</a></b></td>
@@ -248,13 +259,29 @@
} else {
$link .= $group.'/grppg';
}
- $link .= '">'.$lt{$action}.'</a>';
+ $link .= '">'.$lt{$action}.'</a>';
+ if ($action eq 'view') {
+ if (($manage_permission) &&
+ ($env{'form.refpage'} ne 'enrl')) {
+ $link .= ' '.$actionlinks{'modify'}.
+ $group.'">'.$lt{'modify'}.'</a>';
+ }
+ }
$r->print('<tr bgcolor="'.$rowColor.'"><td><small>'.$link.'</small></td><td><small>'.$group.'</small></td><td><small>'.$description.'</small></td><td><small>'.$creator.'</small></td><td><small>'. &Apache::lonnavmaps::timeToHumanString($creation).'</small></td><td><small>'. &Apache::lonnavmaps::timeToHumanString($modified).'</small></td><td><small>'.$functionality.'</small></td><td><small>'.$quota.'</small></td><td><small>'.$totalmembers.'</small></td><td><small>'.$totalfiles.'</small></td><td><small>'.$boards.'</small></td><td><small>'.$diskuse.'</small></td></tr>');
$rowNum ++;
}
}
$r->print('</table>');
$r->print(&Apache::lonhtmlcommon::end_pick_box());
+ $r->print('<input type="hidden" name="refpage" '.
+ 'value="'.$env{'form.refpage'}.'" />');
+ if ($action eq 'view') {
+ if (!defined($state)) {
+ $state = 'view';
+ }
+ $r->print('<input type="hidden" name="state" value="'.
+ $state.'" />');
+ }
} else {
$r->print($lt{'nogr'});
if ($manage_permission) {
@@ -288,7 +315,7 @@
}
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 = ();
@@ -303,7 +330,6 @@
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'})) {
@@ -342,7 +368,11 @@
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') {
@@ -560,11 +590,17 @@
}
if (($state eq 'pick_privs') || ($state eq 'change_privs') ||
- (($specificity eq 'No') &&
- (($state eq 'addresult') || ($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;
}
@@ -705,7 +741,7 @@
@{$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'}}});
}
@@ -801,7 +837,7 @@
$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);
}
@@ -903,7 +939,7 @@
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);
@@ -1207,7 +1243,8 @@
'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',
@@ -1229,7 +1266,7 @@
<td colspan="3">
<b>'.$lt{'gmem'}.'</b><br/>'.$lt{'picr'});
if ($action eq 'create') {
- $r->print($lt{'meof'}.'<br />'.$lt{'ifno'});
+ $r->print($lt{'meof'}.'<br />'.$lt{'ifno'}.'<br />'.$lt{'asub'});
} else {
$r->print($lt{'admg'});
}
@@ -2906,6 +2943,8 @@
my $num_fail = 0;
my %group_privs = ();
my %curr_privs = ();
+ my %curr_start = ();
+ my %curr_end = ();
my %tooltype = ();
foreach my $tool (@{$tools}) {
@@ -2962,21 +3001,21 @@
$groupname);
foreach my $key (sort(keys(%membership))) {
if ($key =~ /^\Q$groupname\E:([^:]+:[^:]+)$/) {
- (undef,undef,$curr_privs{$1})=split(/:/,$membership{$key},3);
+ ($curr_end{$1},$curr_start{$1},$curr_privs{$1}) =
+ split(/:/,$membership{$key},3);
}
}
if (@expire + @deletion > 0) {
foreach my $user (@expire) {
- my ($currend,$currstart,$grp_privs) =
- split(/:/,$membership{$groupname.':'.$user},3);
- if ($currstart > $now) {
- $currstart = $now;
+ my $savestart = $curr_start{$user};
+ if ($savestart > $now) {
+ $savestart = $now;
}
- $usersettings{$groupname.':'.$user} = $now.':'.$currstart.':'.
- $grp_privs;
+ $usersettings{$groupname.':'.$user} = $now.':'.$savestart.':'.
+ $curr_privs{$user};
if (&Apache::lonnet::modify_group_roles($cdom,$cnum,$groupname,
- $user,$now,$currstart,
- $grp_privs) eq 'ok') {
+ $user,$now,$savestart,
+ $curr_privs{$user}) eq 'ok') {
push(@{$added{'expired'}},$user);
$num_ok ++;
} else {
@@ -3011,15 +3050,24 @@
push(@unchanged,$user);
next;
}
+ if (exists($curr_start{$user})) {
+ $start = $curr_start{$user};
+ }
+ if (exists($curr_end{$user})) {
+ $end = $curr_end{$user};
+ }
$type = 'modified';
if (@activate > 0) {
if (grep/^$user$/,@activate) {
$start = $now;
+ $end = $enddate;
$type = 'activated';
}
}
if (@reenable > 0) {
if (grep/^$user$/,@reenable) {
+ $start = $startdate;
+ $end = $enddate;
$type = 'reenabled';
}
}
--raeburn1148337349--