Moodle PHP Documentation 5.1
Moodle 5.1dev (Build: 20250711) (9addea9f0ac)
|
Public Member Functions | |
__construct (protected moodle_database readonly moodle_database $db,) | |
Create a new AI manager. | |
change_provider_order (int $providerid, int $direction) | |
Change the order of the provider instance relative to other provider instances. | |
create_provider_instance (string $classname, string $name, bool $enabled=false, ?array $config=null, ?array $actionconfig=null,) | |
Create a new provider instance. | |
delete_provider_instance (provider $provider) | |
Delete the provider instance. | |
disable_provider_instance (provider $provider) | |
Disable a provider. | |
enable_provider_instance (provider $provider) | |
Enable a provider instance. | |
get_provider_instances (?array $filter=null) | |
Get a list of all provider instances. | |
get_provider_record (array $filter=[], int $strictness=IGNORE_MISSING) | |
Get single provider record according to the filter. | |
get_provider_records (?array $filter=null) | |
Get the provider records according to the filter. | |
get_providers_for_actions (array $actions, bool $enabledonly=false) | |
Given a list of actions get the provider instances that support them. | |
get_sorted_providers () | |
Get the configured ai providers from the manager. | |
is_action_available (string $actionclass) | |
Check if an action is available. | |
is_action_enabled (string $plugin, string $actionclass, int $instanceid=0) | |
Check if an action is enabled for a given plugin. | |
process_action (base $action) | |
Process an action. | |
set_action_state (string $plugin, string $actionbasename, int $enabled, int $instanceid=0) | |
Set the action state for a given plugin. | |
set_provider_config (array $data, string $plugin) | |
Sets config variable for given provider instance. | |
update_provider_instance (provider $provider, ?array $config=null, ?array $actionconfig=null) | |
Update provider instance. | |
update_provider_order (int $providerid, string|int $action) | |
Update the provider instance order configuration. | |
Static Public Member Functions | |
static | get_supported_actions (string $pluginname) |
Get the list of actions that this provider or placement supports, given the name of the plugin. | |
static | get_user_policy_status (int $userid) |
Get the user policy. | |
static | sort_providers_by_order (array $unsorted) |
Sorts provider instances by configured order. | |
static | user_policy_accepted (int $userid, int $contextid) |
Set the policy acceptance for a given user. | |
Protected Member Functions | |
call_action_provider (provider $provider, base $action) | |
Call the action provider. | |
core_ai\manager::__construct | ( | protected moodle_database readonly moodle_database | $db | ) |
Call the action provider.
The named provider will process the action and return the result.
provider | $provider | The provider to call. |
base | $action | The action to process. |
responses::response_base | The result of the action. |
core_ai\manager::change_provider_order | ( | int | $providerid, |
int | $direction ) |
Change the order of the provider instance relative to other provider instances.
When possible, the change will be stored into the config_log table, to let admins check when/who has modified it.
int | $providerid | The provider ID. |
int | $direction | The direction to move the provider instance. Negative numbers mean up, Positive mean down. |
bool | Whether the provider has been updated or not. |
core_ai\manager::create_provider_instance | ( | string | $classname, |
string | $name, | ||
bool | $enabled = false, | ||
?array | $config = null, | ||
?array | $actionconfig = null ) |
Create a new provider instance.
string | $classname | Classname of the provider. |
string | $name | The name of the provider config. |
bool | $enabled | The enabled state of the provider. |
array | null | $config | The config json. |
array | null | $actionconfig | The action config json. |
provider |
core_ai\manager::delete_provider_instance | ( | provider | $provider | ) |
Delete the provider instance.
provider | $provider | The provider instance. |
bool |
core_ai\manager::disable_provider_instance | ( | provider | $provider | ) |
Disable a provider.
provider | $provider |
provider |
core_ai\manager::enable_provider_instance | ( | provider | $provider | ) |
Enable a provider instance.
provider | $provider |
provider |
core_ai\manager::get_provider_instances | ( | ?array | $filter = null | ) |
Get a list of all provider instances.
This method retrieves provider records from the database, attempts to instantiate each provider class, and returns an array of provider instances. It filters out any records where the provider class does not exist.
null | array | $filter | The database filter to apply when fetching provider records. |
array | An array of instantiated provider objects. |
core_ai\manager::get_provider_record | ( | array | $filter = [], |
int | $strictness = IGNORE_MISSING ) |
Get single provider record according to the filter.
array | $filter | The filterable elements to get the record from |
int | $strictness |
stdClass|false |
core_ai\manager::get_provider_records | ( | ?array | $filter = null | ) |
Get the provider records according to the filter.
array | null | $filter | The filterable elements to get the records from. |
array |
core_ai\manager::get_providers_for_actions | ( | array | $actions, |
bool | $enabledonly = false ) |
Given a list of actions get the provider instances that support them.
Will return an array of arrays, indexed by action name.
array | $actions | An array of fully qualified action class names. |
bool | $enabledonly | If true, only return enabled providers. |
array | An array of provider instances indexed by action name. |
core_ai\manager::get_sorted_providers | ( | ) |
Get the configured ai providers from the manager.
array |
|
static |
Get the list of actions that this provider or placement supports, given the name of the plugin.
string | $pluginname | The name of the plugin to get the actions for. |
array | An array of action class names. |
|
static |
Get the user policy.
int | $userid | The user id. |
bool | True if the policy was accepted, false otherwise. |
core_ai\manager::is_action_available | ( | string | $actionclass | ) |
Check if an action is available.
Action is available if it is enabled for at least one enabled provider.
string | $actionclass | The fully qualified action class name to be checked. |
bool |
core_ai\manager::is_action_enabled | ( | string | $plugin, |
string | $actionclass, | ||
int | $instanceid = 0 ) |
Check if an action is enabled for a given plugin.
string | $plugin | The name of the plugin. |
string | $actionclass | The fully qualified action class name to be checked. |
int | $instanceid | The instance id of the plugin. |
bool | Returns the configuration value of the action for the given plugin. |
core_ai\manager::process_action | ( | base | $action | ) |
Process an action.
This is the entry point for processing an action.
base | $action | The action to process. Action must be configured. |
responses::response_base | The result of the action. |
core_ai\manager::set_action_state | ( | string | $plugin, |
string | $actionbasename, | ||
int | $enabled, | ||
int | $instanceid = 0 ) |
Set the action state for a given plugin.
string | $plugin | The name of the plugin. |
string | $actionbasename | The action to be set. |
int | $enabled | The state to be set (e.g., enabled or disabled). |
int | $instanceid | The instance id of the instance. |
bool | Returns true if the configuration was successfully set, false otherwise. |
core_ai\manager::set_provider_config | ( | array | $data, |
string | $plugin ) |
Sets config variable for given provider instance.
array | $data | The data to set. |
string | $plugin | The plugin name. |
bool | true or exception. |
dml_exception |
|
static |
Sorts provider instances by configured order.
array | $unsorted | of provider instance objects |
array | of provider instance objects |
core_ai\manager::update_provider_instance | ( | provider | $provider, |
?array | $config = null, | ||
?array | $actionconfig = null ) |
Update provider instance.
provider | $provider | The provider instance. |
array | null | $config | the configuration of the provider instance to be updated. |
array | null | $actionconfig | the action configuration of the provider instance to be updated. |
provider |
core_ai\manager::update_provider_order | ( | int | $providerid, |
string|int | $action ) |
Update the provider instance order configuration.
int | $providerid | The provider ID. |
string | int | $action |
dml_exception |
|
static |
Set the policy acceptance for a given user.
int | $userid | The user id. |
int | $contextid | The context id the policy was accepted in. |
bool | True if the policy was set, false otherwise. |