diff --git a/mod/quiz/classes/structure.php b/mod/quiz/classes/structure.php index aae5c245ac417..e9321167cd863 100644 --- a/mod/quiz/classes/structure.php +++ b/mod/quiz/classes/structure.php @@ -993,12 +993,16 @@ public function update_page_break($slotid, $type) { /** * Add a section heading on a given page and return the sectionid * @param int $pagenumber the number of the page where the section heading begins. - * @param string $heading the heading to add. + * @param string|null $heading the heading to add. If not given, a default is used. */ - public function add_section_heading($pagenumber, $heading = 'Section heading ...') { + public function add_section_heading($pagenumber, $heading = null) { global $DB; $section = new \stdClass(); - $section->heading = $heading; + if ($heading !== null) { + $section->heading = $heading; + } else { + $section->heading = get_string('newsectionheading', 'quiz'); + } $section->quizid = $this->get_quizid(); $slotsonpage = $DB->get_records('quiz_slots', array('quizid' => $this->get_quizid(), 'page' => $pagenumber), 'slot DESC'); $section->firstslot = end($slotsonpage)->slot; diff --git a/mod/quiz/lang/en/quiz.php b/mod/quiz/lang/en/quiz.php index d3608845a05c0..1b8b7b9a02e42 100644 --- a/mod/quiz/lang/en/quiz.php +++ b/mod/quiz/lang/en/quiz.php @@ -510,6 +510,7 @@ $string['newpage'] = 'New page'; $string['newpage_help'] = 'For longer quizzes it makes sense to stretch the quiz over several pages by limiting the number of questions per page. When adding questions to the quiz, page breaks will automatically be inserted according to this setting. However page breaks may later be moved manually on the editing page.'; $string['newpageevery'] = 'Automatically start a new page'; +$string['newsectionheading'] = 'New heading'; $string['noanswers'] = 'No answers were selected!'; $string['noattempts'] = 'No attempts have been made on this quiz'; $string['noattemptsfound'] = 'No attempts found.'; diff --git a/mod/quiz/tests/behat/editing_section_headings.feature b/mod/quiz/tests/behat/editing_section_headings.feature index aa6ac70652eae..c53c349bf731e 100644 --- a/mod/quiz/tests/behat/editing_section_headings.feature +++ b/mod/quiz/tests/behat/editing_section_headings.feature @@ -386,7 +386,7 @@ Feature: Edit quiz page - section headings And I click on the "Remove" page break icon after question "TF1" And I open the "Page 2" add to quiz menu And I choose "a new section heading" in the open action menu - Then "TF3" "list_item" should exist in the "Section heading ..." "list_item" + Then "TF3" "list_item" should exist in the "New heading" "list_item" @javascript Scenario: Add section works after removing a page break with more than 10 pages @@ -425,4 +425,4 @@ Feature: Edit quiz page - section headings And I click on the "Remove" page break icon after question "TF10" And I open the "Page 10" add to quiz menu And I choose "a new section heading" in the open action menu - Then "TF10" "list_item" should exist in the "Section heading ..." "list_item" + Then "TF10" "list_item" should exist in the "New heading" "list_item"