Wednesday, October 07, 2026

query to find number of concurrent users - and what they are doing - in Moodle

(for my reference, conversation with Gemini is at https://aistudio.google.com/prompts/1rp43v9LvY7d-b6pk82fgF0dDVQPWmJh8 )

Query to run on the database to find the number of concurrent users - 

SELECT COUNT(DISTINCT l.userid) AS unique_users_active
FROM mdl_logstore_standard_log l
WHERE l.timecreated BETWEEN [START_UNIX_TIMESTAMP] AND [END_UNIX_TIMESTAMP]; 

and similarly, to know what they were doing,

SELECT 
    u.username, 
    u.firstname, 
    u.lastname, 
    FROM_UNIXTIME(l.timecreated) AS time_of_action,
    l.eventname, 
    l.component, 
    l.target
FROM mdl_logstore_standard_log l
JOIN mdl_user u ON u.id = l.userid
WHERE l.timecreated BETWEEN 1791281400 AND 1791285000
ORDER BY l.timecreated ASC;

No comments:

Post a Comment