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

Extends the IMS Tool provider library data connector for moodle. More...

Inheritance diagram for enrol_lti\data_connector:
IMSGlobal\LTI\ToolProvider\DataConnector\DataConnector

Public Member Functions

 __construct ()
 data_connector constructor.
 
 deleteContext ($context)
 Delete context object.
 
 deleteResourceLink ($resourcelink)
 Delete resource link object.
 
 deleteResourceLinkShareKey ($sharekey)
 Delete resource link share key object.
 
 deleteToolConsumer ($consumer)
 Delete tool consumer object and related records.
 
 deleteToolProxy ($toolproxy)
 Delete the tool proxy from the database.
 
 deleteUser ($user)
 Delete user object.
 
 get_consumers_mapped_to_tool ($toolid)
 Fetches the list of ToolConsumer objects that are linked to a tool.
 
 get_contexts_from_consumer (ToolConsumer $consumer)
 Fetches the list of Context objects that are linked to a ToolConsumer.
 
 get_resourcelink_from_consumer (ToolConsumer $consumer)
 Fetches a resource link record that is associated with a ToolConsumer.
 
 get_resourcelink_from_context (Context $context)
 Fetches a resource link record that is associated with a Context object.
 
 getSharesResourceLink ($resourcelink)
 Get array of shares defined for this resource link.
 
 getToolConsumers ()
 Load all tool consumers from the database.
 
 getUserResultSourcedIDsResourceLink ($resourcelink, $localonly, $idscope)
 Get array of user objects.
 
 loadConsumerNonce ($nonce)
 Load nonce object.
 
 loadContext ($context)
 Load context object.
 
 loadResourceLink ($resourcelink)
 Load resource link object.
 
 loadResourceLinkShareKey ($sharekey)
 Load resource link share key object.
 
 loadToolConsumer ($consumer)
 Load tool consumer object.
 
 loadToolProxy ($toolproxy)
 Load the tool proxy from the database.
 
 loadUser ($user)
 Load user object.
 
 saveConsumerNonce ($nonce)
 Save nonce object.
 
 saveContext ($context)
 Save context object.
 
 saveResourceLink ($resourcelink)
 Save resource link object.
 
 saveResourceLinkShareKey ($sharekey)
 Save resource link share key object.
 
 saveToolConsumer ($consumer)
 Save tool consumer object.
 
 saveToolProxy ($toolproxy)
 Save the tool proxy to the database.
 
 saveUser ($user)
 Save user object.
 

Static Public Member Functions

static getDataConnector ($dbTableNamePrefix='', $db=null, $type='')
 Create data connector object.
 
static getRandomString ($length=8)
 Generate a random string.
 
static quoted ($value, $addQuotes=true)
 Quote a string for use in a database query.
 

Public Attributes

const CONSUMER_TABLE_NAME = 'lti2_consumer'
 Default name for database table used to store tool consumers.
 
const CONTEXT_TABLE_NAME = 'lti2_context'
 Default name for database table used to store contexts.
 
const NONCE_TABLE_NAME = 'lti2_nonce'
 Default name for database table used to store nonce values.
 
const RESOURCE_LINK_SHARE_KEY_TABLE_NAME = 'lti2_share_key'
 Default name for database table used to store resource link share keys.
 
const RESOURCE_LINK_TABLE_NAME = 'lti2_resource_link'
 Default name for database table used to store resource links.
 
const TOOL_PROXY_TABLE_NAME = 'lti2_tool_proxy'
 Default name for database table used to store pending tool proxies.
 
const USER_RESULT_TABLE_NAME = 'lti2_user_result'
 Default name for database table used to store users.
 

Protected Member Functions

 build_tool_consumer_object ($record, ToolConsumer $consumer)
 Builds a ToolConsumer object from a record object from the DB.
 

Static Protected Member Functions

static getConsumerKey ($key)
 Return a hash of a consumer key for values longer than 255 characters.
 

Protected Attributes

string $consumertable
 Tool consumer table name.
 
string $contexttable
 Context table name.
 
string $dateFormat = 'Y-m-d'
 SQL date format (default = 'Y-m-d')
 
object $db = null
 Database object.
 
