--- loncom/interface/loncoursegroups.pm 2010/01/26 03:26:02 1.101.4.2
+++ loncom/interface/loncoursegroups.pm 2009/06/05 12:49:50 1.102
@@ -1,6 +1,6 @@
# The LearningOnline Network with CAPA
#
-# $Id: loncoursegroups.pm,v 1.101.4.2 2010/01/26 03:26:02 raeburn Exp $
+# $Id: loncoursegroups.pm,v 1.102 2009/06/05 12:49:50 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/community groups";
+ "/adm/coursegroups:mdg:0:0:Cannot edit or view course groups";
return HTTP_NOT_ACCEPTABLE;
}
@@ -537,7 +537,7 @@ sub group_administration {
if (ref($stored{'autorole'}) eq 'ARRAY') {
foreach my $role (@{$stored{'autorole'}}) {
- unless (($role eq 'cc') || ($role eq 'co')) {
+ unless ($role eq 'cc') {
$elements{'modify'}{'change_settings'}{'sec_'.$role} =
'selectbox';
}
@@ -1086,7 +1086,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,$crstype);
+ $states,$navbuttons,$gpterm,$ucgpterm);
} elsif ($state eq 'pick_members') {
&choose_members_form($r,$cdom,$cnum,$action,$state,$page,
$groupname,$description,$granularity,$quota,
@@ -1119,15 +1119,15 @@ sub display_control {
my %stored = &retrieve_settings($cdom,$cnum,$groupname,$action);
if ($state eq 'verify') {
&verify_delete($r,$groupname,$state,$action,$page,$states,
- \%stored,$crstype);
+ \%stored);
} elsif ($state eq 'result') {
- &delete_group($r,$cdom,$cnum,$groupname,$crstype);
+ &delete_group($r,$cdom,$cnum,$groupname);
}
} 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,$crstype);
+ \%stored);
} elsif ($state eq 'result') {
&reenable_group($r,$cdom,$cnum,$groupname);
}
@@ -1135,20 +1135,15 @@ sub display_control {
}
sub verify_delete {
- my ($r,$groupname,$formname,$action,$page,$states,$stored,$crstype) = @_;
+ my ($r,$groupname,$formname,$action,$page,$states,$stored) = @_;
$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.').'
');
- 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."));
- }
+ '
'.&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.'));
my $prevtext = &mt('Go back');
my $nexttext = &mt('Delete group');
my $prev;
@@ -1161,7 +1156,7 @@ sub verify_delete {
}
sub delete_group {
- my ($r,$cdom,$cnum,$groupname,$crstype) = @_;
+ my ($r,$cdom,$cnum,$groupname) = @_;
my %membership = &Apache::lonnet::get_group_membership($cdom,$cnum,
$groupname);
my $now = time;
@@ -1203,24 +1198,22 @@ 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,$crstype);
+ my $outcome = &modify_folders($cdom,$cnum,$groupname);
if ($outcome eq '') {
$r->print('
'
.&mt('Group successfully deleted.')
.'
');
} else {
- $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('
');
+ $r->print('
'
+ .&mt("Although the group was deleted, an error occurred when removing"
+ ." the group's folder from the 'Course Groups' folder: [_1]",$outcome)
+ .'
');
}
} else {
$r->print('
'
@@ -1232,16 +1225,11 @@ sub delete_group {
}
sub reenable_folder {
- my ($cdom,$cnum,$groupname,$description,$crstype) = @_;
+ my ($cdom,$cnum,$groupname,$description) = @_;
my $outcome;
my $crspath = '/uploaded/'.$cdom.'/'.$cnum.'/';
my $allgrpsmap = $crspath.'group_allfolders.sequence';
- my $foldertitle;
- if ($crstype eq 'Community') {
- $foldertitle = &mt("Community Folder -[_1]",$description);
- } else {
- $foldertitle = &mt("Course Folder -[_1]",$description);
- }
+ my $foldertitle = &mt('Course Folder -[_1]',$description);
my $mapurl = $crspath.'group_folder_'.
$groupname.'.sequence';
my ($errtext,$fatal)=&LONCAPA::map::mapread($allgrpsmap);
@@ -1270,19 +1258,14 @@ sub reenable_folder {
}
sub modify_folders {
- my ($cdom,$cnum,$groupname,$crstype) = @_;
+ my ($cdom,$cnum,$groupname) = @_;
my ($outcome,$groupmap,$groupmapres,$map,$id,$src);
my $navmap = Apache::lonnavmaps::navmap->new();
if (!defined($navmap)) {
- $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 .= '
';
+ $outcome = '
'.
+ &mt('Error reading course contents.').' '.
+ &mt('You need to re-initialize the course.').
+ '
';
return $outcome;
}
$groupmap = '/uploaded/'.$cdom.'/'.$cnum.'/'.'group_folder_'.
@@ -1337,18 +1320,13 @@ sub modify_folders {
}
sub verify_reenable {
- my ($r,$groupname,$formname,$action,$page,$states,$stored,$crstype) = @_;
+ my ($r,$groupname,$formname,$action,$page,$states,$stored) = @_;
$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.').'
');
- 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('
');
+ '
'.&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.').'
');
my $prevtext = &mt('Go back');
my $nexttext = &mt('Reenable group');
my $prev;
@@ -1361,7 +1339,7 @@ sub verify_reenable {
}
sub reenable_group {
- my ($r,$cdom,$cnum,$groupname,$crstype) = @_;
+ my ($r,$cdom,$cnum,$groupname) = @_;
my %groups =
&Apache::longroup::coursegroups($cdom,$cnum,$groupname,
'deleted_groups');
@@ -1435,19 +1413,15 @@ $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,$crstype);
+ my $outcome = &reenable_folder($cdom,$cnum,$groupname,$description);
if ($outcome eq '') {
$r->print('
'
.&mt('Group successfully re-enabled.')
.'
');
} else {
- $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('
');
+ $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)
+ .'
');
}
} else {
$r->print('
'
@@ -1614,7 +1588,7 @@ sub general_settings_form {
@{$tools} = sort(keys(%{$functions}));
&privilege_specificity($r,$action,3,$tools,$stored,$toolprivs,
$fixedprivs,\@available,$formname,
- $gpterm,$ucgpterm,$functions,$crstype);
+ $gpterm,$ucgpterm,$functions);
&mapping_options($r,$action,$formname,$page,$sectioncount,
$states,$stored,$navbuttons,4,5,
$gpterm,$ucgpterm,$crstype,$cdom,$cnum);
@@ -1767,49 +1741,38 @@ sub get_quota_constraints {
}
sub membership_options {
- my ($r,$cdom,$cnum,$action,$state,$sectioncount,$image,$gpterm,$ucgpterm,$crstype)=@_;
+ my ($r,$cdom,$cnum,$action,$state,$sectioncount,$image,$gpterm,$ucgpterm)=@_;
+ my $crstype = &Apache::loncommon::course_type();
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 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.',
+ '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.",
'acty' => 'Access types',
- 'coro' => 'Course roles',
- 'cose' => 'Course sections',
+ 'coro' => $crstype.' roles',
+ 'cose' => $crstype.' 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');
- if ($crstype eq 'Community') {
- push(@roles,'co');
- } else {
- push(@roles,'cc');
- }
- push (@roles,('in','ta','ep','ad','cr'));
+ my @roles = ('st','cc','in','ta','ep','cr');
my @sections = keys(%{$sectioncount});
$r->print(&Apache::lonhtmlcommon::topic_bar($image,$lt{'pipa'}).'
- '.$lt{'gmem'}.' ');
-
+ '.$lt{'gmem'}.' '.$lt{'picr'});
if ($action eq 'create') {
- $r->print($lt{'picr'}.' '.$lt{'ifno'}.' '.$lt{'asub'});
+ $r->print($lt{'meof'}.' '.$lt{'ifno'}.' '.$lt{'asub'});
} else {
- $r->print($lt{'pica'});
+ $r->print($lt{'admg'});
}
$r->print('
@@ -1925,8 +1888,7 @@ sub choose_members_form {
}
}
&privilege_specificity($r,$action,$specimg,$tools,$stored,$toolprivs,
- $fixedprivs,\@available,$formname,$gpterm,$ucgpterm,
- $functions,$crstype);
+ $fixedprivs,\@available,$formname,$gpterm,$ucgpterm);
my $newusers = &pick_new_members($r,$action,$formname,\@available,$idx,
$stored,$memimg,$users,$userdata,
$granularity,\%origmembers,$gpterm,
@@ -2104,7 +2066,7 @@ sub pick_new_members {
&check_uncheck_buttons($r,$formname,'member',$lt{'addm'});
if (@{$available} > 0 && $granularity eq 'Yes') {
$r->print('
-
', @tableHeader));
$r->print(&Apache::lonhtmlcommon::row_closure(1));
my $fixed = '';
@@ -2557,7 +2516,7 @@ sub current_membership {
$r->print('
-
+
@@ -2715,7 +2674,7 @@ sub check_uncheck_buttons {
$r->print('
-
+
@@ -2795,7 +2754,7 @@ sub change_privs_form {
sub add_members_form {
my ($r,$cdom,$cnum,$action,$formname,$page,$startdate,$enddate,$groupname,
$description,$granularity,$quota,$sectioncount,$tools,$functions,
- $stored,$states,$navbuttons,$gpterm,$ucgpterm,$crstype)=@_;
+ $stored,$states,$navbuttons,$gpterm,$ucgpterm)=@_;
$r->print(' ');
my @available = ();
my @unavailable = ();
@@ -2804,7 +2763,7 @@ sub add_members_form {
$groupname,$description,$granularity,$quota,
\@available,\@unavailable,$gpterm,$ucgpterm);
&membership_options($r,$cdom,$cnum,$action,$formname,$sectioncount,1,$gpterm,
- $ucgpterm,$crstype);
+ $ucgpterm);
my $nexttext = $$navbuttons{'gtns'};
my $prevtext = $$navbuttons{'gtpp'};
&display_navbuttons($r,$formname,$$states{$action}[$page-1],$prevtext,
@@ -3015,7 +2974,7 @@ sub member_privileges_form {
$r->print('
');
}
$r->print(
- '
'
+ '
'
.''
.' '
@@ -3135,7 +3094,7 @@ sub process_request {
&process_membership($r,$cdom,$cnum,$action,$state,$groupname,$tools,
$enddate,$startdate,$userdata,$idx,$toolprivs,
$usertools,$specificity,\@defprivs,$memchg,$gpterm,
- $ucgpterm,$crstype);
+ $ucgpterm);
}
return;
}
@@ -3297,28 +3256,17 @@ sub write_group_data {
}
undef($navmap);
} else {
- if ($crstype eq 'Community') {
- $error = &mt("An error occurred while setting parameters '.
- 'for Discussion Boards folder: '.
- 'Could not retrieve community information");
- } else {
- $error = &mt("An error occurred while setting parameters '.
+ $error = &mt('An error occurred while setting parameters '.
'for Discussion Boards folder: '.
- 'Could not retrieve course information");
- }
+ 'Could not retrieve course information' );
}
} else {
$r->print($outcome);
}
}
} else {
- $error = &mt("An error occurred while retrieving the contents of the group's folder.").' ';
- if ($crstype eq 'Community') {
- $error .= &mt("You need to re-initialize the community.");
-
- } else {
- $error .= &mt("You need to re-initialize the course.");
- }
+ $error = &mt("An error occurred while retrieving the contents of the group's folder.").' '.
+ &mt('You need to re-initialize the course.');
}
if ($error ne '') {
$r->print('
'.$error.'
');
@@ -3347,7 +3295,7 @@ sub write_group_data {
sub process_membership {
my ($r,$cdom,$cnum,$action,$state,$groupname,$tools,$enddate,$startdate,
$userdata,$idx,$toolprivs,$usertools,$specificity,$defprivs,$memchg,
- $gpterm,$ucgpterm,$crstype)=@_;
+ $gpterm,$ucgpterm)=@_;
my %usersettings = ();
my %added= ();
my %failed = ();
@@ -3552,20 +3500,13 @@ sub process_membership {
$r->print('
'
.&mt($ucgpterm.' membership list updated.')
.'
');
- $r->print('
');
- if ($crstype eq 'Community') {
- $r->print(&mt("Any currently logged in community users affected by the changes you made"
- .' to group membership or privileges for the [_1] group will need to log out'
- .' and log back in for their LON-CAPA sessions to reflect these changes.'
- ,''.$groupname.''));
-
- } else {
- $r->print(&mt("Any currently logged in course users affected by the changes you made"
+ $r->print('
'
+ .&mt('Any currently logged in course users affected by the changes you made'
.' to group membership or privileges for the [_1] group will need to log out'
.' and log back in for their LON-CAPA sessions to reflect these changes.'
- ,''.$groupname.''));
- }
- $r->print('
'
.&mt("An error occurred while updating the $gpterm membership list:")
@@ -3636,7 +3577,7 @@ sub mapping_settings {
@sections = ('all','none');
}
$r->print(&Apache::lonhtmlcommon::topic_bar($image,$$lt{'pirs'}));
- my @roles = &standard_roles($crstype);
+ my @roles = &standard_roles();
my %customroles = &Apache::lonhtmlcommon::course_custom_roles($cdom,$cnum);
$r->print(&Apache::loncommon::start_data_table().
&Apache::loncommon::start_data_table_header_row());
@@ -3679,10 +3620,10 @@ sub print_autorole_item {
my ($role,$roletitle,$sections) = @_;
my $sections_sel;
if (@{$sections} > 0) {
- if (($role eq 'cc') || ($role eq 'co')) {
+ if ($role eq 'cc') {
$sections_sel = '
'.
&mt('all sections').'
';
+ 'name="sec_cc" value="all" />
';
} else {
$sections_sel='
'.
§ions_selection($sections,'sec_'.$role).
@@ -3698,13 +3639,7 @@ sub print_autorole_item {
}
sub standard_roles {
- my ($crstype) = @_;
- my @roles = qw(in ta ep ad st);
- if ($crstype eq 'Community') {
- unshift(@roles,'co');
- } else {
- unshift(@roles,'cc');
- }
+ my @roles = ('cc','in','ta','ep','st');
return @roles;
}
@@ -3843,14 +3778,9 @@ sub add_group_folder {
my ($cdom,$cnum,$now,$groupname,$action,$description,$tools,$groupinfo,
$gpterm,$ucgpterm,$crstype) = @_;
if ($cdom eq '' || $cnum eq '') {
- my $error = '';
- if ($crstype eq 'Community') {
- $error .= &mt("Error: invalid community domain or number - group folder creation failed.");
- } else {
- $error .= &mt("Error: invalid course domain or number - group folder creation failed.");
- }
- $error .= '';
- return $error;
+ return ''
+ .&mt('Error: invalid course domain or number - group folder creation failed.')
+ .'';
}
my ($outcome,$allgrpsmap,$grpmap,$boardsmap,$grppage,$warning);
my $crspath = '/uploaded/'.$cdom.'/'.$cnum.'/';
@@ -3918,16 +3848,8 @@ sub add_group_folder {
my ($furl,$ferr)= &Apache::lonuserstate::readmap($cdom.'/'.$cnum);
my $navmap = Apache::lonnavmaps::navmap->new();
if (!defined($navmap)) {
- $warning .= '';
- if ($crstype eq 'Community') {
- $warning .= &mt("Error retrieving community contents").
- ' '.&mt("You need to re-initialize the community.");
- } else {
- $warning .= &mt("Error retrieving course contents").
- ' '.&mt("You need to re-initialize the course.");
- }
- $warning .= '';
- return $warning;
+ return $warning.''.&mt('Error retrieving course contents').
+ ' '.&mt('You need to re-initialize the course.').'';
}
# modify parameters
my $parm_result;
@@ -4032,18 +3954,14 @@ sub new_map {
}
sub parm_setter {
- my ($navmap,$cdom,$url,$groupname,$crstype) = @_;
+ my ($navmap,$cdom,$url,$groupname) = @_;
+ my $allresults;
if (!defined($navmap)) {
- my $allresults;
- if ($crstype eq 'Community') {
- $allresults = &mt("Parameters not set for [_1] because the contents of the community could not be retrieved.",$url).' '.
- &mt("You need to reinitialize the community.");
- } else {
- $allresults = &mt("Parameters not set for [_1] because the contents of the course could not be retrieved.",$url).' '.
- &mt("You need to reinitialize the course.");
-
- }
- return '
'.$allresults.'
';
+ $allresults = '
'.
+ &mt('Parameters not set for [_1] because the contents of the course could not be retrieved.',$url).' '.
+ &mt('You need to reinitialize the course.').
+ '
';
+ return $allresults;
}
my %hide_settings = (
'course' => {
@@ -4057,7 +3975,6 @@ sub parm_setter {
},
);
my $res = $navmap->getResourceByUrl($url);
- my $allresults;
if ($res) {
my $symb = $res->symb();
foreach my $level (keys(%hide_settings)) {
@@ -4074,13 +3991,10 @@ sub parm_setter {
}
}
} else {
- $allresults = '
';
- if ($crstype eq 'Community') {
- $allresults .= &mt("Parameters not set for [_1] because the resource was not recognized as part of the community.",''.$url.'');
- } else {
- $allresults .= &mt('Parameters not set for [_1] because the resource was not recognized as part of the course.',''.$url.'');
- }
- $allresults .= '
';
+ $allresults = '
'
+ .&mt('Parameters not set for [_1] because the resource was not recognized'
+ .' as part of the course.',''.$url.'')
+ .'