mirror of
https://github.com/moodle/moodle.git
synced 2025-02-21 01:48:45 +01:00
Merge branch 'MDL-75300' of https://github.com/paulholden/moodle
This commit is contained in:
commit
5fd5650838
@ -357,6 +357,9 @@ class manager {
|
||||
|
||||
// But excluding all reviewattempts users converting a capabilities join into left join.
|
||||
$reviewersjoin = get_with_capability_join($context, 'mod/h5pactivity:reviewattempts', 'u.id');
|
||||
if ($reviewersjoin->cannotmatchanyrows) {
|
||||
return $capjoin;
|
||||
}
|
||||
|
||||
$capjoin = new sql_join(
|
||||
$capjoin->joins . "\n LEFT " . str_replace('ra', 'reviewer', $reviewersjoin->joins),
|
||||
|
@ -737,6 +737,41 @@ class manager_test extends \advanced_testcase {
|
||||
$this->assertEqualsCanonicalizing([$teacher->username, $userone->username], $users);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test getting active users join where there are no roles with 'mod/h5pactivity:reviewattempts' capability
|
||||
*/
|
||||
public function test_get_active_users_join_no_reviewers(): void {
|
||||
global $DB;
|
||||
|
||||
$this->resetAfterTest();
|
||||
$this->setAdminUser();
|
||||
|
||||
$course = $this->getDataGenerator()->create_course();
|
||||
$activity = $this->getDataGenerator()->create_module('h5pactivity', ['course' => $course]);
|
||||
$user = $this->getDataGenerator()->create_and_enrol($course, 'student');
|
||||
|
||||
$manager = manager::create_from_instance($activity);
|
||||
|
||||
// By default manager and editingteacher can review attempts, prohibit both.
|
||||
$rolemanager = $DB->get_field('role', 'id', ['shortname' => 'manager']);
|
||||
role_change_permission($rolemanager, $manager->get_context(), 'mod/h5pactivity:reviewattempts', CAP_PROHIBIT);
|
||||
|
||||
$roleeditingteacher = $DB->get_field('role', 'id', ['shortname' => 'editingteacher']);
|
||||
role_change_permission($roleeditingteacher, $manager->get_context(), 'mod/h5pactivity:reviewattempts', CAP_PROHIBIT);
|
||||
|
||||
// Generate users join SQL to find matching users.
|
||||
$usersjoin = $manager->get_active_users_join(true);
|
||||
$usernames = $DB->get_fieldset_sql(
|
||||
"SELECT u.username
|
||||
FROM {user} u
|
||||
{$usersjoin->joins}
|
||||
WHERE {$usersjoin->wheres}",
|
||||
$usersjoin->params
|
||||
);
|
||||
|
||||
$this->assertEquals([$user->username], $usernames);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test static count_attempts.
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user