General developer forum

 
 
Anne Krijger
Sanity check after my module is installed
Group Particularly helpful Moodlers

I was wondering if it is possible to do a sanity check after the custom module I've written is installed.

For example for a module that exposes a webservice to work, the webservice functionality and the correct protocol must be enabled as well as the correct permissions set.

What I would like to do is do a check after my custom module is installed and if any of the checks fails show some text outlining the problems and making suggestions as what to change.

Ideally I would also like to have a 'do sanity check' button somewhere that would allow an admin to check if all requirements for using my module are met.

I didn't find any reference in the dev docs of where or how I could implement this.

As always, any suggestions are welcomed.

Anne.

 
Average of ratings: -
Tim at Lone Pine Koala Sanctuary
Re: Sanity check after my module is installed
Group DevelopersGroup Documentation writersGroup Particularly helpful Moodlers

For qtype_stack, we made a healthcheck script, accessible via the admin menu, that does the required sanity checks:

https://github.com/maths/moodle-qtype_stack/blob/master/settings.php#L34

https://github.com/maths/moodle-qtype_stack/blob/master/healthcheck.php

 
Average of ratings:Useful (1)
Anne Krijger
Re: Sanity check after my module is installed
Group Particularly helpful Moodlers

Hi Tim,

The addition to the admin page I should have thought of myself smile
I've only used it for text fields thus far, but there's nothing stopping me from adding a button or url.

I did some more digging through the code, but as far as I can see there is no 'hook' available that I could use to run the check automatically after the module is installed.
upgrade_plugins_modules(...) does have an endcallback reference, but this is only called from upgrade_noncore(..) where endcallback is set to 'print_upgrade_part_end'.

Anne.

 
Average of ratings: -
Tim at Lone Pine Koala Sanctuary
Re: Sanity check after my module is installed
Group DevelopersGroup Documentation writersGroup Particularly helpful Moodlers

No, there is no way to automate it. You need to assume that administrators using your plugin are sensible.

 
Average of ratings: -
Anne Krijger
Re: Sanity check after my module is installed
Group Particularly helpful Moodlers

Unfortunately I've had some bad experiences in the past.
One admin once only executed the 1st 4 steps of an 11 step update and then went home...

Having a sanity check in the admin pages should at least make it easier to figure out if there is a deployment issue.

 
Average of ratings: -