MDL-22033 groupings now enabled unconditionally, groupmembersonly kept as experimental - this simplifies groups code logic a bit, user interface changes should not be significant because the groupings are not visible much until at least one created; hopefully the new description of groupmembersonly will have to preventsome gradebook complaints

This commit is contained in:
Petr Skoda 2010-04-07 07:37:12 +00:00
parent e8c2189d78
commit 98da60215e
31 changed files with 137 additions and 214 deletions

View file

@ -15,6 +15,7 @@ if ($hassiteconfig) { // speedup for non-admins, add all caps used on this page
$temp->add(new admin_setting_configcheckbox('experimentalsplitrestore', get_string('experimentalsplitrestore', 'admin'), get_string('configexperimentalsplitrestore', 'admin'), 0));
$temp->add(new admin_setting_configcheckbox('enableimsccimport', get_string('enable_cc_import', 'imscc'), get_string('enable_cc_import_description', 'imscc'), 0));
$temp->add(new admin_setting_configcheckbox('enablesafebrowserintegration', get_string('enablesafebrowserintegration', 'admin'), get_string('configenablesafebrowserintegration', 'admin'), 0));
$temp->add(new admin_setting_configcheckbox('enablegroupmembersonly', get_string('enablegroupmembersonly', 'admin'), get_string('configenablegroupmembersonly', 'admin'), 0));
$ADMIN->add('experimental', $temp);

View file

@ -2,8 +2,6 @@
if ($hassiteconfig) { // speedup for non-admins, add all caps used on this page
$optionalsubsystems->add(new admin_setting_configcheckbox('enablegroupings', get_string('enablegroupings', 'admin'), get_string('configenablegroupings', 'admin'), 0));
$optionalsubsystems->add(new admin_setting_configcheckbox('enableoutcomes', get_string('enableoutcomes', 'grades'), get_string('configenableoutcomes', 'grades'), 0));
$optionalsubsystems->add(new admin_setting_configcheckbox('usecomments', get_string('enablecomments', 'admin'), get_string('configenablecomments', 'admin'), 1));

View file

@ -87,11 +87,7 @@
}
if (!isset($restore_groups)) {
if (empty($CFG->enablegroupings)) {
$restore_groups = RESTORE_GROUPS_ONLY;
} else {
$restore_groups = RESTORE_GROUPS_GROUPINGS;
}
$restore_groups = RESTORE_GROUPS_GROUPINGS;
}
if (!isset($restore_logs)) {
@ -466,15 +462,10 @@ function selectItemInCheckboxByName(formId, checkName, checked ) {
$helplink = $OUTPUT->help_icon('grouprestore', get_string('groups'));
echo '<label for="menurestore_groups">'.get_string ("groups").'</label>'.$helplink;
echo "</b></td><td colspan=\"2\">";
if (empty($CFG->enablegroupings)) {
$group_options[RESTORE_GROUPS_NONE] = get_string('no');
$group_options[RESTORE_GROUPS_ONLY] = get_string('yes');
} else {
$group_options[RESTORE_GROUPS_NONE] = get_string('none');
$group_options[RESTORE_GROUPS_ONLY] = get_string('groupsonly', 'group');
$group_options[RESTORE_GROUPINGS_ONLY] = get_string('groupingsonly', 'group');
$group_options[RESTORE_GROUPS_GROUPINGS] = get_string('groupsgroupings', 'group'); //all.
}
$group_options[RESTORE_GROUPS_NONE] = get_string('none');
$group_options[RESTORE_GROUPS_ONLY] = get_string('groupsonly', 'group');
$group_options[RESTORE_GROUPINGS_ONLY] = get_string('groupingsonly', 'group');
$group_options[RESTORE_GROUPS_GROUPINGS] = get_string('groupsgroupings', 'group'); //all.
echo html_writer::select($group_options, 'restore_groups', $restore_groups, false);
echo "</td></tr>";

View file

@ -299,12 +299,10 @@ class course_edit_form extends moodleform {
$mform->setHelpButton('groupmodeforce', array('groupmodeforce', get_string('groupmodeforce')), true);
$mform->setDefault('groupmodeforce', $courseconfig->groupmodeforce);
if (!empty($CFG->enablegroupings)) {
//default groupings selector
$options = array();
$options[0] = get_string('none');
$mform->addElement('select', 'defaultgroupingid', get_string('defaultgrouping', 'group'), $options);
}
//default groupings selector
$options = array();
$options[0] = get_string('none');
$mform->addElement('select', 'defaultgroupingid', get_string('defaultgrouping', 'group'), $options);
//--------------------------------------------------------------------------------
$mform->addElement('header','', get_string('availability'));

View file

@ -1356,7 +1356,7 @@ function print_section($course, $section, $mods, $modnamesused, $absolute=false,
if ($accessiblebutdim || !$mod->uservisible) {
echo "</div>";
}
if (!empty($CFG->enablegroupings) && !empty($mod->groupingid) && has_capability('moodle/course:managegroups', get_context_instance(CONTEXT_COURSE, $course->id))) {
if (!empty($mod->groupingid) && has_capability('moodle/course:managegroups', get_context_instance(CONTEXT_COURSE, $course->id))) {
if (!isset($groupings)) {
$groupings = groups_get_all_groupings($course->id);
}
@ -1417,7 +1417,7 @@ function print_section($course, $section, $mods, $modnamesused, $absolute=false,
'<img src="'.$icon.'" class="activityicon" alt="" /> '.
$accesstext.'<span>'.$instancename.$altname.'</span></a>';
if (!empty($CFG->enablegroupings) && !empty($mod->groupingid) && has_capability('moodle/course:managegroups', get_context_instance(CONTEXT_COURSE, $course->id))) {
if (!empty($mod->groupingid) && has_capability('moodle/course:managegroups', get_context_instance(CONTEXT_COURSE, $course->id))) {
if (!isset($groupings)) {
$groupings = groups_get_all_groupings($course->id);
}

View file

@ -375,26 +375,24 @@ abstract class moodleform_mod extends moodleform {
$mform->setHelpButton('groupmode', array('groupmode', get_string('groupmode')));
}
if (!empty($CFG->enablegroupings)) {
if ($this->_features->groupings or $this->_features->groupmembersonly) {
//groupings selector - used for normal grouping mode or also when restricting access with groupmembersonly
$options = array();
$options[0] = get_string('none');
if ($groupings = $DB->get_records('groupings', array('courseid'=>$COURSE->id))) {
foreach ($groupings as $grouping) {
$options[$grouping->id] = format_string($grouping->name);
}
if ($this->_features->groupings or $this->_features->groupmembersonly) {
//groupings selector - used for normal grouping mode or also when restricting access with groupmembersonly
$options = array();
$options[0] = get_string('none');
if ($groupings = $DB->get_records('groupings', array('courseid'=>$COURSE->id))) {
foreach ($groupings as $grouping) {
$options[$grouping->id] = format_string($grouping->name);
}
$mform->addElement('select', 'groupingid', get_string('grouping', 'group'), $options);
$mform->setHelpButton('groupingid', array('grouping', get_string('grouping', 'group')));
$mform->setAdvanced('groupingid');
}
$mform->addElement('select', 'groupingid', get_string('grouping', 'group'), $options);
$mform->setHelpButton('groupingid', array('grouping', get_string('grouping', 'group')));
$mform->setAdvanced('groupingid');
}
if ($this->_features->groupmembersonly) {
$mform->addElement('checkbox', 'groupmembersonly', get_string('groupmembersonly', 'group'));
$mform->setHelpButton('groupmembersonly', array('groupmembersonly', get_string('groupmembersonly', 'group')));
$mform->setAdvanced('groupmembersonly');
}
if ($this->_features->groupmembersonly) {
$mform->addElement('checkbox', 'groupmembersonly', get_string('groupmembersonly', 'group'));
$mform->setHelpButton('groupmembersonly', array('groupmembersonly', get_string('groupmembersonly', 'group')));
$mform->setAdvanced('groupmembersonly');
}
$mform->addElement('modvisible', 'visible', get_string('visible'));

View file

@ -42,13 +42,11 @@ class course_reset_form extends moodleform {
$mform->setAdvanced('reset_groups_members');
$mform->disabledIf('reset_groups_members', 'reset_groups_remove', 'checked');
if (!empty($CFG->enablegroupings)) {
$mform->addElement('checkbox', 'reset_groupings_remove', get_string('deleteallgroupings', 'group'));
$mform->setAdvanced('reset_groupings_remove');
$mform->addElement('checkbox', 'reset_groupings_members', get_string('removegroupingsmembers', 'group'));
$mform->setAdvanced('reset_groupings_members');
$mform->disabledIf('reset_groupings_members', 'reset_groupings_remove', 'checked');
}
$mform->addElement('checkbox', 'reset_groupings_remove', get_string('deleteallgroupings', 'group'));
$mform->setAdvanced('reset_groupings_remove');
$mform->addElement('checkbox', 'reset_groupings_members', get_string('removegroupingsmembers', 'group'));
$mform->setAdvanced('reset_groupings_members');
$mform->disabledIf('reset_groupings_members', 'reset_groupings_remove', 'checked');
$unsupported_mods = array();
if ($allmods = $DB->get_records('modules') ) {

View file

@ -55,23 +55,21 @@ class autogroup_form extends moodleform {
$mform->setDefault('namingscheme', $template);
}
if (!empty($CFG->enablegroupings)) {
$options = array('0' => get_string('no'),
'-1'=> get_string('newgrouping', 'group'));
if ($groupings = groups_get_all_groupings($COURSE->id)) {
foreach ($groupings as $grouping) {
$options[$grouping->id] = strip_tags(format_string($grouping->name));
}
$options = array('0' => get_string('no'),
'-1'=> get_string('newgrouping', 'group'));
if ($groupings = groups_get_all_groupings($COURSE->id)) {
foreach ($groupings as $grouping) {
$options[$grouping->id] = strip_tags(format_string($grouping->name));
}
$mform->addElement('select', 'grouping', get_string('createingrouping', 'group'), $options);
if ($groupings) {
$mform->setDefault('grouping', '-1');
}
$mform->addElement('text', 'groupingname', get_string('groupingname', 'group'), $options);
$mform->setType('groupingname', PARAM_MULTILANG);
$mform->disabledIf('groupingname', 'grouping', 'noteq', '-1');
}
$mform->addElement('select', 'grouping', get_string('createingrouping', 'group'), $options);
if ($groupings) {
$mform->setDefault('grouping', '-1');
}
$mform->addElement('text', 'groupingname', get_string('groupingname', 'group'), $options);
$mform->setType('groupingname', PARAM_MULTILANG);
$mform->disabledIf('groupingname', 'grouping', 'noteq', '-1');
$mform->addElement('hidden','courseid');
$mform->setType('courseid', PARAM_INT);

View file

@ -47,18 +47,12 @@ $strnogroups = get_string('nogroups', 'group');
$strdescription = get_string('description');
// Get all groupings
if (empty($CFG->enablegroupings)) {
$groupings = array();
$members = array(-1 => array()); //groups not in a grouping
$groupingid = 0;
} else {
$groupings = $DB->get_records('groupings', array('courseid'=>$courseid), 'name');
$members = array();
foreach ($groupings as $grouping) {
$members[$grouping->id] = array();
}
$members[-1] = array(); //groups not in a grouping
$groupings = $DB->get_records('groupings', array('courseid'=>$courseid), 'name');
$members = array();
foreach ($groupings as $grouping) {
$members[$grouping->id] = array();
}
$members[-1] = array(); //groups not in a grouping
// Get all groups
$groups = $DB->get_records('groups', array('courseid'=>$courseid), 'name');
@ -71,28 +65,19 @@ if ($groupid) {
$groupwhere = "";
}
if (empty($CFG->enablegroupings)) {
$sql = "SELECT g.id AS groupid, NULL AS groupingid, u.id AS userid, u.firstname, u.lastname, u.idnumber, u.username
FROM {groups} g
LEFT JOIN {groups_members} gm ON g.id = gm.groupid
LEFT JOIN {user} u ON gm.userid = u.id
WHERE g.courseid = :courseid $groupwhere
ORDER BY g.name, u.lastname, u.firstname";
if ($groupingid) {
$groupingwhere = "AND gg.groupingid = :groupingid";
$params['groupingid'] = $groupingid;
} else {
if ($groupingid) {
$groupingwhere = "AND gg.groupingid = :groupingid";
$params['groupingid'] = $groupingid;
} else {
$groupingwhere = "";
}
$sql = "SELECT g.id AS groupid, gg.groupingid, u.id AS userid, u.firstname, u.lastname, u.idnumber, u.username
FROM {groups} g
LEFT JOIN {groupings_groups} gg ON g.id = gg.groupid
LEFT JOIN {groups_members} gm ON g.id = gm.groupid
LEFT JOIN {user} u ON gm.userid = u.id
WHERE g.courseid = :courseid $groupwhere $groupingwhere
ORDER BY g.name, u.lastname, u.firstname";
$groupingwhere = "";
}
$sql = "SELECT g.id AS groupid, gg.groupingid, u.id AS userid, u.firstname, u.lastname, u.idnumber, u.username
FROM {groups} g
LEFT JOIN {groupings_groups} gg ON g.id = gg.groupid
LEFT JOIN {groups_members} gm ON g.id = gm.groupid
LEFT JOIN {user} u ON gm.userid = u.id
WHERE g.courseid = :courseid $groupwhere $groupingwhere
ORDER BY g.name, u.lastname, u.firstname";
if ($rs = $DB->get_recordset_sql($sql, $params)) {
foreach ($rs as $row) {
@ -132,18 +117,16 @@ echo $OUTPUT->heading(format_string($course->shortname) .' '.$stroverview, 3);
echo $strfiltergroups;
if (!empty($CFG->enablegroupings)) {
$options = array();
$options[0] = get_string('all');
foreach ($groupings as $grouping) {
$options[$grouping->id] = strip_tags(format_string($grouping->name));
}
$popupurl = new moodle_url($rooturl.'&group='.$groupid);
$select = new single_select($popupurl, 'grouping', $options, $groupingid, array());
$select->label = $strgrouping;
$select->formid = 'selectgrouping';
echo $OUTPUT->render($select);
$options = array();
$options[0] = get_string('all');
foreach ($groupings as $grouping) {
$options[$grouping->id] = strip_tags(format_string($grouping->name));
}
$popupurl = new moodle_url($rooturl.'&group='.$groupid);
$select = new single_select($popupurl, 'grouping', $options, $groupingid, array());
$select->label = $strgrouping;
$select->formid = 'selectgrouping';
echo $OUTPUT->render($select);
$options = array();
$options[0] = get_string('all');
@ -196,16 +179,14 @@ foreach ($members as $gpgid=>$groupdata) {
if ($groupid and empty($table->data)) {
continue;
}
if (!empty($CFG->enablegroupings)) {
if ($gpgid < 0) {
echo $OUTPUT->heading($strnotingrouping, 3);
} else {
echo $OUTPUT->heading(format_string($groupings[$gpgid]->name), 3);
$description = file_rewrite_pluginfile_urls($groupings[$gpgid]->description, 'pluginfile.php', $context->id, 'course_grouping_description', $gpgid);
$options = new stdClass;
$options->noclean = true;
echo $OUTPUT->box(format_text($description, $groupings[$gpgid]->descriptionformat, $options), 'generalbox boxwidthnarrow boxaligncenter');
}
if ($gpgid < 0) {
echo $OUTPUT->heading($strnotingrouping, 3);
} else {
echo $OUTPUT->heading(format_string($groupings[$gpgid]->name), 3);
$description = file_rewrite_pluginfile_urls($groupings[$gpgid]->description, 'pluginfile.php', $context->id, 'course_grouping_description', $gpgid);
$options = new stdClass;
$options->noclean = true;
echo $OUTPUT->box(format_text($description, $groupings[$gpgid]->descriptionformat, $options), 'generalbox boxwidthnarrow boxaligncenter');
}
echo html_writer::table($table);
$printed = true;

View file

@ -4,11 +4,9 @@
$CFG->wwwroot.'/group/index.php?id='.$courseid,
get_string('groups'));
if (!empty($CFG->enablegroupings)) {
$row[] = new tabobject('groupings',
$CFG->wwwroot.'/group/groupings.php?id='.$courseid,
get_string('groupings', 'group'));
}
$row[] = new tabobject('groupings',
$CFG->wwwroot.'/group/groupings.php?id='.$courseid,
get_string('groupings', 'group'));
$row[] = new tabobject('overview',
$CFG->wwwroot.'/group/overview.php?id='.$courseid,

View file

@ -155,7 +155,7 @@ $string['configenablecalendarexport'] = 'Enable exporting or subscribing to cale
$string['configenablecourserequests'] = 'This will allow any user to request a course be created.';
$string['configenablecomments'] = 'Enable comments';
$string['configenableglobalsearch'] = 'This setting enables global text searching in resources and activities, it is not compatible with PHP 4.';
$string['configenablegroupings'] = 'This setting enables groupings of groups.';
$string['configenablegroupmembersonly'] = 'This setting enables group members only feature. Please note it is incresing your server load and it is necessary to use some advanced tricks in the gradebook.';
$string['configenablehtmlpurifier'] = 'Use HTML Purifier instead of KSES for cleaning of untrusted text. HTML Purifier is actively developed and is believed to be more secure, but it is more resource intensive. Expect minor visual differences in the resulting html code. Please note that embed and object tags can not be enabled, MathML tags and old lang tags are not supported. ';
$string['configenablerssfeeds'] = 'This switch will enable RSS feeds from across the site. To actually see any change you will need to enable RSS feeds in the individual modules too - go to the Modules settings under Admin Configuration.';
$string['configenablerssfeedsdisabled'] = 'It is not available because RSS feeds are disabled in all the Site. To enable them, go to the Variables settings under Admin Configuration.';
@ -427,7 +427,7 @@ $string['enablecalendarexport'] = 'Enable calendar export';
$string['enablecourserequests'] = 'Enable course requests';
$string['enablecomments'] = 'Enable comments';
$string['enableglobalsearch'] = 'Enable global search';
$string['enablegroupings'] = 'Enable groupings';
$string['enablegroupmembersonly'] = 'Enable group members only';
$string['enablehtmlpurifier'] = 'Enable HTML Purifier';
$string['enablerecordcache'] = 'Enable Record Cache';
$string['enablerssfeeds'] = 'Enable RSS feeds';

View file

@ -3056,7 +3056,7 @@ WHERE gradeitemid IS NOT NULL AND grademax IS NOT NULL");
}
if ($result && $oldversion < 2010033101.02) {
/// Define table license to be created
$table = new xmldb_table('license');
@ -3435,6 +3435,17 @@ WHERE gradeitemid IS NOT NULL AND grademax IS NOT NULL");
upgrade_main_savepoint($result, 2010033102.09);
}
if ($result && $oldversion < 2010040700) {
// migrate old groupings --> groupmembersonly setting
if (isset($CFG->enablegroupings)) {
set_config('enablegroupmembersonly', $CFG->enablegroupings);
unset_config('enablegroupings');
}
// Main savepoint reached
upgrade_main_savepoint($result, 2010040700);
}
return $result;
}

View file

@ -320,7 +320,7 @@ class external_api {
throw new invalid_parameter_exception('Invalid activity.');
}
// verify group memebers
if (!empty($CFG->enablegroupings) and $cm and $cm->groupmembersonly and !has_capability('moodle/site:accessallgroups', get_context_instance(CONTEXT_MODULE, $cm->id))) {
if (!empty($CFG->enablegroupmembersonly) and $cm and $cm->groupmembersonly and !has_capability('moodle/site:accessallgroups', get_context_instance(CONTEXT_MODULE, $cm->id))) {
if (!groups_has_membership($cm)) {
throw new invalid_parameter_exception('Must be member of at least one group.');
}

View file

@ -144,12 +144,6 @@ function groups_get_grouping($groupingid, $fields='*', $strictness=IGNORE_MISSIN
function groups_get_all_groups($courseid, $userid=0, $groupingid=0, $fields='g.*') {
global $CFG, $DB;
// groupings are ignored when not enabled
if (empty($CFG->enablegroupings)) {
$groupingid = 0;
}
if (empty($userid)) {
$userfrom = "";
$userwhere = "";
@ -238,10 +232,6 @@ function groups_get_user_groups($courseid, $userid=0) {
function groups_get_all_groupings($courseid) {
global $CFG, $DB;
// groupings are ignored when not enabled
if (empty($CFG->enablegroupings)) {
return(false);
}
return $DB->get_records_sql("SELECT *
FROM {groupings}
WHERE courseid = ?
@ -287,11 +277,6 @@ function groups_has_membership($cm, $userid=null) {
static $cache = array();
// groupings are ignored when not enabled
if (empty($CFG->enablegroupings)) {
$cm->groupingid = 0;
}
if (empty($userid)) {
$userid = $USER->id;
}
@ -521,11 +506,6 @@ function groups_print_activity_menu($cm, $urlroot, $return=false, $hideallpartic
DEBUG_DEVELOPER);
}
// groupings are ignored when not enabled
if (empty($CFG->enablegroupings)) {
$cm->groupingid = 0;
}
if (!$groupmode = groups_get_activity_groupmode($cm)) {
if ($return) {
return '';
@ -694,11 +674,6 @@ function groups_get_course_group($course, $update=false) {
function groups_get_activity_group($cm, $update=false) {
global $CFG, $USER, $SESSION;
// groupings are ignored when not enabled
if (empty($CFG->enablegroupings)) {
$cm->groupingid = 0;
}
if (!$groupmode = groups_get_activity_groupmode($cm)) {
// NOGROUPS used
return false;
@ -807,7 +782,7 @@ function groups_course_module_visible($cm, $userid=null) {
if (empty($userid)) {
$userid = $USER->id;
}
if (empty($CFG->enablegroupings)) {
if (empty($CFG->enablegroupmembersonly)) {
return true;
}
if (empty($cm->groupmembersonly)) {

View file

@ -2216,7 +2216,7 @@ function require_login($courseorid=0, $autologinguest=true, $cm=null, $setwantsu
}
/// groupmembersonly access control
if (!empty($CFG->enablegroupings) and $cm and $cm->groupmembersonly and !has_capability('moodle/site:accessallgroups', get_context_instance(CONTEXT_MODULE, $cm->id))) {
if (!empty($CFG->enablegroupmembersonly) and $cm and $cm->groupmembersonly and !has_capability('moodle/site:accessallgroups', get_context_instance(CONTEXT_MODULE, $cm->id))) {
if (isguestuser() or !groups_has_membership($cm)) {
print_error('groupmembersonlyerror', 'group', $CFG->wwwroot.'/course/view.php?id='.$cm->course);
}
@ -2393,7 +2393,7 @@ function require_course_login($courseorid, $autologinguest=true, $cm=null, $setw
if ($cm and empty($cm->visible)) {
// hidden activities are not accessible without login
require_login($courseorid, $autologinguest, $cm, $setwantsurltome);
} else if ($cm and !empty($CFG->enablegroupings) and $cm->groupmembersonly) {
} else if ($cm and !empty($CFG->enablegroupmembersonly) and $cm->groupmembersonly) {
// not-logged-in users do not have any group membership
require_login($courseorid, $autologinguest, $cm, $setwantsurltome);
} else {
@ -2841,7 +2841,7 @@ function &get_fast_modinfo(&$course, $userid=0) {
if ((!$cm->visible or !$cm->available) and !has_capability('moodle/course:viewhiddenactivities', $modcontext, $userid)) {
$cm->uservisible = false;
} else if (!empty($CFG->enablegroupings) and !empty($cm->groupmembersonly)
} else if (!empty($CFG->enablegroupmembersonly) and !empty($cm->groupmembersonly)
and !has_capability('moodle/site:accessallgroups', $modcontext, $userid)) {
if (is_null($modinfo->groups)) {
$modinfo->groups = groups_get_user_groups($course->id, $userid);

View file

@ -1248,8 +1248,6 @@ get_string('configmemcachedpconn', 'admin', NULL);
get_string('no', '', NULL);
get_string('yes', '', NULL);
get_string('registration', 'admin', NULL);
get_string('enablegroupings', 'admin', NULL);
get_string('configenablegroupings', 'admin', NULL);
get_string('enableoutcomes', 'grades', NULL);
get_string('configenableoutcomes', 'grades', NULL);
get_string('usetags', 'admin', NULL);

View file

@ -1248,8 +1248,6 @@ old_get_string('configmemcachedpconn', 'admin', NULL);
old_get_string('no', '', NULL);
old_get_string('yes', '', NULL);
old_get_string('registration', 'admin', NULL);
old_get_string('enablegroupings', 'admin', NULL);
old_get_string('configenablegroupings', 'admin', NULL);
old_get_string('enableoutcomes', 'grades', NULL);
old_get_string('configenableoutcomes', 'grades', NULL);
old_get_string('usetags', 'admin', NULL);

View file

@ -891,7 +891,7 @@ class assignment_base {
}
// if groupmembersonly used, remove users who are not in any group
if ($users and !empty($CFG->enablegroupings) and $cm->groupmembersonly) {
if ($users and !empty($CFG->enablegroupmembersonly) and $cm->groupmembersonly) {
if ($groupingusers = groups_get_grouping_members($cm->groupingid, 'u.id', 'u.id')) {
$users = array_intersect($users, array_keys($groupingusers));
}
@ -1143,7 +1143,7 @@ class assignment_base {
}
// if groupmembersonly used, remove users who are not in any group
if ($users and !empty($CFG->enablegroupings) and $cm->groupmembersonly) {
if ($users and !empty($CFG->enablegroupmembersonly) and $cm->groupmembersonly) {
if ($groupingusers = groups_get_grouping_members($cm->groupingid, 'u.id', 'u.id')) {
$users = array_intersect($users, array_keys($groupingusers));
}
@ -2952,7 +2952,7 @@ function assignment_count_real_submissions($cm, $groupid=0) {
}
// if groupmembersonly used, remove users who are not in any group
if ($users and !empty($CFG->enablegroupings) and $cm->groupmembersonly) {
if ($users and !empty($CFG->enablegroupmembersonly) and $cm->groupmembersonly) {
if ($groupingusers = groups_get_grouping_members($cm->groupingid, 'u.id', 'u.id')) {
$users = array_intersect($users, array_keys($groupingusers));
}

View file

@ -531,7 +531,7 @@ function chat_get_users($chatid, $groupid=0, $groupingid=0) {
$groupselect = "";
}
if (!empty($CFG->enablegroupings) && !(empty($groupingid))) {
if (!empty($groupingid)) {
$groupingjoin = "JOIN {groups_members} gm ON u.id = gm.userid
JOIN {groupings_groups} gg ON gm.groupid = gg.groupid AND gg.groupingid = :groupingid ";

View file

@ -1937,10 +1937,7 @@ function forum_get_readable_forums($userid, $courseid=0) {
if (is_null($modinfo->groups)) {
$modinfo->groups = groups_get_user_groups($course->id, $USER->id);
}
if (empty($CFG->enablegroupings)) {
$forum->onlygroups = $modinfo->groups[0];
$forum->onlygroups[] = -1;
} else if (isset($modinfo->groups[$cm->groupingid])) {
if (isset($modinfo->groups[$cm->groupingid])) {
$forum->onlygroups = $modinfo->groups[$cm->groupingid];
$forum->onlygroups[] = -1;
} else {
@ -2556,14 +2553,10 @@ function forum_count_discussions($forum, $cm, $course) {
$modinfo->groups = groups_get_user_groups($course->id, $USER->id);
}
if (empty($CFG->enablegroupings)) {
$mygroups = $modinfo->groups[0];
if (array_key_exists($cm->groupingid, $modinfo->groups)) {
$mygroups = $modinfo->groups[$cm->groupingid];
} else {
if (array_key_exists($cm->groupingid, $modinfo->groups)) {
$mygroups = $modinfo->groups[$cm->groupingid];
} else {
$mygroups = false; // Will be set below
}
$mygroups = false; // Will be set below
}
// add all groups posts
@ -7062,11 +7055,7 @@ function forum_tp_count_forum_unread_posts($cm, $course) {
$modinfo->groups = groups_get_user_groups($course->id, $USER->id);
}
if (empty($CFG->enablegroupings)) {
$mygroups = $modinfo->groups[0];
} else {
$mygroups = $modinfo->groups[$cm->groupingid];
}
$mygroups = $modinfo->groups[$cm->groupingid];
// add all groups posts
if (empty($mygroups)) {

View file

@ -492,7 +492,7 @@ function hotpot_is_visible(&$cm) {
// check grouping
$modulecontext = get_context_instance(CONTEXT_MODULE, $cm->id);
if (empty($CFG->enablegroupings) || empty($cm->groupmembersonly) || has_capability('moodle/site:accessallgroups', $modulecontext)) {
if (empty($CFG->enablegroupmembersonly) || empty($cm->groupmembersonly) || has_capability('moodle/site:accessallgroups', $modulecontext)) {
// groupings not applicable
} else if (!isguestuser() && groups_has_membership($cm)) {
// user is in one of the groups in the allowed grouping

View file

@ -243,7 +243,7 @@ switch ($mode) {
list($usql, $parameters) = $DB->get_in_or_equal(array_keys($pages));
if ($essayattempts = $DB->get_records_select('lesson_attempts', 'pageid '.$usql, $parameters)) {
// Get all the users who have taken this lesson, order by their last name
if (!empty($CFG->enablegroupings) && !empty($cm->groupingid)) {
if (!empty($cm->groupingid)) {
$params["groupinid"] = $cm->groupingid;
$sql = "SELECT DISTINCT u.*
FROM {lesson_attempts} a

View file

@ -44,7 +44,7 @@ $context = get_context_instance(CONTEXT_MODULE, $cm->id);
require_capability('mod/lesson:manage', $context);
$params = array("lessonid" => $lesson->id);
if (!empty($CFG->enablegroupings) && !empty($cm->groupingid)) {
if (!empty($cm->groupingid)) {
$params["groupid"] = $cm->groupingid;
$sql = "SELECT DISTINCT u.id, u.*
FROM {lesson_attempts} a

View file

@ -857,7 +857,7 @@ function scorm_simple_play($scorm,$user) {
function scorm_get_count_users($scormid, $groupingid=null) {
global $CFG, $DB;
if (!empty($CFG->enablegroupings) && !empty($groupingid)) {
if (!empty($groupingid)) {
$sql = "SELECT COUNT(DISTINCT st.userid)
FROM {scorm_scoes_track} st
INNER JOIN {groups_members} gm ON st.userid = gm.userid

View file

@ -107,7 +107,7 @@
if (empty($a)) {
// No options, show the global scorm report
if (!empty($CFG->enablegroupings) && !empty($cm->groupingid)) {
if (!empty($cm->groupingid)) {
$sql = "SELECT st.userid, st.scormid
FROM {scorm_scoes_track} st
INNER JOIN {groups_members} gm ON st.userid = gm.userid

View file

@ -56,7 +56,7 @@
/// Check to see if groups are being used in this survey
if ($group) {
$users = get_users_by_capability($context, 'mod/survey:participate', '', '', '', '', $group, null, false);
} else if (!empty($CFG->enablegroupings) && !empty($cm->groupingid)) {
} else if (!empty($cm->groupingid)) {
$groups = groups_get_all_groups($courseid, 0, $cm->groupingid);
$groups = array_keys($groups);
$users = get_users_by_capability($context, 'mod/survey:participate', '', '', '', '', $groups, null, false);

View file

@ -132,7 +132,7 @@
if ($currentgroup) {
$users = get_users_by_capability($context, 'mod/survey:participate', '', '', '', '', $currentgroup, null, false);
} else if (!empty($CFG->enablegroupings) && !empty($cm->groupingid)) {
} else if (!empty($cm->groupingid)) {
$groups = groups_get_all_groups($courseid, 0, $cm->groupingid);
$groups = array_keys($groups);
$users = get_users_by_capability($context, 'mod/survey:participate', '', '', '', '', $groups, null, false);

View file

@ -760,7 +760,7 @@ function wiki_get_other_wikis(&$wiki, &$user, &$course, $currentid=0) {
$cm->groupmode = $wiki->groupmode;
$cm->groupingid = $wiki->groupingid;
$cm->groupmembersonly = $wiki->groupmembersonly;
if (!empty($CFG->enablegroupings) && !empty($cm->groupingid)) {
if (!empty($cm->groupingid)) {
$groupingid = $wiki->groupingid;
}
@ -771,7 +771,7 @@ function wiki_get_other_wikis(&$wiki, &$user, &$course, $currentid=0) {
/// Get all the existing entries for this wiki.
$wiki_entries = wiki_get_entries($wiki, 'student');
if (!empty($CFG->enablegroupings) && !empty($wiki->groupingid)) {
if (!empty($wiki->groupingid)) {
$sql = "SELECT gm.userid FROM {groups_members} gm " .
"INNER JOIN {groupings_groups} gg ON gm.groupid = gg.groupid " .
"WHERE gg.groupingid = ? ";
@ -789,7 +789,7 @@ function wiki_get_other_wikis(&$wiki, &$user, &$course, $currentid=0) {
$defpagename = empty($wiki->pagename) ? get_string('wikidefaultpagename', 'wiki') : $wiki->pagename;
foreach ($students as $student) {
if (!empty($CFG->enablegroupings) && !empty($wiki->groupingid) && empty($groupingmembers[$student->id])) {
if (!empty($wiki->groupingid) && empty($groupingmembers[$student->id])) {
continue;
}
/// If this student already has an entry, use its pagename.
@ -810,7 +810,7 @@ function wiki_get_other_wikis(&$wiki, &$user, &$course, $currentid=0) {
if ($students = wiki_get_students($wiki, $mygroupid)) {
$defpagename = empty($wiki->pagename) ? get_string('wikidefaultpagename', 'wiki') : $wiki->pagename;
foreach ($students as $student) {
if (!empty($CFG->enablegroupings) && !empty($wiki->groupingid) && empty($groupingmembers[$student->id])) {
if (!empty($wiki->groupingid) && empty($groupingmembers[$student->id])) {
continue;
}
/// If this student already has an entry, use its pagename.
@ -831,7 +831,7 @@ function wiki_get_other_wikis(&$wiki, &$user, &$course, $currentid=0) {
if ($students = wiki_get_students($wiki, $mygroupid)) {
$defpagename = empty($wiki->pagename) ? get_string('wikidefaultpagename', 'wiki') : $wiki->pagename;
foreach ($students as $student) {
if (!empty($CFG->enablegroupings) && !empty($wiki->groupingid) && empty($groupingmembers[$student->id])) {
if (!empty($wiki->groupingid) && empty($groupingmembers[$student->id])) {
continue;
}
/// If this student already has an entry, use its pagename.
@ -846,7 +846,7 @@ function wiki_get_other_wikis(&$wiki, &$user, &$course, $currentid=0) {
}
}
/// Get all student wikis created, regardless of group.
if (!empty($CFG->enablegroupings) && !empty($wiki->groupingid)) {
if (!empty($wiki->groupingid)) {
$sql = 'SELECT w.id, w.userid, w.pagename, u.firstname, u.lastname '
.' FROM {wiki_entries} w '
.' INNER JOIN {user} u ON w.userid = u.id '
@ -891,7 +891,7 @@ function wiki_get_other_wikis(&$wiki, &$user, &$course, $currentid=0) {
}
if ($viewall !== false) {
if (!empty($CFG->enablegroupings) && !empty($wiki->groupingid)) {
if (!empty($wiki->groupingid)) {
$sql = 'SELECT w.id, w.userid, w.pagename, u.firstname, u.lastname '
.' FROM {wiki_entries} w '
.' INNER JOIN {user} u ON w.userid = u.id '
@ -910,7 +910,7 @@ function wiki_get_other_wikis(&$wiki, &$user, &$course, $currentid=0) {
$wiki_entries = $DB->get_records_sql($sql, $params);
$wiki_entries=is_array($wiki_entries)?$wiki_entries:array();
foreach ($wiki_entries as $wiki_entry) {
if (!empty($CFG->enablegroupings) && !empty($wiki->groupingid) && empty($groupingmembers[$wiki_entry->userid])) {
if (!empty($wiki->groupingid) && empty($groupingmembers[$wiki_entry->userid])) {
continue;
}
@ -975,7 +975,7 @@ function wiki_get_other_wikis(&$wiki, &$user, &$course, $currentid=0) {
}
/// A user can see other group wikis if there are visible groups.
else if ($groupmode == VISIBLEGROUPS) {
if (!empty($CFG->enablegroupings) && !empty($wiki->groupingid)) {
if (!empty($wiki->groupingid)) {
$sql = 'SELECT w.id, w.groupid, w.pagename, g.name as gname '
.' FROM {wiki_entries} w '
.' INNER JOIN {groups} g ON g.id = w.groupid '
@ -1025,7 +1025,7 @@ function wiki_get_other_wikis(&$wiki, &$user, &$course, $currentid=0) {
}
/// A teacher can see all other group teacher wikis.
else if ($groupmode) {
if (!empty($CFG->enablegroupings) && !empty($wiki->groupingid)) {
if (!empty($wiki->groupingid)) {
$sql = 'SELECT w.id, w.groupid, w.pagename, g.name as gname '
.' FROM {wiki_entries} w '
.' INNER JOIN {groups} g ON g.id = w.groupid '
@ -1064,7 +1064,7 @@ function wiki_get_other_wikis(&$wiki, &$user, &$course, $currentid=0) {
$viewall = false;
}
if ($viewall !== false) {
if (!empty($CFG->enablegroupings) && !empty($wiki->groupingid)) {
if (!empty($wiki->groupingid)) {
$sql = 'SELECT w.id, w.groupid, w.pagename, g.name as gname '
.' FROM {wiki_entries} w '
.' INNER JOIN {groups} g ON g.id = w.groupid '

View file

@ -372,7 +372,7 @@ class workshop {
if (empty($users)) {
return $grouped;
}
if (!empty($CFG->enablegroupings) and $this->cm->groupmembersonly) {
if (!empty($CFG->enablegroupmembersonly) and $this->cm->groupmembersonly) {
// Available for group members only - the workshop is available only
// to users assigned to groups within the selected grouping, or to
// any group if no grouping is selected.

View file

@ -356,10 +356,8 @@
if ($groupmode != 0) {
$tablecolumns[] = 'groups';
$tableheaders[] = get_string('groups');
if (!empty($CFG->enablegroupings)) {
$tablecolumns[] = 'groupings';
$tableheaders[] = get_string('groupings', 'group');
}
$tablecolumns[] = 'groupings';
$tableheaders[] = get_string('groupings', 'group');
}
}
@ -821,9 +819,7 @@
if ($groupmode != 0) {
// htmlescape with s() and implode the array
$data[] = implode(', ', array_map('s',$userlist_extra[$user->id]['group']));
if (!empty($CFG->enablegroupings)) {
$data[] = implode(', ', array_map('s', $userlist_extra[$user->id]['gping']));
}
$data[] = implode(', ', array_map('s', $userlist_extra[$user->id]['gping']));
}
}
@ -930,16 +926,11 @@ function get_participants_extra ($userids, $course, $context) {
$contextids = substr($context->path, 1); // kill leading slash
$contextids = str_replace('/', ',', $contextids);;
if (!empty($CFG->enablegroupings)) {
$gpjoin = "LEFT OUTER JOIN {groupings_groups} gpg
ON gpg.groupid=g.id
LEFT OUTER JOIN {groupings} gp
ON (gp.courseid={$course->id} AND gp.id=gpg.groupingid)";
$gpselect = ',gp.id AS gpid, gp.name AS gpname ';
} else {
$gpjoin = '';
$gpselect = '';
}
$gpjoin = "LEFT OUTER JOIN {groupings_groups} gpg
ON gpg.groupid=g.id
LEFT OUTER JOIN {groupings} gp
ON (gp.courseid={$course->id} AND gp.id=gpg.groupingid)";
$gpselect = ',gp.id AS gpid, gp.name AS gpname ';
// Note: this returns strange redundant rows, perhaps
// due to the multiple OUTER JOINs. If we can tweak the

View file

@ -6,7 +6,7 @@
// This is compared against the values stored in the database to determine
// whether upgrades should be performed (see lib/db/*.php)
$version = 2010033103; // YYYYMMDD = date of the last version bump
$version = 2010040700; // YYYYMMDD = date of the last version bump
// XX = daily increments
$release = '2.0 dev (Build: 20100407)'; // Human-friendly version name