Actualización

This commit is contained in:
Xes
2025-04-10 12:24:57 +02:00
parent 8969cc929d
commit 45420b6f0d
39760 changed files with 4303286 additions and 0 deletions

View File

@@ -0,0 +1,89 @@
The Activity Profile API
========================
Activity Profiles
-----------------
A LMS can use the xAPI to store documents associated to a certain activity using
activity profiles. An activity profile is dedicated to an activity and a profile
id:
```php
use Xabbuh\XApi\Model\ActivityProfile;
// ...
$profile = new ActivityProfile();
$profile->setActivity($activity);
$profile->setProfileId($profileId);
```
Documents
---------
Documents are simple collections of key-value pairs and can be accessed like arrays:
```php
use Xabbuh\XApi\Model\ActivityProfileDocument;
// ...
$document = new ActivityProfileDocument();
$document->setActivityProfile($profile);
$document['x'] = 'foo';
$document['y'] = 'bar';
```
Obtaining the Activity Profile API Client
-----------------------------------------
After you have [built the global xAPI client](client.md), you can obtain an activity
profile API client by calling its ``getActivityProfileApiClient()`` method:
```php
$activityProfileApiClient = $xApiClient->getActivityProfileApiClient();
```
Storing Activity Profile Documents
----------------------------------
You can simply store an ``ActivityProfileDocument`` passing it to the
``createOrUpdateActivityProfileDocument()`` method of the xAPI client:
```php
$document = ...; // the activity profile document
$activityProfileApiClient->createOrUpdateActivityProfileDocument($document);
```
If a document already exists for this activity 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 ``createOrReplaceActivityProfileDocument()``
method instead:
```php
$document = ...; // the activity profile document
$activityProfileApiClient->createOrReplaceActivityProfileDocument($document);
```
Deleting Activity Profile Documents
-----------------------------------
An ``ActivityProfileDocument`` is deleted by passing the particular ``ActivityProfile``
to the ``deleteActivityProfileDocument()`` method:
```php
$profile = ...; // the activity profile the document should be deleted from
$activityProfileApiClient->deleteActivityProfileDocument($profile);
```
Retrieving Activity Profile Documents
-------------------------------------
Similarly, you receive a document for a particular activity profile by passing
the profile to the ``getActivityProfileDocument()`` method:
```php
$profile = ...; // the activity profile the document should be retrieved from
$document = $activityProfileApiClient->getActivityProfileDocument($profile);
```

View File

