Para mapear a lista a lista de alunos que concluíram uma determinada atividade do curso da Plataforma Moodle, basta executar o comando a seguir:
SELECT u.id, u.firstname,u.lastname, u.email,u.username,cmp.timemodified AS timecompletation FROM mdl_course_modules_completion cmp INNER JOIN mdl_user u ON cmp.userid=u.id INNER JOIN mdl_course_modules cm ON cmp.coursemoduleid = cm.id INNER JOIN mdl_role_assignments rs ON rs.userid=u.id INNER JOIN mdl_context e ON rs.contextid=e.id INNER JOIN mdl_role r ON rs.roleid=r.id WHERE e.instanceid=cm.course AND r.shortname ='student' AND cmp.completionstate > 0 AND cmp.completionstate < 3 AND cm.id =?
Passe o parâmetro id da atividade em cm.id=?