how do i get total duration of the course

how do i get total duration of the course

by Sushma R -
Number of replies: 10

Hi all,

I have 2 queries about the duration of the course, below are my queries.,

How do i get to know about total duration of the course?

How do i get  total time spent by user on the course?

Do we have any other way to fetch duration other than referring to the standard_logs?


Thanks in advance,

Average of ratings: -
In reply to Sushma R

Re: how do i get total duration of the course

by Geoffrey Van Wyk -
Picture of Plugin developers

> How do i get to know about total duration of the course?

Do you want to know as a user or a developer? As a developer, you can use $course->startdate and $course->enddate to determine the duration.

> How do i get  total time spent by user on the course?

The logs can tell you how many times they have visited a course page. I do not know if every activity also triggers an event when their pages are viewed.

In reply to Geoffrey Van Wyk

Re: how do i get total duration of the course

by Sushma R -
Thank You for the reply,
Do you want to know as a user or a developer? As a developer, you can use $course->startdate and $course->enddate to determine the duration.
-> this is needed, when i show to the participants/student, i need to show him atleast approx. time it takes to finish the course.

The logs can tell you how many times they have visited a course page. I do not know if every activity also triggers an event when their pages are viewed.
-> is the log only option? we have enabled a very small duration to keep the logs. what can we do i this case?
In reply to Sushma R

Re: how do i get total duration of the course

by Geoffrey Van Wyk -
Picture of Plugin developers
> this is needed, when i show to the participants/student, i need to show him atleast approx. time it takes to finish the course.

You can base it on the average time previous students took to complete the same course. The time it took to complete a course you could calculate from the time they first accessed the course to the time they completed it.

> is the log only option? we have enabled a very small duration to keep the logs. what can we do i this case?

Yes, logs are basically the only option I can see. Something else you might consider are the analytics models (Site administration > Analytics > Analytics Models).
In reply to Geoffrey Van Wyk

Re: how do i get total duration of the course

by kanthsree s -
Apart from empirically determining the actual hours previous students took, which could be useful for some situations, there is the simple question about an appropriate Field during Course creation where the Creator can enter an approximate number of hours of work it will take for the student to complete the Course.

Is there a good field for Course creator to enter the above-mentioned Course duration?
(The point is to give the student a hint as to whether this is a 160 hour course or a 1600 hour course and not for accurate EMPIRICAL info).
In reply to kanthsree s

Re: how do i get total duration of the course

by Richard Oelmann -
Picture of Core developers Picture of Plugin developers Picture of Testers
Personally I would either write it in the course description, or alternatively, Moodle allows you to set up Custom Course Fields. Create one for 'Expected Course Duration' and then you can fill it in there. However, note that using custom course fields means you will probably also need to do some work to display the contents of that field (hence my suggestion to simply add it to the Course Description).
Average of ratings: Useful (1)
In reply to Sushma R

Re: how do i get total duration of the course

by Davo Smith -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
This question comes up from time to time and I've yet to read a convincing explanation of what is meant by "time spent by user on the course".

Do you mean the time the server spent generating the page for the user? (Probably a fraction of a second for each page loaded)
Do you mean the time the user had the page open in a browser? (Regardless of whether or not the user was actually looking at the page, maybe they just opened it and walked off to make a cup of tea)
Does having the course open in 2 tabs at once count double?
Should it count against them if they have tabs for 3 different courses open at once - or does it count as them being on each of those courses? (even though they can't possibly be reading all of them at once)

The closest I've seen is to parse the logs and apply some cut-off for the maximum time between two log entries for a single course (i.e. if two log entries for a user on a course are more than 15 min apart, then count them as two separate sessions on the course). This still doesn't really give any idea if the user is actually engaging with the course, or just occasionally randomly clicking on links (it also breaks if they watch a 20 minute video on the course - that might end up splitting two sessions, if they didn't do anything else at the same time).

I hope that helps, but please consider using better measures of student engagement (number of posts on forums, performance against formative / summative assessment quizzes, etc.)
Average of ratings: Useful (3)
In reply to Davo Smith

Re: how do i get total duration of the course

by Dan Marsden -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Plugins guardians Picture of Testers Picture of Translators
The dedication block tries to give an approximate amount of time spent in a course by using the logs - and it provides custom report builder sources so you can report on this across the site:
https://moodle.org/plugins/block_dedication
That uses the logs-based approach that Davo describes above, but as Davo and others mention - this is a very blunt approach and is not a very reliable measure.

We do have some very clever people here at Catalyst .. and one of them recently put together some POC code that uses the Page Visibility API which allows us to monitor when a user switches to a different tab/minimises a window and using that as an alternative method for tracking time spent, which appears to be another interesting approach to tracking time spent within a course - you can read more about this approach here:
https://github.com/catalyst/moodle-block_dedication/issues/70

Unfortunately that POC code is not currently open-source/publicly available code, but one day, we'd like to see if we can pull that POC code out and drop it into the course dedication block to allow you to get an approximate timespent using the page visibility api as well as the logs-based approach so you can compare the 2 different values in one go.
Average of ratings: Useful (1)
In reply to Dan Marsden

Re: how do i get total duration of the course

by Brett Dalton -
Picture of Moodle HQ Picture of Particularly helpful Moodlers
@dan I'd be really interested to see how it interacts with LTI's and SCORM which often launch in other windows. I've worked on this problem a lot over the years and still havn't seen a good solution for determining the time students are actually studying as either a lot is lots (they legitimately have a doc open in another window) or attributed when its not happening (open tab with no activity). This goes back to my days working with lecture capture solutions and trying to measure student engagement with the videos, even something that simple is really hard to be accurate.
In reply to Brett Dalton

Re: how do i get total duration of the course

by Dan Marsden -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Plugins guardians Picture of Testers Picture of Translators
yeah - there are no "good" solutions... just different methods that attempt to get an approximation - I think the use of the page visibility api is a nice step forwards, but doesn't solve "everything" - I'm interested to see how it compares with using the logs-based analysis side by side if we manage to get that into the dedication block code-base too.

The page visibility api would work for scorms that show in the Moodle current window and new window options - the packages that spawn their own pop-up window might prove a challenge, but I do wonder if there's a way around that as we are still talking about content hosted on the same domain as the Moodle site and although we'd have to deal with some cross-window JS, we're not going to hit cross-domain JS issues. Scorm objects are also supposed to record time spent by the user themselves into the session_time and total_time vars - but again the reliability of that data is also quite low as it depends on the authoring tool implementing a useful method of tracking time spent (and passing that back to the LMS.) I don't recall seeing anything in the LTI spec around tracking user activity like time spent either, so there's no nice way of doing that for LTI's either afaik.
In reply to Brett Dalton

Re: how do i get total duration of the course

by Marcus Green -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
Calculating the time an individual student has spent focusing on a course requires kind of optic nerve/brain implant is the true solution, but there are privacy/health issues. I am more interested in finding out what students have learnt. (I am guessing an unhelpful rating might be useful in the course sometimes.....)
Average of ratings: Useful (1)