Hello, I want a report that gives information about last time users accessed courses, as it can be seen in user's profiles. Last login to moodle seems to work fine, but I cannot get last access to each course an user is enrolled to. Maybe I'm in the wrong table? JOIN it's no correct? Here is my query, I've bolded what seems not to be working.
Thanks a lot in advance.
SELECT u.username AS UserName
,rn.shortname AS RoleName
,c.fullname AS CourseName
,u.lastname AS APELLIDO
,u.firstname AS NOMBRE
,u.email AS CORREO
,c.category AS CategoriaID
,c.shortname AS NomCorto
,c.timecreated AS CreadoEl
,u.currentlogin AS ULTIMOLOGIN
,u.firstaccess AS primerACCESO
,ul.timeaccess AS ULTIMOACCCURSO
FROM prefix_role_assignments AS r
JOIN prefix_user AS u on r.userid = u.id
JOIN prefix_role AS rn on r.roleid = rn.id
JOIN prefix_context AS ctx on r.contextid = ctx.id
JOIN prefix_course AS c on ctx.instanceid = c.id
JOIN prefix_user_lastaccess AS ul on ul.courseid = c.id