From 1554c68933d220299cb68b93d9675f78456781fa Mon Sep 17 00:00:00 2001 From: Paul Holden Date: Fri, 5 Jul 2024 12:44:45 +0100 Subject: [PATCH] MDL-82391 courseformat: correct selector element section URLs. It's required by themes that don't use the course index component, e.g. Classic theme. --- .../output/local/content/sectionselector.php | 2 +- .../tests/behat/course_sections.feature | 30 +++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 theme/classic/tests/behat/course_sections.feature diff --git a/course/format/classes/output/local/content/sectionselector.php b/course/format/classes/output/local/content/sectionselector.php index 5694dc5e49c..a78ff80baa5 100644 --- a/course/format/classes/output/local/content/sectionselector.php +++ b/course/format/classes/output/local/content/sectionselector.php @@ -85,7 +85,7 @@ class sectionselector implements named_templatable, renderable { $numsections = $format->get_last_section_number(); while ($section <= $numsections) { $thissection = $modinfo->get_section_info($section); - $url = course_get_url($course, $section); + $url = course_get_url($course, $section, ['navigation' => true]); if ($thissection->uservisible && $url && $section != $data->currentsection) { $sectionmenu[$url->out(false)] = get_section_name($course, $section); } diff --git a/theme/classic/tests/behat/course_sections.feature b/theme/classic/tests/behat/course_sections.feature new file mode 100644 index 00000000000..8a207754028 --- /dev/null +++ b/theme/classic/tests/behat/course_sections.feature @@ -0,0 +1,30 @@ +@theme_classic +Feature: Select course sections using classic theme + In order to view course sections when using the classic theme + As a teacher + I need to select the section from the section selector + + Background: + Given the following "course" exists: + | fullname | Course 1 | + | shortname | C1 | + | numsections | 3 | + | initsections | 1 | + And the following "activities" exist: + | course | activity | name | idnumber | section | + | C1 | assign | Assignment 1 | assign1 | 1 | + | C1 | assign | Assignment 2 | assign2 | 2 | + + @javascript + Scenario: Use the course section selector in classic theme + Given I am on the "C1" "Course" page logged in as "admin" + And I turn editing mode on + When I choose the "View" item in the "Edit" action menu of the "Section 1" "section" + Then I should see "Section 1" + And I should see "Assignment 1" + And I should not see "Assignment 2" + And I select "Section 2" from the "jump" singleselect + And I should see "Section 2" + And I should not see "Assignment 1" + And I should see "Assignment 2" + And the "jump" select box should contain "Section 3"