Skip to content

Commit

Permalink
[docs] check: add webservice and admin setting docs
Browse files Browse the repository at this point in the history
New features as part of MDL-67898
  • Loading branch information
matthewhilton committed Sep 26, 2023
1 parent df2a305 commit ef6af6e
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions docs/apis/subsystems/check/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit ef6af6e

Please sign in to comment.