diff --git a/docs/apis/subsystems/check/index.md b/docs/apis/subsystems/check/index.md index 2885b49617..861a456fff 100644 --- a/docs/apis/subsystems/check/index.md +++ b/docs/apis/subsystems/check/index.md @@ -225,6 +225,30 @@ https://github.com/moodle/moodle/blob/master/lib/classes/check/access/riskxss_re Some checks are by their nature asynchronous. For instance having moodle send an email to itself and then having it processed by the inbound mail handler to make it's properly configured (see [MDL-48800](https://tracker.moodle.org/browse/MDL-48800)). In cases like these please make sure the age or staleness of the check is shown in the summary, and you should also consider turning the result status into a warning if the result is too old. If appropriate make the threshold a configurable admin setting. +## Accessing checks externally + +Checks are exposed via a webservice `core_check_get_result`. + +The user accessing them must have the capability `moodle/site:getcheckresult`. This is separate from the site administration capability so that it's possible for external programs (such as a monitoring program) to connect to your Moodle site and read status checks, without giving them full site administration access. + +This has options to include/exclude details (as they may be slow to load) as well as render a HTML version of the result of the check. + +## Showing checks in admin settings. + +Even though checks will appear in the corresponding report pages, it may be useful to have these show up in admin settings close to where they may be actioned. For example, showing a LDAP connection check on the same page as the LDAP connection settings. + +Use the `admin_setting_check` class to easily add these. + +```php title="mod/myplugin/settings.php" +$settings->add(new admin_setting_check('myplugin/usefulcheck', (new \mod\myplugin\check\usefulcheck())->get_ref())); + +// Or with multiple instances of checks +$settings->add(new admin_setting_check('myplugin/usefulcheck1', (new \mod\myplugin\check\usefulcheck(1))->get_ref())); +$settings->add(new admin_setting_check('myplugin/usefulcheck2', (new \mod\myplugin\check\usefulcheck(2))->get_ref())); +``` + +The results of the check are fetched asynchronously using Ajax, so the page loading time is impacted as little as possible. + ## See also - [Performance overview](https://docs.moodle.org/en/Performance_overview) user docs