From 5d69038bb69133db57674999a19260f6c8711521 Mon Sep 17 00:00:00 2001 From: cescobedo <carlos.escobedo@gmail.com> Date: Thu, 7 Nov 2019 10:17:28 +0100 Subject: [PATCH] MDL-66683 core: Revert MDL-66181 because created regressions This reverts commit ed080a580ffd0eea70ad3eaa9214234cf2463034. This issue reverts the behaviour modified in MDL-66181, as that change negatively impacted course-creation workflows. As this appears to be the intended functionality, the Security team has agreed to revert this change. --- course/edit.php | 8 +++----- course/tests/behat/course_creation.feature | 17 ----------------- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/course/edit.php b/course/edit.php index 2072fe044ba..87c277a161a 100644 --- a/course/edit.php +++ b/course/edit.php @@ -166,11 +166,9 @@ if ($editform->is_cancelled()) { if (!empty($CFG->creatornewroleid) and !is_viewing($context, NULL, 'moodle/role:assign') and !is_enrolled($context, NULL, 'moodle/role:assign')) { // Deal with course creators - enrol them internally with default role. - if (user_can_assign($context, $CFG->creatornewroleid)) { - enrol_try_internal_enrol($course->id, $USER->id, $CFG->creatornewroleid); - } else { - enrol_try_internal_enrol($course->id, $USER->id); - } + // Note: This does not respect capabilities, the creator will be assigned the default role. + // This is an expected behaviour. See MDL-66683 for further details. + enrol_try_internal_enrol($course->id, $USER->id, $CFG->creatornewroleid); } // The URL to take them to if they chose save and display. diff --git a/course/tests/behat/course_creation.feature b/course/tests/behat/course_creation.feature index 8571b97ece6..859afcc8e07 100644 --- a/course/tests/behat/course_creation.feature +++ b/course/tests/behat/course_creation.feature @@ -85,7 +85,6 @@ Feature: Managers can create courses | moodle/course:create | Allow | | moodle/course:manageactivities | Allow | | moodle/course:viewparticipants | Allow | - | moodle/role:assign | Allow | And I log out And I log in as "kevin" And I am on site homepage @@ -96,20 +95,4 @@ Feature: Managers can create courses And I press "Save and display" And I follow "Participants" Then I should see "Kevin the" - And I should not see "Teacher" - And I log out - Given I log in as "admin" - And I define the allowed role assignments for the "Creator" role as: - | Teacher | Assignable | - And I log out - And I log in as "kevin" - And I am on site homepage - And I turn editing mode on - When I press "Add a new course" - And I set the following fields to these values: - | Course full name | My second course | - | Course short name | mysecondcourse | - And I press "Save and display" - And I follow "Participants" - Then I should see "Kevin the" And I should see "Teacher"