Other: Navigation buttons

block_navbuttons
Maintained by DavoDavo Smith
Add customisable navigation buttons (next/prev/etc.) to the bottom of each activity page (Moodle 1.9/2.0+)
477 sites
258 downloads
29 fans
Current versions available: 4

Travis build status

Navigation buttons (for Moodle 1.9 / 2.0+)
This block adds customisable navigation buttons (first/previous/next/etc.) to the bottom of each activity/resource page in a course.

It is based on an idea from Penny Mondani: http://pennymondani.com
Thanks also to the US company that sponsored the development, who wish to remain anonymous.

Installation:

  1. Download the file and unzip it somewhere convenient.
  2. On your server, in the 'blocks' folder, create a subfolder called 'navbuttons'
  3. Upload all the files inside the 'davosmith-moodle-navbuttons-???????' folder to this new 'navbuttons' folder on your server.
  4. Log in to your Moodle site as an administrator and click on the 'Notifications' option in the Admin settings block.
  5. You need to make a small change to one Moodle core file to make this work (the change is different between Moodle 1.9 & Moodle 2.0 - see the included README.txt for details).
  6. Add the block to a course (turn editing on, select 'Navigation Buttons' from the 'Blocks - Add' menu)
  7. Customise the button appearance by clicking on 'Edit the Navigation Button settings' in the newly created block.
  8. Check the message at the bottom of the screen (under the 'Save changes' button) - it should read "Navbuttons self-test: required core modifications have been completed successfully". If not, then go back to step 5 above and check carefully.

Note: The block is only visible to users who are able to edit courses modules. Deleting the block will remove the navigation buttons (they can also be disabled through the settings).

For a quick demo, there is a screencast available here:

Screenshots

Screenshot #0

Contributors

Davo
Davo Smith (Lead maintainer)
Please login to view contributors details and/or to contact them

Comments RSS

