Commit 97857063 authored by John Yao's avatar John Yao
Browse files

MDL-67524 book: fixing view hidden chapter issue

* Users who has permission should be able to view after turning editing off
parent 7850f76a
...@@ -58,11 +58,6 @@ Feature: Book activity chapter visibility management ...@@ -58,11 +58,6 @@ Feature: Book activity chapter visibility management
And I follow "Test book" And I follow "Test book"
Then the "class" attribute of "a[title='Second chapter']" "css_element" should contain "dimmed_text" 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 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 turn editing mode on
And I follow "Next" And I follow "Next"
And I should see "Second chapter" in the ".book_content" "css_element" And I should see "Second chapter" in the ".book_content" "css_element"
...@@ -80,3 +75,8 @@ Feature: Book activity chapter visibility management ...@@ -80,3 +75,8 @@ Feature: Book activity chapter visibility management
And I follow "Test book" And I follow "Test book"
And I should not see "Second chapter" in the "Table of contents" "block" 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 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"
...@@ -80,7 +80,7 @@ if ($chapterid == '0') { // Go to first chapter if no given. ...@@ -80,7 +80,7 @@ if ($chapterid == '0') { // Go to first chapter if no given.
book_view($book, null, false, $course, $cm, $context); book_view($book, null, false, $course, $cm, $context);
foreach ($chapters as $ch) { foreach ($chapters as $ch) {
if ($edit) { if ($edit || ($ch->hidden && $viewhidden)) {
$chapterid = $ch->id; $chapterid = $ch->id;
break; break;
} }
...@@ -132,7 +132,7 @@ $nexttitle = null; ...@@ -132,7 +132,7 @@ $nexttitle = null;
$navnexttitle = null; $navnexttitle = null;
$last = null; $last = null;
foreach ($chapters as $ch) { foreach ($chapters as $ch) {
if (!$edit and $ch->hidden) { if (!$edit and ($ch->hidden && !$viewhidden)) {
continue; continue;
} }
if ($last == $chapter->id) { if ($last == $chapter->id) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment