diff --git a/mod/book/view.php b/mod/book/view.php index f1a1c4b5bc5..42d07502c8d 100644 --- a/mod/book/view.php +++ b/mod/book/view.php @@ -149,7 +149,6 @@ foreach ($chapters as $ch) { $last = $ch->id; } -$islastchapter = false; if ($book->navstyle) { $navprevicon = right_to_left() ? 'nav_next' : 'nav_prev'; $navnexticon = right_to_left() ? 'nav_prev' : 'nav_next'; @@ -196,11 +195,15 @@ if ($book->navstyle) { $chnavigation .= ' ' . '' . $navexit . ' ' . $OUTPUT->uarrow() . ''; } - - $islastchapter = true; } } +// We need to discover if this is the last chapter to mark activity as completed. +$islastchapter = false; +if (!$nextid) { + $islastchapter = true; +} + book_view($book, $chapter, $islastchapter, $course, $cm, $context); // =====================================================