Skip to content

Commit

Permalink
only show enrolled users with ratings in the allocations_table
Browse files Browse the repository at this point in the history
  • Loading branch information
irinahpe committed Apr 15, 2024
1 parent c18a786 commit d7f687c
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1619,18 +1619,27 @@ public function get_rating_data_for_user($userid) {
}

/**
* Returns all ids of users who handed in a rating to any choice of the instance.
* Returns all ids of users in this course who handed in a rating to any choice of the instance.
* @return array of userids
*/
public function get_users_with_ratings() {

$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";
WHERE c.ratingallocateid = :ratingallocateid AND c.active = 1 AND r.userid IN ( :ratersincourse )";

return $this->db->get_records_sql($sql, array(
'ratingallocateid' => $this->ratingallocateid
'ratingallocateid' => $this->ratingallocateid,
'ratersincourse' => implode(
" , ",
array_map(function ($rater) {
return $rater->id;
}, $this-> get_raters_in_course())
)
));

}

/**
Expand Down

0 comments on commit d7f687c

Please sign in to comment.