Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Send xAPI statements to a remote LRS #45

Open
nadavkav opened this issue Apr 8, 2016 · 18 comments
Open

Send xAPI statements to a remote LRS #45

nadavkav opened this issue Apr 8, 2016 · 18 comments

Comments

@nadavkav
Copy link
Contributor

nadavkav commented Apr 8, 2016

Is there any plans (roadmap) on adding an xAPI dispatcher?
outside of Moodle, to an LRS?
or inside Moodle, (1) into a custom hvp DB table (2) Moodle's mdl_logstore_standard_log ?

@nadavkav
Copy link
Contributor Author

nadavkav commented Apr 8, 2016

A quick wip...
I have added adlnet xAPIWrapper to hvp (there are others too)
and used it on two different LRS clouds (grassblade & watershedlrs) which worked great.
using the following JS code

Added the following code to mod/hvp/view.php

// xAPI (ADL) js wrapper.
$PAGE->requires->js(new moodle_url($CFG->httpswwwroot . '/mod/hvp/xapi-jswrapper/dist/xapiwrapper.min.js'), true);
$PAGE->requires->jquery();
$PAGE->requires->js(new moodle_url($CFG->httpswwwroot . '/mod/hvp/js/xapi-stmt-dispatcher.js'), true);

And some basic JS code (xapi-stmt-dispatcher.js) that listens to xAPI events and send the statement to an external LRS

$(document).ready(function () {
    ADL.XAPIWrapper.changeConfig({
        'endpoint': 'https://sandbox.watershedlrs.com/api/organizations/2991/lrs/',
        "auth" : "Basic " + toBase64('username:password')

    });
    H5P.externalDispatcher.on('xAPI', function(event) {
        console.log(event.data.statement);
        var stmt = new ADL.XAPIStatement(
            event.data.statement.actor,
            event.data.statement.verb,
            event.data.statement.object);
        stmt.generateId();
        stmt.generateRegistration();
        console.log(JSON.stringify(stmt));
        ADL.XAPIWrapper.sendStatement(stmt);

    });
});

@falcon-git
Copy link
Member

Thanks for sharing! We plan to add server side evaluation of answers and APIs so that third party plugins may send xAPI statements to LRS with secure server to server communication.

@nadavkav
Copy link
Contributor Author

Super cool :-)

We discussed the above prototype today, and we plan to send all the xAPI statements directly into Moodle's log (mdl_logstore_standard_log) by extending the your ajax.php file. (have the above js code send the xAPI statements locally to Moodle)

What do you think?

Do you plan to have a local hvp special Moodle table to hold all the events that happen inside each h5p interaction?

@falcon-git
Copy link
Member

On Drupal and WordPress H5P doesn't store the statements at all. Only makes them available for other plugins. Initially I would prefer doing the same on Moodle, but I think I have to study Moodle a bit more first. Perhaps we should do something along the lines you suggest instead. Is this a normal way of using Moodle's log? What is it normally used for?

@nadavkav
Copy link
Contributor Author

@falcon-git , Is it Ok with you guys that I use the adlnet xAPIWrapper when sending PR with this patch?

@garemoko
Copy link

As mentioned here, I'd have the logstore plugin send all the statement server side (and handle re-sending when there's an error etc etc) rather than send them client side with the JS library.

@falcon-git
Copy link
Member

I agree with @garemoko.

@nadavkav
Copy link
Contributor Author

Agreed (thank you)

@garemoko
Copy link

garemoko commented Aug 8, 2016

Reflecting some more on this, it would be really cool if H5P were to be implemented as Moodle quiz question types. In that case, potentially all of the tracking could be handled by existing Moodle xAPI tracking code.

@nadavkav
Copy link
Contributor Author

nadavkav commented Aug 8, 2016

@garemoko you might be interested watching this: #104

@polarbear717
Copy link

@nadavkav hello there, were are currently two students setting up moodle with the H5P plugin and connecting it to Learning Locker. We are not familiar with Java Script and just followed your suggested instructions to send the H5P xAPI Statements to Learning Locker. It all works fine, but the "result" Object is missing although it is generated. It seems like the xAPIWrapper doesnt catch it. Is there any solution to do so?
xapi_statements

@nadavkav
Copy link
Contributor Author

nadavkav commented Sep 7, 2018

@polarbear717 , both LL and H5P changed so much since this code was used, and also it was only a prototype. which eventually was not the proper way to go about it.
Now, I use https://moodle.org/plugins/logstore_xapi to send all Moodle events (including H5P) to LL.

H5P JS is already sending xAPI into Moodle and store them in a local table. better use a Moodle observer to catch them on the server side.

@polarbear717
Copy link

polarbear717 commented Sep 8, 2018

@nadavkav thank you alot for your support. Is there any special solution you could recommend for setting up the Moodle observer or a ready to run one out there? (We just need the xAPI Statements from H5P to evaluate the quality of our created courses, especially the "result" object)

@nadavkav
Copy link
Contributor Author

nadavkav commented Sep 8, 2018

There is no specific H5P event that you can observe (listen to) when a client side (JS) activity finishes
The xAPI statement is saved: https://github.com/h5p/h5p-moodle-plugin/blob/master/classes/xapi_result.php#L116
But you might like to observer Moodle core grade update events for hvp?
https://github.com/h5p/h5p-moodle-plugin/blob/582e10fc31576e68982ff8cf92b7bb681a6d3167/classes/user_grades.php#L81

@polarbear717
Copy link

I am not sure if I got it right, does the Moodle core grade update happen everytime someone answers a question from some sort of hvp course and provides information about their selected answer or does it trigger when the person finishes the course and I am not able to see the individual answers they selected?
For example a course with two multiple choice questions:

1.Question 5 + 4 = ?

  1. Answer 7
  2. Answer 8
  3. Answer 9
  4. Answer 10

The student selects the 2nd answer. Does it trigger the moodle core grade update? Am I able to see he selected answer 2 , or do I just get the feedback 0/1 Points?

2.Question 3 * 6 = ?

  1. Answer 18
  2. Answer 19
  3. Answer 20
  4. Answer 21

The student selects the 1st answer. The course is completed and now the moodle core grade update is triggerd, I receive the information the student scored 1/2 Points but no further information?

@nadavkav
Copy link
Contributor Author

nadavkav commented Sep 8, 2018

I am not entirely sure what do you mean when you refer to a "course"?
Is it a H5P activity? (If YES... than Moodle update a user's grade after an attempt to answer it finishes)

@polarbear717
Copy link

My bad, course is indeed the wrong word, "class" would have made much more sense. But anyway your assumption, that I´m referrering to the H5P activitys, is correct.

Thank you for your patience and support 👍 keep up the good work

@flxzt
Copy link

flxzt commented Sep 10, 2018

Hi nadavkay, sorry to hijack this issue thread for our problem. I'm working with polarbear717 and I am very interested on how you managed to catch and store the xapi statements in the logstore. Unfortunatly we both have no experience in PHP/JS, so we're a little bit stuck (We have the same configuration with H5P, Moodle and learninglocker). The code you used would be greatly appreciated:) Kind regards, Felix

jasonliancatalyst referenced this issue in catalyst/moodle-mod_hvp Jun 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants