LRS Connector


Introduction

TRAX LRS provides an LRS connector which can be used to push/pull statements to/from an external LRS. This feature is accessible only from the console.

Configuration

The default settings of the LRS connector can be changed in the .env file. They include the LRS endpoint, the Basic HTTP credentials, as well as the number of statements for each request, which is 100 by default.

LRS_PUSH_ENDPOINT=http://traxlrs.com/trax/api/f9cf31d5-4835-43e2-bbb3-a9ab3b6e0edf/xapi/std
LRS_PUSH_USERNAME=testsuite
LRS_PUSH_PASSWORD=aaaaaaaa
LRS_PUSH_BATCH_SIZE=100

LRS_PULL_ENDPOINT=http://traxlrs.com/trax/api/f9cf31d5-4835-43e2-bbb3-a9ab3b6e0edf/xapi/std
LRS_PULL_USERNAME=testsuite
LRS_PULL_PASSWORD=aaaaaaaa
LRS_PULL_BATCH_SIZE=100
LRS_PULL_AUTHORITY_NAME=pull
LRS_PULL_AUTHORITY_HOMEPAGE=http://traxlrs.com

Commands

Before using these commands, you must create a store in your LRS.

Pushing statements

You can create a pushing job for each store and entity.

php artisan statements:lrs-push

The following parameters are optional. When not provided in the command line, some of them will be asked.

Option Example of value Description
--endpoint http://traxlrs.com/xapi The LRS endpoint
--username lrs-client The Elasticsearch username
--password 123456 The Elasticsearch password
--batch 50 The batch size
--owner 1 Internal ID of the LRS store
--entity 1 Internal ID of an LRS entity, or -1 (all entities), or omitted (no entity)
--noprompt Don't ask options (take defaults)
--restart Restart from the 1st record
--ignore-first-error Ignore the first error when resuming

Showing the push status

You can display the status of the last push with:

php artisan statements:lrs-push-status

When not provided in the command line, the following option will be asked.

Option Example of value Description
--owner 1 Internal ID of the LRS store
--entity 1 Internal ID of an LRS entity

Pulling statements

You can create a pulling job for each store and entity.

php artisan statements:lrs-pull

The following parameters are optional. When not provided in the command line, some of them will be asked.

Option Example of value Description
--endpoint http://traxlrs.com/xapi The LRS endpoint
--username lrs-client The Elasticsearch username
--password 123456 The Elasticsearch password
--batch 50 The batch size
--owner 1 Internal ID of the LRS store
--entity 1 Internal ID of an LRS entity
--pseudo Pseudonymize statements
--noprompt Don't ask options (take defaults)
--restart Restart from the 1st record

Showing the pull status

You can display the status of the last push with:

php artisan statements:lrs-pull-status

When not provided in the command line, the following option will be asked.

Option Example of value Description
--owner 1 Internal ID of the LRS store
--entity 1 Internal ID of an LRS entity

Resuming

When a push or pull request fails or when the process is interrupted, you can resume it where it stopped. Relaunch the command and it will ask you if you want to resume or restart.

When the --noprompt option is used, it always tries to resume, except when the --restart option is used together.

Important information

Statements ID

2 statements can't have the same ID in an LRS store.

So if you try to pull the same dataset twice, an error will be thrown. Therefore, you should always remove the pulled data before trying to restart the import.

furthermore, when pushing a batch of statements to an external LRS, the pushing job may be interrupted. When resuming, it has no way to know if the last batch was recorded or not by the external LRS. So it will retry to send the last batch.

If the external LRS already recorded the statements on the first attempt, it will return a 400 error because it will find a conflict between the statements IDs. And the pushing job has no way to know the reason of the 400 error.

In such a situation, you can use the --ignore-first-error option. The pushing job will ignore the first error and will continue to push the next batches.

Validation

We assume that you are pulling statements from another xAPI conformant LRS, so the pull command will not validate the incoming statements again.

You can use php artisan statements:validate to validate the statements afterwards. See statements validation.

Furthermore, the push command will ignore the statements which have been marked as invalid in your LRS. This may be the case after a php artisan statements:validate command.

Logs

If you enabled the logging system, be aware that pulling statements does not generate any log.

Attachments

Currently, the pull and push commands are not able to transfer raw attachments. Statements with raw attachments can be pulled or pushed, but their attachments section will be modified in order to remove the raw attachments.

Voided statements

When pushing or pulling statements to/from an external LRS, only non-voided statements are processed.

Pull frequency

If you need to sync TRAX LRS with an external LRS with to the pull command, it is recommended to run it once a day or more.

Why? Because TRAX LRS will try to use the more property returned by the external LRS in order to get a new batch of statements. The xAPI spec says that this property MUST be usable for at least 24 hours after it is returned by the LRS.

After a delay of 24 hours, TRAX LRS will not use the more property anymore,