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
Copy file name to clipboardExpand all lines: general/app/development/plugins-development-guide/index.md
+65Lines changed: 65 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -597,6 +597,17 @@ In the previous section, we learned about some of the existing options for handl
597
597
- Any other value — Your block will immediately call the method specified in `mobile.php` and it will use the template to render the block.
598
598
-`fallback` (optional) — This option allows you to specify a block to use in the app instead of your block. For example, you can make the app display the "My overview" block instead of your block in the app by setting `'fallback' => 'myoverview'`. The fallback will only be used if you don't specify a `method` and the `type` is different to `'title'` or `'prerendered'`. Supported from the 3.9.0 version of the app.
599
599
600
+
### Options only for CoreEnrolDelegate
601
+
602
+
-`enrolmentAction` (optional): The type of action done by the enrolment plugin. Defaults to 'browser'. Possible values:
603
+
-`browser` — When the user clicks to enrol, open a browser to perform the enrol in the browser. It doesn't require any JavaScript to work in the app.
604
+
-`self` — The user can self enrol in the app. Requires implementing the 'enrol' function in your JavaScript code.
605
+
-`guest` — Allows the user to enter the course as guest in the app. Requires implementing the 'canAccess' and 'validateAccess' functions in your JavaScript code.
606
+
-`infoIcons` (optional) — Icons related to the enrolment to display next to the course. If the icons need to be calculated dynamically based on the course you need to implement the function 'getInfoIcons' in your JavaScript code. Properties for each icon:
607
+
-`icon` (required) — The icon name. E.g. 'fas-credit-card'.
608
+
-`label` (required) — The label of the icon (for accessibility).
609
+
-`className` (optional) — A CSS class to add to the icon element.
610
+
600
611
## Delegates
601
612
602
613
Delegates can be classified by type of plugin. For more info about type of plugins, please see the [Types of plugins](#types-of-plugins) section.
@@ -678,6 +689,7 @@ These delegates require JavaScript to be supported. See [Initialisation](#initia
678
689
-`CoreFileUploaderDelegate`
679
690
-`CorePluginFileDelegate`
680
691
-`CoreFilterDelegate`
692
+
-`CoreEnrolDelegate` (added in 4.3 version of the app)
681
693
682
694
## Available components and directives
683
695
@@ -1631,6 +1643,59 @@ class AddonSingleActivityFormatHandler {
The `CoreEnrolDelegate` handler allows you to support enrolment plugins in the app. This example will show how to support a self enrol plugin, you can find an example of each type of plugin in the issue [MOBILE-4323](https://tracker.moodle.org/browse/MOBILE-4323).
1649
+
1650
+
Here's an example on how to create a prefetch handler using the JS returned by the main method:
1651
+
1652
+
```javascript
1653
+
constgetEnrolmentInfo= (id) => {
1654
+
// Get enrolment info for the enrol instance.
1655
+
// Used internally, you can use any name, parameters and return data in here.
1656
+
};
1657
+
1658
+
constselfEnrol= (method, info) => {
1659
+
// Self enrol the user in the course.
1660
+
// Used internally, you can use any name, parameters and return data in here.
The JavaScript API is only supported by the delegates specified in the [Templates downloaded on login and rendered using JS data](#templates-downloaded-on-login-and-rendered-using-js-data) section. This API allows you to override any of the functions of the default handler.
0 commit comments