Skip to content

Commit

Permalink
MDL-78099 core_group: add grouping to group selector
Browse files Browse the repository at this point in the history
  • Loading branch information
Nathan Nguyen committed Feb 7, 2025
1 parent 139a0ad commit 8988e66
Show file tree
Hide file tree
Showing 12 changed files with 307 additions and 27 deletions.
2 changes: 1 addition & 1 deletion course/amd/build/actionbar/group.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion course/amd/build/actionbar/group.min.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion course/amd/src/actionbar/group.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,16 @@ export default class Group extends GroupSearch {
* Build up the link that is dedicated to a particular result.
*
* @param {Number} groupID The ID of the group selected.
* @param {Number} groupingID The ID of the grouping selected.
* @returns {string}
*/
selectOneLink(groupID) {
selectOneLink(groupID, groupingID = 0) {
const url = new URL(this.baseUrl);
url.searchParams.set('groupsearchvalue', this.getSearchTerm());
url.searchParams.set('group', groupID);
if (groupingID > 0) {
url.searchParams.set('grouping', groupingID);
}

return url.toString();
}
Expand Down
11 changes: 11 additions & 0 deletions grade/report/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,8 @@ public static function supports_mygrades() {
* Sets up this object's group variables, mainly to restrict the selection of users to display.
*/
protected function setup_groups() {
global $DB;

// find out current groups mode
if ($this->groupmode = groups_get_course_groupmode($this->course)) {
if (empty($this->gpr->groupid)) {
Expand All @@ -452,6 +454,15 @@ protected function setup_groups() {
$this->groupsql = " JOIN {groups_members} gm ON gm.userid = u.id ";
$this->groupwheresql = " AND gm.groupid = :gr_grpid ";
$this->groupwheresql_params = array('gr_grpid'=>$this->currentgroup);
} else {
$currentgrouping = groups_get_course_grouping($this->course);
if ($currentgrouping) {
$allowedgroups = groups_get_course_allowed_groups($this->course, null, $currentgrouping);
[$insql, $inparams] = $DB->get_in_or_equal(array_keys($allowedgroups), SQL_PARAMS_NAMED, 'gr_grpid');
$this->groupsql = " JOIN {groups_members} gm ON gm.userid = u.id ";
$this->groupwheresql = " AND gm.groupid $insql ";
$this->groupwheresql_params = $inparams;
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion group/amd/build/comboboxsearch/group.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 8988e66

Please sign in to comment.