Moodle PHP Documentation 4.5
Moodle 4.5dev (Build: 20240606) (d3ae1391abe)
enrol_lti\helper Class Reference

LTI enrolment plugin helper class. More...

Static Public Member Functions

static assign_user_tool_data ($tool, $user)
 Adds default values for the user object based on the tool provided.
 
static count_lti_tools ($params=array())
 Returns the number of LTI tools.
 
static create_cartridge ($toolid)
 Create an IMS cartridge for the tool.
 
static create_service_body ($source, $grade)
 Create a IMS POX body request for sync grades.
 
static create_username ($consumerkey, $ltiuserid)
 Creates a unique username.
 
static enrol_user ($tool, $userid)
 Enrol a user in a course.
 
static generate_cartridge_token ($toolid)
 Returns a unique hash for this site and this enrolment instance.
 
static generate_proxy_token ($toolid)
 Returns a unique hash for this site and this enrolment instance.
 
static get_cartridge_url ($tool)
 Returns the url to the cartridge representing the tool.
 
static get_description ($tool)
 Returns a description of the course or module that this lti instance points to.
 
static get_icon ($tool)
 Returns the icon of the tool.
 
static get_launch_url ($toolid)
 Returns the url to launch the lti tool.
 
static get_lti_tool ($toolid)
 Returns the LTI tool.
 
static get_lti_tools ($params=array(), $limitfrom=0, $limitnum=0)
 Returns the LTI tools requested.
 
static get_name ($tool)
 Returns the name of the lti enrolment instance, or the name of the course/module being shared.
 
static get_proxy_url ($tool)
 Returns the url to the tool proxy registration url.
 
static update_user_profile_image ($userid, $url)
 Updates the users profile image.
 
static user_match ($newuser, $olduser)
 Compares two users.
 
static verify_cartridge_token ($toolid, $token)
 Verifies that the given token matches the cartridge token of the given shared tool.
 
static verify_proxy_token ($toolid, $token)
 Verifies that the given token matches the proxy token of the given shared tool.
 

Public Attributes

const ENROLMENT_FINISHED = 'enrolmentfinished'
 Error code for enrolment when enrolment has finished.
 
const ENROLMENT_MAX_ENROLLED = 'maxenrolledreached'
 Error code for enrolment when max enrolled reached.
 
const ENROLMENT_NOT_STARTED = 'enrolmentnotstarted'
 Error code for enrolment has not started.
 
const ENROLMENT_SUCCESSFUL = true
 Code for when an enrolment was successful.
 
const MEMBER_SYNC_ENROL_AND_UNENROL = 1
 
const MEMBER_SYNC_ENROL_NEW = 2
 
const MEMBER_SYNC_UNENROL_MISSING = 3
 
const PROFILE_IMAGE_UPDATE_FAILED = 'profileimagefailed'
 Error code for when an image file fails to upload.
 
const PROFILE_IMAGE_UPDATE_SUCCESSFUL = true
 Error code for when an image file fails to upload.
 

Static Protected Member Functions

static get_cartridge_parameters ($toolid)
 Returns the parameters of the cartridge as an associative array of partial xpath.
 
static set_xpath ($xpath, $parameters, $prefix='')
 Traverses a recursive associative array, setting the properties of the corresponding xpath element.
 

Detailed Description

LTI enrolment plugin helper class.

License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

Member Function Documentation

◆ assign_user_tool_data()

static enrol_lti\helper::assign_user_tool_data ( $tool,
$user )
static

Adds default values for the user object based on the tool provided.

Parameters
stdClass$tool
stdClass$user
Return values
stdClassThe $user class with added default values

◆ count_lti_tools()

static enrol_lti\helper::count_lti_tools ( $params = array())
static

Returns the number of LTI tools.

Parameters
array$paramsThe list of SQL params (eg. array('columnname' => value, 'columnname2' => value)).
Return values
intThe number of tools

◆ create_cartridge()

static enrol_lti\helper::create_cartridge ( $toolid)
static

Create an IMS cartridge for the tool.

Parameters
int$toolidThe id of the shared tool
Return values
stringrepresenting the generated cartridge
Since
Moodle 3.2

◆ create_service_body()

static enrol_lti\helper::create_service_body ( $source,
$grade )
static

Create a IMS POX body request for sync grades.

Parameters
string$sourceSourceid required for the request
float$gradeUser final grade
Return values
string

◆ create_username()

static enrol_lti\helper::create_username ( $consumerkey,
$ltiuserid )
static

Creates a unique username.

Parameters
string$consumerkeyConsumer key
string$ltiuseridExternal tool user id
Return values
stringThe new username

◆ enrol_user()

static enrol_lti\helper::enrol_user ( $tool,
$userid )
static

Enrol a user in a course.

Parameters
stdclass$toolThe tool object (retrieved using self\get_lti_tool() or self\get_lti_tools())
int$useridThe user id
Return values
bool|stringreturns true if successful, else an error code

◆ generate_cartridge_token()

static enrol_lti\helper::generate_cartridge_token ( $toolid)
static

Returns a unique hash for this site and this enrolment instance.

