marinaglancy / moodle-format_flexsections

25 stars 25 forks source link

No visible summarytext on some / most sections displayed as link #81

Open VOOM108 opened 7 months ago

VOOM108 commented 7 months ago

In a new course on a new Moodle 4.1 out of the 5 sections that are displayed as links, only the first .course-content-item-content.collapse has a class of .show - I tried to remove the .collapse:not(.show) { display: none; } but since I cannot find a way to discern sections that are displayed on the course page from those displayed as links, that would remove the summarytext etc. from the sections that are to be displayed on the course page as well.

The class .show seems to be used for the expandable sections, but it should be added to all sections that are links, which it is not.

Plugin Version is: 4.0.6 2023122300

VOOM108 commented 7 months ago

I made a workaround, but it would be better to solve this natively of course.

<script>
document.addEventListener('DOMContentLoaded', function() {
    document.querySelectorAll('.flexsections > li').forEach(function(li) {
        // Check if the li element does NOT contain a collapsible toggle
        if (!li.querySelector('.course-section-header > div > div > a[data-toggle="collapse"]')) {
            // Find the .course-content-item-content within the li and add the 'show' class
            var contentItem = li.querySelector('.course-content-item-content');
            if (contentItem) {
                contentItem.classList.add('show');
            }
        }
    });
});
</script>