Skip to content

Conversation

@akolson
Copy link
Member

@akolson akolson commented Dec 9, 2025

Summary

This PR implements scroll-based progress tracking for the SafeHTML5 viewer to more accurately measure user engagement with content. It also updates the scroll-completion threshold to account for real-world browser behavior, where scrolling often stops just short of the theoretical maximum (1 in our case)

References

Closes #13828

Reviewer guidance

  • Install the Safe Html5 plugin by running kolibri plugin enable kolibri.plugings.safe_html5_viewer
  • Run Kolibri and view HTML5 content
  • Ensure no regressions

@akolson akolson added this to the HTML5 Article Renderer milestone Dec 9, 2025
@akolson akolson requested a review from rtibbles December 9, 2025 13:23
@github-actions github-actions bot added DEV: renderers HTML5 apps, videos, exercises, etc. DEV: frontend SIZE: small labels Dec 9, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Dec 9, 2025

@rtibbles rtibbles self-assigned this Dec 11, 2025
Copy link
Member

@rtibbles rtibbles left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some thoughts on cleanup - I must admit, the duration based progress feels like something we can do further cleanup, outside of the scope of this PR too - I'll think on what that might look like!

progress = this.scrollBasedProgress;
}
this.$emit('updateProgress', progress);
if (progress >= 1) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we could maintain this strictness here - but instead add a correction during the scroll based calculation instead? Otherwise we may end up with a lot of content marked as in progress when a learner thinks they have finished (the finished event doesn't trigger anything progress tracking wise, it's used to disambiguate the technical completion from when it is desirable to trigger further follow up for a user - like displaying the completion modal).


// Wait for DOM update after loading completes
await this.$nextTick();
this.setupScrollListener();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this would be better done in a mounted hook rather than created, to ensure the DOM exists?

setupScrollListener() {
const wrapper = this.$refs.safeHtmlWrapper;
if (wrapper) {
wrapper.addEventListener('scroll', this.handleScroll);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels like a natural candidate for debouncing - so that we don't bother triggering while the user is still actively scrolling.

Will want to set the debounced scroll function on this so you can refer to it when unbinding the function.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could probably conditionalize this on this.forceDurationBasedProgress - if it's not set, we can just call recordProgress at the end of handleScroll?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Properly handle progress tracking based on scroll in the SafeHTML5Viewer

2 participants