From e8f4b6ff60fdd44929416ae93bf13fb7949dfec0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luca=20B=C3=B6sch?= Date: Wed, 15 Sep 2021 20:37:03 +0200 Subject: [PATCH] MDL-72590 enrol: Course in success message after unenroll passes filter --- enrol/self/tests/behat/self_enrolment.feature | 20 +++++++++++++++++++ enrol/self/unenrolself.php | 3 ++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/enrol/self/tests/behat/self_enrolment.feature b/enrol/self/tests/behat/self_enrolment.feature index c21729f6fc0..b4975fa6bc3 100644 --- a/enrol/self/tests/behat/self_enrolment.feature +++ b/enrol/self/tests/behat/self_enrolment.feature @@ -127,3 +127,23 @@ Feature: Users can auto-enrol themself in courses where self enrolment is allowe When I click on "//a[@data-action='unenrol']" "xpath_element" in the "student1" "table_row" And I click on "Unenrol" "button" in the "Unenrol" "dialogue" Then I should not see "Student 1" in the "participants" "table" + + @javascript + Scenario: Self unenrol as a self-enrolled student from the course + Given the "multilang" filter is "on" + And the "multilang" filter applies to "content and headings" + And I am on the "C1" "Course" page logged in as "teacher1" + When I add "Self enrolment" enrolment method with: + | Custom instance name | Test student enrolment | + And I am on "Course 1" course homepage + And I navigate to "Edit settings" in current page administration + And I set the field "Course full name" in the "General" "fieldset" to "CourseCorso 1" + And I press "Save and display" + And I log out + And I am on the "C1" Course page logged in as student1 + And I press "Enrol me" + And I should see "You are enrolled in the course" + And I am on the "C1" Course page + And I navigate to "Unenrol me from C1" in current page administration + And I click on "Continue" "button" in the "Confirm" "dialogue" + Then I should see "You are unenrolled from the course \"Course 1\"" diff --git a/enrol/self/unenrolself.php b/enrol/self/unenrolself.php index 007caabc008..8d9ace66c6b 100644 --- a/enrol/self/unenrolself.php +++ b/enrol/self/unenrolself.php @@ -50,7 +50,8 @@ $PAGE->set_title($plugin->get_instance_name($instance)); if ($confirm and confirm_sesskey()) { $plugin->unenrol_user($instance, $USER->id); - \core\notification::success(get_string('youunenrolledfromcourse', 'enrol', $course->fullname)); + \core\notification::success(get_string('youunenrolledfromcourse', 'enrol', format_string($course->fullname, true, + ["context" => $context]))); redirect(new moodle_url('/index.php')); }