@@ -0,0 +1,88 @@
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:
```php
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:
```php
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](client.md), you can obtain an agent
profile API client by calling its ``getAgentProfileApiClient()`` method:
```php
$agentProfileApiClient = $xApiClient->getAgentProfileApiClient();
```
Storing Agent Profile Documents
-------------------------------
You can simply store an ``AgentProfileDocument`` passing it to the
``createOrUpdateAgentProfileDocument()`` method of the xAPI client:
```php
$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:
```php
$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:
```php
$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:
```php
$profile = ...; // the agent profile the document should be retrieved from
$document = $agentProfileApiClient->getAgentProfileDocument($profile);
```

70
vendor/php-xapi/client/doc/client.md vendored Normal file
View File

@@ -0,0 +1,70 @@
Building an xAPI Client
=======================
The xAPI client library ships with a builder class which eases the process of
creating an instance of an ``XApiClient`` class:
```php
use Xabbuh\XApi\Client\XApiClientBuilder;
$builder = new XApiClientBuilder();
$xApiClient = $builder->setBaseUrl('http://example.com/lrs/api')
->setVersion('1.0.0')
->build();
```
The builder creates a client for the 1.0.1 API version if you don't set a version.
HTTP Basic Authentication
-------------------------
Use the ``setAuth()`` method if access to the LRS resources is protected with
HTTP Basic authentication:
```php
use Xabbuh\XApi\Client\XApiClientBuilder;
$builder = new XApiClientBuilder();
$xApiClient = $builder->setBaseUrl('http://example.com/lrs/api')
->setAuth('username', 'password')
->build();
```
OAuth1 Authentication
---------------------
Using the ``setOAuthCredentials()`` method, you can configure the client to
access OAuth1 protected resources:
```php
use Xabbuh\XApi\Client\XApiClientBuilder;
$builder = new XApiClientBuilder();
$xApiClient = $builder->setBaseUrl('http://example.com/lrs/api')
->setOAuthCredentials('consumer-key', 'consumer-secret', 'token', 'token-secret')
->build();
```
Using the APIs
--------------
The Experience API consists of four sub APIs: the statements API, the state API,
the activity profile API and the agent profile API. A client for each of these
APIs can be obtained from the global ``XApiClient`` instance:
```php
$statementsApiClient = $xApiClient->getStatementsApiClient();
$stateApiClient = $xApiClient->getStateApiClient();
$activityProfileApiClient = $xApiClient->getActivityProfileApiClient();
$agentProfileApiClient = $xApiClient->getAgentProfileApiClient();
```
Read the dedicated chapters of the sub APIs to learn how to make use of them:
1. [The Statements API](statements.md)
1. [The State API](state.md)
1. [The Activity Profile API](activity_profile.md)
1. [The Agent profile API](agent_profile.md)

12
vendor/php-xapi/client/doc/index.md vendored Normal file
View File

@@ -0,0 +1,12 @@
Documentation
=============
1. [Obtaining an xAPI client](client.md)
1. [The Statements API](statements.md)
1. [The State API](state.md)
1. [The Activity Profile API](activity_profile.md)
1. [The Agent profile API](agent_profile.md)

90
vendor/php-xapi/client/doc/state.md vendored Normal file
View File

@@ -0,0 +1,90 @@
The State API
=============
States
------
A LMS can use the xAPI to store documents associated to a certain state. A state
is dedicated to an activity, an actor, a state id and an optional registration
id (for example a user id):
```php
use Xabbuh\XApi\Model\State;
// ...
$state = new State();
$state->setActivity($activity);
$state->setActor($actor);
$state->setStateId($stateId);
```
Documents
---------
Documents are simple collections of key-value pairs and can be accessed like arrays:
```php
use Xabbuh\XApi\Model\StateDocument;
// ...
$document = new StateDocument();
$document->setState($state);
$document['x'] = 'foo';
$document['y'] = 'bar';
```
Obtaining the State API Client
------------------------------
After you have [built the global xAPI client](client.md), you can obtain a state
API client by calling its ``getStateApiClient()`` method:
```php
$stateApiClient = $xApiClient->getStateApiClient();
```
Storing State Documents
-----------------------
You can simply store a ``StateDocument`` passing it to the ``createOrUpdateStateDocument()``
method of the xAPI client:
```php
$document = ...; // the state document
$stateApiClient->createOrUpdateStateDocument($document);
```
If a document already exists for this state, 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 ``createOrReplaceStateDocument()`` method
instead:
```php
$document = ...; // the state document
$stateApiClient->createOrReplaceStateDocument($document);
```
Deleting State Documents
------------------------
A ``StateDocument`` is deleted by passing the particular ``State`` to the ``deleteStateDocument()``
method:
```php
$state = ...; // the state the document should be deleted from
$stateApiClient->deleteStateDocument($state);
```
Retrieving State Documents
--------------------------
Similarly, you receive a document for a particular state by passing the state to
the ``getStateDocument()`` method:
```php
$state = ...; // the state the document should be retrieved from
$document = $stateApiClient->getStateDocument($state);
```

123
vendor/php-xapi/client/doc/statements.md vendored Normal file
View File

@@ -0,0 +1,123 @@
The Statements API
==================
Obtaining the Agent Profile API Client
--------------------------------------
After you have [built the global xAPI client](client.md), you can obtain a statements
API client by calling its ``getStatementsApiClient()`` method:
```php
$statementsApiClient = $xApiClient->getStatementsApiClient();
```
Storing Statements
------------------
The ``storeStatement()`` and ``storeStatements()`` methods can be used to store
a single Statement or a collection of Statements. Both method return the stored
Statement(s) each having a unique id created by the remote LRS.
```php
use Xabbuh\XApi\Model\Statement;
$statement = new Statement();
// ...
// store a single Statement
$statementsApiClient->storeStatement($statement);
$statement2 = new Statement();
// ...
// store a collection of clients
$statementsApiClient->storeStatements(array($statement, $statement2));
```
Retrieving Statements
---------------------
Use the ``getStatement()`` method to obtain a certain Statement given its id:
```php
// ...
// get a single Statement
$statement = $statementsApiClient->getStatement($statementId);
```
``getStatements()`` returns a collection of Statements encapsulated in a
StatementResult instance:
```php
// ...
// returns all accessible Statements
$result = $statementsApiClient->getStatements();
```
You can even filter Statements using a StatementFilter:
```php
use Xabbuh\XApi\Model\StatementsFilter;
// ...
$filter = new StatementsFilter();
$filter
->byActor($actor) // filter by Actor
->byVerb($verb) // filter by Verb
->byActivity($activity) // filter by Activity
->byRegistration(...) // filter for Statements matching the given
// registration id
->enableRelatedActivityFilter() // apply the Activity filter to Sub-Statements
->disableRelatedActivityFilter() // apply the Activity filter to Sub-Statements
->enableRelatedAgentFilter() // apply the Agent filter to Sub-Statements
->disableRelatedAgentFilter() // apply the Agent filter to Sub-Statements
->since(new \DateTime(...)) // filter for Statements stored since
// the given timestamp
->until(new \DateTime(...)) // filter for Statements stored before
// the given timestamp
->limit(5) // limit the number of Statements returned
->format(...) // the result format (one of "ids", "exact",
// "canonical")
->includeAttachments() // return Statements with attachments included
->excludeAttachments() // return Statements without attachments
->ascending() // ascending order of stored time
->descending(); // ascending order of stored time
$result = $statementsApiClient->getStatements($filter->getFilter());
```
If you limited the number of returned results, you can get the next Statements
by calling the ``getNextStatements()`` method passing the ``StatementResult``
of the previous request to it:
```php
// ....
$filter = new StatementsFilter();
$filter->limit(3);
$firstStatementResult = $statementsApiClient->getStatements($filter);
// get the next Statements
$nextStatementResult = $statementsApiClient->getNextStatements($firstStatementResult);
```
The Experience API doesn't allow to delete Statements. You have to mark them as
voided instead:
```php
// ...
$statement = ...; // The Statement being voided
$actor = ...; // The Actor voiding the Statement
$statementsApiClient->voidStatement($statement, $actor);
```
Voided Statements won't be returned when requesting either a single Statement or
a collection of Statements. Though, you can retrieve a single voided Statement
using the ``getVoidedStatement()`` method:
```php
// ...
$voidedStatement = $statementsApiClient->getVoidedStatement($statementId);
```