Skip to content

Commit

Permalink
MDL-67524 book: fixing view hidden chapter issue
Browse files Browse the repository at this point in the history
* Users who has permission should be able to view after turning editing off
  • Loading branch information
John Yao committed Dec 22, 2019
1 parent 7850f76 commit 9785706
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions mod/book/tests/behat/show_hide_chapters.feature
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,6 @@ Feature: Book activity chapter visibility management
And I follow "Test book"
Then the "class" attribute of "a[title='Second chapter']" "css_element" should contain "dimmed_text"
And the "class" attribute of "a[title='Third chapter']" "css_element" should contain "dimmed_text"
And I follow "Next"
And I should see "Fourth chapter" in the ".book_content" "css_element"
And I follow "Exit book"
And I follow "Test book"
And I should see "First chapter" in the ".book_content" "css_element"
And I turn editing mode on
And I follow "Next"
And I should see "Second chapter" in the ".book_content" "css_element"
Expand All @@ -80,3 +75,8 @@ Feature: Book activity chapter visibility management
And I follow "Test book"
And I should not see "Second chapter" in the "Table of contents" "block"
And I should not see "Third chapter" in the "Table of contents" "block"
And I follow "Next"
And I should see "Fourth chapter" in the ".book_content" "css_element"
And I follow "Exit book"
And I follow "Test book"
And I should see "First chapter" in the ".book_content" "css_element"
4 changes: 2 additions & 2 deletions mod/book/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
book_view($book, null, false, $course, $cm, $context);

foreach ($chapters as $ch) {
if ($edit) {
if ($edit || ($ch->hidden && $viewhidden)) {
$chapterid = $ch->id;
break;
}
Expand Down Expand Up @@ -132,7 +132,7 @@
$navnexttitle = null;
$last = null;
foreach ($chapters as $ch) {
if (!$edit and $ch->hidden) {
if (!$edit and ($ch->hidden && !$viewhidden)) {
continue;
}
if ($last == $chapter->id) {
Expand Down

0 comments on commit 9785706

Please sign in to comment.