H5P quiz multiple results not saving

Hello everyone,

I have a problem/bug that i want to share it with you and find possible answer. I have a website, with h5p interactive content question sets, where an user has two complete the quiz atleast 2 times to see his/her improvements. The problem is that when an user completes the same question set, only one ( probably the latest ) score is stored in the database and shown in the results page. What i need is for the database to save all the scores. I tried surfing throughout the code by myself, but can't seem to find the answer.

Any help or suggestions would be greatly appreciated.

thomasmars's picture

The database layer is tightly coupled with the cms integration. I think your best bet is to listen for 'xAPI' events and record the results in an LRS or a system of your own, this way you can catch the scores, and stored them separately if you please.

A step in the right direction would be to check out how to catch xAPI statements: https://h5p.org/documentation/x-api

Hello,

Thank you alot for your answer. I modified the database by deleting content_id and uid as the primary keys and adding "id" as auto_increment. Everything works as if nothing has changed and i added manually to the database one more answer with the same uid and content_id but different answer and at the result page everything was showing as intendent, but the problem is that after the test completes the code searches for the same uid and content_id to update the database and i want to delete that and just always add to the db. Maybe you know, where can i find that part of the code, because searching manually and googling it didn't work.

Thank you for your time.

thomasmars's picture

The function for updating the score in the database varies between the different plugins, since it is tightly integrated with the CMS. For Drupal it is found in h5p.module in the function h5p_set_finished, which updates the points of given content_id.

If i get it right, the logic behind this is that the h5p saves content_id, uid and started time, and after the user has scored the question set it searches for the content_id and uid and updates it with results and other stuff? If yes, then i need to delete the code to always add one more line in the db, and then add a condition to add the score to the max id? I made a sample of the code and because i'm just a student and trying to learn i attached a picture for your recomendations and fixes.

Thank you again for your time.

Attachments: 

Hello Thomas,

I wanted to say Thank you for quick replies. I managed to fix it. This is the instruction for those who are still searching for the answer:

1. Go to sql database -> h5p_points table and add column with name "id" and add it to the Primary Key array

2. Find file h5p.module in .../sites/all/modules/h5p and edit it (i prefer notepad++)

3. Search for "Callback function for storing the users results in the database"

4. Edit code as seen in the picture.

And you are done. Now everytime user completes a quiz, the answer will be added separatedly and all the answers.

P.S i dont need to know the starting and ending times, so i just make it the ending time.

Attachments: 
thomasmars's picture

I'm glad you got it to work. I would love to read a post on what you can achieve with this and what your use-cases are if you ever decide on writing about it :) Could be very interesting for other users as well, with some visualization!

Any chance this type of functionality will be added to the official Drupal module? It could be made a configurable option for those who want to avoid database bloat, but I imagine this would be highly valued by most users of the Drupal module. It would bring H5P on Drupal closer to being a complete and robust LMS. 

thomasmars's picture

There are no concrete plans for this at the moment as far as I know.

There may be some simple reporting features coming in the future, however in general this should be left to LRS's that specialize in storing this type of data and visualizing it. H5P makes all scores available to LRS's so that they may store each attempt, progress and visualize this.

- Thomas

That's disappointing, particularly for those of us who use Drupal itself (and related modules, such as Course) as our LMS and do not connect to an external LRS for reporting purposes.