adaptlearning / adapt-contrib-xapi

TinCan/xAPI extension for the Adapt Framework
GNU General Public License v3.0
12 stars 28 forks source link

Responding with a 404 from basic LRS implementation causes getState to fail #121

Open jimjoes opened 1 year ago

jimjoes commented 1 year ago

Subject of the issue/enhancement/features

I'm rolling my own (very simple) xapi endpoint and trying to get a course that uses this plugin to work. It's failing on the initial get state call. The xapi response to a get request to the activities/state endpoint when the state doesn't exist is a 404 with no body. The code here seems to be assuming the objects passed to the callback function are error and the xhr object, respectively. But, as far as I can tell, the xapiwrapper function passes the xhr object and the response... As the xhr object is always there, it seems the code block I've linked to always evaluates to true, which would appear to be incorrect, unless I've misunderstood something - I think that's why the course is failing to initialise? That being said, this comment appears to contradict my thinking, so I'm not sure how to proceed.

Your environment

5.31.7

Steps to reproduce

  1. Create new course
  2. Add xapi plugin and configure for xapi endpoint that replies with a 404 to the activities/state path if no state is found.
  3. Publish course.
  4. Browse to the course.

Expected behaviour

I would expect the 404 to be handled gracefully and for the course to post a 'virgin' state object

Actual behaviour

The GET method fails and the course hangs.

Screenshots (if you can)

error error