adlnet / CATAPULT

The goal of the cmi5 Advanced Testing Application and Player Underpinning Learning Technologies (CATAPULT) project is to create a cmi5 player and test suite software to help the DoD education and training community transition from legacy e-learning systems and tools toward an integrated enterprise-wide learning ecosystem.
https://adlnet.gov/projects/cmi5-CATAPULT/
Apache License 2.0
44 stars 21 forks source link

Failure on /api/v1/sessions/21/lrs/activities/state #44

Open mogadanez opened 2 years ago

mogadanez commented 2 years ago

I did setup catapult with cloud lrs.io

more or less working but I have strange issue in with call to GET /api/v1/sessions/21/lrs/activities/state

Added few console.logs at cts/service/plugins/routes/v1/sessions.js

                            if (req.method === "get" && req.params.resource === "activities/state") {
                                if (req.query.stateId === "LMS.LaunchData") {
                                    console.log(uri)
                                    console.log(rawProxyResponsePayload.toString())

on package initialize I'm getting:

Catapult CTS service running on http://4bebdc12c5c3:3399
http://player:3398/lrs/activities/state?agent=%7B%22name%22%3A%22Johnnie%20Schinner%22%2C%22account%22%3A%7B%22name%22%3A%2269d917f%22%2C%22homePage%22%3A%22urn%3Acatapult-cts%3A8bff369%22%7D%2C%22objectType%22%3A%22Agent%22%7D&activityId=https%3A%2F%2Fw3id.org%2Fxapi%2Fcmi5%2Fcatapult%2Fplayer%2Fcourse%2F3d318298-8ad8-468e-a301-3bdb15c62131%2Fau%2F0&stateId=LMS.LaunchData&registration=f8cadac8-30cb-4064-b5b9-a3a0d142c297
! ��Φ��,x�xD�"�V!�P��mY�X��i ɷ_����7�\>j���l�!�£q��a�>�;�5�1Ta0;~��0rF�����L���<L�
                                                                                  uN/VM��auƝ�/d\C}�!��Wi�������uГ�>m�c��D#\���x�bFZ$q�R(1nm�����K={/f���r^�ugDE\�K/�e׳�^�.�k���@����P�k��
               �����io��o���$�����_q����o��q5
Debug: internal, implementation, error 
    SyntaxError: Unexpected token ! in JSON at position 0
    at JSON.parse (<anonymous>)
    at handler (/usr/src/app/plugins/routes/v1/sessions.js:505:64)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at async exports.Manager.execute (/usr/src/app/node_modules/@hapi/hapi/lib/toolkit.js:60:28)
    at async Object.internals.handler (/usr/src/app/node_modules/@hapi/hapi/lib/handler.js:46:20)
    at async exports.execute (/usr/src/app/node_modules/@hapi/hapi/lib/handler.js:31:20)
    at async Request._lifecycle (/usr/src/app/node_modules/@hapi/hapi/lib/request.js:372:32)
    at async Request._execute (/usr/src/app/node_modules/@hapi/hapi/lib/request.js:280:9)

But strange thing is - if I do copy as CURL and repeat it from postman - it works fine and show:

http://player:3398/lrs/activities/state?agent=%7B%22name%22%3A%22Johnnie%20Schinner%22%2C%22account%22%3A%7B%22name%22%3A%2269d917f%22%2C%22homePage%22%3A%22urn%3Acatapult-cts%3A8bff369%22%7D%2C%22objectType%22%3A%22Agent%22%7D&activityId=https%3A%2F%2Fw3id.org%2Fxapi%2Fcmi5%2Fcatapult%2Fplayer%2Fcourse%2F3d318298-8ad8-468e-a301-3bdb15c62131%2Fau%2F0&stateId=LMS.LaunchData&registration=f8cadac8-30cb-4064-b5b9-a3a0d142c297
{"launchMode":"Normal","masteryScore":1,"moveOn":"CompletedAndPassed","contextTemplate":{"contextActivities":{"grouping":[{"id":"https://github.com/xapijs/cmi5-demo/cmi5-demo"}]},"extensions":{"https://w3id.org/xapi/cmi5/context/extensions/sessionid":"973a1ea5-0dd2-473a-9933-566a811a3ddd"}},"entitlementKey":{},"returnURL":"https://localhost/api/v1/sessions/__sessionId__/return-url"}
mogadanez commented 2 years ago

hm... interesting. seems my browser added header Accept-Encoding: gzip, deflate, br and it fail with it.

ahanley commented 5 months ago

@mogadanez your ticket helped me as i was banging my head for hours on this as well!! What i ended up doing was adding the code below to the lrs.js file! delete options.headers["accept-encoding"];