Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.2.x will end 22 April 2024 (12 months).
  • Bug fixes for security issues in 4.2.x will end 7 October 2024 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.1.x is supported too.

(no description)

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

Defines 1 class

state:: (12 methods):
  __construct()
  jsonSerialize()
  get_record_data()
  minify()
  set_state_data()
  get_state_data()
  get_user()
  get_activity_id()
  get_agent()
  get_activity()
  get_state_id()
  get_registration()


Class: state  - X-Ref

State resource object for xAPI structure checking and validation.

__construct(item_agent $agent,item_activity $activity,string $stateid,?stdClass $statedata,?string $registration)   X-Ref
State constructor.

param: item_agent $agent The state agent (user)
param: item_activity $activity The state activity owner
param: string $stateid The state identifier
param: stdClass|null $statedata The state data
param: string|null $registration The state registration

jsonSerialize()   X-Ref
Return the data to serialize in case JSON state when needed.

return: stdClass The state data structure. If statedata is null, this method will return an empty class.

get_record_data()   X-Ref
Return the record data of this state.

return: stdClass the record data structure

minify()   X-Ref
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: array the minimal state needed to be stored a part from logstore data

set_state_data(?stdClass $statedata)   X-Ref
Set the state data.

param: stdClass|null $statedata the state data

get_state_data()   X-Ref
Returns the state data.
For getting the JSON representation of this state data, use jsonSerialize().

return: stdClass|null The state data object.

get_user()   X-Ref
Returns the moodle user represented by this state agent.

return: stdClass user record

get_activity_id()   X-Ref
Returns the state activity ID.

return: string activity ID

get_agent()   X-Ref
Return the state agent.

return: item_agent

get_activity()   X-Ref
Return the state object if it is defined.

return: item_activity|null

get_state_id()   X-Ref
Returns the state id.

return: string state identifier

get_registration()   X-Ref
Returns the state registration if any.

return: string|null state registration