From b071a7b8388a3fc6bc45f4edd9ab725b1c672c5e Mon Sep 17 00:00:00 2001 From: Ilya Tregubov Date: Tue, 18 May 2021 12:30:34 +0200 Subject: [PATCH] MDL-71382 course: Don't allow empty name for section 0. --- course/classes/output/section_format.php | 3 +- course/tests/behat/sectionzero_title.feature | 45 ++++++++++++++++++++ 2 files changed, 46 insertions(+), 2 deletions(-) create mode 100644 course/tests/behat/sectionzero_title.feature diff --git a/course/classes/output/section_format.php b/course/classes/output/section_format.php index feb54c1f0b9..6ff0f0f2c03 100644 --- a/course/classes/output/section_format.php +++ b/course/classes/output/section_format.php @@ -162,8 +162,7 @@ class section_format implements renderable, templatable { $data->completioninfo = $completioninfo->display_help_icon(); $header = new $this->headerclass($format, $thissection); - if (empty($this->hidetitle) && !is_null($thissection->name) - && !($thissection->name === '')) { + if (empty($this->hidetitle)) { $data->header = $header->export_for_template($output); } return $data; diff --git a/course/tests/behat/sectionzero_title.feature b/course/tests/behat/sectionzero_title.feature new file mode 100644 index 00000000000..d0416ce8386 --- /dev/null +++ b/course/tests/behat/sectionzero_title.feature @@ -0,0 +1,45 @@ +@core @core_course +Feature: Section 0 default/custom title + In order to set up a course + As a teacher + I need to be able to use/change default section 0 title + + Background: + Given the following "users" exist: + | username | firstname | lastname | email | + | teacher1 | Teacher | 1 | teacher1@example.com | + And the following "courses" exist: + | fullname | shortname | format | + | Course 1 | C1 | topics | + And the following "activities" exist: + | activity | name | intro | course | idnumber | section | + | data | Test database name | Test database description | C1 | database1 | 2 | + | forum | Test forum name | Test forum name description | C1 | forum1 | 1 | + And the following "course enrolments" exist: + | user | course | role | + | teacher1 | C1 | editingteacher | + + @javascript + Scenario: Default section 0 title is General + Given I log in as "teacher1" + When I am on "Course 1" course homepage with editing mode on + Then I should see "General" in the "li#section-0" "css_element" + + @javascript + Scenario: Editing section 0 title + Given I log in as "teacher1" + And I am on "Course 1" course homepage with editing mode on + And I edit the section "0" and I fill the form with: + | Custom | 1 | + | New value for Section name | Edited section 0 | + And I should see "Edited section 0" in the "li#section-0" "css_element" + When I set the field "Edit topic name" in the "li#section-0" "css_element" to "" + Then I should not see "Edited section 0" in the "li#section-0" "css_element" + And I should see "General" in the "li#section-0" "css_element" + And "New name for topic" "field" should not exist + And I set the field "Edit topic name" in the "li#section-0" "css_element" to "Edited section 0" + And I should see "Edited section 0" in the "li#section-0" "css_element" + And I edit the section "0" and I fill the form with: + | Custom | 0 | + And I should not see "Edited section 0" in the "li#section-0" "css_element" + And I should see "General" in the "li#section-0" "css_element"