Skip to content

Commit

Permalink
modify sql for returning users with ratings
Browse files Browse the repository at this point in the history
  • Loading branch information
irinahpe committed Jul 30, 2024
1 parent 46973e0 commit 6085cb3
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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())
),
]);

}
Expand Down

0 comments on commit 6085cb3

Please sign in to comment.