Interactive Video: Refresh (F5) before submitting resets xAPI state to [null,null] and prevents new answers in that try (lock)

 

Description

Summary

When a learner watches an Interactive Video to the end and refreshes the page before the submit screen (⭐) appears, the H5P xAPI state saved by Moodle is overwritten from a valid value to:

"interactionsProgress":[null,null]

After that refresh, the question markers (“dots”) appear unanswered and clicking a dot no longer shows the question (only a “Continue” button). The submit screen never appears, and no attempt is created in mod_h5pactivity. This is reproducible and leads to stuck progress for the learner.

Steps to reproduce

  1. In Moodle, create an H5P activity with Interactive Video containing at least two questions.

    • H5P activity settings: “Save content state” = enabled; “Attempts allowed” = ≥ 1.

    • H5P content created in the Content bank and attached to the activity (but the issue is the same with the hvp plugin).

  2. As a student, open the activity and answer all questions while watching the video to the end.

  3. When the timeline reaches the end (star marker is visible, submit card has not yet popped up), press F5 (browser refresh).

  4. Re-open the question dots: they show as unanswered; clicking a dot shows only “Continue” (no question).

  5. Check the database:

    • Before the refresh, mdl_xapi_states.statedata contained:

      {"h5p":"{\"progress\":...,\"interactionsProgress\":[1,1], ... }"}
    • After the refresh, the same row is overwritten to:

      {"h5p":"{\"progress\":...,\"interactionsProgress\":[null,null], ... }"}
    • No row is created in mdl_h5pactivity_attempts for that user/activity (since the submit never happens).

Expected behavior

  • Refreshing the page should not erase already answered interactions.

  • The submit screen should appear reliably once the end is reached (or shortly before), allowing the learner to submit and generate an attempt.

Actual behavior

  • A plain browser refresh at the end resets interactionsProgress to [null,null], the submit card does not appear, dots look empty, and the learner cannot resubmit those interactions. No attempt is recorded.

Platform / versions

  • Platform: Moodle 5.0.

  • H5P activity (core, mod_h5pactivity):  updated.

  • H5P content type: Interactive Video, latest from H5P Hub as of Oct 2025.

  • OS / PHP: AlmaLinux 9.6, PHP 8.3 (PHP-FPM).

  • Database: PostgreSQL 17.

  • Save content state: Enabled (site setting).

  • Attempts allowed: ≥ 1.

Mobile or Desktop

  • Desktop.

Browsers

  • Chrome (stable). (Also reproducible in a private window with no extensions.)
    (If you can, add exact versions you tested.)

Browser console errors

  • None observed during reproduction.

Network observations (optional but helpful)

  • On the refresh, the browser sends a POST to the xAPI state endpoint (e.g., /lib/xapi/...post_state) whose payload includes "interactionsProgress":[null,null], overwriting the prior [1,1].

PHP / server errors

  • No PHP-FPM errors at the exact timestamps of the refresh. (Earlier, pool saturation was seen on the server, but this particular issue reproduces without any PHP errors.)

Sample data / evidence

  • Before refresh (mdl_xapi_states.statedata.sample):

    {"h5p":"{\"progress\":945.833,\"maxTimeReached\":945.833,\"answers\":[{\"progress\":1,\"answers\":{\"corrects\":1,\"wrongs\":0},\"userResponses\":[0]},{\"progress\":1,\"answers\":{\"corrects\":1,\"wrongs\":0},\"userResponses\":[0]}],\"interactionsProgress\":[1,1]}"}
  • After refresh:

    {"h5p":"{\"progress\":945,\"maxTimeReached\":945.833,\"answers\":[{\"progress\":1,\"answers\":{\"corrects\":1,\"wrongs\":0},\"userResponses\":[0]},{\"progress\":1,\"answers\":{\"corrects\":1,\"wrongs\":0},\"userResponses\":[0]}],\"interactionsProgress\":[null,null]}"}
  • No attempts for the user/activity:

    SELECT * FROM mdl_h5pactivity_attempts WHERE userid = <user_id> AND h5pactivityid = <activity_id>; -- returns zero rows

Recent changes

  • Migrated from legacy HVP to core H5P activity recently; content libraries updated via H5P Hub.

  • PHP-FPM enabled and tuned; no ModSecurity blocks seen during reproduction.

Workarounds tried

  • Moving the submit/star overlay ~2 seconds before the end helps reliability.

  • Allowing multiple attempts lets learners start fresh, but does not fix the reset of state on refresh.

  • Manually deleting the learner’s xAPI state row restores normal behavior for that user, but he has to rewatch.

Attachments

  • Beware that the video might be locked for embedding in other domains, it might be needed to change the video to an youtube flick.

 

If you want, I can also tailor this for the Moodle Tracker (component mod_h5pactivity) vs. the H5P Interactive Video GitHub repo — same content, slightly different headings.

Content types: