From 2a44fbea381daa700f89cccad1b3868224062cdc Mon Sep 17 00:00:00 2001 From: ferran Date: Tue, 26 Aug 2025 11:37:22 +0200 Subject: [PATCH] [docs] activity other purpose documentation --- .../plugintypes/mod/_files/lib_description.md | 18 +++++++++--------- docs/devupdate.md | 11 +++++++++++ 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/docs/apis/plugintypes/mod/_files/lib_description.md b/docs/apis/plugintypes/mod/_files/lib_description.md index daa8c49786..4cb032b7ee 100644 --- a/docs/apis/plugintypes/mod/_files/lib_description.md +++ b/docs/apis/plugintypes/mod/_files/lib_description.md @@ -61,7 +61,9 @@ function [modname]_supports($feature) { :::tip -To have your Activity plugin classified in the right Activity category, you must define the function `[modname]_supports` and add the `FEATURE_MOD_PURPOSE` constant: +To have your Activity plugin classified in the right Activity category, you must define the function `[modname]_supports` and add the `FEATURE_MOD_PURPOSE` constant. + +Optionally, if your plugin fits in a secondary purpose, you should add the `FEATURE_MOD_OTHERPURPOSE` constant as well.
View example @@ -69,14 +71,12 @@ To have your Activity plugin classified in the right Activity category, you must ```php function [modname]_supports(string $feature) { - switch ($feature) { - [...] - case FEATURE_MOD_PURPOSE: - return MOD_PURPOSE_XXXXXX; - - default: - return null; - } + return match ($feature) { + // The rest of features should be listed here... + FEATURE_MOD_PURPOSE => MOD_PURPOSE_COLLABORATION, + FEATURE_MOD_OTHERPURPOSE => MOD_PURPOSE_COMMUNICATION, // Could be omitted if not needed. + default => null, + }; } ``` diff --git a/docs/devupdate.md b/docs/devupdate.md index 06d7c35daa..1fd9b2a8d5 100644 --- a/docs/devupdate.md +++ b/docs/devupdate.md @@ -9,6 +9,17 @@ tags: This page highlights the important changes that are coming in Moodle 5.1 for developers. +## Activity modules: now activities can define a secondary purpose + + + +From now on, activity modules can define two different features in their `PLUGINNAME_supports` function: + +- `FEATURE_MOD_PURPOSE`: This is the mandatory main activity purpose, and also the one that will determine the activity's icon color. +- `FEATURE_MOD_OTHERPURPOSE`: An optional secondary purpose to be used as an extra category in the activity chooser modal. + +See the [Activity module support functions](./apis/plugintypes/mod#activity-module-support-functions) for further information. + ## Code Structure