Used to verify that the link to the cartridge has not just been guessed.

Parameters
int$toolidThe id of the shared tool
Return values
stringMD5 hash of combined site ID and enrolment instance ID.
Since
Moodle 3.2

◆ generate_proxy_token()

static enrol_lti\helper::generate_proxy_token ( $toolid)
static

Returns a unique hash for this site and this enrolment instance.

Used to verify that the link to the proxy has not just been guessed.

Parameters
int$toolidThe id of the shared tool
Return values
stringMD5 hash of combined site ID and enrolment instance ID.
Since
Moodle 3.2

◆ get_cartridge_parameters()

static enrol_lti\helper::get_cartridge_parameters ( $toolid)
staticprotected

Returns the parameters of the cartridge as an associative array of partial xpath.

Parameters
int$toolidThe id of the shared tool
Return values
arrayRecursive associative array with partial xpath to be concatenated into an xpath expression before setting the value.
Since
Moodle 3.2

◆ get_cartridge_url()

static enrol_lti\helper::get_cartridge_url ( $tool)
static

Returns the url to the cartridge representing the tool.

If you have slash arguments enabled, this will be a nice url ending in cartridge.xml. If not it will be a php page with some parameters passed.

Parameters
stdClass$toolThe lti tool
Return values
stringThe url to the cartridge representing the tool
Since
Moodle 3.2

◆ get_description()

static enrol_lti\helper::get_description ( $tool)
static

Returns a description of the course or module that this lti instance points to.

Parameters
stdClass$toolThe lti tool
Return values
stringA description of the tool
Since
Moodle 3.2

◆ get_icon()

static enrol_lti\helper::get_icon ( $tool)
static

Returns the icon of the tool.

Parameters
stdClass$toolThe lti tool
Return values
moodle_urlA url to the icon of the tool
Since
Moodle 3.2

◆ get_launch_url()

static enrol_lti\helper::get_launch_url ( $toolid)
static

Returns the url to launch the lti tool.

Parameters
int$toolidthe id of the shared tool
Return values
moodle_urlthe url to launch the tool
Since
Moodle 3.2

◆ get_lti_tool()

static enrol_lti\helper::get_lti_tool ( $toolid)
static

Returns the LTI tool.

Parameters
int$toolid
Return values
stdClassthe tool

◆ get_lti_tools()

static enrol_lti\helper::get_lti_tools ( $params = array(),
$limitfrom = 0,
$limitnum = 0 )
static

Returns the LTI tools requested.

Parameters
array$paramsThe list of SQL params (eg. array('columnname' => value, 'columnname2' => value)).
int$limitfromreturn a subset of records, starting at this point (optional).
int$limitnumreturn a subset comprising this many records in total
Return values
arrayof tools

◆ get_name()

static enrol_lti\helper::get_name ( $tool)
static

Returns the name of the lti enrolment instance, or the name of the course/module being shared.

Parameters
stdClass$toolThe lti tool
Return values
stringThe name of the tool
Since
Moodle 3.2

◆ get_proxy_url()

static enrol_lti\helper::get_proxy_url ( $tool)
static

Returns the url to the tool proxy registration url.

If you have slash arguments enabled, this will be a nice url ending in cartridge.xml. If not it will be a php page with some parameters passed.

Parameters
stdClass$toolThe lti tool
Return values
stringThe url to the cartridge representing the tool

◆ set_xpath()

static enrol_lti\helper::set_xpath ( $xpath,
$parameters,
$prefix = '' )
staticprotected

Traverses a recursive associative array, setting the properties of the corresponding xpath element.

Parameters
DOMXPath$xpathThe xpath with the xml to modify
array$parametersThe array of xpaths to search through
string$prefixThe current xpath prefix (gets longer the deeper into the array you go)
Return values
void
Since
Moodle 3.2

◆ update_user_profile_image()

static enrol_lti\helper::update_user_profile_image ( $userid,
$url )
static

Updates the users profile image.

Parameters
int$useridthe id of the user
string$urlthe url of the image
Return values
bool|stringtrue if successful, else a string explaining why it failed

◆ user_match()

static enrol_lti\helper::user_match ( $newuser,
$olduser )
static

Compares two users.

Parameters
stdClass$newuserThe new user
stdClass$olduserThe old user
Return values
boolTrue if both users are the same

◆ verify_cartridge_token()

static enrol_lti\helper::verify_cartridge_token ( $toolid,
$token )
static

Verifies that the given token matches the cartridge token of the given shared tool.

Parameters
int$toolidThe id of the shared tool
string$tokenhash for this site and this enrolment instance
Return values
booleanTrue if the token matches, false if it does not
Since
Moodle 3.2

◆ verify_proxy_token()

static enrol_lti\helper::verify_proxy_token ( $toolid,
$token )
static

Verifies that the given token matches the proxy token of the given shared tool.

Parameters
int$toolidThe id of the shared tool
string$tokenhash for this site and this enrolment instance
Return values
booleanTrue if the token matches, false if it does not
Since
Moodle 3.2

The documentation for this class was generated from the following file: