mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 16:32:18 +02:00
MDL-60384 mod_book: Add a label to highlight the previous chapter
* Added current chapter's title to the button title so it's clear where you're adding the chapter to. * Update the behat tests to reflect the changes made to the title
This commit is contained in:
parent
9e5d41ee1d
commit
448584b5df
@ -54,6 +54,15 @@ if ($chapterid) {
|
||||
}
|
||||
$chapter->cmid = $cm->id;
|
||||
|
||||
// Get the previous page number.
|
||||
$prevpage = $chapter->pagenum - 1;
|
||||
if ($prevpage) {
|
||||
$currentchapter = $DB->get_record('book_chapters', ['pagenum' => $prevpage, 'bookid' => $book->id]);
|
||||
if ($currentchapter) {
|
||||
$chapter->currentchaptertitle = $currentchapter->title;
|
||||
}
|
||||
}
|
||||
|
||||
$options = array('noclean'=>true, 'subdirs'=>true, 'maxfiles'=>-1, 'maxbytes'=>0, 'context'=>$context);
|
||||
$chapter = file_prepare_standard_editor($chapter, 'content', $options, $context, 'mod_book', 'chapter', $chapter->id);
|
||||
|
||||
|
@ -48,6 +48,13 @@ class book_chapter_edit_form extends moodleform {
|
||||
$mform->addElement('header', 'general', get_string('addafter', 'mod_book'));
|
||||
}
|
||||
|
||||
if (isset($chapter->currentchaptertitle)) {
|
||||
$mform->addElement('static', 'details',
|
||||
get_string('previouschapter', 'mod_book'),
|
||||
$chapter->currentchaptertitle
|
||||
);
|
||||
}
|
||||
|
||||
$mform->addElement('text', 'title', get_string('chaptertitle', 'mod_book'), array('size'=>'30'));
|
||||
$mform->setType('title', PARAM_RAW);
|
||||
$mform->addRule('title', null, 'required', null, 'client');
|
||||
|
@ -87,6 +87,8 @@ $string['numbering3'] = 'Indented';
|
||||
$string['numberingoptions'] = 'Available options for chapter formatting';
|
||||
$string['numberingoptions_desc'] = 'Options for displaying chapters and subchapters in the table of contents';
|
||||
$string['addafter'] = 'Add new chapter';
|
||||
$string['addafterchapter'] = 'Add new chapter after "{$a->title}"';
|
||||
$string['previouschapter'] = 'Previous chapter';
|
||||
$string['confchapterdelete'] = 'Do you really want to delete this chapter?';
|
||||
$string['confchapterdeleteall'] = 'Do you really want to delete this chapter and all its subchapters?';
|
||||
$string['top'] = 'top';
|
||||
|
@ -336,8 +336,10 @@ function book_get_toc($chapters, $chapter, $book, $cm, $edit) {
|
||||
$OUTPUT->pix_icon('t/hide', get_string('hidechapter', 'mod_book', $title)),
|
||||
array('title' => get_string('hidechapter', 'mod_book', $titleunescaped)));
|
||||
}
|
||||
|
||||
$buttontitle = get_string('addafterchapter', 'mod_book', ['title' => $ch->title]);
|
||||
$toc .= html_writer::link(new moodle_url('edit.php', array('cmid' => $cm->id, 'pagenum' => $ch->pagenum, 'subchapter' => $ch->subchapter)),
|
||||
$OUTPUT->pix_icon('add', get_string('addafter', 'mod_book'), 'mod_book'), array('title' => get_string('addafter', 'mod_book')));
|
||||
$OUTPUT->pix_icon('add', $buttontitle, 'mod_book'), array('title' => $buttontitle));
|
||||
$toc .= html_writer::end_tag('div');
|
||||
|
||||
if (!$ch->subchapter) {
|
||||
|
@ -28,13 +28,15 @@ Feature: In a book, create chapters and sub chapters
|
||||
| Content | Dream is the start of a journey |
|
||||
And I press "Save changes"
|
||||
And I should see "1. Dummy first chapter" in the "Table of contents" "block"
|
||||
And I click on "Add new chapter" "link" in the "Table of contents" "block"
|
||||
And I click on "Add new chapter after \"Dummy first chapter\"" "link" in the "Table of contents" "block"
|
||||
And I should see "Dummy first chapter"
|
||||
And I set the following fields to these values:
|
||||
| Chapter title | Dummy second chapter |
|
||||
| Content | The path is the second part |
|
||||
And I press "Save changes"
|
||||
And I should see "2. Dummy second chapter" in the "Table of contents" "block"
|
||||
And I click on "Add new chapter" "link" in the "Table of contents" "block"
|
||||
And I click on "Add new chapter after \"Dummy first chapter\"" "link" in the "Table of contents" "block"
|
||||
And I should see "Dummy first chapter"
|
||||
And I set the following fields to these values:
|
||||
| Chapter title | Dummy first subchapter |
|
||||
| Content | The path is the second part |
|
||||
@ -75,4 +77,4 @@ Feature: In a book, create chapters and sub chapters
|
||||
Then "Edit chapter \"1. Dummy first chapter\"" "link" should not exist in the "Table of contents" "block"
|
||||
And "Delete chapter \"1. Dummy first chapter\"" "link" should not exist in the "Table of contents" "block"
|
||||
And "Hide chapter \"1. Dummy first chapter\"" "link" should not exist in the "Table of contents" "block"
|
||||
And "Add new chapter" "link" should not exist in the "Table of contents" "block"
|
||||
And "Add new chapter after \"Dummy first chapter\"" "link" should not exist in the "Table of contents" "block"
|
||||
|
@ -25,24 +25,24 @@ Feature: In a book, chapters and subchapters can be rearranged
|
||||
| Chapter title | Originally first chapter |
|
||||
| Content | #1 chapter content |
|
||||
And I press "Save changes"
|
||||
And I click on "a[href*='pagenum=1']" "css_element"
|
||||
And I click on "Add new chapter after \"Originally first chapter\"" "link"
|
||||
And I set the following fields to these values:
|
||||
| Chapter title | A great second chapter |
|
||||
| Content | #2 chapter content |
|
||||
And I press "Save changes"
|
||||
And I click on "a[href*='pagenum=2']" "css_element"
|
||||
And I click on "Add new chapter after \"A great second chapter\"" "link"
|
||||
And I set the following fields to these values:
|
||||
| Chapter title | Second chapter, subchapter 1 |
|
||||
| Content | #21 subchapter content |
|
||||
| Subchapter | 1 |
|
||||
And I press "Save changes"
|
||||
And I click on "a[href*='pagenum=3']" "css_element"
|
||||
And I click on "Add new chapter after \"Second chapter, subchapter 1\"" "link"
|
||||
And I set the following fields to these values:
|
||||
| Chapter title | Second chapter, subchapter 2 |
|
||||
| Content | #22 subchapter content |
|
||||
| Subchapter | 1 |
|
||||
And I press "Save changes"
|
||||
And I click on "a[href*='pagenum=4']" "css_element"
|
||||
And I click on "Add new chapter after \"Second chapter, subchapter 2\"" "link"
|
||||
And I set the following fields to these values:
|
||||
| Chapter title | There aren't 2 without 3 |
|
||||
| Content | #3 subchapter content |
|
||||
|
@ -26,24 +26,24 @@ Feature: Book activity chapter visibility management
|
||||
| Chapter title | First chapter |
|
||||
| Content | First chapter |
|
||||
And I press "Save changes"
|
||||
And I click on "a[href*='pagenum=1']" "css_element"
|
||||
And I click on "Add new chapter after \"First chapter\"" "link"
|
||||
And I set the following fields to these values:
|
||||
| Chapter title | Second chapter |
|
||||
| Content | Second chapter |
|
||||
And I press "Save changes"
|
||||
And I click on "a[href*='pagenum=2']" "css_element"
|
||||
And I click on "Add new chapter after \"Second chapter\"" "link"
|
||||
And I set the following fields to these values:
|
||||
| Chapter title | Sub chapter |
|
||||
| subchapter | 1 |
|
||||
| Content | Sub chapter |
|
||||
And I press "Save changes"
|
||||
And I click on "a[href*='pagenum=3']" "css_element"
|
||||
And I click on "Add new chapter after \"Sub chapter\"" "link"
|
||||
And I set the following fields to these values:
|
||||
| Chapter title | Third chapter |
|
||||
| subchapter | 0 |
|
||||
| Content | Third chapter |
|
||||
And I press "Save changes"
|
||||
And I click on "a[href*='pagenum=4']" "css_element"
|
||||
And I click on "Add new chapter after \"Third chapter\"" "link"
|
||||
And I set the following fields to these values:
|
||||
| Chapter title | Fourth chapter |
|
||||
| Content | Fourth chapter |
|
||||
|
Loading…
x
Reference in New Issue
Block a user