diff --git a/locallib.php b/locallib.php index 7304a4a0..6b14463c 100644 --- a/locallib.php +++ b/locallib.php @@ -27,6 +27,7 @@ */ defined('MOODLE_INTERNAL') || die(); +use core_availability\info_module; use ratingallocate\db as this_db; global $CFG; @@ -178,11 +179,20 @@ class ratingallocate { /** * Returns all users enrolled in the course the ratingallocate is in + * @throws moodle_exception */ - public function get_raters_in_course() { - // Pulling this sorted from the database improves performance of distribution of unallocated users by a lot. - $raters = get_enrolled_users($this->context, 'mod/ratingallocate:give_rating', 0, 'u.*', 'id'); - return $raters; + public function get_raters_in_course(): array { + + $modinfo = get_fast_modinfo($this->course); + $cm = $modinfo->get_cm($this->coursemodule->id); + + $raters = get_enrolled_users($this->context, 'mod/ratingallocate:give_rating'); + $info = new info_module($cm); + // Only show raters who had the ability to access this activity. This funktion ignores the visibility setting, + // so the ratings and allocations are still shown, even when the activity is hidden + $filteredraters = $info->filter_user_list($raters); + + return $filteredraters; } /**