From f6ac445e523727d52b46fef1294aaeb6aaeadf93 Mon Sep 17 00:00:00 2001 From: lenaherf Date: Mon, 22 Jun 2026 15:07:24 +0200 Subject: [PATCH 1/7] add counts of the groupings next to groupings and groups --- classes/output/renderer.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/classes/output/renderer.php b/classes/output/renderer.php index 11563d2..915654f 100644 --- a/classes/output/renderer.php +++ b/classes/output/renderer.php @@ -41,9 +41,14 @@ public function teaching_groups_or_groupings_list($elementarray, $group) { } else { $type = 'grouping'; } - $contentgroups = html_writer::tag('input', '', ['type' => "checkbox", 'value' => "1", - 'class' => "blockgroupsandgroupingcheckbox", 'id' => 'checkbox' . $type]) . - html_writer::tag('label', get_string($type, 'block_groups'), ['for' => "checkbox" . $type]); + $labeltext = get_string($type, 'block_groups') . ' (' . count($elementarray) . ')'; + $contentgroups = html_writer::tag('input', '', [ + 'type' => "checkbox", + 'value' => "1", + 'class' => "blockgroupsandgroupingcheckbox", + 'id' => 'checkbox' . $type + ]) . + html_writer::tag('label', $labeltext, ['for' => "checkbox" . $type]); $contentgroups .= html_writer::alist($elementarray, ['class' => 'wrapperlist' . $type]); return html_writer::tag('div', $contentgroups, ['class' => 'wrapperblockgroupsandgroupingcheckbox']); } From 8080ce4bc7400cdfb6bf4f9ea85bdce348271ca9 Mon Sep 17 00:00:00 2001 From: lenaherf Date: Mon, 22 Jun 2026 15:08:10 +0200 Subject: [PATCH 2/7] add arrow to show groupings and groups can be clicked to show more information --- styles.css | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/styles.css b/styles.css index 13b7653..64253e6 100644 --- a/styles.css +++ b/styles.css @@ -48,3 +48,25 @@ .block_groups .block-groups-spinner { padding-right: 6px; } + +.block_groups input.blockgroupsandgroupingcheckbox { + cursor: pointer; + display: none; + text-align: left; +} + +.block_groups input.blockgroupsandgroupingcheckbox ~ label { + cursor: pointer; +} + +.block_groups input.blockgroupsandgroupingcheckbox ~ label::before { + content: "▸"; + display: inline-block; + width: 0.8em; + margin-right: 0.2rem; + font-size: 1.5em; +} + +.block_groups input.blockgroupsandgroupingcheckbox:checked ~ label::before { + content: "▾"; +} From bef1e8779892f52f2ce2e9d2d096c5e234da24f8 Mon Sep 17 00:00:00 2001 From: lenaherf Date: Mon, 22 Jun 2026 15:21:50 +0200 Subject: [PATCH 3/7] codechecker --- classes/output/renderer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/output/renderer.php b/classes/output/renderer.php index 915654f..bb67db1 100644 --- a/classes/output/renderer.php +++ b/classes/output/renderer.php @@ -46,7 +46,7 @@ public function teaching_groups_or_groupings_list($elementarray, $group) { 'type' => "checkbox", 'value' => "1", 'class' => "blockgroupsandgroupingcheckbox", - 'id' => 'checkbox' . $type + 'id' => 'checkbox' . $type, ]) . html_writer::tag('label', $labeltext, ['for' => "checkbox" . $type]); $contentgroups .= html_writer::alist($elementarray, ['class' => 'wrapperlist' . $type]); From 14562583660f9e04ce84edc9c8b5bcecebc3cb40 Mon Sep 17 00:00:00 2001 From: lenaherf Date: Wed, 8 Jul 2026 10:42:54 +0200 Subject: [PATCH 4/7] show groups of groupings --- block_groups.php | 28 +++++++++++++++++++++++++++- classes/output/renderer.php | 15 +++++++++++++-- styles.css | 4 ++++ 3 files changed, 44 insertions(+), 3 deletions(-) diff --git a/block_groups.php b/block_groups.php index f09b046..2f7e7ad 100644 --- a/block_groups.php +++ b/block_groups.php @@ -187,12 +187,38 @@ public function build_grouping_array($allgroupings, $courseid) { $countgroupingmember = $arrayofmembers[$value->id]->number; } - $groupingsarray[$g] = $renderer->get_grouping($value, $countgroupingmember); + $groupnames = $this->get_groups_for_grouping($value->id, $courseid); + + $groupingsarray[$g] = $renderer->get_grouping($value, $countgroupingmember, $groupnames); } } return $groupingsarray; } + /** + * Returns the names of all groups belonging to a grouping. + * + * @param $groupingid + * @param $courseid + * @return array + * @throws dml_exception + */ + private function get_groups_for_grouping($groupingid, $courseid) { + global $DB; + + $sql = "SELECT g.id, g.name + FROM {groups} g + JOIN {groupings_groups} gg ON gg.groupid = g.id + WHERE gg.groupingid = :groupingid + AND g.courseid = :courseid + ORDER BY g.name ASC"; + + return $DB->get_records_sql($sql, [ + 'groupingid' => $groupingid, + 'courseid' => $courseid, + ]); + } + /** * Tells moodle, that the groups block has a settings file. * @return bool true diff --git a/classes/output/renderer.php b/classes/output/renderer.php index bb67db1..f0dbc20 100644 --- a/classes/output/renderer.php +++ b/classes/output/renderer.php @@ -101,7 +101,7 @@ public function get_string_group($value, $href, $countmembers, $visibility) { * @param integer $counter * @return string html-string */ - public function get_grouping($grouping, $counter) { + public function get_grouping($grouping, $counter, $groups = []) { $line = html_writer::span( $grouping->name . ' ' . get_string('brackets', 'block_groups', $counter), 'wrapperblockgroupsgrouping' @@ -110,7 +110,18 @@ public function get_grouping($grouping, $counter) { $showlink = $this->create_grouping_link('show', $grouping->id, false); $hidelink = $this->create_grouping_link('hide', $grouping->id, false); - return html_writer::span($line . $showlink . $hidelink, 'grouping-' . $grouping->id); + if (!empty($groups)) { + $groupitems = []; + + foreach ($groups as $group) { + $groupitems[] = s($group->name); + } + $groupslist = html_writer::alist($groupitems, [ + 'class' => 'wrapperlistgroupinggroups', + ]); + } + + return html_writer::span($line . $showlink . $hidelink . $groupslist, 'grouping-' . $grouping->id); } /** * Renders line to change all groups. diff --git a/styles.css b/styles.css index 64253e6..56362b3 100644 --- a/styles.css +++ b/styles.css @@ -70,3 +70,7 @@ .block_groups input.blockgroupsandgroupingcheckbox:checked ~ label::before { content: "▾"; } + + .block_groups .wrapperlistgroupinggroups { + opacity: 0.85; + } \ No newline at end of file From d998ce91c662e09786ea64a87d18139f5a1e7617 Mon Sep 17 00:00:00 2001 From: lenaherf Date: Wed, 8 Jul 2026 10:45:45 +0200 Subject: [PATCH 5/7] fix indentation --- styles.css | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/styles.css b/styles.css index 56362b3..ea17e8b 100644 --- a/styles.css +++ b/styles.css @@ -71,6 +71,6 @@ content: "▾"; } - .block_groups .wrapperlistgroupinggroups { - opacity: 0.85; - } \ No newline at end of file +.block_groups .wrapperlistgroupinggroups { + opacity: 0.85; +} \ No newline at end of file From 8c38f6a42aa10b8ae543499e0394d08df5cdd880 Mon Sep 17 00:00:00 2001 From: lenaherf Date: Wed, 8 Jul 2026 11:07:26 +0200 Subject: [PATCH 6/7] phpcs --- block_groups.php | 4 ++-- classes/output/renderer.php | 10 +++++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/block_groups.php b/block_groups.php index 2f7e7ad..5b4476b 100644 --- a/block_groups.php +++ b/block_groups.php @@ -198,8 +198,8 @@ public function build_grouping_array($allgroupings, $courseid) { /** * Returns the names of all groups belonging to a grouping. * - * @param $groupingid - * @param $courseid + * @param integer $groupingid + * @param integer $courseid * @return array * @throws dml_exception */ diff --git a/classes/output/renderer.php b/classes/output/renderer.php index f0dbc20..ed93e36 100644 --- a/classes/output/renderer.php +++ b/classes/output/renderer.php @@ -95,11 +95,15 @@ public function get_string_group($value, $href, $countmembers, $visibility) { 'data-action' => $action]); return html_writer::span($line, 'group-' . $value->id); } + /** * Generates string for a grouping list item - * @param stdClass $grouping - * @param integer $counter - * @return string html-string + * + * @param $grouping + * @param $counter + * @param $groups + * @return string + * @throws \coding_exception */ public function get_grouping($grouping, $counter, $groups = []) { $line = html_writer::span( From ceaebb3adf36a0b8e09dcc201822196f861b46ff Mon Sep 17 00:00:00 2001 From: lenaherf Date: Wed, 8 Jul 2026 11:14:06 +0200 Subject: [PATCH 7/7] phpcs --- classes/output/renderer.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/classes/output/renderer.php b/classes/output/renderer.php index ed93e36..f99e0ba 100644 --- a/classes/output/renderer.php +++ b/classes/output/renderer.php @@ -99,9 +99,9 @@ public function get_string_group($value, $href, $countmembers, $visibility) { /** * Generates string for a grouping list item * - * @param $grouping - * @param $counter - * @param $groups + * @param stdClass $grouping + * @param integer $counter + * @param array $groups * @return string * @throws \coding_exception */