File tree Expand file tree Collapse file tree 1 file changed +11
-8
lines changed Expand file tree Collapse file tree 1 file changed +11
-8
lines changed Original file line number Diff line number Diff line change @@ -765,14 +765,17 @@ private function process_action_manual_allocation() {
765765 * @return array of group ids used in rateable choices
766766 */
767767 public function get_all_groups_of_choices (): array {
768- $ rateablechoiceswithgrouprestrictions = array_filter ($ this ->get_rateable_choices (),
769- fn ($ choice ) => !empty ($ choice ->usegroups ) && !empty ($ this ->get_choice_groups ($ choice ->id )));
770- $ rateablechoiceids = array_map (fn ($ choice ) => $ choice ->id , $ rateablechoiceswithgrouprestrictions );
771- $ groupids = [];
772- foreach ($ rateablechoiceids as $ choiceid ) {
773- $ groupids = array_merge ($ groupids , array_map (fn ($ group ) => $ group ->id , $ this ->get_choice_groups ($ choiceid )));
774- }
775- return array_unique ($ groupids );
768+ global $ DB ;
769+
770+ $ sql = 'SELECT DISTINCT g.id
771+ FROM {ratingallocate_group_choices} gc
772+ JOIN {ratingallocate_choices} rc on rc.id = gc.choiceid
773+ JOIN {groups} g ON gc.groupid=g.id
774+ WHERE rc.ratingallocateid=:id ' ;
775+
776+ $ groupids = $ DB ->get_fieldset_sql ($ sql , ['id ' => $ this ->ratingallocateid ]);
777+
778+ return $ groupids ;
776779 }
777780
778781 /**
You can’t perform that action at this time.
0 commit comments