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

@ -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.