SQL time spent on site

SQL time spent on site

by scott braithwaite -
Number of replies: 7

Hi all am trying find out is there a way to find out how long users have spent on our moodle site since first logged in, over a week, month year.


If I can extract this data somehow I then need to look at how to get the overall average time spent logged in as well.


Thanks in advance 

Scott

Average of ratings: -
In reply to scott braithwaite

Re: SQL time spent on site

by scott braithwaite -

just to be a bit more specific: I will get the full length of time someone has spent on moodle e.g have they spent 4 hours on the site since the first time they logged on, but may have only spent 20 minutes in the last week.  I have been looking through the tables and also the ER diagram to look for clues to this but am not certain how to pull this data out of the database or if it currently exists.  We are using Moodle 3.0 and MariaDB.  


Once I have extracted this data (presuming it is possible)  I then need to calculate the average time spent for all users when logged in either for the full time since they have signed up or over a specific period of time.  I could also get away with doing it per login session here as long as I can extract some data.


Can anyone tell me if this is possible, is the data available to carry this out ?


Thanks


Scott

In reply to scott braithwaite

Re: SQL time spent on site

by Davo Smith -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Your best bet will be the mdl_logstore_standard_log table - but it will be up to you to define what you mean by 'how long a user has spent on Moodle'.

Does clicking on a page, then clicking on another page 5 min later count as spending 5 min on Moodle? What about clicking on one page, then clicking on another page 1 hour later? Is 1 hour later a separate visit, or did they spend that time reading through a very long document on that page? What about two log entries 6 hours apart?

You'll have to figure out for yourself what the threshold is for two log entries being part of the same visit (and how you can determine if they were actually looking at the pages, rather than clicking on them and then going off to make a cup of tea).


In reply to Davo Smith

Re: SQL time spent on site

by scott braithwaite -

Thanks Davo 

Have been worrying over the same thing myself, but have been asked to look at producing a report along these lines mores as a proof of concept so may suggest against using this report when I show them the queries I have put together later in the week but its just having something in place for then in case we go ahead with it.

As I don't think that you can accurately tell whether a user is just on the page and doing something else or actually reading the material on the pages, what if they have just left the page open in another tab.


So what ever data is produced is going to be suspect at best but I will look at the log table and see what I can put together for now.


Thanks Scott 

In reply to scott braithwaite

Re: SQL time spent on site

by Marcus Green -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers

Hi Scott

The data will be worse than suspect, it will tell you little more than calculating the time between item requests from a web site tells you nothing useful. The request for a report like this is quite common and it relates to a peculiar desire to equate time apparently spent with concepts learnt. It is like awarding qualifications for time spent in the classroom, or for amount of time watching video.

By contrast a good set of quizzes can give some interesting insights into what learning has occurred. However that requires more repeated quite difficult creative work, rather than the running of standard reports.

It is worth doing some searches of these forums over the years to read the discussions of this idea.

In reply to Marcus Green

Re: SQL time spent on site

by Matt Bury -
Picture of Plugin developers

Hi,

I've been following this discussion and others on this topic with interest because it is, as Marcus mentioned, a common request.

I don't think presenting the data in reports is a problem, it's the interpretation, so I think it's desirable to present the data in such a way as to make it clear of what we're looking at, i.e. HTTP requests to the server only.

Perhaps presenting the requests per user along a time-line, then we can be transparently speculative over what this data might mean? How does that sound?

BTW, here's an amusing website dedicated to misleading analytics data: http://www.unfitbits.com/index.html

In reply to Matt Bury

Re: SQL time spent on site

by scott braithwaite -

Hi Marcus and Matt

Thanks for your comments and much appreciate the help here, I have been looking over a few of the posts around the forum, and have to agree trying to pull what they want for time spent on site just isn't going to be accurate, however I may look into the http requests that matt suggested as an alternative am going to suggest this tomorrow and see how I get on.


Thanks 


Scott

In reply to scott braithwaite

Re: SQL time spent on site

by Chris Wharton -

Hi Scott, we have implemented this for a client in a different way.

The course and activity tables have an additional field called "learning time". When a course or activity is edited, a value can be added that represents the time that the item "should" take. The use case is meeting required professional development hours, eg. "A learner must complete 8 hours of PD per month"

For example a particular SCORM activity might be worth 1 hour of learning time. The whole course is 1 day.

Then we use custom reports to show the effective time spent in courses, independent of the "real" time spent clicking around the browser.