How to desactivate the course index ?

How to desactivate the course index ?

by Francis Vendrell -
Number of replies: 21
Hello,

I have updated Moodle 3.10.6 to Moodle 4.1.4. I use theme Adaptable v 401.1.5

The course index appears now per default on the left of some pages (not all). I'd like to disable it on all pages, but I can't find a way to do it, despite intensive searching.
This is all the more strange given that this feature was introduced in Moodle 4.2 and should thus not affect Moodle 4.1 !

The problem seems to be related to the theme Boost, on which the theme Adaptable is based. I am using Boost V 2022112800.

All help is welcome!

Average of ratings: -
In reply to Francis Vendrell

Re: How to desactivate the course index ?

by Mary Cooch -
Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Testers Picture of Translators
Hello there. Sorry the course index was new in 4.0 not 4.2 (I have updated the docs) So it is present in 4.1 as well.
Average of ratings:Useful (1)
In reply to Francis Vendrell

Re: How to desactivate the course index ?

by Gareth J Barnard -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers
There is no setting to deactivate the course index in Adaptable.
In reply to Francis Vendrell

Re: How to desactivate the course index ?

by Rick Jerz -
Picture of Particularly helpful Moodlers Picture of Testers
In my Moodle 4.2 using Boost, I use the CSS shown below. Gareth would know if this CSS would work in Adaptable.

/* Remove the left-side Course Index */
.drawer-toggles .drawer-left-toggle .btn {
display: none;
}
In reply to Rick Jerz

Re: How to desactivate the course index ?

by Francis Vendrell -
Hello,

Thank you for your answers !
As for me, I modified the code as follows:
In theme/adaptable/layout/includes/courseindexheader.php, line 33, remplace
$courseindexopen = (get_user_preferences('drawer-open-index', true) == true);
by
$courseindexopen = (get_user_preferences('drawer-open-index', true) == false);

In reply to Francis Vendrell

Re: How to desactivate the course index ?

by Rick Jerz -
Picture of Particularly helpful Moodlers Picture of Testers
Your solution, if it works, is fine. However, managing code changes is a little more difficult than managing CSS.
In reply to Rick Jerz

Re: How to desactivate the course index ?

by Francis Vendrell -
Yes, indeed, it's always better to modify CSS rather than the code.
The CSS solution above doesn't seem to work for all Moodle pages. I tested it and it failed in at least one particular case. There seem to be a lot of CSS elements involved here and I spent a lot of time trying to find the right ones... That's why I finally opted to modify the code.
The solution proposed in the code is simple. Since the index only appears once connected, the solution aims to deactivate the index once connected (if I have understood well...).
Best regards
In reply to Francis Vendrell

Re: How to desactivate the course index ?

by Rick Jerz -
Picture of Particularly helpful Moodlers Picture of Testers
The only problem I have had with that CSS is that the first time a new student accesses the course, the "course index" might show.  But as soon as the student does anything, it seems to disappear.  This is a minor issue for me.
 
Your code could be fine. You must remember to redo it every time you upgrade your Moodle.
In reply to Francis Vendrell

Re: How to desactivate the course index ?

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
This has been discussed in very many places, I lost touch. MDL-75683 is a recent one. The exact issue of that item is not the course index. But it appears in the comments towards the end. (Hopefully, it is not the End of it.)
In reply to Visvanath Ratnaweera

Re: How to desactivate the course index ?

by Francis Vendrell -
Thank you Visvanath for you suggestion.
As suggested, I have tested to replace in theme/boost/config.php and theme/adaptable/config.php

$THEME->usescourseindex = true;
to
$THEME->usescourseindex = false;

but it didn't work.

As far as I can tell, what works is to replace in theme/adaptable/layout/includes/courseindexheader.php, line 33,
$courseindexopen = (get_user_preferences('drawer-open-index', true) == true);
by
$courseindexopen = (get_user_preferences('drawer-open-index', true) == false);

AND to add in the adaptable CSS (as suggested by Rick):

/* Remove the left-side Course Index */
.drawer-toggles .drawer-left-toggle .btn {
display: none;
}

Hopefully there will be a way in the future to enable/disable the course index in the adaptable parameters.
In reply to Francis Vendrell

Re: How to desactivate the course index ?

