You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
227
227
228
+
## Showing checks in admin settings
229
+
230
+
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.
231
+
232
+
Use the `admin_setting_check` class to easily add these.
233
+
234
+
```php title="mod/myplugin/settings.php"
235
+
$settings->add(
236
+
new admin_setting_check(
237
+
'myplugin/usefulcheck',
238
+
new \mod\myplugin\check\usefulcheck(),
239
+
),
240
+
);
241
+
242
+
// Or with multiple instances of checks.
243
+
$settings->add(
244
+
new admin_setting_check(
245
+
'myplugin/usefulcheck1',
246
+
new \mod\myplugin\check\usefulcheck(1),
247
+
),
248
+
);
249
+
$settings->add(
250
+
new admin_setting_check(
251
+
'myplugin/usefulcheck2',
252
+
new \mod\myplugin\check\usefulcheck(2),
253
+
),
254
+
);
255
+
```
256
+
257
+
The results of the check are fetched asynchronously using AJAX, so the page loading time is impacted as little as possible.
258
+
259
+
### Utilising as a plugin configuration check
260
+
261
+
Internally, the `admin_setting_check` class calls a webservice that will load the admin tree to find the check object it is linked to. Therefore it is possible to include checks here that are not included in your plugin's lib.php callback, or pass flags to your checks to change how they behave.
262
+
263
+
For example, a check might look like the following:
0 commit comments