string $dbTableNamePrefix = ''
 Prefix for database table names.
 
string $noncetable
 Consumer nonce table name.
 
string $resourcelinktable
 Resource link table name.
 
string $sharekeytable
 Resource link share key table name.
 
string $timeFormat = 'H:i:s'
 SQL time format (default = 'H:i:s')
 
string $toolproxytable
 Tool proxy table name.
 
string $userresulttable
 User result table name.
 

Detailed Description

Extends the IMS Tool provider library data connector for moodle.

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

Member Function Documentation

◆ build_tool_consumer_object()

enrol_lti\data_connector::build_tool_consumer_object ( $record,
ToolConsumer $consumer )
protected

Builds a ToolConsumer object from a record object from the DB.

Parameters
stdClass$recordThe DB record object.
ToolConsumer$consumer

◆ deleteContext()

enrol_lti\data_connector::deleteContext ( $context)

Delete context object.

Parameters
Context$contextContext object
Return values
booleanTrue if the Context object was successfully deleted

Reimplemented from IMSGlobal\LTI\ToolProvider\DataConnector\DataConnector.

◆ deleteResourceLink()

enrol_lti\data_connector::deleteResourceLink ( $resourcelink)

Delete resource link object.

Parameters
ResourceLink$resourcelinkResourceLink object
Return values
booleanTrue if the resource link object and its related records were successfully deleted. Otherwise, a DML exception is thrown.

Reimplemented from IMSGlobal\LTI\ToolProvider\DataConnector\DataConnector.

◆ deleteResourceLinkShareKey()

enrol_lti\data_connector::deleteResourceLinkShareKey ( $sharekey)

Delete resource link share key object.

Parameters
ResourceLinkShareKey$sharekeyResource link share key object
Return values
booleanTrue if the resource link share key object was successfully deleted

Reimplemented from IMSGlobal\LTI\ToolProvider\DataConnector\DataConnector.

◆ deleteToolConsumer()

enrol_lti\data_connector::deleteToolConsumer ( $consumer)

Delete tool consumer object and related records.

Parameters
ToolConsumer$consumerConsumer object
Return values
booleanTrue if the tool consumer object was successfully deleted

Reimplemented from IMSGlobal\LTI\ToolProvider\DataConnector\DataConnector.

◆ deleteToolProxy()

enrol_lti\data_connector::deleteToolProxy ( $toolproxy)

Delete the tool proxy from the database.

Parameters
ToolProxy$toolproxy
Return values
bool

Reimplemented from IMSGlobal\LTI\ToolProvider\DataConnector\DataConnector.

◆ deleteUser()

enrol_lti\data_connector::deleteUser ( $user)

Delete user object.

Parameters
User$userUser object
Return values
booleanTrue if the user object was successfully deleted

Reimplemented from IMSGlobal\LTI\ToolProvider\DataConnector\DataConnector.

◆ get_consumers_mapped_to_tool()

enrol_lti\data_connector::get_consumers_mapped_to_tool ( $toolid)

Fetches the list of ToolConsumer objects that are linked to a tool.

Parameters
int$toolid
Return values
ToolConsumer[]

◆ get_contexts_from_consumer()

enrol_lti\data_connector::get_contexts_from_consumer ( ToolConsumer $consumer)

Fetches the list of Context objects that are linked to a ToolConsumer.

Parameters
ToolConsumer$consumer
Return values
Context[]

◆ get_resourcelink_from_consumer()

enrol_lti\data_connector::get_resourcelink_from_consumer ( ToolConsumer $consumer)

Fetches a resource link record that is associated with a ToolConsumer.

Parameters
ToolConsumer$consumer
Return values
ResourceLink

◆ get_resourcelink_from_context()

enrol_lti\data_connector::get_resourcelink_from_context ( Context $context)

Fetches a resource link record that is associated with a Context object.

Parameters
Context$context
Return values
ResourceLink

◆ getConsumerKey()

static IMSGlobal\LTI\ToolProvider\DataConnector\DataConnector::getConsumerKey ( $key)
staticprotectedinherited

Return a hash of a consumer key for values longer than 255 characters.

Parameters
string$key
Return values
string

◆ getDataConnector()