Comments

  • Davo
    Wed, May 20, 2020, 7:07 PM
    Antonio - you could probably open up the file footer.php in the plugin and remove the lines: if (!$mod->uservisible) { continue; }

    That would mean that the next activity in the course is linked to, even if it is hidden or not available due to conditional restrictions, but that will lead to lots of error screens if the activity is still not available to the user after they've clicked on the link (so hiding an activity in the course would lead to everyone getting an error when reaching it, rather than just skipping over it to get to the next activity).

    An alternative might be more complex code that refreshes the buttons via javascript once the activity is complete, but that is beyond the scope of what I'd be able to do in my spare time (maybe could be tackled in work time, if you had a budget to pay for it).
  • Davo
    Tue, Jun 16, 2020, 12:56 AM
    Checks suggest this is still working fine with Moodle 3.9.
  • Picture of Aysenur Kazokoglu
    Thu, Sep 24, 2020, 8:37 PM
    hi,

    in our moodle with adaptable as theme, the plugin isn't working properly. as i understand the readme file correctly, we have to change the file renderers.php from the theme folder. in this file the lines connected to the footer are:

    public function get_footer_blocks($layoutrow = 'footerlayoutrow') {
    global $PAGE, $OUTPUT;
    $fields = array();
    $blockcount = 0;
    $style = '';

    if (!$this->get_footer_visibility()) {
    return '';
    }

    $output = '
    ' . $OUTPUT->course_footer() . '
    ';

    for ($i = 1; $i <= 3; $i++) {
    $footerrow = $layoutrow . $i;
    $footerrow = $PAGE->theme->settings->$footerrow;
    if ($footerrow != '0-0-0-0') {
    $fields[] = $footerrow;
    }
    }

    foreach ($fields as $field) {
    $output .= '
    ';
    $vals = explode('-', $field);
    foreach ($vals as $val) {
    if ($val > 0) {
    $blockcount ++;
    $footerheader = 'footer' . $blockcount . 'header';
    $footercontent = 'footer' . $blockcount . 'content';
    if (!empty($PAGE->theme->settings->$footercontent)) {
    $output .= '
    ';
    if (!empty($PAGE->theme->settings->$footerheader)) {
    $output .= '

    ';
    $output .= $OUTPUT->get_setting($footerheader, 'format_text');
    $output .= '

    ';
    }
    $output .= $OUTPUT->get_setting($footercontent, 'format_html');
    $output .= '
    ';
    }
    }
    }
    $output .= '
    ';
    }
    $output .= '
    ';
    return $output;
    }

    which line do we need to change to put these lines:

    require_once($CFG->dirroot.'/blocks/navbuttons/footer.php');
    $output = draw_navbuttons().$this->container_end_all(true);

    thanks for any support!
  • Davo
    Thu, Sep 24, 2020, 9:58 PM
    As stated in the README, you need to change the line $this->container_end_all(true). I don't know where that occurs in theme_adaptable, but it will be in a function called footer(), not get_footer_blocks(). If there is no footer() function in theme_adaptable, then you need to make the change to the core version of footer() instead.
  • Picture of Aysenur Kazokoglu
    Thu, Sep 24, 2020, 11:37 PM
    in the renderers.php, there is the line $output = $this->container_end_all(true); in the function public function footer() {global $CFG;
    i have to replace $output = $this->container_end_all(true); with $output = draw_navbuttons().$this->container_end_all(true);
    where do i have to add? require_once($CFG->dirroot.'/blocks/navbuttons/footer.php');
    is this correct?
  • Davo
    Thu, Sep 24, 2020, 11:39 PM
    As it says in the instructions, replace the line:
    $output = $this->container_end_all(true);

    With the lines:

    require_once($CFG->dirroot.'/blocks/navbuttons/footer.php');
    $output = draw_navbuttons().$this->container_end_all(true);

  • Picture of Aysenur Kazokoglu
    Fri, Sep 25, 2020, 3:49 PM
    hi davo, thanks, the navigation buttons are now available, but what do we need to do to remove the default navigation, next activity, previous activity. currently we have a double navigation displayed.
  • Davo
    Fri, Sep 25, 2020, 3:51 PM
    I cannot offer any advice about removing the default navigation - that is something you'll have to post on the forums or figure out for yourself (my plugin long predates the default navigation, so I've never looked into it).
  • Picture of Aysenur Kazokoglu
    Fri, Sep 25, 2020, 4:20 PM
    ok, thanks
  • Picture of Christian Wig
    Fri, Oct 2, 2020, 4:08 AM
    This seems like a great plugin!

    But I have one question: Is there a way to DISABLE the rendering with the navigation buttons on a SPECIFIC page? I have a problem with the embed_question plugin, which generates an embedded page based upon a quiz question. Then the buttons are rendered twice, both for the embedded page and 'real' page. And the buttons for the embedded pages do not work as wanted, as they change the contents only of the embedded section.
  • Davo
    Fri, Oct 2, 2020, 3:30 PM
    Christian, there aren't currently any settings for disabling the navigation buttons on a specific page. You can turn them off for an activity type, or you can set them to only show once the activity is marked as 'complete' (for a quiz, you can set them to only show once an attempt has been submitted, if that helps at all).

    It is probably fairly straightforward to add a specific exception to not show using embed_question, but I've not tried that plugin, so I would need to find some time to try it out and see what happens (in the meantime, I'm happy to accept a simple patch that solves this problem, if you are able to look at the code in blocks/navbuttons/footer.php).
  • Picture of Christian Wig
    Sun, Oct 4, 2020, 7:44 PM
    Thanks for your reply, Davo! I think your navigation buttons make the user interface so much simpler, so I am (more!) willing to drop the use of embedded questions. smile

    But I really like the embedded question plugin as well, as it allows to just use ONE question from the question bank to reinforce the learning on a specific page, without the somewhat complex user interface of running a quiz (several steps: starting the quiz, submitting the quiz, confirming that you want to submit etc.).

    A problem vs. the navigation buttons is that the embedded question (to my knowledge!) does not 'behave' like a quiz or any other activity type, so it is not possible to use the functionality for behavior of the navigation buttons for specific activity types. It 'just' generates portions of a web page.

    I have access to the blocks/navbuttons/footer.php code, but adjusting this code is far beyond my competence in PHP. And regarding the embed_question plugin, I really do not know how use the tags that it generates in order to NOT generate nav buttons for this kind of (sub-)pages.

    In the HTML code the plugin generates an iframe with recognizable contents, like
  • Picture of Christian Wig
    Sun, Oct 4, 2020, 7:49 PM
    ... one more try to give you relevant portions of the iframe code generated by the embed_question plugin:
    iframe class="filter_embedquestion-iframe" ..."" title="Embedded question" src="https://.../filter/embedquestion/showquestion.php?...
  • Davo
    Sun, Oct 4, 2020, 8:33 PM
    Hi Christian - I've pushed a quick fix that should solve the problem (it certainly stops the buttons from appearing on embedded questions with my local install of Moodle). Please can you install the version from the 'Source control URL', above?
  • Picture of Christian Wig
    Sun, Oct 4, 2020, 9:31 PM
    What a fantastic service, Davo! And on a Sunday. smile Now the buttons work perfectly, also on a page with embedded questions. Thanks x1000!
Please login to post comments