File tree Expand file tree Collapse file tree 1 file changed +15
-8
lines changed Expand file tree Collapse file tree 1 file changed +15
-8
lines changed Original file line number Diff line number Diff line change @@ -685,14 +685,21 @@ private function process_action_manual_allocation() {
685685 * @return array of group ids used in rateable choices
686686 */
687687 public function get_all_groups_of_choices (): array {
688- $ rateablechoiceswithgrouprestrictions = array_filter ($ this ->get_rateable_choices (),
689- fn ($ choice ) => !empty ($ choice ->usegroups ) && !empty ($ this ->get_choice_groups ($ choice ->id )));
690- $ rateablechoiceids = array_map (fn ($ choice ) => $ choice ->id , $ rateablechoiceswithgrouprestrictions );
691- $ groupids = [];
692- foreach ($ rateablechoiceids as $ choiceid ) {
693- $ groupids = array_merge ($ groupids , array_map (fn ($ group ) => $ group ->id , $ this ->get_choice_groups ($ choiceid )));
694- }
695- return array_unique ($ groupids );
688+ $ sql = '
689+ SELECT DISTINCT
690+ g.id
691+ FROM
692+ {ratingallocate_choices} c
693+ JOIN {ratingallocate_group_choices} gc ON gc.choiceid = c.id
694+ JOIN {groups} g ON gc.groupid = g.id
695+ WHERE
696+ c.ratingallocateid = :id
697+ AND c.usegroups = 1
698+ AND c.active = 1 ' ;
699+
700+ $ groupids = $ this ->db ->get_fieldset_sql ($ sql , ['id ' => $ this ->ratingallocateid ]);
701+
702+ return $ groupids ;
696703 }
697704
698705 /**
You can’t perform that action at this time.
0 commit comments