Skip to content

Commit

Permalink
Merge pull request #256 from learnweb/fix/get_raters_with_access
Browse files Browse the repository at this point in the history
Fix/get raters with access
  • Loading branch information
Laur0r authored May 16, 2023
2 parents 9b2fc18 + 6852199 commit 8610a4a
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
*/
defined('MOODLE_INTERNAL') || die();

use core_availability\info_module;
use ratingallocate\db as this_db;

global $CFG;
Expand Down Expand Up @@ -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;
}

/**
Expand Down

0 comments on commit 8610a4a

Please sign in to comment.