Open danmarsden opened 1 year ago
Hi, any chance of get access to this new feature in beta or alpha mode? I'd like to evaluate if it solves an old issue in SCORM packages.
BR.
sorry - this isn't something we are able to share externally at this stage - feel free to reach out privately if you would like to fund development on the plugin - thanks!
This issue relates to an internal project (block_timespent) with existing code we would like to port to this plugin to provide a 2nd method for obtaining time spent inside a course - the following excerpt is a copy/paste of the concept implemented by that plugin:
The Page Visibility API provides a JavaScript event that can monitor when a document becomes visible or hidden, as well as features to look at the current visibility state of the page. This API is especially useful for saving resources and improving performance by letting a page avoid performing unnecessary tasks when the document isn’t visible.
When the actor switches to a different tab or minimizes the window, the API triggers a visibilitychange event. If we have listeners for this event, we can change state. For example, a actor is looking through some information available on the course, when this happens every minute or so his time spent on the course is sent to the server. And stored in the database. Then the actor switches tabs. We now want to switch off that behavior. This way we decrease the performance load on the actors machine, and we are not submitting time that is being actively spent on the course.
Above you can see the state diagram applicable to this system. This helps us explain when time is tracked and submitted. Time is only tracked when the actor is in the visible state. It increments a variable by one on a one second timer. Okay, so when do we submit the time? For a prevention of loss we submit the time when before mentioned variable hit's a value of
(60 - randomNumber(-10, 10))
. Essentially submitting the time every minute. We also submit time when this one second timer is stopped. The timer is stopped when the actor switches from the visible state to the hidden state, or when the actor switches from the visible state to the idle state. The actor enters the idle state when there are no keystrokes or mouse movements for a configurable amount of time. This means if you've configured the block to enter idle state after 20 minutes, the time submitted could be equal or greater than 20 minutes.