Merge branch 'MDL-52105-31' of git://github.com/lameze/moodle into MOODLE_31_STABLE
This commit is contained in:
@@ -52,9 +52,6 @@ $capabilities = array(
|
||||
|
||||
'captype' => 'write',
|
||||
'contextlevel' => CONTEXT_COURSE,
|
||||
'archetypes' => array(
|
||||
'manager' => CAP_PROHIBIT,
|
||||
)
|
||||
),
|
||||
|
||||
/* Voluntarily unenrol self from course - watch out for data loss. */
|
||||
|
||||
@@ -39,5 +39,21 @@ function xmldb_enrol_self_upgrade($oldversion) {
|
||||
// Moodle v3.1.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
if ($oldversion < 2016052301) {
|
||||
global $DB;
|
||||
// Get roles with manager archetype.
|
||||
$managerroles = get_archetype_roles('manager');
|
||||
if (!empty($managerroles)) {
|
||||
// Remove wrong CAP_PROHIBIT from self:holdkey.
|
||||
foreach ($managerroles as $role) {
|
||||
$DB->execute("DELETE
|
||||
FROM {role_capabilities}
|
||||
WHERE roleid = ? AND capability = ? AND permission = ?",
|
||||
array($role->id, 'enrol/self:holdkey', CAP_PROHIBIT));
|
||||
}
|
||||
}
|
||||
upgrade_mod_savepoint(true, 2016052301, 'enrol_self');
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
@enrol @enrol_self
|
||||
Feature: Users can be defined as key holders in courses where self enrolment is allowed
|
||||
In order to participate in courses
|
||||
As a user
|
||||
I need to auto enrol me in courses
|
||||
|
||||
Background:
|
||||
Given the following "users" exist:
|
||||
| username | firstname | lastname | email |
|
||||
| manager1 | Manager | 1 | manager1@example.com |
|
||||
| student1 | Student | 1 | student1@example.com |
|
||||
And the following "courses" exist:
|
||||
| fullname | shortname | format |
|
||||
| Course 1 | C1 | topics |
|
||||
And I log in as "admin"
|
||||
And I navigate to "Define roles" node in "Site administration > Users > Permissions"
|
||||
And I click on "Add a new role" "button"
|
||||
And I click on "Continue" "button"
|
||||
And I set the following fields to these values:
|
||||
| Short name | keyholder |
|
||||
| Custom full name | Key holder |
|
||||
| contextlevel50 | 1 |
|
||||
| enrol/self:holdkey | 1 |
|
||||
And I click on "Create this role" "button"
|
||||
And I navigate to "Courses" node in "Site administration > Appearance"
|
||||
And I set the following fields to these values:
|
||||
| Key holder | 1 |
|
||||
And I press "Save changes"
|
||||
And the following "course enrolments" exist:
|
||||
| user | course | role |
|
||||
| manager1 | C1 | keyholder |
|
||||
And I log out
|
||||
|
||||
@javascript
|
||||
Scenario: The key holder name is displayed on site home page
|
||||
Given I log in as "admin"
|
||||
And I am on site homepage
|
||||
And I follow "Course 1"
|
||||
When I add "Self enrolment" enrolment method with:
|
||||
| Custom instance name | Test student enrolment |
|
||||
| Enrolment key | moodle_rules |
|
||||
And I log out
|
||||
And I log in as "student1"
|
||||
And I am on site homepage
|
||||
And I follow "Course 1"
|
||||
And I should see "You should have received this enrolment key from:"
|
||||
And I should see "Manager 1"
|
||||
And I set the following fields to these values:
|
||||
| Enrolment key | moodle_rules |
|
||||
And I press "Enrol me"
|
||||
Then I should see "Topic 1"
|
||||
And I should not see "Enrolment options"
|
||||
And I should not see "Enrol me in this course"
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$plugin->version = 2016052300; // The current plugin version (Date: YYYYMMDDXX)
|
||||
$plugin->version = 2016052301; // The current plugin version (Date: YYYYMMDDXX)
|
||||
$plugin->requires = 2016051900; // Requires this Moodle version
|
||||
$plugin->component = 'enrol_self'; // Full name of the plugin (used for diagnostics)
|
||||
$plugin->cron = 600;
|
||||
|
||||
Reference in New Issue
Block a user