Skip to content

Commit 8610a4a

Browse files
author
Laur0r
authored
Merge pull request #256 from learnweb/fix/get_raters_with_access
Fix/get raters with access
2 parents 9b2fc18 + 6852199 commit 8610a4a

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

locallib.php

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
*/
2828
defined('MOODLE_INTERNAL') || die();
2929

30+
use core_availability\info_module;
3031
use ratingallocate\db as this_db;
3132

3233
global $CFG;
@@ -178,11 +179,20 @@ class ratingallocate {
178179

179180
/**
180181
* Returns all users enrolled in the course the ratingallocate is in
182+
* @throws moodle_exception
181183
*/
182-
public function get_raters_in_course() {
183-
// Pulling this sorted from the database improves performance of distribution of unallocated users by a lot.
184-
$raters = get_enrolled_users($this->context, 'mod/ratingallocate:give_rating', 0, 'u.*', 'id');
185-
return $raters;
184+
public function get_raters_in_course(): array {
185+
186+
$modinfo = get_fast_modinfo($this->course);
187+
$cm = $modinfo->get_cm($this->coursemodule->id);
188+
189+
$raters = get_enrolled_users($this->context, 'mod/ratingallocate:give_rating');
190+
$info = new info_module($cm);
191+
// Only show raters who had the ability to access this activity. This funktion ignores the visibility setting,
192+
// so the ratings and allocations are still shown, even when the activity is hidden
193+
$filteredraters = $info->filter_user_list($raters);
194+
195+
return $filteredraters;
186196
}
187197

188198
/**

0 commit comments

Comments
 (0)