Skip to content

Commit

Permalink
adding xAPI version to cts/player
Browse files Browse the repository at this point in the history
  • Loading branch information
adl-trey committed May 21, 2024
1 parent 8baba1a commit afb781a
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 2 deletions.
1 change: 1 addition & 0 deletions cts/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ services:
- LRS_ENDPOINT
- LRS_USERNAME
- LRS_PASSWORD
- LRS_XAPI_VERSION
networks:
- public

Expand Down
2 changes: 1 addition & 1 deletion cts/service/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ const provision = async () => {
(req) => ({
baseUrl: LRS_ENDPOINT.endsWith("/") ? LRS_ENDPOINT : LRS_ENDPOINT + "/",
headers: {
"X-Experience-API-Version": "1.0.3",
"X-Experience-API-Version": (process.env.LRS_XAPI_VERSION || "1.0.3"),
Authorization: `Basic ${Buffer.from(`${LRS_USERNAME}:${LRS_PASSWORD}`).toString("base64")}`
},
json: true
Expand Down
7 changes: 7 additions & 0 deletions cts/service/plugins/routes/v1/sessions.js
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,13 @@ module.exports = {
options.headers["x-forwarded-host"] = options.headers["x-forwarded-host"] || req.info.host;
}

// The cmi5 JS stuff won't know what the configured LRS's xAPI version is
// between 1.0.3 and 2.0, so replace that here if it was specified.
//
let configuredXAPIVersion = process.env.LRS_XAPI_VERSION;
if (configuredXAPIVersion != undefined)
options.headers["x-experience-api-version"] = configuredXAPIVersion;

// Concurrency check required or xAPI 2.0
//
if (req.method == "post" || req.method == "put") {
Expand Down
1 change: 1 addition & 0 deletions player/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ services:
- LRS_ENDPOINT
- LRS_USERNAME
- LRS_PASSWORD
- LRS_XAPI_VERSIONs
- DATABASE_USER=catapult
- DATABASE_USER_PASSWORD=quartz
- DATABASE_NAME=catapult_player
Expand Down
8 changes: 7 additions & 1 deletion player/service/plugins/routes/lrs.js
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,13 @@ module.exports = {
options.headers["x-forwarded-host"] = options.headers["x-forwarded-host"] || req.info.host;
}

// console.error(uri, options);

// The cmi5 JS stuff won't know what the configured LRS's xAPI version is
// between 1.0.3 and 2.0, so replace that here if it was specified.
//
let configuredXAPIVersion = process.env.LRS_XAPI_VERSION;
if (configuredXAPIVersion != undefined)
options.headers["x-experience-api-version"] = configuredXAPIVersion;

let lrsResourcePath = req.params.resource;

Expand Down

0 comments on commit afb781a

Please sign in to comment.