trax-project / moodle-trax-video

This plugin let's you add xAPI videos into your Moodle courses.
GNU General Public License v3.0
3 stars 2 forks source link

Can only send navigated-in action, no other actions. #2

Closed fishfree closed 3 years ago

fishfree commented 3 years ago

I install the latest master branches of trax-log and trax-video from Github in my Moodle 3.10. But only send navigated-in action, no seek/pause/mute/time spent actions. The navigated-in log is as below:

{
  "stored": "2021-04-22T03:11:34.769Z",
  "active": true,
  "completedForwardingQueue": [],
  "failedForwardingLog": [],
  "client": "6061377a8700b0a25fde4a0b",
  "lrs_id": "60613d068700b0a25fde4a0c",
  "completedQueues": [],
  "activities": [
    "https://moodle.***.com/xapi/activities/traxvideo/f4e4b58b-2de7-455b-8e3a-8440459ada27"
  ],
  "hash": "a20995e9f55eb538c087b4073721449577b2e5f5",
  "agents": [
    "https://moodle.***.com|1993"
  ],
  "statement": {
    "authority": {
      "objectType": "Agent",
      "name": "New Client",
      "mbox": "mailto:hello@learninglocker.net"
    },
    "stored": "2021-04-22T03:11:34.769Z",
    "context": {
      "contextActivities": {
        "category": [
          {
            "id": "http://vocab.xapi.fr/categories/learning-unit",
            "definition": {
              "type": "http://vocab.xapi.fr/activities/granularity-level"
            },
            "objectType": "Activity"
          },
          {
            "id": "http://vocab.xapi.fr/categories/vle-profile",
            "definition": {
              "type": "http://adlnet.gov/expapi/activities/profile"
            },
            "objectType": "Activity"
          },
          {
            "id": "http://vocab.xapi.fr/categories/moodle/traxvideo",
            "definition": {
              "type": "http://adlnet.gov/expapi/activities/profile"
            },
            "objectType": "Activity"
          }
        ],
        "grouping": [
          {
            "id": "https://moodle.***.com",
            "definition": {
              "type": "http://vocab.xapi.fr/activities/system"
            },
            "objectType": "Activity"
          }
        ],
        "parent": [
          {
            "id": "https://moodle.***.com/xapi/activities/course/cb1e1884-eb6e-4d51-a728-b8540b621e59",
            "definition": {
              "type": "http://vocab.xapi.fr/activities/course"
            },
            "objectType": "Activity"
          }
        ]
      },
      "extensions": {
        "http://vocab.xapi.fr/extensions/platform-event": "\\mod_traxvideo\\event\\course_module_viewed"
      },
      "platform": "Moodle"
    },
    "actor": {
      "objectType": "Agent",
      "name": "先生 王",
      "account": {
        "name": "1993",
        "homePage": "https://moodle.***.com"
      }
    },
    "timestamp": "2021-04-22T11:11:34+08:00",
    "version": "1.0.0",
    "id": "9b0e034b-27aa-4293-b3a5-e5b4aefd2aee",
    "verb": {
      "id": "http://vocab.xapi.fr/verbs/navigated-in"
    },
    "object": {
      "id": "https://moodle.***.com/xapi/activities/traxvideo/f4e4b58b-2de7-455b-8e3a-8440459ada27",
      "definition": {
        "type": "http://vocab.xapi.fr/activities/web-content",
        "name": {
          "zh": "可跟踪视频"
        },
        "extensions": {
          "http://vocab.xapi.fr/extensions/platform-concept": "traxvideo",
          "http://vocab.xapi.fr/extensions/concept-family": "resource",
          "http://vocab.xapi.fr/extensions/standard": "xapi"
        }
      },
      "objectType": "Activity"
    }
  },
  "hasGeneratedId": true,
  "deadForwardingQueue": [],
  "voided": false,
  "verbs": [
    "http://vocab.xapi.fr/verbs/navigated-in"
  ],
  "processingQueues": [],
  "person": null,
  "timestamp": "2021-04-22T03:11:34.000Z",
  "relatedActivities": [
    "https://moodle.***.com/xapi/activities/traxvideo/f4e4b58b-2de7-455b-8e3a-8440459ada27",
    "https://moodle.***.com/xapi/activities/course/cb1e1884-eb6e-4d51-a728-b8540b621e59",
    "https://moodle.***.com",
    "http://vocab.xapi.fr/categories/learning-unit",
    "http://vocab.xapi.fr/categories/vle-profile",
    "http://vocab.xapi.fr/categories/moodle/traxvideo"
  ],
  "relatedAgents": [
    "https://moodle.***.com|1993",
    "mailto:hello@learninglocker.net"
  ],
  "organisation": "606019faffbe0ca63d3d0123",
  "_id": "6080e966b29dbb0945518131",
  "registrations": [],
  "pendingForwardingQueue": []
}
sfraysse commented 3 years ago

