4.1 Topics Format

4.1 Topics Format

by Blair F. -
Number of replies: 3
Picture of Particularly helpful Moodlers

I just happened to notice that the new 4.1 Topics format, which is now collapsible, starts out in the fully expanded position. Is there a way to set it so that when a course is visited for the first time, the topics are collapsed? I haven't been able to find anything.

Average of ratings: Useful (1)
In reply to Blair F.

Re: 4.1 Topics Format

by Bob Gilmore -
Picture of Particularly helpful Moodlers
As far as Im aware, there isn't from within the Moodle UI. You can kinda hack it into any courses if you need to, but it's a bit ugly.

You first need to change your user preferences to use the 'plain text area' text editor. This is so Atto/Tiny doesn't strip out any of the code you write.

On the course in question, edit the general section / section-0 and make sure the summary text area is using HTML format. Then, paste the following code into the text area:

<script>
addEventListener('load', (event) => { 
if( document.getElementById('collapsesections').getAttribute('aria-expanded') === 'true') {
   setTimeout( () => { document.getElementById('collapsesections').click(); }, 1000) ;
   }
} );
</script>
This check to see if the document is fully loaded and then if the collapse sections element is not already set to collapsed. It then clicks this element after a 1 second delay (Im unsure exactly why we need the 1 sec delay - Ive asked elsewhere to see if I can find a more elegant solution).

Once you've checked that it works, you can change your editor back to Atto/Tiny, but will need to return to the plain text area if you want to change the code for any reason.

Obviously this is on a course by course basis. You should be able to perform the save using the Site Admin > Appearance > Additional HTML > Within HEAD section, although I haven't tested this.

As an aside, the topics / weekly course formats really need this option built into their settings (i.e. start collapsed) as well as an in-between where the section summary is shown, but the activities are collapsed. Also, give me a setting to not show the general / topic-0 on every page when one section per page is selected!
Average of ratings: Useful (1)
In reply to Bob Gilmore

Re: 4.1 Topics Format

by Sally Hanford -
Picture of Testers

Have any accessibility issues been reported for Topics format in Moodle 4.1? In our dev install, folk have noted that using keyboard shortcuts to navigate a module does not work as expected and is 'erratic' - I am trying to replicate but so far it works fine for me. Am I right in assuming that Topics format in Moodle core 4.1 passed WCAG accessibility testing?