diff --git a/.github/workflows/moodle.yml b/.github/workflows/moodle.yml index 28f1f96..d7ecb99 100644 --- a/.github/workflows/moodle.yml +++ b/.github/workflows/moodle.yml @@ -30,8 +30,8 @@ jobs: strategy: fail-fast: false matrix: - php: ['7.3', '7.4'] - moodle-branch: ['MOODLE_39_STABLE', 'MOODLE_310_STABLE', 'MOODLE_311_STABLE'] + php: ['7.3', '7.4', '8.0'] + moodle-branch: ['MOODLE_400_STABLE'] database: [pgsql, mariadb] steps: diff --git a/README.md b/README.md index 8725d86..dd96e6e 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,11 @@ moodle-format_flexsections ========================== +Version 4.0.0 +------------- + +- Support for Moodle 4.0, however UI remains the same as in previous versions + Version 3.5.2 ------------- diff --git a/renderer.php b/renderer.php index 34386fd..c6b924f 100644 --- a/renderer.php +++ b/renderer.php @@ -296,11 +296,11 @@ protected function section_availability_message($section, $canviewhidden) { $o = ''; if (!$section->visible) { if ($canviewhidden) { - $o .= $this->courserenderer->availability_info(get_string('hiddenfromstudents'), 'ishidden'); + $o .= $this->availability_info(get_string('hiddenfromstudents'), 'ishidden'); } else { // We are here because of the setting "Hidden sections are shown in collapsed form". // Student can not see the section contents but can see its name. - $o .= $this->courserenderer->availability_info(get_string('notavailable'), 'ishidden'); + $o .= $this->availability_info(get_string('notavailable'), 'ishidden'); } } else if (!$section->uservisible) { if ($section->availableinfo) { @@ -308,7 +308,7 @@ protected function section_availability_message($section, $canviewhidden) { // so there is definitely something to print. $formattedinfo = \core_availability\info::format_info( $section->availableinfo, $section->course); - $o .= $this->courserenderer->availability_info($formattedinfo, 'isrestricted'); + $o .= $this->availability_info($formattedinfo, 'isrestricted'); } } else if ($canviewhidden && !empty($CFG->enableavailability)) { // Check if there is an availability restriction. @@ -317,12 +317,41 @@ protected function section_availability_message($section, $canviewhidden) { if ($fullinfo) { $formattedinfo = \core_availability\info::format_info( $fullinfo, $section->course); - $o .= $this->courserenderer->availability_info($formattedinfo, 'isrestricted isfullinfo'); + $o .= $this->availability_info($formattedinfo, 'isrestricted isfullinfo'); } } return $o; } + /** + * Displays availability info for a course section or course module + * + * @param string $text + * @param string $additionalclasses + * @return string + */ + public function availability_info($text, $additionalclasses = '') { + + $data = ['text' => $text, 'classes' => $additionalclasses]; + $additionalclasses = array_filter(explode(' ', $additionalclasses)); + + if (in_array('ishidden', $additionalclasses)) { + $data['ishidden'] = 1; + + } else if (in_array('isstealth', $additionalclasses)) { + $data['isstealth'] = 1; + + } else if (in_array('isrestricted', $additionalclasses)) { + $data['isrestricted'] = 1; + + if (in_array('isfullinfo', $additionalclasses)) { + $data['isfullinfo'] = 1; + } + } + + return $this->render_from_template('core/availability_info', $data); + } + /** * Displays a confirmation dialogue when deleting the section (for non-JS mode) * diff --git a/styles.css b/styles.css index f4865ef..1827f5f 100644 --- a/styles.css +++ b/styles.css @@ -1,7 +1,7 @@ .format-flexsections .course-content ul.flexsections { margin: 0; padding: 0; - list-style: none !important; + list-style: none !important; /* stylelint-disable-line declaration-no-important */ } .format-flexsections .course-content ul.flexsections li.section { padding: 1rem 0; diff --git a/tests/behat/basic_actions.feature b/tests/behat/basic_actions.feature index 0f02bc9..08772f9 100644 --- a/tests/behat/basic_actions.feature +++ b/tests/behat/basic_actions.feature @@ -62,10 +62,12 @@ Feature: Using course in flexsections format And I should not see "Second module" Scenario: Collapsing section in flexsections format + Given the following config values are set as admin: + | unaddableblocks | | theme_boost| Given I add the "Navigation" block if not present And I open the "Recent activity" blocks action menu And I click on "Delete Recent activity block" "link" - And I press "Yes" + And I click on "Delete" "button" in the "Delete block?" "dialogue" When I click on "Show collapsed" "link" in the "li#section-2" "css_element" And I log out And I log in as "student1" @@ -82,13 +84,15 @@ Feature: Using course in flexsections format And I should see "Second module" in the "Navigation" "block" Scenario: Collapsing section with subsections in flexsections format + Given the following config values are set as admin: + | unaddableblocks | | theme_boost| Given I add the "Navigation" block if not present And I open the "Recent activity" blocks action menu And I click on "Delete Recent activity block" "link" - And I press "Yes" + And I click on "Delete" "button" in the "Delete block?" "dialogue" And I open the "Upcoming events" blocks action menu And I click on "Delete Upcoming events block" "link" - And I press "Yes" + And I click on "Delete" "button" in the "Delete block?" "dialogue" When I click on "Show collapsed" "link" in the "li#section-1" "css_element" And I log out And I log in as "student1" @@ -109,13 +113,15 @@ Feature: Using course in flexsections format And I should see "Second module" in the "Navigation" "block" Scenario: Merging subsection in flexsections format + Given the following config values are set as admin: + | unaddableblocks | | theme_boost| Given I add the "Navigation" block if not present And I open the "Recent activity" blocks action menu And I click on "Delete Recent activity block" "link" - And I press "Yes" + And I click on "Delete" "button" in the "Delete block?" "dialogue" Given I open the "Upcoming events" blocks action menu And I click on "Delete Upcoming events block" "link" - And I press "Yes" + And I click on "Delete" "button" in the "Delete block?" "dialogue" When I click on "Merge with parent" "link" in the "li#section-2" "css_element" And I click on "Yes" "button" in the "Confirm" "dialogue" Then I should see "Topic 1" in the "region-main" "region" diff --git a/tests/format_flexsections_test.php b/tests/format_flexsections_test.php index e0fb648..e5b1536 100644 --- a/tests/format_flexsections_test.php +++ b/tests/format_flexsections_test.php @@ -26,6 +26,7 @@ /** * format_flexsections related unit tests * + * @covers \format_flexsections * @package format_flexsections * @copyright 2020 Marina Glancy * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later diff --git a/version.php b/version.php index 5c35c76..43b9f03 100644 --- a/version.php +++ b/version.php @@ -24,9 +24,9 @@ defined('MOODLE_INTERNAL') || die; -$plugin->version = 2020051101; // The current plugin version (Date: YYYYMMDDXX). -$plugin->requires = 2018051700; // Requires this Moodle 3.5 or above. -$plugin->release = "3.5.2"; +$plugin->version = 2022052000; // The current plugin version (Date: YYYYMMDDXX). +$plugin->requires = 2022041900.00; // Requires this Moodle 3.5 or above. +$plugin->release = "4.0.0"; $plugin->maturity = MATURITY_STABLE; $plugin->component = 'format_flexsections'; // Full name of the plugin (used for diagnostics). -$plugin->supported = [35, 311]; // Moodle 3.5 - 3.11 are supported. Moodle 4.0 is NOT supported! +$plugin->supported = [400, 400];