Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

Differences Between: [Versions 401 and 402] [Versions 401 and 403]

(no description)

File Size: 454 lines (21 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class


Class: sync_members  - X-Ref

LTI Advantage-specific task responsible for syncing memberships from tool platforms with the tool.

This task may gather members from a context-level service call, depending on whether a resource-level service call
(which is made first) was successful. Because of the context-wide memberships, and because each published resource
has per-resource access control (role assignments), this task only enrols user into the course, and does not assign
roles to resource/course contexts. Role assignment only takes place during a launch, via the tool_launch_service.

get_name()   X-Ref
Get the name for this task.

return: string the name of the task.

get_resource_link_level_members(nrps_info $nrps, LtiServiceConnector $sc, LtiRegistration $registration,resource_link $resourcelink)   X-Ref
Make a resource-link-level memberships call.

param: nrps_info $nrps information about names and roles service endpoints and scopes.
param: LtiServiceConnector $sc a service connector object.
param: LtiRegistration $registration the registration
param: resource_link $resourcelink the resource link
return: array an array of members if found.

get_context_level_members(nrps_info $nrps, LtiServiceConnector $sc, LtiRegistration $registration)   X-Ref
Make a context-level memberships call.

param: nrps_info $nrps information about names and roles service endpoints and scopes.
param: LtiServiceConnector $sc a service connector object.
param: LtiRegistration $registration the registration
return: array an array of members.

get_members_from_resource_link(application_registration $appregistration,resource_link $resourcelink)   X-Ref
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.

param: application_registration $appregistration an application registration instance.
param: resource_link $resourcelink a resourcelink instance.
return: array an array of members.

execute()   X-Ref
Performs the synchronisation of members.


sync_unenrol_resourcelink(resource_link $resourcelink, stdClass $resource,array $syncedusers)   X-Ref
Process unenrolment of users for a given resource link and based on the list of recently synced users.

param: resource_link $resourcelink the resource_link instance to which the $synced users pertains
param: stdClass $resource the resource object instance
param: array $syncedusers the array of recently synced users, who are not to be unenrolled.
return: int the number of unenrolled users.

member_is_instructor(array $member)   X-Ref
Check whether the member has an instructor role or not.

param: array $member
return: bool

should_sync_unenrol($syncmode)   X-Ref
Method to determine whether to sync unenrolments or not.

param: int $syncmode The shared resource's membersyncmode.
return: bool true if unenrolment should be synced, false if not.

should_sync_enrol($syncmode)   X-Ref
Method to determine whether to sync enrolments or not.

param: int $syncmode The shared resource's membersyncmode.
return: bool true if enrolment should be synced, false if not.

ltiuser_from_member(stdClass $user, stdClass $resource,resource_link $resourcelink, array $member)   X-Ref
Creates an lti user object from a member entry.

param: stdClass $user the Moodle user record representing this member.
param: stdClass $resource the locally published resource record, used for setting user defaults.
param: resource_link $resourcelink the resource_link instance.
param: array $member the member information from the NRPS service call.
return: user the lti user instance.

sync_member_information(application_registration $appregistration, stdClass $resource,resource_link $resourcelink, array $members)   X-Ref
Performs synchronisation of member information and enrolments.

param: application_registration $appregistration the application_registration instance.
param: stdClass $resource the enrol_lti_tools resource information.
param: resource_link $resourcelink the resource_link instance.
param: user[] $members an array of members to sync.
return: array An array containing the counts of enrolled users and a list of userids.

sync_profile_images()   X-Ref
Performs synchronisation of user profile images.

return: int the count of synced photos.