Moodle PHP Documentation 4.4
Moodle 4.4.1 (Build: 20240610) (db07c09afc5)
|
Public Member Functions | |
can_run () | |
Informs whether this task can be run. | |
disable () | |
Disable the task. | |
enable () | |
Enable the task. | |
eval_cron_field ($field, $min, $max) | |
Take a cron field definition and return an array of valid numbers with the range min-max. | |
execute () | |
Performs the synchronisation of members. | |
get_component () | |
Getter for $component. | |
get_cron_lock () | |
Get the current lock for the entire cron. | |
get_day () | |
Getter for $day. | |
get_day_of_week () | |
Getter for $dayofweek. | |
get_disabled () | |
Getter for $disabled. | |
get_fail_delay () | |
Getter for $faildelay. | |
get_hostname () | |
Getter for $hostname. | |
get_hour () | |
Getter for $hour. | |
get_last_run_time () | |
Get the last run time for this scheduled task. | |
get_lock () | |
Get the current lock for this task. | |
get_minute () | |
Getter for $minute. | |
get_month () | |
Getter for $month. | |
get_name () | |
Get the name for this task. | |
get_next_run_time () | |
Get the next run time for this task. | |
get_next_scheduled_time (int $now=0) | |
Calculate when this task should next be run based on the schedule. | |
get_pid () | |
Getter for $pid. | |
get_run_if_component_disabled () | |
Override this function if you want this scheduled task to run, even if the component is disabled. | |
get_runtime () | |
Returns task runtime. | |
get_runtime_result () | |
Returns if the task has been running for too long. | |
get_timestarted () | |
Getter for $timestarted. | |
has_default_configuration () | |
Determine if this task is using its default configuration changed from the default. | |
replacement | is_blocking () |
is_component_enabled () | |
Informs whether the task's component is enabled. | |
is_customised () | |
Has this task been changed from it's default config? | |
is_enabled () | |
Checks whether the component and the task disabled flag enables to run this task. | |
is_overridden () | |
Has this task been changed from it's default config? | |
is_valid (string $field) | |
Informs whether the given field is valid. | |
replacement | set_blocking ($blocking) |
set_component ($component) | |
Setter for $component. | |
set_cron_lock (\core\lock\lock $lock) | |
Set the current lock for the entire cron process. | |
set_customised ($customised) | |
Set customised for this scheduled task. | |
set_day ($day) | |
Setter for $day. | |
set_day_of_week ($dayofweek, $expandr=true) | |
Setter for $dayofweek. | |
set_disabled ($disabled) | |
Setter for $disabled. | |
set_fail_delay ($faildelay) | |
Setter for $faildelay. | |
set_hostname ($hostname=null) | |
Setter for $hostname. | |
set_hour ($hour, $expandr=true) | |
Setter for $hour. | |
set_last_run_time ($lastruntime) | |
Set the last run time for this scheduled task. | |
set_lock (\core\lock\lock $lock) | |
Set the current lock for this task. | |
set_minute ($minute, $expandr=true) | |
Setter for $minute. | |
set_month ($month) | |
Setter for $month. | |
set_next_run_time ($nextruntime) | |
Set the next run time for this task. | |
set_overridden (bool $overridden) | |
Set the overridden value. | |
set_pid ($pid=null) | |
Setter for $pid. | |
set_timestarted ($timestarted=null) | |
Setter for $timestarted. | |
Static Public Member Functions | |
static | get_html_id (string $classname) |
Produces a valid id string to use as id attribute based on the given FQCN class name. | |
Public Attributes | |
replacement | : null |
Setter for $blocking. | |
replacement | : null |
Getter for $blocking. | |
const | DAYMAX = 31 |
Maximum day of month value. | |
const | DAYMIN = 1 |
Minimum day of month value. | |
const | DAYOFWEEKMAX = 6 |
Maximum dayofweek value. | |
const | DAYOFWEEKMAXINPUT = 7 |
Maximum dayofweek value allowed in input (7 = 0). | |
const | DAYOFWEEKMIN = 0 |
Minimum dayofweek value. | |
const | FIELD_DAY = 'day' |
Day-of-month field identifier. | |
const | FIELD_DAYOFWEEK = 'dayofweek' |
Day-of-week field identifier. | |
const | FIELD_HOUR = 'hour' |
Hour field identifier. | |
const | FIELD_MINUTE = 'minute' |
Minute field identifier. | |
const | FIELD_MONTH = 'month' |
Month field identifier. | |
const | HOURMAX = 23 |
Maximum hour value. | |
const | HOURMIN = 0 |
Minimum hour value. | |
const | MINUTEMAX = 59 |
Maximum minute value. | |
const | MINUTEMIN = 0 |
Minimum minute value. | |
const | MONTHMAX = 12 |
Maximum month value. | |
const | MONTHMIN = 1 |
Minimum month value. | |
const | NEVER_RUN_TIME = 7952342400 |
Time used for the next scheduled time when a task should never run. | |
replacement | reason: 'Blocking tasks are no longer supported' |
replacement | since: '4.4' |
Protected Member Functions | |
get_context_level_members (nrps_info $nrps, LtiServiceConnector $sc, LtiRegistration $registration) | |
Make a context-level memberships call. | |
get_members_from_resource_link (application_registration $appregistration, resource_link $resourcelink) | |
Make the NRPS service call and fetch members based on the given resource link. | |
get_next_scheduled_time_inner (int $now, array $validminutes, array $validhours, array $validdays, array $validdaysofweek, array $validmonths, int $originalyear=0) | |
Recursively calculate the next valid time for this task. | |
get_resource_link_level_members (nrps_info $nrps, LtiServiceConnector $sc, LtiRegistration $registration, resource_link $resourcelink) | |
Make a resource-link-level memberships call. | |
ltiuser_from_member (stdClass $user, stdClass $resource, resource_link $resourcelink, array $member) | |
Creates an lti user object from a member entry. | |
member_is_instructor (array $member) | |
Check whether the member has an instructor role or not. | |
should_sync_enrol ($syncmode) | |
Method to determine whether to sync enrolments or not. | |
should_sync_unenrol ($syncmode) | |
Method to determine whether to sync unenrolments or not. | |
sync_member_information (application_registration $appregistration, stdClass $resource, resource_link $resourcelink, array $members) | |
Performs synchronisation of member information and enrolments. | |
sync_profile_images () | |
Performs synchronisation of user profile images. | |
sync_unenrol_resourcelink (resource_link $resourcelink, stdClass $resource, array $syncedusers) | |
Process unenrolment of users for a given resource link and based on the list of recently synced users. | |
Protected Attributes | |
application_registration_repository | $appregistrationrepo |
$appregistrationrepo for fetching application_registration instances. | |
deployment_repository | $deploymentrepo |
$deploymentrepo for fetching deployment instances. | |
issuer_database | $issuerdb |
$issuerdb library specific registration DB required to create service connectors. | |
resource_link_repository | $resourcelinkrepo |
$resourcelinkrepo for fetching resource_link instances. | |
array | $userphotos = [] |
Array of user photos. | |
user_repository | $userrepo |
$userrepo for fetching and saving lti user information. | |
|
inherited |
Informs whether this task can be run.
bool | true when this task can be run. false otherwise. |
Reimplemented in cachestore_redis\task\ttl.
|
inherited |
Take a cron field definition and return an array of valid numbers with the range min-max.
string | $field | - The field definition. |
int | $min | - The minimum allowable value. |
int | $max | - The maximum allowable value. |
array(int) |
enrol_lti\local\ltiadvantage\task\sync_members::execute | ( | ) |
Performs the synchronisation of members.
Reimplemented from core\task\task_base.
|
inherited |
Getter for $component.
string |
|
protected |
Make a context-level memberships call.
nrps_info | $nrps | information about names and roles service endpoints and scopes. |
LtiServiceConnector | $sc | a service connector object. |
LtiRegistration | $registration | the registration |
array | an array of members. |
|
inherited |
Get the current lock for the entire cron.
core\lock\lock |
|
inherited |
Getter for $day.
string |
|
inherited |
Getter for $dayofweek.
string |
|
inherited |
Getter for $disabled.
bool |
|
inherited |
Getter for $faildelay.
int |
|
inherited |
Getter for $hostname.
string |
|
inherited |
Getter for $hour.
string |
|
staticinherited |
Produces a valid id string to use as id attribute based on the given FQCN class name.
string | $classname | FQCN of a task. |
string | valid string to be used as id attribute. |
|
inherited |
Get the last run time for this scheduled task.
int |
|
inherited |
Get the current lock for this task.
core\lock\lock |
|
protected |
Make the NRPS service call and fetch members based on the given resource link.
Memberships will be retrieved by first trying the link-level memberships service first, falling back to calling the context-level memberships service only if the link-level call fails.
application_registration | $appregistration | an application registration instance. |
resource_link | $resourcelink | a resourcelink instance. |
array | an array of members. |
|
inherited |
Getter for $minute.
string |
|
inherited |
Getter for $month.
string |
enrol_lti\local\ltiadvantage\task\sync_members::get_name | ( | ) |
Get the name for this task.
string | the name of the task. |
Reimplemented from core\task\task_base.
|
inherited |
Get the next run time for this task.
int | timestamp |
|
inherited |
Calculate when this task should next be run based on the schedule.
int | $now | Current time, for testing (leave 0 to use default time) |
int\$nextruntime,. |
|
protectedinherited |
Recursively calculate the next valid time for this task.
int | $now | Start time |
array | $validminutes | Valid minutes |
array | $validhours | Valid hours |
array | $validdays | Valid days |
array | $validdaysofweek | Valid days of week |
array | $validmonths | Valid months |
int | $originalyear | Zero for first call, original year for recursive calls |
int | Next run time |
|
inherited |
Getter for $pid.
int |
|
protected |
Make a resource-link-level memberships call.
nrps_info | $nrps | information about names and roles service endpoints and scopes. |
LtiServiceConnector | $sc | a service connector object. |
LtiRegistration | $registration | the registration |
resource_link | $resourcelink | the resource link |
array | an array of members if found. |
|
inherited |
Override this function if you want this scheduled task to run, even if the component is disabled.
bool |
|
inherited |
Returns task runtime.
int |
|
inherited |
Returns if the task has been running for too long.
result |
|
inherited |
Getter for $timestarted.
int |
|
inherited |
Determine if this task is using its default configuration changed from the default.
Returns true if it is and false otherwise. Does not rely on the customised field.
bool |
|
inherited |
Informs whether the task's component is enabled.
bool | true when enabled. false otherwise. |
|
inherited |
Has this task been changed from it's default config?
bool |
|
inherited |
Checks whether the component and the task disabled flag enables to run this task.
This do not checks whether the task manager allows running them or if the site allows tasks to "run now".
bool | true if task is enabled. false otherwise. |
|
inherited |
Has this task been changed from it's default config?
bool |
|
inherited |
Informs whether the given field is valid.
Use the constants FIELD_* to identify the field. Have to be called after the method set_{field}(string).
string | $field | field identifier; expected values from constants FIELD_*. |
bool | true if given field is valid. false otherwise. |
|
protected |
Creates an lti user object from a member entry.
stdClass | $user | the Moodle user record representing this member. |
stdClass | $resource | the locally published resource record, used for setting user defaults. |
resource_link | $resourcelink | the resource_link instance. |
array | $member | the member information from the NRPS service call. |
user | the lti user instance. |
|
protected |
Check whether the member has an instructor role or not.
array | $member |
bool |
|
inherited |
Setter for $component.
string | $component |
|
inherited |
Set the current lock for the entire cron process.
core\lock\lock | $lock |
|
inherited |
Set customised for this scheduled task.
bool |
|
inherited |
Setter for $day.
string | $day |
|
inherited |
Setter for $dayofweek.
string | $dayofweek | |
bool | $expandr | - if true (default) an 'R' value in a time is expanded to an appropriate int. If false, they are left as 'R' |
|
inherited |
Setter for $disabled.
bool | $disabled |
|
inherited |
Setter for $faildelay.
int | $faildelay |
|
inherited |
Setter for $hostname.
string | $hostname |
|
inherited |
Setter for $hour.
Accepts a special 'R' value which will be translated to a random hour.
string | $hour | |
bool | $expandr | - if true (default) an 'R' value in a time is expanded to an appropriate int. If false, they are left as 'R' |
|
inherited |
Set the last run time for this scheduled task.
int | $lastruntime |
|
inherited |
Set the current lock for this task.
core\lock\lock | $lock |
|
inherited |
Setter for $minute.
Accepts a special 'R' value which will be translated to a random minute.
string | $minute | |
bool | $expandr | - if true (default) an 'R' value in a time is expanded to an appropriate int. If false, they are left as 'R' |
|
inherited |
Setter for $month.
string | $month |
|
inherited |
Set the next run time for this task.
int | $nextruntime |
|
inherited |
Set the overridden value.
bool | $overridden |
|
inherited |
Setter for $pid.
int | $pid |
|
inherited |
Setter for $timestarted.
int | $timestarted |
|
protected |
Method to determine whether to sync enrolments or not.
int | $syncmode | The shared resource's membersyncmode. |
bool | true if enrolment should be synced, false if not. |
|
protected |
Method to determine whether to sync unenrolments or not.
int | $syncmode | The shared resource's membersyncmode. |
bool | true if unenrolment should be synced, false if not. |
|
protected |
Performs synchronisation of member information and enrolments.
application_registration | $appregistration | the application_registration instance. |
stdClass | $resource | the enrol_lti_tools resource information. |
resource_link | $resourcelink | the resource_link instance. |
user[] | $members | an array of members to sync. |
array | An array containing the counts of enrolled users and a list of userids. |
|
protected |
Performs synchronisation of user profile images.
int | the count of synced photos. |
|
protected |
Process unenrolment of users for a given resource link and based on the list of recently synced users.
resource_link | $resourcelink | the resource_link instance to which the $synced users pertains |
stdClass | $resource | the resource object instance |
array | $syncedusers | the array of recently synced users, who are not to be unenrolled. |
int | the number of unenrolled users. |
|
inherited |
|
inherited |
|
inherited |
Time used for the next scheduled time when a task should never run.
This is 2222-01-01 00:00 GMT which is a large time that still fits in 10 digits.