From 6085cb3ae2dfd0e07f9297f993a64e7507a20593 Mon Sep 17 00:00:00 2001 From: Irina Hoppe Date: Tue, 30 Jul 2024 10:40:52 +0200 Subject: [PATCH] modify sql for returning users with ratings --- locallib.php | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/locallib.php b/locallib.php index 84125b79..34b474e7 100644 --- a/locallib.php +++ b/locallib.php @@ -1738,22 +1738,20 @@ public function get_rating_data_for_user($userid) { */ public function get_users_with_ratings() { + $raters = array_map( + function ($rater) { + return $rater->id; + }, + $this->get_raters_in_course()); + $sql = "SELECT DISTINCT r.userid FROM {ratingallocate_choices} c JOIN {ratingallocate_ratings} r ON c.id = r.choiceid - WHERE c.ratingallocateid = :ratingallocateid AND c.active = 1 AND r.userid IN ( :ratersincourse )"; + WHERE c.ratingallocateid = :ratingallocateid AND c.active = 1 AND r.userid IN (" . implode(",", $raters) . ") "; return $this->db->get_records_sql($sql, [ 'ratingallocateid' => $this->ratingallocateid, - 'ratersincourse' => implode( - " , ", - array_map( - function ($rater) { - return $rater->id; - }, - $this->get_raters_in_course()) - ), ]); }