Skip to content

Commit e32ac63

Browse files
authored
Merge branch 'main' into MDL85316
2 parents 5928204 + 0c24a0a commit e32ac63

File tree

13 files changed

+316
-5
lines changed

13 files changed

+316
-5
lines changed

docs/apis/core/comment/index.md

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
---
2+
title: Comment API
3+
tags:
4+
- comment
5+
---
6+
7+
The Comment API provides a standardized way to manage comments within Moodle. It allows developers to create, retrieve, update, and delete comments associated with various Moodle entities, such as courses, activities, and user submissions.
8+
9+
## Usage
10+
11+
The `\core_comment\manager` is responsible for handling all comment-related operations within Moodle. This includes rendering and managing comment data.
12+
13+
The instantiation of the comment class is done by a single arguments object that defines the context and other relevant information for the comment being created or managed.
14+
15+
The basic attributes for the argument object are:
16+
17+
- `context`: the `core\context` object the comment is associated with.
18+
- `component`: the name of the component the comment is related to.
19+
- `itemid`: optional, the ID of the item the comment is associated with.
20+
- `area`: optional, the area the comment is associated with.
21+
- `cm`: optional, the `core_course\cm_info` object.
22+
- `course`: optional, course object (will be loaded from context if not provided).
23+
24+
Optional attributes related to the comment area rendering:
25+
26+
- `client_id`: a unique id to identify the comment area (it will be auto-generated if not provided).
27+
- `autostart`: a boolean indicating whether the comment area should be automatically expanded.
28+
- `showcount`: a boolean indicating whether to show the comment count.
29+
- `displaycancel`: a boolean indicating whether to display a cancel button.
30+
- `notoggle`: a boolean indicating whether to disable toggling of the comment area.
31+
- `linktext`: a string to indicate alternative text for the show/hide link.
32+
33+
Once instantiated, the class provides simple methods to handle comment-related operations.
34+
35+
## Rendering a comment area
36+
37+
The manager class has an `output` method to get the comment area HTML. Here is a simple example of how to use it:
38+
39+
```php
40+
$args = (object) [
41+
'context' => \core\context\module::instance($cm->id),
42+
'component' => 'mod_data',
43+
'area' => 'database_entry',
44+
'itemid' => $entry->id,
45+
'cm' => $cm,
46+
];
47+
$comment = new \core_comment\manager($args);
48+
echo $comment->output();
49+
```
50+
51+
Additionally, the manager class offers methods to customize the default options for the comment area:
52+
53+
- `set_view_permission(bool $newvalue)`: Set the view permissions for the comment area.
54+
- `set_post_permission(bool $newvalue)`: Set the post permissions for the comment area.
55+
- `set_notoggle(bool $newvalue)`: Set the toggle option for the comment area.
56+
- `set_autostart(bool $newvalue)`: Set the autostart option for the comment area.
57+
- `set_displaycancel(bool $newvalue)`: Set the display cancel option for the comment area.
58+
- `set_displaytotalcount(bool $newvalue)`: Set the display total count option for the comment area.
59+
60+
## Retrieving comments
61+
62+
You can use the `get_comments()` method to fetch all comments associated with the defined context. The method has the following parameters:
63+
64+
- `int $page`: The page number to retrieve.
65+
- `int $sortdirection` (default `DESC`): The sorting for the comments.
66+
67+
The number of comments displayed per page is defined by the `$CFG->commentsperpage` configuration setting. The default value is 15.
68+
69+
There is also a `count` method to get the total number of comments for the defined context.
70+
71+
```php
72+
$comment = new \core_comment\manager($args);
73+
74+
$count = $comment->count();
75+
echo get_string('totalcomments', 'mod_myplugin', $count);
76+
77+
$comments = $comment->get_comments();
78+
foreach ($comments as $comment) {
79+
echo $comment->content;
80+
}
81+
```
82+
83+
## Add plugin control
84+
85+
Similar to files, when a plugin wants to use comments it must provide a callback method to validate the comment area is correct. To do so, they must implement a callback in their `lib.php` file, specifically in the `PLUGINNAME_comment_display` function.
86+
87+
This is an example of a possible callback for plugin `mod_myplugin`:
88+
89+
```php
90+
/**
91+
* Validate comment data before displaying comments
92+
*
93+
* @param stdClass $comment
94+
* @param stdClass $args
95+
* @return boolean
96+
*/
97+
function mod_myplugin_comment_display(stdClass $comments, stdClass $args): stdClass {
98+
if ($args->commentarea != 'entry_comments') {
99+
throw new comment_exception('invalidcommentarea');
100+
}
101+
if ($args->itemid != 0) {
102+
throw new comment_exception('invalidcommentitemid');
103+
}
104+
return $comments;
105+
}
106+
```
107+
108+
## Add and remove comments
109+
110+
The manager class provides several methods to add and remove comments:
111+
112+
- `add(string $content, int $format = FORMAT_MOODLE): stdClass`: Add a new comment with the given content and format.
113+
- `delete(int|stdClass $comment): bool`: Delete a specific comment.
114+
- `static delete_comments(stdClass $args): bool`: Delete all comments for the specified `context`, `itemid`, and `commentarea`.

