How to get a list of courses with no participants? Or courses with no recent activity?

How to get a list of courses with no participants? Or courses with no recent activity?

by Samuli Karevaara -
Number of replies: 7

We are doing a massive spring cleaning on our site. I'm looking for ways to find a bunch of courses that could be deleted.

1) Is there a way to browse courses with no participants?

2) Is there a way to browse courses that have no recent (say, for the last five years) activity? I remember browsing a list like this but for the life of me can't find it anymore...

We are using Moodle 3.4.6+

Average of ratings: -
In reply to Samuli Karevaara

Re: How to get a list of courses with no participants? Or courses with no recent activity?

by S. kavita -
Picture of Testers

Hi,

I think Recent activity block might help.

https://docs.moodle.org/36/en/Recent_activity_block

Average of ratings: Useful (1)
In reply to S. kavita

Re: How to get a list of courses with no participants? Or courses with no recent activity?

by Samuli Karevaara -

Thanks, but as far as I understand the Recent activity block only shows the activity for one course at a time? We have more than 5 000 courses in our Moodle so I'm hoping to find tools to find a bunch of them to clean up at once.

Average of ratings: Useful (1)
In reply to Samuli Karevaara

Re: How to get a list of courses with no participants? Or courses with no recent activity?

by Jonathan Newman -
We were able to use the Configurable Reports block to compile a list of courses. We then were able to move them into the same category and remove them. Problem is the Configurable Reports block is dated and in need of updates. It made many icons invisible throughout our Moodle 3.4 installation (Boost related themes, the Clean theme was fine...). Once we had the report we needed we simply deleted the Configurable Reports block. 


I do wish there was a clean report in Moodle that could sort courses by total data size and usage. 

In reply to Samuli Karevaara

Re: How to get a list of courses with no participants? Or courses with no recent activity?

by Rick Jerz -
Picture of Particularly helpful Moodlers Picture of Testers

I think that the answer is "use custom sql."

For example, below is a query that I created that shows students how have been in my Moodle in the last hour.  Of course, this can be modified for any time frame.  (Please suggest improvements to my SQL.)  I am posting this simply to get you thinking.

Also, consider voting on my Tracker item: MDL-19190.  This is a request to add filtering of users by "not in any course."


# Shows users logged IN LAST hour

SELECT firstname,

       lastname,

       from_unixtime(lastaccess) AS LastClick,

       timediff(curtime(),time(from_unixtime(lastaccess))) AS LastAccess

FROM prefix_user HAVING LastClick > now()-interval 60 MINUTE

ORDER BY lastaccess ASC

In reply to Rick Jerz

Re: How to get a list of courses with no participants? Or courses with no recent activity?

by Samuli Karevaara -

Thanks, this is what I'm doing currently. However, we are moving from self-hosted to hosted and I probably won't have the same level of DB access in the future. But for now, some queries if others might benefit from them also:


/* Courses sorted by their modified date, date in a human readable form */

SELECT cou.id, cat.name, cou.fullname, cou.shortname, cou.summary,

FROM_UNIXTIME(cou.timecreated, '%Y-%m-%d') AS created, FROM_UNIXTIME(cou.timemodified, '%Y-%m-%d') AS modified

FROM mdl_course AS cou, mdl_course_categories AS cat

WHERE cou.category = cat.id ORDER BY modified ASC;


/* Return the number of enrolled participants for each course */

SELECT e.courseid, COUNT(ue.id) FROM mdl_user_enrolments AS ue, mdl_enrol AS e WHERE ue.enrolid = e.id GROUP BY e.courseid;


The latter won't give the empty ones but it's easy to do a "NOT IN" query based on these courseids.

In reply to Samuli Karevaara

Re: How to get a list of courses with no participants? Or courses with no recent activity?

by Rick Jerz -
Picture of Particularly helpful Moodlers Picture of Testers

Well Samuli, in the process of picking a Moodle partner make sure to demand that you have access to the database, or as a minimum, some form of "Configurable Reports."

In reply to Samuli Karevaara

Re: How to get a list of courses with no participants? Or courses with no recent activity?

by John Provasnik -
Picture of Particularly helpful Moodlers Picture of Testers

I know the new analytics system tells you if there are not teachers in a course. I wonder if it tells you if there are no students, or at least no activity...