Files
Xes 73154ae174
Behat tests 1.11.x 🐞 / PHP 7.4 Test on ubuntu-latest (push) Canceled after 0s
PHP-CS-Fixer / composer_install (7.4) (push) Canceled after 0s
Chamilo 1.11.40 (ZIP oficial v1.11.40)
Fuente: https://github.com/chamilo/chamilo-lms/releases/download/v1.11.40/chamilo-1.11.40.zip
sha256: 1cf4bf2cc7bae1ef1a1eff643235db1d552f78ddf4b6dd1e2d2dac9868679439
Snapshot independiente (rama huerfana); diffable vs 1.11.38. vendor incluido.
2026-08-06 17:59:45 +02:00

2.5 KiB

The Agent Profile API

Agent Profiles

A LMS can use the xAPI to store documents associated to a certain agent using agent profiles. An agent profile is dedicated to an agent and a profile id:

use Xabbuh\XApi\Model\AgentProfile;

// ...
$profile = new AgentProfile();
$profile->setAgent($agent);
$profile->setProfileId($profileId);

Documents

Documents are simple collections of key-value pairs and can be accessed like arrays:

use Xabbuh\XApi\Model\AgentProfileDocument;

// ...
$document = new AgentProfileDocument();
$document->setAgentProfile($profile);
$document['x'] = 'foo';
$document['y'] = 'bar';

Obtaining the Agent Profile API Client

After you have built the global xAPI client, you can obtain an agent profile API client by calling its getAgentProfileApiClient() method:

$agentProfileApiClient = $xApiClient->getAgentProfileApiClient();

Storing Agent Profile Documents

You can simply store an AgentProfileDocument passing it to the createOrUpdateAgentProfileDocument() method of the xAPI client:

$document = ...; // the agent profile document
$agentProfileApiClient->createOrUpdateAgentProfileDocument($document);

If a document already exists for this agent profile, the existing document will be updated. This means that new fields will be updated, existing fields that are included in the new document will be overwritten and existing fields that are not included in the new document will be kept as they are.

If you want to replace a document, use the createOrReplaceAgentProfileDocument() method instead:

$document = ...; // the agent profile document
$agentProfileApiClient->createOrReplaceAgentProfileDocument($document);

Deleting Agent Profile Documents

An AgentProfileDocument is deleted by passing the particular AgentProfile to the deleteAgentProfileDocument() method:

$profile = ...; // the agent profile the document should be deleted from
$agentProfileApiClient->deleteAgentProfileDocument($profile);

Retrieving Agent Profile Documents

Similarly, you receive a document for a particular agent profile by passing the profile to the getAgentProfileDocument() method:

$profile = ...; // the agent profile the document should be retrieved from
$document = $agentProfileApiClient->getAgentProfileDocument($profile);