otacke / h5pxapikatchu

WordPress plugin to store xAPI statements emitted by H5P
MIT License
10 stars 6 forks source link

Statements not being stored #6

Closed thedeviousdev closed 6 years ago

thedeviousdev commented 6 years ago

Hey Oliver,

I am trying to get the statements to be stored and am having no luck. I turned on the console debugging, and statements are being captured via h5pxapikatchu but they don't seem to be displayed in the WP back-end (wp-admin/admin.php?page=h5pxapikatchu_options). I get the following message:

There is no xAPI information stored.

I've checked my database, and the tables are being created: wp_h5pxapikatchu, wp_h5pxapikatchu_actor, wp_h5pxapikatchu_result, wp_h5pxapikatchu_verb.

There are statements being stored in the wp_h5pxapikatchu table. Belong is an example:

{"actor":{"name":"ivadmin","mbox":"mailto:samara@name.com.au","objectType":"Agent"},"verb":{"id":"http://adlnet.gov/expapi/verbs/interacted","display":{"en-US":"interacted"}},"object":{"id":"http://name.com.au/clients/name/wp-admin/admin-ajax.php?action=h5p_embed&id=6?subContentId=b535852c-7543-4b8a-bd08-93eb094f123c","objectType":"Activity","definition":{"extensions":{"http://h5p.org/x-api/h5p-local-content-id":6,"http://h5p.org/x-api/h5p-subContentId":"b535852c-7543-4b8a-bd08-93eb094f123c"},"name":{"en-US":"Where should you store Gavin and the gang to keep them fr..."}}},"context":{"contextActivities":{"parent":[{"id":"http://name.com.au/clients/name/wp-admin/admin-ajax.php?action=h5p_embed&id=6","objectType":"Activity"}],"category":[{"id":"http://h5p.org/libraries/H5P.MultiChoice-1.10","objectType":"Activity"}]},"extensions":{"http://id.tincanapi.com/extension/ending-point":"PT33S"}}}

I have tried enabling Store complete statements in-case that was causing an issue but that did not resolve it either.

Am I looking in the wrong place for this data?

Thanks for creating this plugin!

otacke commented 6 years ago

Hi Samara!

Thanks for reaching out and sorry that you're having trouble.

So, the xAPI statement is stored in the xAPI field of the h5pxapikatchu table, but the other fields are empty?

If the complete table instead is still empty: Are you testing your content on the admin dashboard of WordPress? No statements are stored then, because that'd mess with your statistics.

If possible, you might also have a look at the PHP error log of the server. If there's still a bug in the code, it might have left some traces there.

Best, Oliver

thedeviousdev commented 6 years ago

Hi Oliver,

Sorry, I should have posted the entire row (attached an image). I am testing the content with a public facing page (H5P shortcode), I've tried it while logged in and not.

I have debugging turned on and nothing seemed to come up, but I'll another look at the the logs when I am back in the office.

data

otacke commented 6 years ago

For whatever reason, the column "id_object" contains 0, so there's no object data to link to. It seems, that on your setup, somewhere the true id is lost -- can't say why.

How does the object table look like?

thedeviousdev commented 6 years ago

I've removed the plugin and made sure the collation of all of my tables are the same as the one being set by your plugin. This is the error log being generated when I activate the plugin:

[21-May-2018 23:31:02 UTC] WordPress database error You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '(id) ) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_520_ci' at line 10 for query CREATE TABLE wp_h5pxapikatchu_object ( id mediumint(9) NOT NULL AUTO_INCREMENT, xobject_id TEXT, object_name TEXT, object_description TEXT, object_choices TEXT, object_correct_responses_pattern TEXT, h5p_content_id INT(10), h5p_subcontent_id VARCHAR(36) PRIMARY KEY (id) ) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_520_ci made by activate_plugin, do_action('activate_h5pxapikatchu/h5pxapikachu.php'), WP_Hook->do_action, WP_Hook->apply_filters, H5PXAPIKATCHU\on_activation, H5PXAPIKATCHU\Database::build_tables, dbDelta [21-May-2018 23:31:02 UTC] PHP Notice: wpdb::prepare was called <strong>incorrectly</strong>. The query argument of wpdb::prepare() must have a placeholder. Please see <a href="https://codex.wordpress.org/Debugging_in_WordPress">Debugging in WordPress</a> for more information. (This message was added in version 3.9.0.) in /home/name/public_html/clients/interactive_video/wp-includes/functions.php on line 4147 [21-May-2018 23:31:02 UTC] PHP Notice: wpdb::prepare was called <strong>incorrectly</strong>. The query does not contain the correct number of placeholders (0) for the number of arguments passed (1). Please see <a href="https://codex.wordpress.org/Debugging_in_WordPress">Debugging in WordPress</a> for more information. (This message was added in version 4.8.3.) in /home/name/public_html/clients/interactive_video/wp-includes/functions.php on line 4147

As an aside, this warning is coming up as well:

[21-May-2018 23:30:03 UTC] PHP Deprecated: Non-static method H5PXAPIKATCHU\PrivacyPolicy::add_privacy_policy() should not be called statically in /home/name/public_html/clients/interactive_video/wp-includes/class-wp-hook.php on line 286

otacke commented 6 years ago

The collation is set by WordPress. I used the same pattern as suggested in the official coding guide. I'll try to reproduce the problem on my system and see what I can do.

Thanks for the other hint as well. That's an easy fix.

otacke commented 6 years ago

I just browsed the code, and the problem seems to be a missing comma at the end of https://github.com/otacke/h5pxapikatchu/blob/master/class-database.php#L72

I guess some databases are more tolerant and ignore the error. Could you try if adding a comma fixes the bug on your end? It's the middle of the night in Norway, and I'm waiting to fall asleep ;-)

thedeviousdev commented 6 years ago

Hah, fair enough. The day is just starting here in Australia. ;)

I updated the comma and it did fix it! Thanks for staying up.

otacke commented 6 years ago

Well, thanks a lot for unvoluntarily hunting the bug! I'll fix both issues today and upload an update.