blocks_retained:usestats:algorithm

Block Use Stats (User Time tracking): algorithm

This article is about what the Use Stats block actually “does”.

The Use Stats block is a “usage time” compiler. It tries to determine at best the time spent by the user in the different contexts of Moodle.

To do so, it analyzes the user's traces, and first calculates a differential delay with respect to the last known trace of the same user. It is the “tracking” function of standard traces that makes this calculation over water by “following” the standard trace table as close as possible.

The problems to solve

The two main problems to solve in the analysis and compilation of past times are:

  • The problem of disconnections or break of sessions
  • The problem of choosing time aggregation

Break of sessions

The break in session is far from being an “explicit” event, marked by an action duement recorded in the traces of use. The observation of the practice shows that very few users activate an explicit disconnection of Moodle when they have finished their session of use. Most often, the browser is closed on the last window used, or the computer is stopped by the system command, when other events such as a forced sleep are not triggered.

For this reason, it is necessary to set up a “heuristic” device that will “guess” in which condition a user must be considered to have left the work session, by examining only the tangible data that the block has: traces.

keep_alive approach

A new approach to resolving break in session integrity has been implemented as a Javascript add-on to all Moodle pages. This addition issues an automatic request (every 10 minutes by default) resulting in the creation of a trace event filled with the context of the page from which it is issued. This feature needs to be built into the theme (for example, in the section that specializes a specific footer) in the form of the following call:

  include_once $CFG->dirroot.'/blocks/use_stats/lib.php';
  echo block_use_stats_setup_theme_notification();

In the footer part of the layouts of the theme.

An alternative is indicated in the installation guide of this documentation.

At the moment, the “keep_alive” approach does not handle usage situations with many parallel browsers for the same user.


Back to home - Back to plugin list order by type - Back to the component index - User guide - Technical index

blocks_retained/usestats/algorithm.txt · Last modified: 2024/05/14 15:37 (external edit)