diff --git a/CHANGES.md b/CHANGES.md index b5a90beee8e404923dba502fe96b1d1e749ae743..05cac95a29d11d9d41431429c2c87fae5279ca20 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -6,6 +6,7 @@ Changes ### Unreleased +* 2021-04-12 - Improvement: Modify the hint for unrestricted self enrolment in a way that it is more understandable if enrolment end dates are set or not. * 2021-04-11 - Fix Behat test for random login background image * 2021-03-14 - Fix Behat test for unrestricted self enrolment hint diff --git a/README.md b/README.md index d204c07df7815e6f3e48ddec588504dfde9f0780..d4d86bcf07130ecdddb3d0949c5d14d8736a4a17 100644 --- a/README.md +++ b/README.md @@ -150,9 +150,9 @@ With this setting a hint will appear in the course header as long as the visibil With this setting a hint will appear in the course header when a user is accessing it with the guest access feature. If the course provides an active self enrolment, a link to that page is also presented to the user. -##### Show hint for unrestricted self enrolment +##### Show hint for self enrolment without enrolment key -With this setting a hint will appear in the course header when the course is visible and a unrestricted (no enrolment key or end date is set) self enrolment is active. +With this setting a hint will appear in the course header if the course is visible and an enrolment without enrolment key is currently possible. #### Course settings diff --git a/classes/output/core_renderer.php b/classes/output/core_renderer.php index 179b159c7cd9ad9605515a15141be8e91af7d09b..25adac4793c4567ab886d1efa0883db882133f58 100644 --- a/classes/output/core_renderer.php +++ b/classes/output/core_renderer.php @@ -246,7 +246,7 @@ class core_renderer extends \core_renderer { // MODIFICATION END. // MODIFICATION START: - // If the setting showhintcourseselfenrol is set, a hint for users is shown that the course has an unrestricted self + // If the setting showhintcourseselfenrol is set, a hint for users is shown that the course allows unrestricted self // enrolment. This hint is only shown if the course is visible, the self enrolment is visible and if the user has the // capability "theme/boost_campus:viewhintcourseselfenrol". if (get_config('theme_boost_campus', 'showhintcourseselfenrol') == 'yes' @@ -256,38 +256,140 @@ class core_renderer extends \core_renderer { && $COURSE->visible == true) { // Get the active enrol instances for this course. $enrolinstances = enrol_get_instances($COURSE->id, true); + // Prepare to remember when self enrolment is / will be possible. + $selfenrolmentpossiblecurrently = false; + $selfenrolmentpossiblefuture = false; foreach ($enrolinstances as $instance) { - // Check if unrestricted self enrolment is possible. + // Check if unrestricted self enrolment is possible currently or in the future. $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)) { + (empty($instance->enrolenddate) || $instance->enrolenddate > $now)) { + + // Build enrol instance object with all necessary information for rendering the note later. + $instanceobject = new stdClass(); + + // Remember instance name. if (empty($instance->name)) { - $selfenrolinstances[$instance->id] = get_string('pluginname', 'enrol_self') . + $instanceobject->name = get_string('pluginname', 'enrol_self') . " (" . get_string('defaultcoursestudent', 'core') . ")"; } else { - $selfenrolinstances[$instance->id] = $instance->name; + $instanceobject->name = $instance->name; + } + + // Remember type of unrestrictedness. + if (empty($instance->enrolenddate) && empty($instance->enrolstartdate)) { + $instanceobject->unrestrictedness = 'unlimited'; + $selfenrolmentpossiblecurrently = true; + } else if (empty($instance->enrolstartdate) && + !empty($instance->enrolenddate) && $instance->enrolenddate > $now) { + $instanceobject->unrestrictedness = 'until'; + $selfenrolmentpossiblecurrently = true; + } else if (empty($instance->enrolenddate) && + !empty($instance->enrolstartdate) && $instance->enrolstartdate > $now) { + $instanceobject->unrestrictedness = 'from'; + $selfenrolmentpossiblefuture = true; + } else if (empty($instance->enrolenddate) && + !empty($instance->enrolstartdate) && $instance->enrolstartdate <= $now) { + $instanceobject->unrestrictedness = 'since'; + $selfenrolmentpossiblecurrently = true; + } else if (!empty($instance->enrolstartdate) && $instance->enrolstartdate > $now && + !empty($instance->enrolenddate) && $instance->enrolenddate > $now) { + $instanceobject->unrestrictedness = 'fromuntil'; + $selfenrolmentpossiblefuture = true; + } else if (!empty($instance->enrolstartdate) && $instance->enrolstartdate <= $now && + !empty($instance->enrolenddate) && $instance->enrolenddate > $now) { + $instanceobject->unrestrictedness = 'sinceuntil'; + $selfenrolmentpossiblecurrently = true; + } else { + // This should not happen, thus continue to next instance. + continue; + } + + // Remember enrol start date. + if (!empty($instance->enrolstartdate)) { + $instanceobject->startdate = $instance->enrolstartdate; + } else { + $instanceobject->startdate = null; + } + + // Remember enrol end date. + if (!empty($instance->enrolenddate)) { + $instanceobject->enddate = $instance->enrolenddate; + } else { + $instanceobject->enddate = null; } + + // Remember this instance. + $selfenrolinstances[$instance->id] = $instanceobject; } } - if (!empty($selfenrolinstances)) { - // Give out a hint for each unrestricted active self enrolment in the course. - foreach ($selfenrolinstances as $selfenrolinstanceid => $selfenrolinstancename) { - $html .= html_writer::start_tag('div', array('class' => 'course-selfenrol-infobox alert alert-info')); - $html .= html_writer::tag('i', null, array('class' => 'fa fa-sign-in fa-3x fa-pull-left')); - $html .= get_string('showhintcourseselfenrol', 'theme_boost_campus', - array('name' => $selfenrolinstancename)); - // Only show the link to edit the specific self enrolment if the user has the capability - // to config self enrolments. + // If there is at least one unrestricted enrolment instance, + // show the hint with information about each unrestricted active self enrolment in the course. + if (!empty($selfenrolinstances) && + ($selfenrolmentpossiblecurrently == true || $selfenrolmentpossiblefuture == true)) { + // Start hint box. + $html .= html_writer::start_tag('div', array('class' => 'course-selfenrol-infobox alert alert-info')); + $html .= html_writer::tag('i', null, array('class' => 'fa fa-sign-in fa-3x fa-pull-left')); + + // Show the start of the hint depending on the fact if enrolment is already possible currently or + // will be in the future. + if ($selfenrolmentpossiblecurrently == true) { + $html .= get_string('showhintcourseselfenrolstartcurrently', 'theme_boost_campus'); + } else if ($selfenrolmentpossiblefuture == true) { + $html .= get_string('showhintcourseselfenrolstartfuture', 'theme_boost_campus'); + } + $html .= html_writer::empty_tag('br'); + + // Iterate over all enrolment instances to output the details. + foreach ($selfenrolinstances as $selfenrolinstanceid => $selfenrolinstanceobject) { + // If the user has the capability to config self enrolments, enrich the instance name with the settings link. if (has_capability('enrol/self:config', \context_course::instance($COURSE->id))) { $url = new moodle_url('/enrol/editinstance.php', array('courseid' => $COURSE->id, - 'id' => $selfenrolinstanceid, 'type' => 'self')); - $html .= html_writer::tag('div', get_string('showhintcourseselfenrollink', - 'theme_boost_campus', array('url' => $url->out()))); + 'id' => $selfenrolinstanceid, 'type' => 'self')); + $selfenrolinstanceobject->name = html_writer::link($url, $selfenrolinstanceobject->name); + } + + // Show the enrolment instance information depending on the instance configuration. + if ($selfenrolinstanceobject->unrestrictedness == 'unlimited') { + $html .= get_string('showhintcourseselfenrolunlimited', 'theme_boost_campus', + array('name' => $selfenrolinstanceobject->name)); + } else if ($selfenrolinstanceobject->unrestrictedness == 'until') { + $html .= get_string('showhintcourseselfenroluntil', 'theme_boost_campus', + array('name' => $selfenrolinstanceobject->name, + 'until' => userdate($selfenrolinstanceobject->enddate))); + } else if ($selfenrolinstanceobject->unrestrictedness == 'from') { + $html .= get_string('showhintcourseselfenrolfrom', 'theme_boost_campus', + array('name' => $selfenrolinstanceobject->name, + 'from' => userdate($selfenrolinstanceobject->startdate))); + } else if ($selfenrolinstanceobject->unrestrictedness == 'since') { + $html .= get_string('showhintcourseselfenrolsince', 'theme_boost_campus', + array('name' => $selfenrolinstanceobject->name, + 'since' => userdate($selfenrolinstanceobject->startdate))); + } else if ($selfenrolinstanceobject->unrestrictedness == 'fromuntil') { + $html .= get_string('showhintcourseselfenrolfromuntil', 'theme_boost_campus', + array('name' => $selfenrolinstanceobject->name, + 'until' => userdate($selfenrolinstanceobject->enddate), + 'from' => userdate($selfenrolinstanceobject->startdate))); + } else if ($selfenrolinstanceobject->unrestrictedness == 'sinceuntil') { + $html .= get_string('showhintcourseselfenrolsinceuntil', 'theme_boost_campus', + array('name' => $selfenrolinstanceobject->name, + 'until' => userdate($selfenrolinstanceobject->enddate), + 'since' => userdate($selfenrolinstanceobject->startdate))); } - $html .= html_writer::end_tag('div'); + + // Add a trailing space to separate this instance from the next one. + $html .= ' '; + } + + // If the user has the capability to config self enrolments, add the call for action. + if (has_capability('enrol/self:config', \context_course::instance($COURSE->id))) { + $html .= html_writer::empty_tag('br'); + $html .= get_string('showhintcourseselfenrolinstancecallforaction', 'theme_boost_campus'); } + + // End hint box. + $html .= html_writer::end_tag('div'); } } // MODIFICATION END. diff --git a/lang/en/theme_boost_campus.php b/lang/en/theme_boost_campus.php index 60150835f9575b5284045c746403f257050d8f55..b6849dbbf5e3551c08e58a5d80865b2111de1085 100644 --- a/lang/en/theme_boost_campus.php +++ b/lang/en/theme_boost_campus.php @@ -102,8 +102,8 @@ $string['showhintcoursehiddensetting_desc'] = 'With this setting a hint will app $string['showhintcoursguestaccesssetting'] = 'Show hint for guest access'; $string['showhintcourseguestaccesssetting_desc'] = 'With this setting a hint will appear in the course header when a user is accessing it with the guest access feature. If the course provides an active self enrolment, a link to that page is also presented to the user.'; // ... Show hint for unrestricted self enrolment. -$string['showhintcourseselfenrolsetting'] = 'Show hint for unrestricted self enrolment'; -$string['showhintcourseselfenrolsetting_desc'] = 'With this setting a hint will appear in the course header when the course is visible and a unrestricted (no enrolment key or end date is set) self enrolment is active.'; +$string['showhintcourseselfenrolsetting'] = 'Show hint for self enrolment without enrolment key'; +$string['showhintcourseselfenrolsetting_desc'] = 'With this setting a hint will appear in the course header if the course is visible and an enrolment without enrolment key is currently possible.'; // ...Course settings. $string['coursesettingsheadingsetting'] = 'Course settings'; // ...Show course settings within the course. @@ -313,9 +313,15 @@ $string['showhintcourseguestaccessgeneral'] = 'You are currently viewing this co $string['showhintcourseguestaccesslink'] = 'To have full access to the course, you can <a href="{$a->url}">self enrol into this course</a>.'; $string['showhintcoursehiddengeneral'] = 'This course is currently <strong>hidden</strong>. Only enrolled teachers can access this course when hidden.'; $string['showhintcoursehiddensettingslink'] = 'You can change the visibility in the <a href="{$a->url}">course settings</a>.'; -$string['showhintcourseselfenrol'] = 'This course is currently visible and an <strong>unrestricted self enrolment</strong> is active: <strong>"{$a->name}"</strong>. <br/> -This means, that neither an enrolment key nor a self enrolment end date is set.'; -$string['showhintcourseselfenrollink'] = 'If you don\'t want that any Moodle user can enrol into this course freely, please restrict the settings for this self enrolment instance in the <a href="{$a->url}">enrolment settings</a>.'; +$string['showhintcourseselfenrolstartcurrently'] = 'This course is currently visible and <strong>self enrolment without enrolment key</strong> is currently possible.'; +$string['showhintcourseselfenrolstartfuture'] = 'This course is currently visible and <strong>self enrolment without enrolment key</strong> is planned to become possible.'; +$string['showhintcourseselfenrolunlimited'] = 'The <strong>{$a->name}</strong> enrolment instance allows unrestricted self enrolment infinitely.'; +$string['showhintcourseselfenroluntil'] = 'The <strong>{$a->name}</strong> enrolment instance allows unrestricted self enrolment until {$a->until}.'; +$string['showhintcourseselfenrolfrom'] = 'The <strong>{$a->name}</strong> enrolment instance allows unrestricted self enrolment from {$a->from} on.'; +$string['showhintcourseselfenrolsince'] = 'The <strong>{$a->name}</strong> enrolment instance allows unrestricted self enrolment currently.'; +$string['showhintcourseselfenrolfromuntil'] = 'The <strong>{$a->name}</strong> enrolment instance allows unrestricted self enrolment from {$a->from} until {$a->until}.'; +$string['showhintcourseselfenrolsinceuntil'] = 'The <strong>{$a->name}</strong> enrolment instance allows unrestricted self enrolment until {$a->until}.'; +$string['showhintcourseselfenrolinstancecallforaction'] = 'If you don\'t want that any Moodle user can enrol into this course freely, please restrict the self enrolment settings.'; $string['switchroleto'] = 'Switch role to'; $string['yes_close'] = "Yes, close!"; diff --git a/tests/behat/theme_boost_campus_course_layout_settings.feature b/tests/behat/theme_boost_campus_course_layout_settings.feature index 9b84c05eb6a3a06d6c581cf5fc2026bbb6347cc2..47fd1965f56e406c1bfc695952249f5c22077761 100644 --- a/tests/behat/theme_boost_campus_course_layout_settings.feature +++ b/tests/behat/theme_boost_campus_course_layout_settings.feature @@ -119,81 +119,116 @@ Feature: Configuring the theme_boost_campus plugin for the "Course Layout settin Then I should not see "You are currently viewing this course as Guest." And ".course-guestaccess-infobox" "css_element" should not exist - Scenario: Enable "Show hint for unrestricted self enrolment" + Scenario: Enable "Show hint for self enrolment without enrolment key" 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:" + Then I should not see "This course is currently visible and self enrolment without enrolment key is" 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)\"." + Then I should see "This course is currently visible and self enrolment without enrolment key is" And ".course-selfenrol-infobox" "css_element" should exist And I log out When I log in as "student1" 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 self enrolment without enrolment key is" And ".course-selfenrol-infobox" "css_element" should not exist - Scenario: Enable "Show hint for unrestricted self enrolment" and check that it is hidden when new enrolments are disabled + Scenario: Enable "Show hint for self enrolment without enrolment key" and check that the call for action is shown Given the following config values are set as admin: | config | value | plugin | | showhintcourseselfenrol | yes | theme_boost_campus | + And the following "users" exist: + | username | + | teacher2 | + And the following "course enrolments" exist: + | user | course | role | + | teacher2 | C1 | teacher | 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:" + Then I should not see "This course is currently visible and self enrolment without enrolment key is" + And I should not see "If you don't want that any Moodle user can enrol into this course freely, please restrict the self enrolment settings." 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)\"." + Then I should see "This course is currently visible and self enrolment without enrolment key is" + And I should see "If you don't want that any Moodle user can enrol into this course freely, please restrict the self enrolment settings." + And ".course-selfenrol-infobox" "css_element" should exist + And I log out + When I log in as "teacher2" + And I am on "Course 1" course homepage + Then I should see "This course is currently visible and self enrolment without enrolment key is" + And I should not see "If you don't want that any Moodle user can enrol into this course freely, please restrict the self enrolment settings." And ".course-selfenrol-infobox" "css_element" should exist - When I click on "enrolment settings" "link" in the ".course-selfenrol-infobox" "css_element" + And I log out + When I log in as "student1" + And I am on "Course 1" course homepage + Then I should not see "This course is currently visible and self enrolment without enrolment key is" + And I should not see "If you don't want that any Moodle user can enrol into this course freely, please restrict the self enrolment settings." + And ".course-selfenrol-infobox" "css_element" should not exist + + Scenario: Enable "Show hint for self enrolment without enrolment key" and check that it is hidden when new enrolments are disabled + 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 self enrolment without enrolment key is" + 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 self enrolment without enrolment key is" + And ".course-selfenrol-infobox" "css_element" should exist + When I click on "Self enrolment (Student)" "link" in the ".course-selfenrol-infobox" "css_element" 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)\"" + Then I should not see "This course is currently visible and self enrolment without enrolment key is" 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 + Scenario: Enable "Show hint for self enrolment without enrolment key" 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:" + Then I should not see "This course is currently visible and self enrolment without enrolment key is" 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)\"." + Then I should see "This course is currently visible and self enrolment without enrolment key is" 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 "Self enrolment (Student)" "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)\"" + Then I should not see "This course is currently visible and self enrolment without enrolment key is" 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" + Scenario: Enable "Show hint for self enrolment without enrolment key" and check the hints depending on the configured start and / or end dates 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:" + Then I should not see "This course is currently visible and self enrolment without enrolment key is" 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)\"." + Then I should see "This course is currently visible and self enrolment without enrolment key is currently possible." + And I should see "The Self enrolment (Student) enrolment instance allows unrestricted self enrolment infinitely." 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 "Self enrolment (Student)" "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 | @@ -205,7 +240,7 @@ Feature: Configuring the theme_boost_campus plugin for the "Course Layout settin | id_enrolenddate_minute | 00 | 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)\"" + Then I should not see "This course is currently visible and self enrolment without enrolment key is" 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" @@ -220,7 +255,8 @@ Feature: Configuring the theme_boost_campus plugin for the "Course Layout settin | id_enrolenddate_minute | 00 | 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)\"." + Then I should see "This course is currently visible and self enrolment without enrolment key is currently possible." + And I should see "The Self enrolment (Student) enrolment instance allows unrestricted self enrolment until Saturday, 1 January 2050, 12:00 AM." 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" @@ -235,7 +271,8 @@ Feature: Configuring the theme_boost_campus plugin for the "Course Layout settin | id_enrolenddate_enabled | 0 | 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)\"." + Then I should see "This course is currently visible and self enrolment without enrolment key is currently possible." + And I should see "The Self enrolment (Student) enrolment instance allows unrestricted self enrolment currently." 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" @@ -250,8 +287,9 @@ Feature: Configuring the theme_boost_campus plugin for the "Course Layout settin | id_enrolenddate_enabled | 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 + Then I should see "This course is currently visible and self enrolment without enrolment key is planned to become possible." + And I should see "The Self enrolment (Student) enrolment instance allows unrestricted self enrolment from Saturday, 1 January 2050, 12:00 AM on." + 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: @@ -271,8 +309,9 @@ Feature: Configuring the theme_boost_campus plugin for the "Course Layout settin | id_enrolenddate_minute | 00 | 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 + Then I should see "This course is currently visible and self enrolment without enrolment key is planned to become possible." + And I should see "The Self enrolment (Student) enrolment instance allows unrestricted self enrolment from Saturday, 1 January 2050, 12:00 AM until Sunday, 2 January 2050, 12:00 AM." + 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: @@ -292,7 +331,8 @@ Feature: Configuring the theme_boost_campus plugin for the "Course Layout settin | id_enrolenddate_minute | 00 | 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)\"." + Then I should see "This course is currently visible and self enrolment without enrolment key is currently possible." + And I should see "The Self enrolment (Student) enrolment instance allows unrestricted self enrolment until Saturday, 1 January 2050, 12:00 AM." 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" @@ -313,28 +353,40 @@ Feature: Configuring the theme_boost_campus plugin for the "Course Layout settin | id_enrolenddate_minute | 00 | 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)\"." + Then I should not see "This course is currently visible and self enrolment without enrolment key is" 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 self enrolment without enrolment key" and add more than one self enrolment instance 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" + Then I should not see "This course is currently visible and self enrolment without enrolment key is" 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)\"." + Then I should see "This course is currently visible and self enrolment without enrolment key is" + And I should see "The Self enrolment (Student) enrolment instance allows unrestricted self enrolment infinitely." And ".course-selfenrol-infobox" "css_element" should exist When I add "Self enrolment" enrolment method with: | Custom instance name | Custom self enrolment | + And I navigate to "Users > Enrolment methods" in current page administration + And I click on "Edit" "link" in the "Custom self enrolment" "table_row" + And I set the following fields to these values: + | id_enrolstartdate_enabled | 0 | + | id_enrolenddate_enabled | 1 | + # We can't use the ##tomorrow## notation here. This test will break in the year 2050. + | id_enrolenddate_day | 1 | + | id_enrolenddate_month | January | + | id_enrolenddate_year | 2050 | + | id_enrolenddate_hour | 00 | + | id_enrolenddate_minute | 00 | + 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 - And I should see "This course is currently visible and an unrestricted self enrolment is active: \"Custom self enrolment\"." + Then I should see "This course is currently visible and self enrolment without enrolment key is currently possible." + And I should see "The Self enrolment (Student) enrolment instance allows unrestricted self enrolment infinitely. The Custom self enrolment enrolment instance allows unrestricted self enrolment until Saturday, 1 January 2050, 12:00 AM." 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" @@ -342,8 +394,8 @@ Feature: Configuring the theme_boost_campus plugin for the "Course Layout settin | 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 I should see "This course is currently visible and an unrestricted self enrolment is active: \"Custom self enrolment\"." + Then I should see "This course is currently visible and self enrolment without enrolment key is currently possible." + And I should see "The Custom self enrolment enrolment instance allows unrestricted self enrolment until Saturday, 1 January 2050, 12:00 AM." And ".course-selfenrol-infobox" "css_element" should exist @javascript