Administrators: This article is suitable for Moodle administrators and requires access to modify a plugin. Remember that these changes will be overwritten when you upgrade the plugin.

When using the Moodle Onetopic course format, you can sometimes have the issue that when a user selects a tab, the page reloads and the user is taken to the top of the page.

This is only an issue if you have section 0 set to ‘Visualization mode of section 0‘ as ‘Before tabs’ and you have a lot of content in section 0.

If you have a page with lots of content in section one. Clicking on the Tabs will take the user back to the top of the page instead of taking you down to the tabs menu.

To fix this issue, you will need to edit two lines of code.

I am using version 2018010606 of the Onetopic Course Format, so the line numbers may be different for you if you are using an earlier version of the Onetopic Course Format.

Find the file /courses/format/onetopic/renderer.php

Change line number 237 from

echo html_writer::start_tag('div', array('class' => 'single-section onetopic'));

to

echo html_writer::start_tag('div', array('id' => 'onetopictabs','class' => 'single-section onetopic'));

In the same file, change line number 299 from

$url = course_get_url($course, $section);

to

$url = course_get_url($course, $section)."#onetopictabs";

You can now save this file and test to make sure when you click on a tab using the Onetopic Course Format, that the browser scrolls down to the tabs.

Make sure you test this on a staging server first to make sure you made the changes correctly.

Any questions or thoughts, let me know.

[convertkit form=1092962]