Merge branch 'MDL-65782-master' of git://github.com/marinaglancy/moodle

This commit is contained in:
Adrian Greeve 2019-06-10 11:11:44 +08:00
commit 27e2aba473
5 changed files with 8 additions and 13 deletions

View File

@ -58,7 +58,7 @@ if (!during_initial_install()) { //do not use during installation
foreach ($roles as $role) {
if (empty($role->archetype) or $role->archetype === 'guest' or $role->archetype === 'frontpage' or $role->archetype === 'student') {
$options[$role->id] = $role->localname;
if ($role->archetype === 'frontpage') {
if ($role->archetype === 'frontpage' && !$defaultfrontpageroleid) {
$defaultfrontpageroleid = $role->id;
}
}

View File

@ -76,7 +76,7 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
* Setup function- we will create a course and add an assign instance to it.
*/
protected function setUp() {
global $DB;
global $DB, $CFG;
$this->resetAfterTest(true);
@ -91,9 +91,7 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
$catcontext = context_coursecat::instance($category->id);
// Fetching default authenticated user role.
$userroles = get_archetype_roles('user');
$this->assertCount(1, $userroles);
$authrole = array_pop($userroles);
$authrole = $DB->get_record('role', array('id' => $CFG->defaultuserroleid));
// Reset all default authenticated users permissions.
unassign_capability('moodle/competency:competencygrade', $authrole->id);

View File

@ -522,6 +522,7 @@ class core_cohort_externallib_testcase extends externallib_advanced_testcase {
* Search cohorts.
*/
public function test_search_cohorts() {
global $DB, $CFG;
$this->resetAfterTest(true);
$creator = $this->getDataGenerator()->create_user();
@ -537,9 +538,7 @@ class core_cohort_externallib_testcase extends externallib_advanced_testcase {
$coursecontext = context_course::instance($course->id);
// Fetching default authenticated user role.
$userroles = get_archetype_roles('user');
$this->assertCount(1, $userroles);
$authrole = array_pop($userroles);
$authrole = $DB->get_record('role', array('id' => $CFG->defaultuserroleid));
// Reset all default authenticated users permissions.
unassign_capability('moodle/cohort:manage', $authrole->id);

View File

@ -97,7 +97,7 @@ class core_competency_external_testcase extends externallib_advanced_testcase {
* Setup function- we will create a course and add an assign instance to it.
*/
protected function setUp() {
global $DB;
global $DB, $CFG;
$this->resetAfterTest(true);
@ -114,9 +114,7 @@ class core_competency_external_testcase extends externallib_advanced_testcase {
$othercatcontext = context_coursecat::instance($othercategory->id);
// Fetching default authenticated user role.
$userroles = get_archetype_roles('user');
$this->assertCount(1, $userroles);
$authrole = array_pop($userroles);
$authrole = $DB->get_record('role', array('id' => $CFG->defaultuserroleid));
// Reset all default authenticated users permissions.
unassign_capability('moodle/competency:competencygrade', $authrole->id);

View File

@ -2576,7 +2576,7 @@ class core_competency_privacy_testcase extends provider_testcase {
*/
protected function allow_anyone_to_comment_anywhere() {
global $DB;
$roleid = $DB->get_field('role', 'id', ['archetype' => 'user'], MUST_EXIST);
$roleid = $DB->get_field('role', 'id', ['shortname' => 'user'], MUST_EXIST);
assign_capability('moodle/competency:plancomment', CAP_ALLOW, $roleid, SYSCONTEXTID, true);
assign_capability('moodle/competency:planmanage', CAP_ALLOW, $roleid, SYSCONTEXTID, true);
assign_capability('moodle/competency:planmanagedraft', CAP_ALLOW, $roleid, SYSCONTEXTID, true);