diff --git a/course/editsection_form.php b/course/editsection_form.php index 4575dc1e960..2e4f5babafd 100644 --- a/course/editsection_form.php +++ b/course/editsection_form.php @@ -25,12 +25,19 @@ class editsection_form extends moodleform { $mform->addElement('header', 'generalhdr', get_string('general')); - $mform->addElement('defaultcustom', 'name', get_string('sectionname'), [ - 'defaultvalue' => $this->_customdata['defaultsectionname'], - 'customvalue' => $sectioninfo->name, - ], ['size' => 30, 'maxlength' => 255]); - $mform->setDefault('name', false); - $mform->addGroupRule('name', array('name' => array(array(get_string('maximumchars', '', 255), 'maxlength', 255)))); + $mform->addElement( + 'text', + 'name', + get_string('sectionname'), + [ + 'placeholder' => $this->_customdata['defaultsectionname'], + 'size' => 30, + 'maxlength' => 255, + ], + ); + $mform->setType('name', PARAM_RAW); + $mform->setDefault('name', $sectioninfo->name); + $mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client'); /// Prepare course and the editor @@ -98,9 +105,6 @@ class editsection_form extends moodleform { $editoroptions = $this->_customdata['editoroptions']; $default_values = file_prepare_standard_editor($default_values, 'summary', $editoroptions, $editoroptions['context'], 'course', 'section', $default_values->id); - if (strval($default_values->name) === '') { - $default_values->name = false; - } parent::set_data($default_values); } diff --git a/course/format/topics/tests/behat/edit_delete_sections.feature b/course/format/topics/tests/behat/edit_delete_sections.feature index 5c5e0edd5bf..2626dba4234 100644 --- a/course/format/topics/tests/behat/edit_delete_sections.feature +++ b/course/format/topics/tests/behat/edit_delete_sections.feature @@ -27,22 +27,21 @@ Feature: Sections can be edited and deleted in custom sections format Scenario: View the default name of the general section in custom sections format Given I am on "Course 1" course homepage with editing mode on When I edit the section "0" - Then the field "Custom" matches value "0" - And the field "New value for Section name" matches value "General" + Then the field "Section name" matches value "" + And I should see "General" Scenario: Edit the default name of the general section in custom sections format Given I am on "Course 1" course homepage with editing mode on And I should see "General" in the "General" "section" When I edit the section "0" and I fill the form with: - | Custom | 1 | - | New value for Section name | This is the general section | + | Section name | This is the general section | Then I should see "This is the general section" in the "page" "region" Scenario: View the default name of the second section in custom sections format Given I am on "Course 2" course homepage with editing mode on When I edit the section "1" - Then the field "Custom" matches value "0" - And the field "New value for Section name" matches value "New section" + Then the field "Section name" matches value "" + And I should see "New section" Scenario: Edit section summary in custom sections format Given I am on "Course 1" course homepage with editing mode on @@ -53,8 +52,7 @@ Feature: Sections can be edited and deleted in custom sections format Scenario: Edit section default name in custom sections format Given I am on "Course 1" course homepage with editing mode on When I edit the section "2" and I fill the form with: - | Custom | 1 | - | New value for Section name | This is the second section | + | Section name | This is the second section | Then I should see "This is the second section" in the "page" "region" And I should not see "Section 2" in the "region-main" "region" diff --git a/course/format/weeks/tests/behat/edit_delete_sections.feature b/course/format/weeks/tests/behat/edit_delete_sections.feature index da7ae8868a1..96061da9948 100644 --- a/course/format/weeks/tests/behat/edit_delete_sections.feature +++ b/course/format/weeks/tests/behat/edit_delete_sections.feature @@ -25,19 +25,18 @@ Feature: Sections can be edited and deleted in weekly sections format Scenario: View the default name of the general section in weeks format When I edit the section "0" - Then the field "Custom" matches value "0" - And the field "New value for Section name" matches value "General" + Then the field "Section name" matches value "" + And I should see "General" Scenario: Edit the default name of the general section in weeks format When I edit the section "0" and I fill the form with: - | Custom | 1 | - | New value for Section name | This is the general section | + | Section name | This is the general section | Then I should see "This is the general section" in the "page" "region" Scenario: View the default name of the second section in weeks format When I edit the section "2" - Then the field "Custom" matches value "0" - And the field "New value for Section name" matches value "8 May - 14 May" + Then the field "Section name" matches value "" + And I should see "8 May - 14 May" Scenario: Edit section summary in weeks format When I edit the section "2" and I fill the form with: @@ -47,8 +46,7 @@ Feature: Sections can be edited and deleted in weekly sections format Scenario: Edit section default name in weeks format Given I should see "8 May - 14 May" in the "8 May - 14 May" "section" When I edit the section "2" and I fill the form with: - | Custom | 1 | - | New value for Section name | This is the second week | + | Section name | This is the second week | Then I should see "This is the second week" in the "page" "region" And I should not see "8 May - 14 May" diff --git a/course/tests/behat/course_collapse_sections.feature b/course/tests/behat/course_collapse_sections.feature index d2515fac967..3bc4f824605 100644 --- a/course/tests/behat/course_collapse_sections.feature +++ b/course/tests/behat/course_collapse_sections.feature @@ -64,8 +64,7 @@ Feature: Collapse course sections And I am on site homepage And I turn editing mode on And I click on "Edit" "link" in the "region-main" "region" - And I click on "Custom" "checkbox" - And I set the field "New value for Section name" to "New section name" + And I set the field "Section name" to "New section name" When I press "Save changes" Then "[data-toggle=collapse]" "css_element" should not exist in the "region-main" "region" diff --git a/course/tests/behat/frontpage_topic_section.feature b/course/tests/behat/frontpage_topic_section.feature index 2b1f7cfa813..646bb1d1c8f 100644 --- a/course/tests/behat/frontpage_topic_section.feature +++ b/course/tests/behat/frontpage_topic_section.feature @@ -25,8 +25,7 @@ Feature: Site home activities section And I am on site homepage And I turn editing mode on And I click on "Edit" "link" in the "region-main" "region" - And I click on "Custom" "checkbox" - And I set the field "New value for Section name" to "New section name" + And I set the field "Section name" to "New section name" When I press "Save changes" And I should see "New section name" in the "region-main" "region" Then I turn editing mode off diff --git a/course/tests/behat/sectionzero_title.feature b/course/tests/behat/sectionzero_title.feature index 11935e83846..fdbc7313043 100644 --- a/course/tests/behat/sectionzero_title.feature +++ b/course/tests/behat/sectionzero_title.feature @@ -36,7 +36,6 @@ Feature: Section 0 default/custom title And "New name for section" "field" should not exist And I set the field "Edit section name" in the "li#section-0" "css_element" to "Edited section 0" And I should see "Edited section 0" in the "page" "region" - And I edit the section "0" and I fill the form with: - | Custom | 0 | + And I set the field "Edit section name" in the "li#section-0" "css_element" to "" And I should not see "Edited section 0" in the "page" "region" And I should see "General" in the "page" "region"