MDL-65782 roles: allow several roles with user/frontpage archetype

This commit is contained in:
Marina Glancy 2019-05-29 11:53:13 +02:00
parent 29c395187f
commit 5ecbc5d9f7
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);