SQL 所有未完成课程的用户的特别报告
SQL ad-hoc report of ALL users not completed a course
海刚!
我非常接近找到一份报告,我可以 运行 临时查找所有未注册课程的用户。我确实有一份针对未完成课程的已注册人员的报告,但此搜索未找到甚至未注册的给定学生。
当前代码为
SELECT u.lastname, u.firstname , u.email , c.fullname,
DATE_FORMAT(FROM_UNIXTIME(cc.timecompleted),'%m/%d/%Y %T') AS 'Completed'
FROM
prefix_role_assignments AS ra
JOIN prefix_context AS context ON context.id = ra.contextid
AND
context.contextlevel = 50 JOIN prefix_course AS c ON c.id = context.instanceid
AND
c.fullname LIKE "SAMPLE_COURSE_NAME"
JOIN prefix_user AS u ON u.id = ra.userid
JOIN prefix_course_completions AS cc ON cc.course = c.id
AND cc.userid = u.id
ORDER BY
cc.timecompleted,
u.lastname,
u.firstname
有什么想法吗??
这将列出所有未注册课程的用户 - 不过可能会很大。
将xxx
替换为课程ID
SELECT u.id AS userid, u.firstname, u.lastname, u.email
FROM mdl_user u
WHERE u.deleted = 0
AND u.suspended = 0
AND NOT EXISTS (
SELECT ue.userid
FROM mdl_user_enrolments ue
JOIN mdl_enrol e ON e.id = ue.enrolid AND e.courseid = xxx
WHERE ue.userid = u.id
)
更新...我发现使用“mdl_”在 moodle 框架内不起作用,但您可以将其替换为“prefix_”并且它有效!太感谢了!我永远不会想到这个设置。
SELECT u.id AS userid, u.firstname, u.lastname, u.email
FROM prefix_user u
WHERE u.deleted = 0
AND u.suspended = 0
and firstname not like "Guest user"
AND NOT EXISTS (
SELECT ue.userid
FROM prefix_user_enrolments ue
JOIN prefix_enrol e ON e.id = ue.enrolid AND e.courseid = XXX
WHERE ue.userid = u.id
)
ORDER BY
Lastname,
Firstname
海刚!
我非常接近找到一份报告,我可以 运行 临时查找所有未注册课程的用户。我确实有一份针对未完成课程的已注册人员的报告,但此搜索未找到甚至未注册的给定学生。
当前代码为
SELECT u.lastname, u.firstname , u.email , c.fullname,
DATE_FORMAT(FROM_UNIXTIME(cc.timecompleted),'%m/%d/%Y %T') AS 'Completed'
FROM
prefix_role_assignments AS ra
JOIN prefix_context AS context ON context.id = ra.contextid
AND
context.contextlevel = 50 JOIN prefix_course AS c ON c.id = context.instanceid
AND
c.fullname LIKE "SAMPLE_COURSE_NAME"
JOIN prefix_user AS u ON u.id = ra.userid
JOIN prefix_course_completions AS cc ON cc.course = c.id
AND cc.userid = u.id
ORDER BY
cc.timecompleted,
u.lastname,
u.firstname
有什么想法吗??
这将列出所有未注册课程的用户 - 不过可能会很大。
将xxx
替换为课程ID
SELECT u.id AS userid, u.firstname, u.lastname, u.email
FROM mdl_user u
WHERE u.deleted = 0
AND u.suspended = 0
AND NOT EXISTS (
SELECT ue.userid
FROM mdl_user_enrolments ue
JOIN mdl_enrol e ON e.id = ue.enrolid AND e.courseid = xxx
WHERE ue.userid = u.id
)
更新...我发现使用“mdl_”在 moodle 框架内不起作用,但您可以将其替换为“prefix_”并且它有效!太感谢了!我永远不会想到这个设置。
SELECT u.id AS userid, u.firstname, u.lastname, u.email
FROM prefix_user u
WHERE u.deleted = 0
AND u.suspended = 0
and firstname not like "Guest user"
AND NOT EXISTS (
SELECT ue.userid
FROM prefix_user_enrolments ue
JOIN prefix_enrol e ON e.id = ue.enrolid AND e.courseid = XXX
WHERE ue.userid = u.id
)
ORDER BY
Lastname,
Firstname