Skip to content
Snippets Groups Projects
Commit 952748e8 authored by Alexander Bias's avatar Alexander Bias
Browse files

Bugfix: Unrestricted self enrolment hint did not respect existing but disabled enrolment instances.

parent 092e83e9
No related branches found
No related tags found
No related merge requests found
...@@ -4,6 +4,10 @@ moodle-theme_boost_campus ...@@ -4,6 +4,10 @@ moodle-theme_boost_campus
Changes Changes
------- -------
### Unreleased
* 2021-03-13 - Bugfix: Unrestricted self enrolment hint did not respect existing but disabled enrolment instances.
### v3.10-r3 ### v3.10-r3
* 2021-02-05 - Improvement: Add missing catch branch in Back-to-top button JS * 2021-02-05 - Improvement: Add missing catch branch in Back-to-top button JS
......
...@@ -257,7 +257,11 @@ class core_renderer extends \core_renderer { ...@@ -257,7 +257,11 @@ class core_renderer extends \core_renderer {
// Get the active enrol instances for this course. // Get the active enrol instances for this course.
$enrolinstances = enrol_get_instances($COURSE->id, true); $enrolinstances = enrol_get_instances($COURSE->id, true);
foreach ($enrolinstances as $instance) { foreach ($enrolinstances as $instance) {
if ($instance->enrol == 'self' && empty($instance->password) && empty($instance->enrolenddate)) { // Check if unrestricted self enrolment is possible.
$now = (new \DateTime("now", \core_date::get_server_timezone_object()))->getTimestamp();
if ($instance->enrol == 'self' && empty($instance->password) && $instance->customint6 == 1 &&
(empty($instance->enrolenddate) || $instance->enrolenddate > $now) &&
(empty($instance->enrolstartdate) || $instance->enrolstartdate < $now)) {
if (empty($instance->name)) { if (empty($instance->name)) {
$selfenrolinstances[$instance->id] = get_string('pluginname', 'enrol_self') . $selfenrolinstances[$instance->id] = get_string('pluginname', 'enrol_self') .
" (" . get_string('defaultcoursestudent', 'core') . ")"; " (" . get_string('defaultcoursestudent', 'core') . ")";
......
...@@ -138,7 +138,7 @@ Feature: Configuring the theme_boost_campus plugin for the "Course Layout settin ...@@ -138,7 +138,7 @@ Feature: Configuring the theme_boost_campus plugin for the "Course Layout settin
Then I should not see "This course is currently visible and an unrestricted self enrolment is active: \"Self enrolment (Student)\"" Then I should not see "This course is currently visible and an unrestricted self enrolment is active: \"Self enrolment (Student)\""
And ".course-selfenrol-infobox" "css_element" should not exist And ".course-selfenrol-infobox" "css_element" should not exist
Scenario: Enable "Show hint for unrestricted self enrolment and check that it hides when password or end date is set" Scenario: Enable "Show hint for unrestricted self enrolment" and check that it is hidden when new enrolments are disabled
Given the following config values are set as admin: Given the following config values are set as admin:
| config | value | plugin | | config | value | plugin |
| showhintcourseselfenrol | yes | theme_boost_campus | | showhintcourseselfenrol | yes | theme_boost_campus |
...@@ -153,25 +153,123 @@ Feature: Configuring the theme_boost_campus plugin for the "Course Layout settin ...@@ -153,25 +153,123 @@ Feature: Configuring the theme_boost_campus plugin for the "Course Layout settin
And ".course-selfenrol-infobox" "css_element" should exist And ".course-selfenrol-infobox" "css_element" should exist
When I click on "enrolment settings" "link" in the ".course-selfenrol-infobox" "css_element" When I click on "enrolment settings" "link" in the ".course-selfenrol-infobox" "css_element"
And I set the following fields to these values: And I set the following fields to these values:
| Allow new enrolments | 0 |
And I press "Save changes"
And I am on "Course 1" course homepage
Then I should not see "This course is currently visible and an unrestricted self enrolment is active: \"Self enrolment (Student)\""
And ".course-selfenrol-infobox" "css_element" should not exist
Scenario: Enable "Show hint for unrestricted self enrolment" and check that it is hidden when a password is set
Given the following config values are set as admin:
| config | value | plugin |
| showhintcourseselfenrol | yes | theme_boost_campus |
When I log in as "teacher1"
And I am on "Course 1" course homepage
Then I should not see "This course is currently visible and an unrestricted self enrolment is active:"
And ".course-selfenrol-infobox" "css_element" should not exist
And I navigate to "Users > Enrolment methods" in current page administration
When I click on "Enable" "link" in the "Self enrolment (Student)" "table_row"
And I am on "Course 1" course homepage
Then I should see "This course is currently visible and an unrestricted self enrolment is active: \"Self enrolment (Student)\"."
And ".course-selfenrol-infobox" "css_element" should exist
When I click on "enrolment settings" "link" in the ".course-selfenrol-infobox" "css_element"
And I set the following fields to these values:
| Enrolment key | 1234 |
And I press "Save changes"
And I am on "Course 1" course homepage
Then I should not see "This course is currently visible and an unrestricted self enrolment is active: \"Self enrolment (Student)\""
And ".course-selfenrol-infobox" "css_element" should not exist
Scenario: Enable "Show hint for unrestricted self enrolment and check that it is hidden when appropriate start and / or end dates are set"
Given the following config values are set as admin:
| config | value | plugin |
| showhintcourseselfenrol | yes | theme_boost_campus |
When I log in as "teacher1"
And I am on "Course 1" course homepage
Then I should not see "This course is currently visible and an unrestricted self enrolment is active:"
And ".course-selfenrol-infobox" "css_element" should not exist
And I navigate to "Users > Enrolment methods" in current page administration
When I click on "Enable" "link" in the "Self enrolment (Student)" "table_row"
And I am on "Course 1" course homepage
Then I should see "This course is currently visible and an unrestricted self enrolment is active: \"Self enrolment (Student)\"."
And ".course-selfenrol-infobox" "css_element" should exist
When I click on "enrolment settings" "link" in the ".course-selfenrol-infobox" "css_element"
And I set the following fields to these values:
| id_enrolstartdate_enabled | 0 |
| id_enrolenddate_enabled | 1 | | id_enrolenddate_enabled | 1 |
| id_enrolenddate | ##yesterday## |
And I press "Save changes" And I press "Save changes"
And I am on "Course 1" course homepage And I am on "Course 1" course homepage
Then I should not see "This course is currently visible and an unrestricted self enrolment is active: \"Self enrolment (Student)\"" Then I should not see "This course is currently visible and an unrestricted self enrolment is active: \"Self enrolment (Student)\""
And ".course-selfenrol-infobox" "css_element" should not exist And ".course-selfenrol-infobox" "css_element" should not exist
When I navigate to "Users > Enrolment methods" in current page administration
And I click on "Edit" "link" in the "Self enrolment (Student)" "table_row"
And I set the following fields to these values:
| id_enrolstartdate_enabled | 0 |
| id_enrolenddate_enabled | 1 |
| id_enrolenddate | ##tomorrow## |
And I press "Save changes"
And I am on "Course 1" course homepage
Then I should see "This course is currently visible and an unrestricted self enrolment is active: \"Self enrolment (Student)\"."
And ".course-selfenrol-infobox" "css_element" should exist
When I navigate to "Users > Enrolment methods" in current page administration When I navigate to "Users > Enrolment methods" in current page administration
And I click on "Edit" "link" in the "Self enrolment (Student)" "table_row" And I click on "Edit" "link" in the "Self enrolment (Student)" "table_row"
And I set the following fields to these values: And I set the following fields to these values:
| id_enrolstartdate_enabled | 1 |
| id_enrolstartdate | ##yesterday## |
| id_enrolenddate_enabled | 0 | | id_enrolenddate_enabled | 0 |
And I press "Save changes" And I press "Save changes"
And I am on "Course 1" course homepage And I am on "Course 1" course homepage
Then I should see "This course is currently visible and an unrestricted self enrolment is active: \"Self enrolment (Student)\"." Then I should see "This course is currently visible and an unrestricted self enrolment is active: \"Self enrolment (Student)\"."
And ".course-selfenrol-infobox" "css_element" should exist And ".course-selfenrol-infobox" "css_element" should exist
When I click on "enrolment settings" "link" in the ".course-selfenrol-infobox" "css_element"
When I navigate to "Users > Enrolment methods" in current page administration
And I click on "Edit" "link" in the "Self enrolment (Student)" "table_row"
And I set the following fields to these values: And I set the following fields to these values:
| Enrolment key | 1234 | | id_enrolstartdate_enabled | 1 |
| id_enrolstartdate | ##tomorrow## |
| id_enrolenddate_enabled | 0 |
And I press "Save changes" And I press "Save changes"
And I am on "Course 1" course homepage And I am on "Course 1" course homepage
Then I should not see "This course is currently visible and an unrestricted self enrolment is active: \"Self enrolment (Student)\"" Then I should not see "This course is currently visible and an unrestricted self enrolment is active: \"Self enrolment (Student)\"."
And ".course-selfenrol-infobox" "css_element" should not exist
When I navigate to "Users > Enrolment methods" in current page administration
And I click on "Edit" "link" in the "Self enrolment (Student)" "table_row"
And I set the following fields to these values:
| id_enrolstartdate_enabled | 1 |
| id_enrolstartdate | ##Monday next week## |
| id_enrolenddate_enabled | 1 |
| id_enrolenddate | ##Tuesday next week## |
And I press "Save changes"
And I am on "Course 1" course homepage
Then I should not see "This course is currently visible and an unrestricted self enrolment is active: \"Self enrolment (Student)\"."
And ".course-selfenrol-infobox" "css_element" should not exist
When I navigate to "Users > Enrolment methods" in current page administration
And I click on "Edit" "link" in the "Self enrolment (Student)" "table_row"
And I set the following fields to these values:
| id_enrolstartdate_enabled | 1 |
| id_enrolstartdate | ##yesterday## |
| id_enrolenddate_enabled | 1 |
| id_enrolenddate | ##tomorrow## |
And I press "Save changes"
And I am on "Course 1" course homepage
Then I should see "This course is currently visible and an unrestricted self enrolment is active: \"Self enrolment (Student)\"."
And ".course-selfenrol-infobox" "css_element" should exist
When I navigate to "Users > Enrolment methods" in current page administration
And I click on "Edit" "link" in the "Self enrolment (Student)" "table_row"
And I set the following fields to these values:
| id_enrolstartdate_enabled | 1 |
| id_enrolstartdate | ##3 days ago## |
| id_enrolenddate_enabled | 1 |
| id_enrolenddate | ##2 days ago## |
And I press "Save changes"
And I am on "Course 1" course homepage
Then I should not see "This course is currently visible and an unrestricted self enrolment is active: \"Self enrolment (Student)\"."
And ".course-selfenrol-infobox" "css_element" should not exist And ".course-selfenrol-infobox" "css_element" should not exist
Scenario: Enable "Show hint for unrestricted self enrolment and add more than one self enrolment instance" Scenario: Enable "Show hint for unrestricted self enrolment and add more than one self enrolment instance"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment