Enrolment End Date / Expiry

Re: Enrolment End Date / Expiry

by Leon Stringer -
Number of replies: 0
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)