From 9c54a0abadaa81751deecf470890bd3c93ede9fe Mon Sep 17 00:00:00 2001 From: Mark Nelson Date: Sun, 19 Apr 2015 22:42:25 -0700 Subject: [PATCH 1/2] MDL-49232 enrol_self: display continue button --- enrol/self/lib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/enrol/self/lib.php b/enrol/self/lib.php index c51e3408f96..5c668ef8682 100644 --- a/enrol/self/lib.php +++ b/enrol/self/lib.php @@ -262,12 +262,12 @@ class enrol_self_plugin extends enrol_plugin { * @return bool|string true if successful, else error message or false. */ public function can_self_enrol(stdClass $instance, $checkuserenrolment = true) { - global $DB, $USER, $CFG; + global $CFG, $DB, $OUTPUT, $USER; if ($checkuserenrolment) { if (isguestuser()) { // Can not enrol guest. - return get_string('noguestaccess', 'enrol'); + return get_string('noguestaccess', 'enrol') . $OUTPUT->continue_button(get_login_url()); } // Check if user is already enroled. if ($DB->get_record('user_enrolments', array('userid' => $USER->id, 'enrolid' => $instance->id))) { From e89c5c203cc05dbe0ce39bf57b4c11a7aefc6e0a Mon Sep 17 00:00:00 2001 From: Andrew Nicols Date: Thu, 30 Apr 2015 08:57:02 +0800 Subject: [PATCH 2/2] MDL-49232 enrol_self: Add behat test for non-guest self-enrolment --- enrol/self/tests/behat/self_enrolment.feature | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/enrol/self/tests/behat/self_enrolment.feature b/enrol/self/tests/behat/self_enrolment.feature index 341eebe142e..16d1da7bf8f 100644 --- a/enrol/self/tests/behat/self_enrolment.feature +++ b/enrol/self/tests/behat/self_enrolment.feature @@ -16,6 +16,19 @@ Feature: Users can auto-enrol themself in courses where self enrolment is allowe | user | course | role | | teacher1 | C1 | editingteacher | + @javascript + Scenario: Self-enrolment enabled as guest + Given I log in as "teacher1" + And I follow "Course 1" + And I add "Self enrolment" enrolment method with: + | Custom instance name | Test student enrolment | + And I log out + When I follow "Course 1" + And I press "Log in as a guest" + Then I should see "Guests can not access this course, please try to log in." + And I press "Continue" + And I should see "Log in" + @javascript Scenario: Self-enrolment enabled Given I log in as "teacher1"