Category: Moodle

How to remove Moodle 4 site Home

Just a quick tip.

How to remove the site ‘Home‘ for logged in users in Moodle 4, when using the Moodle 4 BOOST theme

/* Hide the Home tab */
.primary-navigation li:nth-child(1) {
  display: none;
}

This can be added into the Raw SCSS text field in https://<Your-Moodle-site>/admin/settings.php?section=themesettingboost#theme_boost_advanced

Afterwards our Navigation bar now looks like this

Maybe on the full release of Moodle 4 there might be a toggle to remove it from the GUI as it is not useful to everyone.

Expect more of these nuggets to come as we work to releasing Moodle 4 to our users around June 2023

How to copy a Moodle theme

We needed to take a standard Moodle theme ‘Adaptable’, alter it and save that with a new name. This was so it then wasn’t accidentally overwritten with the unaltered standard ‘Adaptable’ theme if we ever had our site rebuilt by our hosting partners. This way we could also package up our extra custom CSS into the theme.

I very much doubt that this post will prove to be useful to you or anyone else.

I’m creating it so I don’t forget how I did it and can reference this in years to come.

Step 1 – Download a fresh copy of your chosen theme

This should give you a .zip file with the theme, unzip it somewhere on your machine.

Step 2 – Find and Replace – Find All

Get hold of a text editor like Notepad ++
In the menu click ‘Search’ / ‘Find in Files…’

Change the following options:

Find what: adaptable
Directory: C:\blah\blah\Adaptable theme 1.8\
Search Mode: Normal
Make sure ‘In all sub-folders‘ is ticked.
Click ‘Find All’

In my case this brings back 1773 hits in 69 files.

Step 3 – Replace in Files

Now you need to do a find and replace to replace the above

Use ‘Find in Files’ again
This time put in the new name of your theme in the ‘Replace with:’ field so lets say ‘adaptable_ray’.
*NOTE never use a minus in the name here xxxx-xxx as it will not work, use an underscore.
Make sure ‘Match case’ is ticked.
Now click ‘Replace in Files’

Step 4 – Theme displayed name

Now you need to Replace the actual displayed name of the theme

In the case of Adaptable this is ‘Adaptable’, so in the ‘Find what:’ field put in ‘Adaptable’ and ‘Replace with:’ ‘Adaptable-Ray’

Step 5 – Tweak JQuery settings

Because of step two you have changed the name of the main themes .js file, but not the actual name of the file. You can either edit /jquery/plugins.php

‘adaptable_ray’ => array(‘files’ => array(‘adaptable_ray.js’)),

To:

‘adaptable_ray’ => array(‘files’ => array(‘adaptable_v2_1_1_2.js’)),

Or Rename the file adaptable_v2_1_1_2.js to adaptable_ray_v2_1_1_2.js.js

Step 6 – Change the name of the Language file

Rename ‘adaptable_ray\lang\en\theme_adaptable.php’ to ‘theme_adaptable_ray.php’
And any subsequent language packs in \es etc folders.

Step 7 – Change settings files

Rename file ‘adaptable_ray\settings\adaptable_admin_setting_putprops.php’ to ‘adaptable_ray\settings\adaptable_ray_admin_setting_putprops.php’
and
‘adaptable_ray\settings\adaptable_admin_setting_getprops.php’ to ‘adaptable_ray\settings\adaptable_ray_admin_setting_getprops.php’

As well as any other file which starts with adaptable_
This is very version depended, ones I've found in Adaptable 3.0.5 for Moodle 3.9 are:
'settings/adaptable_admin_setting_configtemplate.php'
'templates/adaptable_admin_setting_configtemplate.mustache'
'templates/adaptable_admin_setting_configtemplate_nopreview.mustache'
'templates/adaptable_admin_setting_configtemplate_source.mustache'
'templates/adaptable_admin_setting_tabs.mustache'

These all become
'settings/adaptable_ray_admin_setting_configtemplate.php'
'templates/adaptable_ray_admin_setting_configtemplate.mustache'
'templates/adaptable_ray_admin_setting_configtemplate_nopreview.mustache'
'templates/adaptable_ray_admin_setting_configtemplate_source.mustache'
'templates/adaptable_ray_admin_setting_tabs.mustache'