docs/apis/core/hooks/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ If you define a hook which is _not_ in the `[component]\hook\*` namespace then y
126126

127127
namespace mod_example;
128128

129-
class hooks implements \core\hook\hook\discovery_agent {
129+
class hooks implements \core\hook\discovery_agent {
130130
public static function discover_hooks(): array {
131131
return [
132132
[
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
---
2+
title: Shortlinks
3+
tags:
4+
- Short link
5+
- Routing
6+
---
7+
8+
<!-- cspell:ignore shortlink -->
9+
<!-- cspell:ignore shortlinks -->
10+
<!-- cspell:ignore ALPHANUMEXT -->
11+
12+
Shortlinks are concise URLs that route to a fully-qualified URL in Moodle. Comprising of a smaller set of characters, their use is suitable for SMS, convenience, or where a longer URL would not be suitable.
13+
14+
## Requirements
15+
16+
Shortlinks require Moodle's routing system to be enabled and fully functioning as they have been fully integrated into the existing routing subsystem. Ensure routing is configured by following this [routing guide](https://docs.moodle.org/500/en/Configuring_the_Router).
17+
18+
## URL structure
19+
20+
A shortlink URL will be comprised of the following:
21+
22+
- Base domain
23+
- Route group of `s` or `p`
24+
- Shortcode (e.g. `X8fG56aa`)
25+
26+
A complete shortlink will look something like this: `http://yourmoodle.com/s/X8fG56aa`.
27+
28+
## Short codes
29+
30+
Short codes are unique identifiers at the end of a shortlink. The characters available for building short codes is limited to the extended alpha-numeric set (ALPHANUMEXT) with the the omission of ambiguous characters (i.e. upper case 'i' and lower case 'L').
31+
32+
## Generating shortlinks
33+
34+
Before a shortlink can be used, a shortlink will need to be generated. Shortlink generation is random and length can be specified when calling the relevant method.
35+
36+
There are two types of shortlinks:
37+
38+
- Public shortlinks
39+
- Private shortlinks
40+
41+
### Public
42+
43+
Public shortlinks can be accessed by anyone. Their use will be designated with a `/p/` in the URL.
44+
45+
```php
46+
$public = \core\di::get(\core\shortlink::class)->create_shortlink(
47+
component: $component,
48+
linktype: $linktype,
49+
identifier: $identifier,
50+
userid: 0,
51+
minlength: 4,
52+
maxlength: 4,
53+
);
54+
```
55+
56+
### Private
57+
58+
Private shortlinks are tied to a specific user or set of users. Their use will be designated with a `/s/` in the URL.
59+
60+
```php
61+
$private = \core\di::get(\core\shortlink::class)->create_shortlink_for_users(
62+
component: $component,
63+
linktype: $linktype,
64+
identifier: $identifier,
65+
userids: $userids,
66+
minlength: 4,
67+
maxlength: 4,
68+
);
69+
```
70+
71+
## Using shortlinks
72+
73+
Each component using shortlinks will need to have a `shortlink_handler` class. There are two methods that the implemented interface requires:
74+
75+
- `get_valid_linktypes()`
76+
- `process_shortlink()`
77+
78+
```php
79+
class shortlink_handler implements shortlink_handler_interface {
80+
#[\Override]
81+
public function get_valid_linktypes(): array {
82+
return [
83+
'view',
84+
];
85+
}
86+
87+
#[\Override]
88+
public function process_shortlink(
89+
string $type,
90+
string $identifier,
91+
): ?\core\url {
92+
return match ($type) {
93+
'view' => new \core\url('/mod/assign/view.php', [
94+
'id' => $identifier,
95+
]),
96+
default => null,
97+
};
98+
}
99+
}
100+
```
101+
102+
Assuming the shortlink has been generated, the above example would allow a shortlink URL of `http://yourmoodle.com/s/SHORTCODE` to map to `http://yourmoodle.com/mod/assign/view.php?id=IDENTIFIER`
103+
104+
## See also
105+
106+
- [Routing](../routing/index.md)

docs/devupdate.md

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,32 @@ Most Moodle tooling has already been updated to support this, but minor web serv
1919

2020
See the [Restructure documentation](./guides/restructure/index.md) for further information on some of the changes required.
2121

22-
## Course: activity chooser footer has been changed
22+
## Course format: activity chooser is now in core_courseformat
2323

2424
<Since version="5.1" issueNumber="MDL-85597" />
25+
The activity chooser logic and templates have been relocated from `core_course` to `core_courseformat`. This change may impact themes that override the activity chooser rendering, but it also enables format plugins to provide custom outputs and templates for activity chooser elements, similar to other course content components. For details on how format can override outputs, see the [overriding output classes from course format plugin page](http://localhost:3000/docs/5.1/apis/plugintypes/format#override-output-classes).s
26+
27+
**How to check if your plugin is affected:**
28+
29+
For theme plugins, review whether any of the following templates are overridden:
30+
31+
- `core_course/activitychooser` (now in `core_courseformat/activitychooser`)
32+
- `core_course/activitychooserbutton` (now in `core_courseformat/local/content/activitychooserbutton`)
33+
- Any template in `core_course/local/activitychooser` (now in `core_courseformat/local/activitychooser`)
34+
35+
Additionally, renderer methods for loading the activity chooser have changed. Check if your format or theme overrides the following method:
36+
37+
- `core_course_renderer::course_activitychooser` (no longer used)
38+
39+
**What you need to do:**
40+
41+
- Move any overridden templates or AMD modules to their new locations in `core_courseformat`.
42+
- Follow any deprecation notices for the activity chooser.
43+
44+
## Course format: activity chooser footer has been changed
45+
46+
<Since version="5.1" issueNumber="MDL-85597" />
47+
2548
The activity chooser UI now features a dedicated footer button for adding the selected activity to the course. The logic for managing the activity chooser footer has moved to `course/amd/src/local/activitychooser/dialogue.js`, which now controls the visibility of the back and add buttons based on the modal's content. This update may impact plugins that implement custom activity chooser footers.
2649

2750
**How to determine if your plugin is affected:**
@@ -43,3 +66,13 @@ The `maxsections` setting in course formats is now deprecated. Previously, this
4366
Although the `maxsections` setting remains available for now, it is marked as deprecated and will be removed in Moodle 6.0. Also, the `get_max_sections` from `core_courseformat\base` is also deprecated and will be removed in Moodle 6.0.
4467

4568
If your format plugin relies on `maxsections`, you should add a custom setting in your plugin to control section limits. For reference, see the week format plugin, which now uses its own setting for this functionality.
69+
70+
## Course format: new activity chooser rendering
71+
72+
<Since version="5.1" issueNumber="MDL-80295" />
73+
74+
The activity chooser in course formats has been refactored to use a new rendering approach. It now includes additional attributes such as `data-section-id` and `data-returnsectionid`, and the course renderer method for the activity chooser has changed.
75+
76+
This update primarily affects format plugins that customize section or activity card rendering. If your plugin calls `course_section_add_cm_control`, you should update it to use the new `section_add_cm_controls` method.
77+
78+
For themes that override activity chooser templates, ensure that the activity chooser button includes the required `data-section-id` and the `data-returnsectionid` attributes.

docs/guides/templates/index.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,15 @@ Templates can be overridden by a theme.
528528
1. Copy the `ratingui.mustache` file into the newly created `theme/timtam/templates/mod_wiki` and edit it.
529529
You should see your changes immediately if theme designer mode is on. Templates are cached just like CSS, so if you are not using theme designer mode you will need to purge all caches to see the latest version of an edited template. If the template you are overriding contains a documentation comment it is recommended to remove it. It will still show the documentation in the template library.
530530

531+
### Examples
532+
533+
| Path for original template | Component | Theme override path |
534+
| --- | --- | --- |
535+
| `public/blocks/myoverview/templates/view-summary.mustache` | `block_myoverview` | `public/theme/mytheme/templates/block_myoverview/view-summary.mustache` |
536+
| `public/group/templates/group_details.mustache` | `core_group` | `public/theme/mytheme/templates/core_group/group_details.mustache` |
537+
| `public/lib/templates/modal.mustache` | `core` | `public/theme/mytheme/templates/core/modal.mustache` |
538+
| `public/theme/boost/templates/navbar.mustache` | `theme_boost` | `public/theme/mytheme/templates/theme_boost/navbar.mustache` |
539+
531540
## Documenting the templates
532541

533542
Theme designers need to know the limits of what they can expect to change without breaking anything. Also, correctly documented templates can be previewed in the "Template library" tool shipped with Moodle.

general/development/policies/accessibility.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,19 @@ An overview of Moodle LMS' conformance with the [WCAG 2.1](https://www.w3.org/TR
9393

9494
An overview of Moodle Workplace's conformance with the [WCAG 2.1](https://www.w3.org/TR/WCAG21/) guidelines can be found in our [accessibility conformance report](https://docs.moodle.org/en/Moodle_Workplace_VPAT#WCAG_2.x_report).
9595

96+
<!-- cspell:ignore IAAP -->
97+
<!-- cspell:ignore credly -->
98+
99+
## IAAP membership
100+
101+
Moodle is committed to delivering solutions that make learning accessible to all. To demonstrate this commitment, aside from regular accessibility audits of its products, [Moodle joined the International Association of Accessibility Professionals (IAAP)](https://www.accessibilityassociation.org/) in June 2025.
102+
103+
This membership also provides our teams access to accessibility-related resources, training, and a global network of accessibility professionals.
104+
105+
<!-- markdownlint-disable no-inline-html -->
106+
107+
<div data-iframe-width="150" data-iframe-height="270" data-share-badge-id="1f6cd789-8f79-488f-9d85-d72265ed1d6b" data-share-badge-host="https://www.credly.com"></div><script type="text/JavaScript" async src="//cdn.credly.com/assets/utilities/embed.js"></script>
108+
96109
## Authoring features
97110

98111
One of Moodle's biggest features is its ability to create and share content to other users.

general/development/process/testing/qa.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Would you like to help with QA testing? If so, please make sure you have created
1919

2020
## Running tests
2121

22-
1. Go to the [Moodle QA testing dashboard](https://moodle.atlassian.net/secure/Dashboard.jspa?selectPageId=11454) and choose a test from the list of current QA cycle open issues. When viewing a test, if you wish, you can click the 'Assign to me' link on the right, so that nobody else chooses the same test to run. (If you then find you are unable to run the test, you can click the Assign button and set the assignee as 'Unassigned'.) Please note:
22+
1. Go to the [Moodle QA testing dashboard](https://moodle.atlassian.net/jira/dashboards/10612) and choose a test from the list of current QA cycle open issues. When viewing a test, if you wish, you can click the 'Assign to me' link on the right, so that nobody else chooses the same test to run. (If you then find you are unable to run the test, you can click the Assign button and set the assignee as 'Unassigned'.) Please note:
2323
- Only assign an issue to yourself which no one else is testing (Assignee = Unassigned).
2424
- Only assign one issue at a time unless you plan to test a number of related issues within the next 24 hours. In other words, don't assign several issues to yourself then do nothing for several days. ;-)
2525
- The label `test_server_required` indicates issues that can't be tested on the QA testing site. The label `credentials_required` indicates that credentials such as an OAuth 2 service client ID and secret are required.

versioned_docs/version-4.1/guides/templates/index.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,15 @@ Templates can be overridden by a theme.
528528
1. Copy the `ratingui.mustache` file into the newly created `theme/timtam/templates/mod_wiki` and edit it.
529529
You should see your changes immediately if theme designer mode is on. Templates are cached just like CSS, so if you are not using theme designer mode you will need to purge all caches to see the latest version of an edited template. If the template you are overriding contains a documentation comment it is recommended to remove it. It will still show the documentation in the template library.
530530

531+
### Examples
532+
533+
| Path for original template | Component | Theme override path |
534+
| --- | --- | --- |
535+
| `blocks/myoverview/templates/view-summary.mustache` | `block_myoverview` | `theme/mytheme/templates/block_myoverview/view-summary.mustache` |
536+
| `group/templates/group_details.mustache` | `core_group` | `theme/mytheme/templates/core_group/group_details.mustache` |
537+
| `lib/templates/modal.mustache` | `core` | `theme/mytheme/templates/core/modal.mustache` |
538+
| `theme/boost/templates/navbar.mustache` | `theme_boost` | `theme/mytheme/templates/theme_boost/navbar.mustache` |
539+
531540
## Documenting the templates
532541

533542
Theme designers need to know the limits of what they can expect to change without breaking anything. Also, correctly documented templates can be previewed in the "Template library" tool shipped with Moodle.

versioned_docs/version-4.4/apis/core/hooks/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ If you define a hook which is _not_ in the `[component]\hook\*` namespace then y
126126

127127
namespace mod_example;
128128

129-
class hooks implements \core\hook\hook\discovery_agent {
129+
class hooks implements \core\hook\discovery_agent {
130130
public static function discover_hooks(): array {
131131
return [
132132
[

versioned_docs/version-4.4/guides/templates/index.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,15 @@ Templates can be overridden by a theme.
528528
1. Copy the `ratingui.mustache` file into the newly created `theme/timtam/templates/mod_wiki` and edit it.
529529
You should see your changes immediately if theme designer mode is on. Templates are cached just like CSS, so if you are not using theme designer mode you will need to purge all caches to see the latest version of an edited template. If the template you are overriding contains a documentation comment it is recommended to remove it. It will still show the documentation in the template library.
530530

531+
### Examples
532+
533+
| Path for original template | Component | Theme override path |
534+
| --- | --- | --- |
535+
| `blocks/myoverview/templates/view-summary.mustache` | `block_myoverview` | `theme/mytheme/templates/block_myoverview/view-summary.mustache` |
536+
| `group/templates/group_details.mustache` | `core_group` | `theme/mytheme/templates/core_group/group_details.mustache` |
537+
| `lib/templates/modal.mustache` | `core` | `theme/mytheme/templates/core/modal.mustache` |
538+
| `theme/boost/templates/navbar.mustache` | `theme_boost` | `theme/mytheme/templates/theme_boost/navbar.mustache` |
539+
531540
## Documenting the templates
532541

533542
Theme designers need to know the limits of what they can expect to change without breaking anything. Also, correctly documented templates can be previewed in the "Template library" tool shipped with Moodle.

0 commit comments

Comments
 (0)