Hi, Could you open your browser console and observe the network activity when you click on the Play/Pause button of the player? You should see some POST requests on the statements API. Do you see errors?

fishfree commented 3 years ago

@sfraysse Hi, no errors in my console as below. When I paused or seeked the video, it triggered the requests as below: image The response code is 303.

sfraysse commented 3 years ago

@fishfree I am surprised by the 303 response which is a redirection code. You are showing me the request, but could I see the content of the response please?

fishfree commented 3 years ago

@sfraysse I attatched 2 screenshots. The first one is the statements request triggered by clicking pause/resume button of the player, the second one is the response. image

image

sfraysse commented 3 years ago

@fishfree Ok so you get a 303 response code and an empty response body. You should get a 200 response code with an array of UUID in the body.

The reason may be that the redirection is not correctly managed.

You should check why you have this redirection on your LRS server and see if you can avoid it.

If this is not possible, you can take a look at this code which handles your requests: admin/toll/log/store/trax/proxy/statements_post.php, line 64, and see what happens exactly.

You can also play with the Guzzle redirection options which are documented here: https://docs.guzzlephp.org/en/stable/request-options.html

I hope this will help.

fishfree commented 3 years ago

@sfraysse Thank you! Now I noticed another error in the console when clicking on pause/resume button of the video player: image

And in the trax video activity page source, I notice that crypto.js is loaded after the xapiwrapper.js image

fishfree commented 3 years ago

I changed the loading order of the 2 js files by modifying the view.php file. But what's worse, the statements request is even not triggered now. The error is in the console: image

sfraysse commented 3 years ago

@fishfree Regarding the message in your console, you can ignore it. It has no impact. I have the same message and it works. So you don't have to change the view.php.

Regarding your previous issue, as I said, it is related to the 303 status returned by your LRS. Did you investigate this?

fishfree commented 3 years ago

@sfraysse I turn on the debug log on my Learninglocker LRS, but there is no related logs. I guess the xhr request URL is not right in the file xapiwrapper.js, should be there a ".php" after /admin/tool/log/store/trax/proxy/statements ? Becuase I added some debug codes in the statements_post.php, the codes did not execute. image

fishfree commented 3 years ago

Finally, I add a hard-coded rewrite rule in my Nginx conf, it works now: rewrite /admin/tool/log/store/trax/proxy/statements /admin/tool/log/store/trax/proxy/statements.php;

sfraysse commented 3 years ago

Hi @fishfree. Thanks for your feedback.

There is a .htaccess with such rewriting rules located in the proxy folder of the plugin. Maybe it was not taken into account with your config.

RewriteEngine On
RewriteRule "^statements" "statements.php" [PT,QSA]
RewriteRule "^activities/state" "states.php" [PT,QSA]
fishfree commented 3 years ago

@sfraysse Yes, Nginx ignore the .htaccess, which is applicable ot Apache.

sfraysse commented 3 years ago

Thanks for your feedback. I updated the doc: https://github.com/trax-project/moodle-trax-logs/blob/master/doc/install.md#lrs-proxy