Skip to content

Commit

Permalink
MDL-58790 quiz editing: translate hard-coded new heading string
Browse files Browse the repository at this point in the history
  • Loading branch information
timhunt committed Sep 26, 2017
1 parent 469c46a commit ce7cb88
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
10 changes: 7 additions & 3 deletions mod/quiz/classes/structure.php
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions mod/quiz/lang/en/quiz.php
Expand Up @@ -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.';
Expand Down
4 changes: 2 additions & 2 deletions mod/quiz/tests/behat/editing_section_headings.feature
Expand Up @@ -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
Expand Down Expand Up @@ -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"

0 comments on commit ce7cb88

Please sign in to comment.