Merge branch 'MDL-49232_master' of git://github.com/markn86/moodle
This commit is contained in:
+2
-2
@@ -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))) {
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user