Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 15 additions & 8 deletions classes/ratingallocate.php
Original file line number Diff line number Diff line change
Expand Up @@ -685,14 +685,21 @@ private function process_action_manual_allocation() {
* @return array of group ids used in rateable choices
*/
public function get_all_groups_of_choices(): array {
$rateablechoiceswithgrouprestrictions = array_filter($this->get_rateable_choices(),
fn($choice) => !empty($choice->usegroups) && !empty($this->get_choice_groups($choice->id)));
$rateablechoiceids = array_map(fn($choice) => $choice->id, $rateablechoiceswithgrouprestrictions);
$groupids = [];
foreach ($rateablechoiceids as $choiceid) {
$groupids = array_merge($groupids, array_map(fn($group) => $group->id, $this->get_choice_groups($choiceid)));
}
return array_unique($groupids);
$sql = '
SELECT DISTINCT
g.id
FROM
{ratingallocate_choices} c
JOIN {ratingallocate_group_choices} gc ON gc.choiceid = c.id
JOIN {groups} g ON gc.groupid = g.id
WHERE
c.ratingallocateid = :id
AND c.usegroups = 1
AND c.active = 1';

$groupids = $this->db->get_fieldset_sql($sql, ['id' => $this->ratingallocateid]);

return $groupids;
}

/**
Expand Down