Skip to content

Commit 2a44fbe

Browse files
committed
[docs] activity other purpose documentation
1 parent 07bf056 commit 2a44fbe

File tree

2 files changed

+20
-9
lines changed

2 files changed

+20
-9
lines changed

docs/apis/plugintypes/mod/_files/lib_description.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -61,22 +61,22 @@ function [modname]_supports($feature) {
6161

6262
:::tip
6363

64-
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:
64+
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.
65+
66+
Optionally, if your plugin fits in a secondary purpose, you should add the `FEATURE_MOD_OTHERPURPOSE` constant as well.
6567

6668
<details>
6769
<summary>View example</summary>
6870
<div>
6971

7072
```php
7173
function [modname]_supports(string $feature) {
72-
switch ($feature) {
73-
[...]
74-
case FEATURE_MOD_PURPOSE:
75-
return MOD_PURPOSE_XXXXXX;
76-
77-
default:
78-
return null;
79-
}
74+
return match ($feature) {
75+
// The rest of features should be listed here...
76+
FEATURE_MOD_PURPOSE => MOD_PURPOSE_COLLABORATION,
77+
FEATURE_MOD_OTHERPURPOSE => MOD_PURPOSE_COMMUNICATION, // Could be omitted if not needed.
78+
default => null,
79+
};
8080
}
8181
```
8282

docs/devupdate.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,17 @@ tags:
99

1010
This page highlights the important changes that are coming in Moodle 5.1 for developers.
1111

12+
## Activity modules: now activities can define a secondary purpose
13+
14+
<Since version="5.1" issueNumber="MDL-85598" />
15+
16+
From now on, activity modules can define two different features in their `PLUGINNAME_supports` function:
17+
18+
- `FEATURE_MOD_PURPOSE`: This is the mandatory main activity purpose, and also the one that will determine the activity's icon color.
19+
- `FEATURE_MOD_OTHERPURPOSE`: An optional secondary purpose to be used as an extra category in the activity chooser modal.
20+
21+
See the [Activity module support functions](./apis/plugintypes/mod#activity-module-support-functions) for further information.
22+
1223
## Code Structure
1324

1425
<Since version="5.1" issueNumber="MDL-83424" />

0 commit comments

Comments
 (0)