by Rick Jerz -
Picture of Particularly helpful Moodlers Picture of Testers
The solution is for the Moodle developers to provide another Moodle setting, probably at the course level, Enable/Disable Course index. But the Moodle developers seem to like the course index, so adding a setting seems unlikely. However, you could create a feature request in Tracker (if one doesn't already exist). Until then, I live with the CSS modification.

I am not opposed to code changes. As mentioned earlier, you must remember to make this change whenever upgrading.

One more alternative might be to create your own theme. I cannot help with that, but others here on Moodle.org might be able to help.
Average of ratings:Useful (1)
In reply to Rick Jerz

Re: How to desactivate the course index ?

by Francis Vendrell -
Yes indeed !
I have just noticed that some course formats, such as "Designer" and "Flexible sections", allow you to disable/enable the course index. This feature should thus be added to the core course formats... !
In reply to Francis Vendrell

Re: How to desactivate the course index ?

by Rick Jerz -
Picture of Particularly helpful Moodlers Picture of Testers

Consider creating a Tracker item for this idea.  (I am not sure if a Tracker item already exists.)

In reply to Rick Jerz

Re: How to desactivate the course index ?

by Francis Vendrell -
In reply to Francis Vendrell

Re: How to desactivate the course index ?

by Rick Jerz -
Picture of Particularly helpful Moodlers Picture of Testers

Great.  This might get the ball rolling.  I voted for it.

Average of ratings:Useful (1)
In reply to Francis Vendrell

Re: How to desactivate the course index ?

by Rick Jerz -
Picture of Particularly helpful Moodlers Picture of Testers
Francis, I happened to return to this issue of making sure that the course index is closed. Interestingly, I discovered exactly what you had discovered, that "$courseindexopen = (get_user_preferences('drawer-open-index', true) == false);" is what is needed.

I make this change with a script file I use when upgrading my Moodle. This "SED" command (SED exists on many Linux servers" is what I use. Sometimes this SED command will need to be slightly modified for a version of Linux (like MacOS).

I wanted to share this as a temporary fix.

# Do this replacement to remove the courseindex block
# $courseindexopen = (get_user_preferences('drawer-open-index', true) == true);
echo "Modify theme to not display the courseindex."
sed -i 's/true) == true/true) == false/' yourmoodlelocation/theme/boost/layout/drawers.php
In reply to Rick Jerz

Re: How to desactivate the course index ?

by Antonio Beermann -

Hi,

just wanted to leave this for people who use their own child theme and do not want to remove the course-index completly, but want to hide it (close) by default.

I just remove the following lines from the template you want to modify:

just remove or mark the lines check for the usersetting in the proper layout e.g. columns2.php in the layout folder

the drawer will than be as you decide (false or true) but still be adjustable by the user each time the side is loaded

/* if (isloggedin()) { $navdraweropen = (get_user_preferences('drawer-open-nav', 'true') == 'true'); } else { $navdraweropen = false; }*/ $navdraweropen = false;

not perfect, but easy to do and calms down those who are in need of it.

In reply to Antonio Beermann

Re: How to desactivate the course index ?

by Gareth J Barnard -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers
That's the wrong code! Its for the navigation drawer 'drawer-open-nav' not the course index 'drawer-open-index' drawer. Ultimately its a matter of looking for the latter to be false and '$courseindex = core_course_drawer();' to have '$courseindex' as false.
In reply to Gareth J Barnard

Re: How to desactivate the course index ?

by Rick Jerz -
Picture of Particularly helpful Moodlers Picture of Testers
Thanks Gareth and Antonio.

I discovered that my fix didn't quite remove the courseindex. Here is my code that seems to work. Again, I run this code from a script file.

echo "Modify Boost drawers.php file to not display the courseindex."
sed -i 's/(get_user_preferences('drawer-open-index', true) == true)/false/' $mdupcodedir$mdupcodename/theme/boost/layout/drawers.php
In reply to Gareth J Barnard

Re: How to desactivate the course index ?

by Antonio Beermann -

Sorry! 🤦‍♂️ Thank you for checking! We do this in different themes in different flavours (both drawers, custom navigation and our own elements) - It seems I mismatched some code pieces

In reply to Francis Vendrell

Re: How to desactivate the course index ?

by Jim Johnson -
Try using this custom css to prevent it from showing at all.

/* Hide the left-side drawer completely */
.drawer.drawer-left {
display: none !important;
 }

----
It still leaves the left side container, I am working to remove that now but this post only has a 30 minute edit window.  I will reply if I remove the left container as well.

In reply to Jim Johnson

Re: How to desactivate the course index ?

by John Nicholson -

I have the same need - hiding the course index - for Boost Union.  I am testing this CSS which seems to work:

/* Reduce left column course index to 40px - just enough to display the close "x" icon.  In case for some reason it is open */

.drawer.drawer-left {
    width: 40px;
    max-width: 285px;
    left: calc(-285px + -10px);
    visibility: hidden;
}

/* Hide the left "open course index" button*/

.drawer-toggles .drawer-left-toggle {
    left: 0;
    display: none;
}

I am adding this custom CSS in a Boost Union "Flavor" so that I can apply it only to a specific category of courses.  

John