Merge branch 'MDL-49232_master' of git://github.com/markn86/moodle

This commit is contained in:
Andrew Nicols
2015-05-01 09:27:11 +08:00
2 changed files with 15 additions and 2 deletions
+2 -2
View File
@@ -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"