Enrolment End Date / Expiry

Enrolment End Date / Expiry

by Tracy Hodges -
Number of replies: 3
We have upgraded to Moodle 3.6.3.

On the old version of Moodle that we were using, we could see the course expiry date, under Enrolled Users (listed under the heading 'Enrolment Methods', however this is not visible in the new version.

We need to be able to view (and, if possible, download) a list of users with their course expiry dates. 

Is this possible?
Average of ratings: -
In reply to Tracy Hodges

Re: Enrolment End Date / Expiry

by Leon Stringer -
Picture of Core developers Picture of Particularly helpful Moodlers

It looks like this was changed in Moodle 3.4 as part of MDL-59290.

But if you click on 🛈 in the Status column for the user you can see these details:

Enrolment details

You can also download a list of enrolled users (Select all, With selected users..., Download table data as) but this only contains the firstname, lastname and email address. I don't think there's any way to download a report with the end date currently.

Average of ratings: Useful (1)
In reply to Leon Stringer

Re: Enrolment End Date / Expiry

by Tracy Hodges -

Thanks Leon.  The 'i' link is helpful.

I wonder if anyone knows of a plug-in to either display the expiry date to users, or to include it as a heading in the user list?

Average of ratings: Useful (1)
In reply to Tracy Hodges

Re: Enrolment End Date / Expiry

by Leon Stringer -
Picture of Core developers Picture of Particularly helpful Moodlers

To show the expiry date to users it looks like MDL-63029 is suggesting this in which case you could vote for that issue.

For site admins, if you used Configurable Reports (or Ad-hoc Database Queries) then I think the following will report this information:

SELECT u.firstname, u.lastname, r.shortname AS role,
FROM_UNIXTIME(ue.timestart) AS timestart,
IF (ue.timeend = 0, '', FROM_UNIXTIME(ue.timeend)) AS timeend
FROM prefix_user_enrolments ue
INNER JOIN prefix_enrol e ON e.id = ue.enrolid
INNER JOIN prefix_user u ON ue.userid = u.id
INNER JOIN prefix_course c ON e.courseid = c.id
INNER JOIN prefix_context ctx ON c.id = ctx.instanceid AND ctx.contextlevel = 50
INNER JOIN prefix_role_assignments ra ON ra.contextid = ctx.id
INNER JOIN prefix_role r ON ra.roleid = r.id AND u.id = ra.userid
WHERE c.id = %%COURSEID%%

Add a new Configurable Reports block to the course and create a report using Custom SQL with this query.

This uses the MySQL/MariaDB FROM_UNIXTIME() function. If you're using PostgreSQL you'll need to use  to_timestamp() instead. If you're using SQL Server I'm not sure if you can convert the date/time values.

Example:

Sample output from Configurable reports

Average of ratings: Useful (1)