static IMSGlobal\LTI\ToolProvider\DataConnector\DataConnector::getDataConnector ( $dbTableNamePrefix = '',
$db = null,
$type = '' )
staticinherited

Create data connector object.

A data connector provides access to persistent storage for the different objects.

Names of tables may be given a prefix to allow multiple versions to share the same schema. A separate sub-class is defined for each different database connection - the class to use is determined by inspecting the database object passed, but this can be overridden (for example, to use a bespoke connector) by specifying a type. If no database is passed then this class is used which acts as a dummy connector with no persistence.

Parameters
string$dbTableNamePrefixPrefix for database table names (optional, default is none)
object$dbA database connection object or string (optional, default is no persistence)
string$typeThe type of data connector (optional, default is based on $db parameter)
Return values
DataConnectorData connector object

◆ getRandomString()

static IMSGlobal\LTI\ToolProvider\DataConnector\DataConnector::getRandomString ( $length = 8)
staticinherited

Generate a random string.

The generated string will only comprise letters (upper- and lower-case) and digits.

Parameters
int$lengthLength of string to be generated (optional, default is 8 characters)
Return values
stringRandom string

◆ getSharesResourceLink()

enrol_lti\data_connector::getSharesResourceLink ( $resourcelink)

Get array of shares defined for this resource link.

Parameters
ResourceLink$resourcelinkResourceLink object
Return values
arrayArray of ResourceLinkShare objects

Reimplemented from IMSGlobal\LTI\ToolProvider\DataConnector\DataConnector.

◆ getToolConsumers()

enrol_lti\data_connector::getToolConsumers ( )

Load all tool consumers from the database.

Return values
array

Reimplemented from IMSGlobal\LTI\ToolProvider\DataConnector\DataConnector.

◆ getUserResultSourcedIDsResourceLink()

enrol_lti\data_connector::getUserResultSourcedIDsResourceLink ( $resourcelink,
$localonly,
$idscope )

Get array of user objects.

Obtain an array of User objects for users with a result sourcedId. The array may include users from other resource links which are sharing this resource link. It may also be optionally indexed by the user ID of a specified scope.

Parameters
ResourceLink$resourcelinkResource link object
boolean$localonlyTrue if only users within the resource link are to be returned (excluding users sharing this resource link)
int$idscopeScope value to use for user IDs
Return values
arrayArray of User objects

Reimplemented from IMSGlobal\LTI\ToolProvider\DataConnector\DataConnector.

◆ loadConsumerNonce()

enrol_lti\data_connector::loadConsumerNonce ( $nonce)

Load nonce object.

Parameters
ConsumerNonce$nonceNonce object
Return values
booleanTrue if the nonce object was successfully loaded

Reimplemented from IMSGlobal\LTI\ToolProvider\DataConnector\DataConnector.

◆ loadContext()

enrol_lti\data_connector::loadContext ( $context)

Load context object.

Parameters
Context$contextContext object
Return values
booleanTrue if the context object was successfully loaded

Reimplemented from IMSGlobal\LTI\ToolProvider\DataConnector\DataConnector.

◆ loadResourceLink()

enrol_lti\data_connector::loadResourceLink ( $resourcelink)

Load resource link object.

Parameters
ResourceLink$resourcelinkResourceLink object
Return values
booleanTrue if the resource link object was successfully loaded

Reimplemented from IMSGlobal\LTI\ToolProvider\DataConnector\DataConnector.

◆ loadResourceLinkShareKey()

enrol_lti\data_connector::loadResourceLinkShareKey ( $sharekey)

Load resource link share key object.

Parameters
ResourceLinkShareKey$sharekeyResourceLink share key object
Return values
booleanTrue if the resource link share key object was successfully loaded

Reimplemented from IMSGlobal\LTI\ToolProvider\DataConnector\DataConnector.

◆ loadToolConsumer()

enrol_lti\data_connector::loadToolConsumer ( $consumer)

Load tool consumer object.

Parameters
ToolConsumer$consumerToolConsumer object
Return values
booleanTrue if the tool consumer object was successfully loaded

Reimplemented from IMSGlobal\LTI\ToolProvider\DataConnector\DataConnector.

◆ loadToolProxy()

