Moodle PHP Documentation 4.5
Moodle 4.5dev (Build: 20240606) (d3ae1391abe)
core_xapi\local\state Class Reference
Inheritance diagram for core_xapi\local\state:

Public Member Functions

 __construct (item_agent $agent, item_activity $activity, string $stateid, ?stdClass $statedata, ?string $registration)
 State constructor.
 
 get_activity ()
 Return the state object if it is defined.
 
 get_activity_id ()
 Returns the state activity ID.
 
 get_agent ()
 Return the state agent.
 
 get_record_data ()
 Return the record data of this state.
 
 get_registration ()
 Returns the state registration if any.
 
 get_state_data ()
 Returns the state data.
 
 get_state_id ()
 Returns the state id.
 
 get_user ()
 Returns the moodle user represented by this state agent.
 
 jsonSerialize ()
 Return the data to serialize in case JSON state when needed.
 
 minify ()
 Returns a minified version of a given state.
 
 set_state_data (?stdClass $statedata)
 Set the state data.
 

Protected Attributes

item_activity $activity = null
 The state activity owner (the plugin instance).
 
item_agent $agent = null
 The state agent (user).
 
string null $registration = null
 The state registration.
 
stdClass null $statedata = null
 The state data.
 
string $stateid = null
 The state identifier.
 

Constructor & Destructor Documentation

◆ __construct()

core_xapi\local\state::__construct ( item_agent $agent,
item_activity $activity,
string $stateid,
?stdClass $statedata,
?string $registration )

State constructor.

Parameters
item_agent$agentThe state agent (user)
item_activity$activityThe state activity owner
string$stateidThe state identifier
stdClass | null$statedataThe state data
string | null$registrationThe state registration

Member Function Documentation

◆ get_activity()

core_xapi\local\state::get_activity ( )

Return the state object if it is defined.

Return values
item_activity|null

◆ get_activity_id()

core_xapi\local\state::get_activity_id ( )

Returns the state activity ID.

Return values
stringactivity ID

◆ get_agent()

core_xapi\local\state::get_agent ( )

Return the state agent.

Return values
item_agent

◆ get_record_data()

core_xapi\local\state::get_record_data ( )

Return the record data of this state.

Return values
stdClassthe record data structure

◆ get_registration()

core_xapi\local\state::get_registration ( )

Returns the state registration if any.

Return values
string|nullstate registration

◆ get_state_data()

core_xapi\local\state::get_state_data ( )

Returns the state data.

For getting the JSON representation of this state data, use jsonSerialize().

Return values
stdClass|nullThe state data object.

◆ get_state_id()

core_xapi\local\state::get_state_id ( )

Returns the state id.

Return values
stringstate identifier

◆ get_user()

core_xapi\local\state::get_user ( )

Returns the moodle user represented by this state agent.

Return values
stdClassuser record

◆ jsonSerialize()

core_xapi\local\state::jsonSerialize ( )

Return the data to serialize in case JSON state when needed.

Return values
stdClassThe state data structure. If statedata is null, this method will return an empty class.

◆ minify()

core_xapi\local\state::minify ( )

Returns a minified version of a given state.

The returned structure is suitable to store in the "other" field of logstore. xAPI standard specifies a list of attributes that can be calculated instead of stored literally. This function get rid of these attributes.

Note: it also converts stdClass to assoc array to make it compatible with "other" field in the logstore

Return values
arraythe minimal state needed to be stored a part from logstore data

◆ set_state_data()

core_xapi\local\state::set_state_data ( ?stdClass $statedata)

Set the state data.

Parameters
stdClass | null$statedatathe state data

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