我正在尝试获取用户上次完成课程的日期,我有以下工作SQL,但它给出了错误的日期。
我有所有模块的日期,但知道他们错了几个月,我知道昨天完成了1门课程。
SELECT
u.username,
c.shortname,
DATE_FORMAT(FROM_UNIXTIME(gi.timemodified), '%d/%m/%Y') AS 'date'
FROM moodle.user u
JOIN moodle.grade_grades g ON g.userid = u.id
JOIN moodle.grade_items gi ON g.itemid = gi.id
JOIN moodle.course c ON c.id = gi.courseid
WHERE u.email = ?
GROUP BY c.shortname
答案 0 :(得分:2)
课程完成情况应在mdl_course_completions
SELECT u.username,
c.shortname,
cc.timecompleted
FROM mdl_course_completions cc
JOIN mdl_course c ON c.id = cc.course
JOIN mdl_user u ON u.id = cc.userid
WHERE u.email = :email