enrol_lti\data_connector::loadToolProxy ( $toolproxy)

Load the tool proxy from the database.

Parameters
ToolProxy$toolproxy
Return values
bool

Reimplemented from IMSGlobal\LTI\ToolProvider\DataConnector\DataConnector.

◆ loadUser()

enrol_lti\data_connector::loadUser ( $user)

Load user object.

Parameters
User$userUser object
Return values
booleanTrue if the user object was successfully loaded

Reimplemented from IMSGlobal\LTI\ToolProvider\DataConnector\DataConnector.

◆ quoted()

static IMSGlobal\LTI\ToolProvider\DataConnector\DataConnector::quoted ( $value,
$addQuotes = true )
staticinherited

Quote a string for use in a database query.

Any single quotes in the value passed will be replaced with two single quotes. If a null value is passed, a string of 'null' is returned (which will never be enclosed in quotes irrespective of the value of the $addQuotes parameter.

Parameters
string$valueValue to be quoted
bool$addQuotesIf true the returned string will be enclosed in single quotes (optional, default is true)
Return values
stringThe quoted string.

◆ saveConsumerNonce()

enrol_lti\data_connector::saveConsumerNonce ( $nonce)

Save nonce object.

Parameters
ConsumerNonce$nonceNonce object
Return values
booleanTrue if the nonce object was successfully saved

Reimplemented from IMSGlobal\LTI\ToolProvider\DataConnector\DataConnector.

◆ saveContext()

enrol_lti\data_connector::saveContext ( $context)

Save context object.

Parameters
Context$contextContext object
Return values
booleanTrue if the context object was successfully saved

Reimplemented from IMSGlobal\LTI\ToolProvider\DataConnector\DataConnector.

◆ saveResourceLink()

enrol_lti\data_connector::saveResourceLink ( $resourcelink)

Save resource link object.

Parameters
ResourceLink$resourcelinkResource_Link object
Return values
booleanTrue if the resource link object was successfully saved

Reimplemented from IMSGlobal\LTI\ToolProvider\DataConnector\DataConnector.

◆ saveResourceLinkShareKey()

enrol_lti\data_connector::saveResourceLinkShareKey ( $sharekey)

Save resource link share key object.

Parameters
ResourceLinkShareKey$sharekeyResource link share key object
Return values
booleanTrue if the resource link share key object was successfully saved

Reimplemented from IMSGlobal\LTI\ToolProvider\DataConnector\DataConnector.

◆ saveToolConsumer()

enrol_lti\data_connector::saveToolConsumer ( $consumer)

Save tool consumer object.

Parameters
ToolConsumer$consumerConsumer object
Return values
booleanTrue if the tool consumer object was successfully saved

Reimplemented from IMSGlobal\LTI\ToolProvider\DataConnector\DataConnector.

◆ saveToolProxy()

enrol_lti\data_connector::saveToolProxy ( $toolproxy)

Save the tool proxy to the database.

Parameters
ToolProxy$toolproxy
Return values
bool

Reimplemented from IMSGlobal\LTI\ToolProvider\DataConnector\DataConnector.

◆ saveUser()

enrol_lti\data_connector::saveUser ( $user)

Save user object.

Parameters
User$userUser object
Return values
booleanTrue if the user object was successfully saved

Reimplemented from IMSGlobal\LTI\ToolProvider\DataConnector\DataConnector.

Member Data Documentation

◆ $dateFormat

string IMSGlobal\LTI\ToolProvider\DataConnector\DataConnector::$dateFormat = 'Y-m-d'
protectedinherited

SQL date format (default = 'Y-m-d')

$dateFormat

◆ $db

object IMSGlobal\LTI\ToolProvider\DataConnector\DataConnector::$db = null
protectedinherited

Database object.

$db

◆ $dbTableNamePrefix

string IMSGlobal\LTI\ToolProvider\DataConnector\DataConnector::$dbTableNamePrefix = ''
protectedinherited

Prefix for database table names.

$dbTableNamePrefix

◆ $timeFormat

string IMSGlobal\LTI\ToolProvider\DataConnector\DataConnector::$timeFormat = 'H:i:s'
protectedinherited

SQL time format (default = 'H:i:s')

$timeFormat


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