Step 8 – Change Theme CSS name

Rename the main CSS file from ‘adaptable_ray/style/adaptable.css’ to ‘adaptable_ray/style/adaptable_ray.css’

or

Edit config.php and change the line $THEME->sheets = array( ‘adaptable_ray’,
to $THEME->sheets = array( ‘adaptable’,

Step 9 – Change the folder name

Now change the folder name to your new name in lowercase the same name as in Step 3.

Step 9a – Noticed in Moodle 3.10

Search like above for THEME_ADAPTABLE and replace this with THEME_ADAPTABLE_RAY or whatever your theme is called, do a replace in files

Step 10 – Zip up the theme

Zip up the theme as ‘adaptable_ray.zip’

Step 11 – Deploy the theme

Deploy the theme to your local installation and check it all works.

Moodle alerts using New Relic Query Language NRQL

I’ve been using New Relic to monitor our Moodle installation for the past 4 years. Recently New Relic have added some lovely alerting features which use their NRQL language to trigger any application issues.

With my recent change of job roles (Technology Enhanced Learning Manager) I have now being using NR on a daily basis, trying to get the best out of it.

Whilst reading through the help on NRQL alerting available on NR site, NR blog and in the NR forums I hit upon a few issues.

What if you know your site performs early morning syncs with other systems and these syncs will always trigger your alerts. Something that I didn’t want happening. How can you stop this from happening?

This is how I managed it:

NRQL Database spike alert : ignores 2 to 4:59 am

SELECT average(databaseDuration) * 100 FROM Transaction WHERE hourOf(timestamp) IN ('0:00','1:00','5:00','6:00','7:00','8:00','9:00','10:00','11:00','12:00','13:00','14:00','15:00','16:00','17:00','18:00','19:00','20:00','21:00','22:00','23:00') with TIMEZONE 'Europe/London'

The above is checking average database duration in the Transaction only within the hours 0:00-01:59 skipping 02:00 to 4:59 and checking during 05:00-23:59. The * 100 gives the query value the same representation as what you can see in the APM / Database section.

NRQL Errors > 20% : ignores 2 to 4:59 am

SELECT filter(count(*), WHERE `error.message` is not null)*100 / filter(count(*), WHERE duration is not null) as 'Errors' from Transaction, TransactionError WHERE hourOf(timestamp) IN ('0:00','1:00','5:00','6:00','7:00','8:00','9:00','10:00','11:00','12:00','13:00','14:00','15:00','16:00','17:00','18:00','19:00','20:00','21:00','22:00','23:00') with TIMEZONE 'Europe/London'

The above is converting the query value into the same as what you see when looking at the Error rate on the APM / Overview. This is checking in the Transaction only within the hours 0:00-01:59 skipping 02:00 to 4:59 and checking during 05:00-23:59.

NRQL APDEX < 0.5 for 2 minutes

SELECT apdex(duration, 0.5) FROM Transaction WHERE hourOf(timestamp) IN ('0:00','1:00','2:00','3:00','4:00','5:00','6:00','7:00','8:00','9:00','10:00','11:00','12:00','13:00','14:00','15:00','16:00','17:00','18:00','19:00','20:00','21:00','22:00','23:00') with TIMEZONE 'Europe/London'

The above is converting the query value into the same as what you see when looking at the Apdex score APM / Overview. This is checking in the Transaction within all 24hrs in a day.

I’ve got this set to only trigger if the duration is longer than 2 minutes as this can trigger in the early am. When using the threshold type of static and query value below 0.5 you cannot use ‘hourOf(timestamp) IN’ and skip some hours as those hours will trigger as zero which will throw the alert.

When I first tried setting up these alerts I was using ‘hourOf(timestamp) NOT IN’ rather than ‘hourOf(timestamp) IN’ it was thanks to a NR support person who helped me figure out that ‘NOT IN’ wasn’t working correctly.

Hopefully you can get some use out of the above, please leave any examples in the comments below.