--- loncom/interface/loncoursegroups.pm 2010/01/25 22:19:55 1.101.4.1
+++ loncom/interface/loncoursegroups.pm 2012/10/04 13:41:10 1.115
@@ -1,6 +1,6 @@
# The LearningOnline Network with CAPA
#
-# $Id: loncoursegroups.pm,v 1.101.4.1 2010/01/25 22:19:55 raeburn Exp $
+# $Id: loncoursegroups.pm,v 1.115 2012/10/04 13:41:10 bisitz Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -54,7 +54,7 @@ sub handler {
if (! ($env{'request.course.fn'})) {
# Not in a course
$env{'user.error.msg'}=
- "/adm/coursegroups:mdg:0:0:Cannot edit or view course groups";
+ "/adm/coursegroups:mdg:0:0:Cannot edit or view course/community groups";
return HTTP_NOT_ACCEPTABLE;
}
@@ -135,7 +135,7 @@ function changeSort(caller) {
function openGroupRoster(group,status) {
var url = '/adm/grouproster?';
url += 'group='+group+'&status='+status+'&ref=popup';
- var title = 'Group Membership';
+ var title = 'Group_Membership';
var options = 'scrollbars=1,resizable=1,menubar=0';
options += ',width=700,height=600';
rosterbrowser = open(url,title,options,'1');
@@ -170,7 +170,7 @@ sub display_groups {
my %actionlinks = (
modify => ' ' ''.
+ &mt('An error occurred retrieving information about resources in the course.').' '.
+ &mt('It is recommended that you [_1]re-initialize the course[_2] and then return to this page.','','').
+ '');
+ return;
+ }
if ($manage_permission) {
if ($action ne 'reenable') {
$r->print(' '.$lt{'crng'}.'');
@@ -324,7 +332,9 @@ END
$action eq 'reenable') {
$link .= $group;
} else {
- $link .= $group.'/smppg?ref=grouplist';
+ $link .=
+ &Apache::longroup::get_group_link($cdom,$cnum,$group,$navmap);
+ $link .= (($link=~/\?/)?'&':'?').'ref=grouplist';
if (exists($env{'form.refpage'})) {
$link .= '&refpage='.$env{'form.refpage'};
}
@@ -386,16 +396,32 @@ END
$r->print('
');
my %curr_groups = &Apache::longroup::coursegroups($cdom,$cnum);
if (%curr_groups) {
+ my $navmap=Apache::lonnavmaps::navmap->new();
+ if (!defined($navmap)) {
+ $r->print('
'.
+ &mt('An error occurred retrieving information about resources in the course.').' '.
+ &mt('It is recommended that you [_1]re-initialize the course[_2] and then return to this page.','','').
+ '
');
+ return;
+ }
foreach my $group (@coursegroups) {
my %group_info = &Apache::longroup::get_group_settings(
$curr_groups{$group});
my $description = &unescape(
$group_info{description});
- $r->print(''.$group,' '.$description.'
');
}
}
} else {
- $r->print(&mt('You are not currently a member of any active '.$gpterm.'s in this '.lc($crstype).'.'));
+ $r->print(
+ '
'
+ .&mt('You are not currently a member of any active '.$gpterm.'s'
+ .' in this '.lc($crstype).'.')
+ .'
'
+ );
}
}
return;
@@ -537,7 +563,7 @@ sub group_administration {
if (ref($stored{'autorole'}) eq 'ARRAY') {
foreach my $role (@{$stored{'autorole'}}) {
- unless ($role eq 'cc') {
+ unless (($role eq 'cc') || ($role eq 'co')) {
$elements{'modify'}{'change_settings'}{'sec_'.$role} =
'selectbox';
}
@@ -1086,7 +1112,7 @@ sub display_control {
&add_members_form($r,$cdom,$cnum,$action,$state,$page,$startdate,
$enddate,$groupname,$description,$granularity,
$quota,$sectioncount,$tools,$functions,$stored,
- $states,$navbuttons,$gpterm,$ucgpterm);
+ $states,$navbuttons,$gpterm,$ucgpterm,$crstype);
} elsif ($state eq 'pick_members') {
&choose_members_form($r,$cdom,$cnum,$action,$state,$page,
$groupname,$description,$granularity,$quota,
@@ -1119,31 +1145,36 @@ sub display_control {
my %stored = &retrieve_settings($cdom,$cnum,$groupname,$action);
if ($state eq 'verify') {
&verify_delete($r,$groupname,$state,$action,$page,$states,
- \%stored);
+ \%stored,$crstype);
} elsif ($state eq 'result') {
- &delete_group($r,$cdom,$cnum,$groupname);
+ &delete_group($r,$cdom,$cnum,$groupname,$crstype);
}
} elsif ($action eq 'reenable') {
my %stored = &retrieve_settings($cdom,$cnum,$groupname,$action);
if ($state eq 'verify') {
&verify_reenable($r,$groupname,$state,$action,$page,$states,
- \%stored);
+ \%stored,$crstype);
} elsif ($state eq 'result') {
- &reenable_group($r,$cdom,$cnum,$groupname);
+ &reenable_group($r,$cdom,$cnum,$groupname,$crstype);
}
}
}
sub verify_delete {
- my ($r,$groupname,$formname,$action,$page,$states,$stored) = @_;
+ my ($r,$groupname,$formname,$action,$page,$states,$stored,$crstype) = @_;
$r->print(&Apache::lonhtmlcommon::echo_form_input([]));
$r->print(&mt('You have requested deletion of the group [_1].'
,''.$stored->{'description'}.'').
'
'.&mt('When a group is deleted the following occurs:').'
'.
'
'.&mt('All group membership is terminated.').'
'.
- '
'.&mt('The group ceases to be available either for viewing or for modification of group settings and membership.').'
'.
- '
'.&mt('The group folder is removed from the folder containing it - normally this is the "Course Groups" folder which contains folders for all groups in the course.').'
'.
- '
'.&mt('Although a deleted group is no longer accessible, the group name used for the group will be reserved, and will not be available for assignment to a new group in the same course in the future.'));
+ '
'.&mt('The group ceases to be available either for viewing or for modification of group settings and membership.').'
');
+ if ($crstype eq 'Community') {
+ $r->print( '
'.&mt("The group folder is removed from the folder containing it - normally this is the 'Community Groups' folder which contains folders for all groups in the community.").'
'.
+ ''.&mt("Although a deleted group is no longer accessible, the group name used for the group will be reserved, and will not be available for assignment to a new group in the same community in the future."));
+ } else {
+ $r->print( '
'.&mt("The group folder is removed from the folder containing it - normally this is the 'Course Groups' folder which contains folders for all groups in the course.").'
'.
+ ''.&mt("Although a deleted group is no longer accessible, the group name used for the group will be reserved, and will not be available for assignment to a new group in the same course in the future."));
+ }
my $prevtext = &mt('Go back');
my $nexttext = &mt('Delete group');
my $prev;
@@ -1156,7 +1187,7 @@ sub verify_delete {
}
sub delete_group {
- my ($r,$cdom,$cnum,$groupname) = @_;
+ my ($r,$cdom,$cnum,$groupname,$crstype) = @_;
my %membership = &Apache::lonnet::get_group_membership($cdom,$cnum,
$groupname);
my $now = time;
@@ -1198,38 +1229,45 @@ sub delete_group {
.&mt('Group deletion failed because deletion of [_1] out of [_2] members failed.'
,$num_fail,$num_users)
.'');
-
} else {
my ($result,$message) =
&Apache::lonnet::toggle_coursegroup_status($cdom,$cnum,
$groupname,'delete');
if ($result eq 'ok') {
- my $outcome = &modify_folders($cdom,$cnum,$groupname);
+ my $outcome = &modify_folders($cdom,$cnum,$groupname,$crstype);
if ($outcome eq '') {
- $r->print('
'
- .&mt("Although the group was deleted, an error occurred when removing"
- ." the group's folder from the 'Course Groups' folder: [_1]",$outcome)
- .'
');
+ $r->print('
');
+ if ($crstype eq 'Community') {
+ $r->print(&mt("Although the group was deleted, an error occurred when removing the group's folder from the 'Community Groups' folder: [_1]",$outcome));
+ } else {
+ $r->print(&mt("Although the group was deleted, an error occurred when removing the group's folder from the 'Course Groups' folder: [_1]",$outcome));
+ }
+ $r->print('
');
}
} else {
- $r->print('
'
- .&mt('Group deletion failed.')
- .'
');
+ my $msg = &Apache::lonhtmlcommon::confirm_success(&mt('Group deletion failed.'),1);
+ $msg = &Apache::loncommon::confirmwrapper($msg);
+ $r->print($msg);
}
}
return;
}
sub reenable_folder {
- my ($cdom,$cnum,$groupname,$description) = @_;
+ my ($cdom,$cnum,$groupname,$description,$crstype) = @_;
my $outcome;
my $crspath = '/uploaded/'.$cdom.'/'.$cnum.'/';
my $allgrpsmap = $crspath.'group_allfolders.sequence';
- my $foldertitle = &mt('Course Folder -[_1]',$description);
+ my $foldertitle;
+ if ($crstype eq 'Community') {
+ $foldertitle = &mt("Community Folder -[_1]",$description);
+ } else {
+ $foldertitle = &mt("Course Folder -[_1]",$description);
+ }
my $mapurl = $crspath.'group_folder_'.
$groupname.'.sequence';
my ($errtext,$fatal)=&LONCAPA::map::mapread($allgrpsmap);
@@ -1243,7 +1281,7 @@ sub reenable_folder {
$LONCAPA::map::resources[$idx] = $foldertitle.':'.$mapurl.
':false:normal:res';
$LONCAPA::map::order[1+$#LONCAPA::map::order]=$idx;
- my ($outtext,$errtext) = &LONCAPA::map::storemap($allgrpsmap,1);
+ my ($outtext,$errtext) = &LONCAPA::map::storemap($allgrpsmap,1,1);
if ($errtext) {
$outcome='
'
.&mt('An error occurred when saving updated parent folder to group:'
@@ -1258,14 +1296,19 @@ sub reenable_folder {
}
sub modify_folders {
- my ($cdom,$cnum,$groupname) = @_;
+ my ($cdom,$cnum,$groupname,$crstype) = @_;
my ($outcome,$groupmap,$groupmapres,$map,$id,$src);
my $navmap = Apache::lonnavmaps::navmap->new();
if (!defined($navmap)) {
- $outcome = '
'.
- &mt('Error reading course contents.').' '.
- &mt('You need to re-initialize the course.').
- '
';
+ $outcome = '
';
+ if ($crstype eq 'Community') {
+ $outcome .= &mt("Error reading community contents.").' '.
+ &mt("You need to re-initialize the community.");
+ } else {
+ $outcome .= &mt("Error reading course contents.").' '.
+ &mt("You need to re-initialize the course.");
+ }
+ $outcome .= '
';
return $outcome;
}
$groupmap = '/uploaded/'.$cdom.'/'.$cnum.'/'.'group_folder_'.
@@ -1303,7 +1346,7 @@ sub modify_folders {
$LONCAPA::map::order[$i] = $LONCAPA::map::order[$i+1];
}
$#LONCAPA::map::order--;
- my ($outtext,$errtext) = &LONCAPA::map::storemap($map,1);
+ my ($outtext,$errtext) = &LONCAPA::map::storemap($map,1,1);
if ($errtext) {
$outcome='
'
.&mt('An error occurred when saving updated parent folder to group:')
@@ -1320,13 +1363,18 @@ sub modify_folders {
}
sub verify_reenable {
- my ($r,$groupname,$formname,$action,$page,$states,$stored) = @_;
+ my ($r,$groupname,$formname,$action,$page,$states,$stored,$crstype) = @_;
$r->print(&Apache::lonhtmlcommon::echo_form_input([]));
$r->print(&mt('You have requested enabling the previously deleted group [_1].'
,''.$stored->{'description'}.'').
'
'.&mt('When a deleted group is re-enabled the following occurs:').'
'.
- '
'.&mt('Group settings and membership at the time the group was deleted are reinstated.').'
'.
- '
'.&mt('A group folder is added to the "Course Groups" folder which contains folders for all groups in the course.').'
');
+ '
'.&mt('Group settings and membership at the time the group was deleted are reinstated.').'
');
+ if ($crstype eq 'Community') {
+ $r->print(&mt("A group folder is added to the 'Community Groups' folder which contains folders for all groups in the community."));
+ } else {
+ $r->print(&mt("A group folder is added to the 'Course Groups' folder which contains folders for all groups in the course."));
+ }
+ $r->print('
');
my $prevtext = &mt('Go back');
my $nexttext = &mt('Reenable group');
my $prev;
@@ -1339,7 +1387,7 @@ sub verify_reenable {
}
sub reenable_group {
- my ($r,$cdom,$cnum,$groupname) = @_;
+ my ($r,$cdom,$cnum,$groupname,$crstype) = @_;
my %groups =
&Apache::longroup::coursegroups($cdom,$cnum,$groupname,
'deleted_groups');
@@ -1413,20 +1461,24 @@ $context) eq 'ok') {
.&mt('There were no group members to reinstate, as none were removed when the group was deleted.')
.'
');
}
- my $outcome = &reenable_folder($cdom,$cnum,$groupname,$description);
+ my $outcome = &reenable_folder($cdom,$cnum,$groupname,$description,$crstype);
if ($outcome eq '') {
- $r->print('
'
- .&mt("Although the group was re-enabled, an error occurred when adding the group's folder to the 'Course Groups' folder: [_1]",$outcome)
- .'
');
+ $r->print('
');
+ if ($crstype eq 'Community') {
+ $r->print(&mt("Although the group was re-enabled, an error occurred when adding the group's folder to the 'Community Groups' folder: [_1]",$outcome));
+ } else {
+ $r->print(&mt("Although the group was re-enabled, an error occurred when adding the group's folder to the 'Course Groups' folder: [_1]",$outcome));
+ }
+ $r->print('
');
}
} else {
- $r->print('
'
- .&mt('Re-enabling group failed.')
- .'
');
+ my $message = &Apache::lonhtmlcommon::confirm_success(&mt('Re-enabling group failed.'),1);
+ $message = &Apache::loncommon::confirmwrapper($message);
+ $r->print($message);
}
return;
}
@@ -1500,16 +1552,19 @@ sub build_members_list {
sub group_files {
my ($group,$portpath,$numfiles,$numdirs) = @_;
my $dirptr=16384;
- my @dir_list=&Apache::portfolio::get_dir_list($portpath,undef,$group);
- foreach my $line (@dir_list) {
- my ($filename,$dom,undef,$testdir,undef,undef,undef,undef,$size,undef,$mtime,undef,undef,undef,$obs,undef)=split(/\&/,$line,16);
- if (($filename !~ /^\.\.?$/) && ($filename !~ /\.meta$/ ) && ($filename !~ /(.*)\.(\d+)\.([^\.]*)$/) && ($filename ne 'no_such_dir')) {
- if ($dirptr&$testdir) {
- $portpath .= '/'.$filename;
- $$numdirs ++;
- &group_files($group,$portpath,$numfiles,$numdirs)
- } else {
- $$numfiles ++;
+ my ($dirlistref,$listerror) =
+ &Apache::portfolio::get_dir_list($portpath,undef,$group);
+ if (ref($dirlistref) eq 'ARRAY') {
+ foreach my $line (@{$dirlistref}) {
+ my ($filename,$dom,undef,$testdir,undef,undef,undef,undef,$size,undef,$mtime,undef,undef,undef,$obs,undef)=split(/\&/,$line,16);
+ if (($filename !~ /^\.\.?$/) && ($filename !~ /\.meta$/ ) && ($filename !~ /(.*)\.(\d+)\.([^\.]*)$/) && ($filename ne 'no_such_dir')) {
+ if ($dirptr&$testdir) {
+ $portpath .= '/'.$filename;
+ $$numdirs ++;
+ &group_files($group,$portpath,$numfiles,$numdirs)
+ } else {
+ $$numfiles ++;
+ }
}
}
}
@@ -1579,7 +1634,7 @@ sub general_settings_form {
&access_date_settings($r,$action,$formname,$stored,2,$gpterm,$ucgpterm);
if ($action eq 'create') {
&membership_options($r,$cdom,$cnum,$action,$formname,$sectioncount,3,
- $gpterm,$ucgpterm);
+ $gpterm,$ucgpterm,$crstype);
$nexttext = $$navbuttons{'gtns'};
} else {
my @available = ();
@@ -1588,7 +1643,7 @@ sub general_settings_form {
@{$tools} = sort(keys(%{$functions}));
&privilege_specificity($r,$action,3,$tools,$stored,$toolprivs,
$fixedprivs,\@available,$formname,
- $gpterm,$ucgpterm,$functions);
+ $gpterm,$ucgpterm,$functions,$crstype);
&mapping_options($r,$action,$formname,$page,$sectioncount,
$states,$stored,$navbuttons,4,5,
$gpterm,$ucgpterm,$crstype,$cdom,$cnum);
@@ -1741,38 +1796,47 @@ sub get_quota_constraints {
}
sub membership_options {
- my ($r,$cdom,$cnum,$action,$state,$sectioncount,$image,$gpterm,$ucgpterm)=@_;
- my $crstype = &Apache::loncommon::course_type();
+ my ($r,$cdom,$cnum,$action,$state,$sectioncount,$image,$gpterm,$ucgpterm,$crstype)=@_;
my %lt = &Apache::lonlocal::texthash(
'pipa' => 'Build a list of users for selection of group members',
- 'gmem' => "Group membership selection list criteria:",
- 'picr' => 'Pick the criteria to use to build a list of '.
- lc($crstype).' users from which you will select ',
- '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, there is no need to pick any criteria.",
- 'asub' => "A subsequent step will also allow you to specify automatic adding/dropping of group members triggered by specified user role and section changes in the course.",
+ 'gmem' => 'Group membership selection list criteria:',
+ 'picr' => 'Pick the criteria to use to build a list of course users from which you will select members of the new group.',
+ 'pica' => 'Pick the criteria to use to build a list of course users from which you will select additional members of the group.',
+ 'ifno' => 'If you do not wish to add members when you first create the group, there is no need to pick any criteria.',
'acty' => 'Access types',
- 'coro' => $crstype.' roles',
- 'cose' => $crstype.' sections',
+ 'coro' => 'Course roles',
+ 'cose' => 'Course sections',
);
+ if ($crstype eq 'Community') {
+ $lt{'picr'} = &mt('Pick the criteria to use to build a list of community participants from which you will select ');
+ $lt{'asub'} = &mt('A subsequent step will also allow you to specify automatic adding/dropping of group members triggered by specified user role and section [_1]changes[_2] in the course.','','');
+ $lt{'coro'} = &mt('Community roles');
+ $lt{'cose'} = &mt('Community sections');
+ } else {
+ $lt{'asub'} = &mt('A subsequent step will also allow you to specify automatic adding/dropping of group members triggered by specified user role and section [_1]changes[_2] in the course.','','');
+ }
my %status_types = (
active => &mt('Currently has access'),
previous => &mt('Previously had access'),
future => &mt('Will have future access'),
);
- my @roles = ('st','cc','in','ta','ep','cr');
+ my @roles = ('st');
+ if ($crstype eq 'Community') {
+ push(@roles,'co');
+ } else {
+ push(@roles,'cc');
+ }
+ push (@roles,('in','ta','ep','ad','cr'));
my @sections = keys(%{$sectioncount});
$r->print(&Apache::lonhtmlcommon::topic_bar($image,$lt{'pipa'}).'
- '.$lt{'gmem'}.' '.$lt{'picr'});
+ '.$lt{'gmem'}.' ');
if ($action eq 'create') {
- $r->print($lt{'meof'}.' '.$lt{'ifno'}.' '.$lt{'asub'});
+ $r->print($lt{'picr'}.' '.$lt{'ifno'}.' '.$lt{'asub'});
} else {
- $r->print($lt{'admg'});
+ $r->print($lt{'pica'});
}
$r->print('
@@ -1889,7 +1953,7 @@ sub choose_members_form {
}
&privilege_specificity($r,$action,$specimg,$tools,$stored,$toolprivs,
$fixedprivs,\@available,$formname,$gpterm,$ucgpterm,
- $functions);
+ $functions,$crstype);
my $newusers = &pick_new_members($r,$action,$formname,\@available,$idx,
$stored,$memimg,$users,$userdata,
$granularity,\%origmembers,$gpterm,
@@ -2067,7 +2131,7 @@ sub pick_new_members {
&check_uncheck_buttons($r,$formname,'member',$lt{'addm'});
if (@{$available} > 0 && $granularity eq 'Yes') {
$r->print('