Query Needed (Login/Logout)

Query Needed (Login/Logout)

by Nancy Cotton -
Number of replies: 5

Moodle administrator of version 3.9.3 (build 20210108) which is hosted.  I am in need of a query to use with configurable reports that will record the login and logout time of a participant.  If anyone has one available please share or if you know of a plugin that will assist me with this please share also.


Thanks in advance.

Average of ratings: -
In reply to Nancy Cotton

Re: Query Needed (Login/Logout)

by Asoc. LiberaTIC -
Hi Nancy. We would like to help you, but I need more detailed info about what you're expecting: a site list (table format) or the list for a filtered participant. Please, develop a little more your requirements!
In reply to Asoc. LiberaTIC

Re: Query Needed (Login/Logout)

by Nancy Cotton -
Thanks for your response, I am looking for a filtered list for a participant. Want to see if I can determine how long a participant was on the system based on their login and logoff status, even if the system logged them out.
In reply to Nancy Cotton

Re: Query Needed (Login/Logout)

by Nancy Cotton -
Also forgot to add want to include a range of days basically student enrolled on 8-week cycle and need to show the time student actually logged into system.
In reply to Nancy Cotton

Re: Query Needed (Login/Logout)

by Ken Task -
Picture of Particularly helpful Moodlers

Not a report but bash shell query for 24 hour activity ...

script called '24hr' and is executable - contents:

mysql -u root -p -e "use moodle;select userid,action,other,ip,realuserid,origin,ip,timecreated from mdl_logstore_standard_log WHERE timecreated > UNIX_TIMESTAMP(NOW() - INTERVAL 24 HOUR);" > 24hours.txt; cat 24hours.txt|more; wc -l 24hours.txt

24hours.txt looks like:

userid  action  other   ip    realuserid    origin  ip    timecreated
12539   viewed  N;    10.14.7.81    NULL    web     10.14.7.81    1634760025
12539   viewed  N;    10.14.7.81    NULL    web     10.14.7.81    1634760027
12117   viewed  N;    10.14.14.234    NULL    web     10.14.14.234    1634760032
11979   viewed  N;    45.25.37.162    NULL    web     45.25.37.162    1634760036

If one uses:
fgrep 'loggedin' 24hours.txt

output like this:
12500    loggedin    a:1:{s:8:"username";s:9:"user.name";}    10.14.1.221    NULL    web    10.14.1.221    1634845353

If one uses:
fgrep 'loggedout' 24hours.txt

output like this:
12111    loggedout    a:1:{s:9:"sessionid";s:26:"baoe5brkbqm5r26morc7nscdaj";}    10.14.0.225    NULL    web    10.14.0.225    1634760743

In this example:
fgrep 'loggedout' 24hours.txt |wc -l
26

26 users logged out

fgrep 'loggedin' 24hours.txt |wc -l
1070

1070 users logged

Bottom line ... will never 'match up' ... can't control users preventing them from closing the moodle window in browser.

Session eventually times out (240 seconds I think) ... but there is no record of session being erased in that table.

So kinda futile, IMHO! :|

'SoS', Ken