h5p / h5p-wordpress-plugin

Adds support for H5P Content in WordPress.
https://wordpress.org/plugins/h5p/
70 stars 75 forks source link

Content results not being shown #183

Open malimart opened 4 weeks ago

malimart commented 4 weeks ago

Description:

I noticed what appears to be a bug where admins of a WordPress site are unable to check the results of the H5P quizzes. Instead of showing the results a message is displayed. The message says "There are no logged results for this content" even though the results are saved in the database.

Unfortunately I was unable to reproduce the bug consistently, so I'm writing here in the hopes that somebody will be able to help.

Steps to Reproduce:

  1. Navigate to the "All H5P Content" section in the WordPress admin dashboard (wp-admin/admin.php?page=h5p)
  2. Click on results.

Expected Behavior:

If the selected content has results saved in the database, they should appear here like so:

Screenshot from 2024-08-20 11-06-29

Actual Behavior:

Sometimes even if the results exist, they do not get displayed. Instead a message is shown (There are no logged results for this content.) This happens for all the content, not just one quiz.

image

Troubleshooting

In the settings logging of results is enabled:

image

The results do get saved to the database:

mysql> select * from wp_50240_h5p_results;
+-----+------------+---------+-------+-----------+------------+------------+------+
| id  | content_id | user_id | score | max_score | opened     | finished   | time |
+-----+------------+---------+-------+-----------+------------+------------+------+
|   1 |          4 |   78480 |     1 |         1 | 1664951616 | 1664951624 |    0 |
|   2 |          4 |   17315 |     0 |         1 | 1664951648 | 1664951650 |    0 |
|   3 |          6 |   78481 |     1 |         8 | 1677227754 | 1677227780 |    0 |
|   4 |          7 |   78481 |     6 |         6 | 1677413842 | 1677413909 |    0 |
|   5 |          8 |   78481 |     2 |         2 | 1672305441 | 1672305448 |    0 |
|   6 |          9 |   78481 |     0 |         4 | 1672305977 | 1672305986 |    0 |

I noticed that the Ajax request is returning empty rows (/wp-admin/admin-ajax.php?action=h5p_content_results&id=4):

image

I checked the database and in this case the results table does have 5 results for this content id. You can see in the picture above that 5 rows have indeed been found. However, an empty array is returned instead of the actual results.

Additional Information:

Like I said the error seems to be inconsistent. Sometimes I am able to reproduce it sometimes not. The only thing I can say for sure is that the "bug" appears only on versions >= 1.15.7. Version 1.15.6 and bellow never have this problem.

I also noticed that when the bug appears, the users are still able to see their results under the My Results submenu (wp-admin/admin.php?page=h5p_results). I'm not sure what would cause such behavior. I ruled out plugin conflicts.