我们利用 Moodle 为员工招收课程。我们要求报告课程完成情况,包括完整的和不完整的。
对于我们 99% 的课程,在数据库中查询很简单。不过,我们设置了一门课程,是用来让学生查看文档的,设置如下:
我们已启用跟踪。
我正在努力查询数据库以找出员工注册了哪些文档以及他们已经/未查看过哪些文档。
以下 SQL 查询为我提供了每个用户查看过的内容的列表:
SELECT cmc.userid AS [Moodle User ID] ,
d.data as [User Service ID] ,
u.firstname as [Employee FirstName],
u.lastname as [Employee Surname],
cs.id AS [Section ID] ,
cs. name AS [Section Name] ,
murl.name AS [Document Name] , dateadd(s, cmc.timemodified, '1970-01-01') [Completed Date]
FROM mdl_course_modules cm
LEFT JOIN mdl_course_sections cs ON cs.id = cm.section
LEFT JOIN mdl_url murl ON murl.id = cm.instance
LEFT JOIN mdl_course_modules_completion cmc ON cm.id=cmc.coursemoduleid
LEFT JOIN mdl_user u ON u.id = cmc.userid
LEFT JOIN mdl_user_info_data d ON d.id = cmc.userid
WHERE cm.course='128'
cm.course = '128'
是用于上面解释的课程的课程 ID。
这个查询效果很好,但是我们还需要通过了解他们注册的内容来找出他们没有查看的内容,这就是我目前陷入困境的地方。
任何帮助,我们将不胜感激。
谢谢
检查用户是否已查看模块
CASE WHEN cmc.viewed = 0 THEN 'Yes' ELSE 'No' END AS module_viewed
这些是 Moodle 常量
/**
* User has viewed this activity.
* Completion viewed state (course_modules_completion/viewed)
*/
define('COMPLETION_VIEWED', 1);
/**
* User has not viewed this activity.
* Completion viewed state (course_modules_completion/viewed)
*/
define('COMPLETION_NOT_VIEWED', 0);
检查用户是否已完成模块
CASE WHEN cmc.completionstate <> 0 THEN 'Yes' ELSE 'No' END AS module_completed
这些也是 Moodle 常量
/**
* The user has not completed this activity.
* This is a completion state value (course_modules_completion/completionstate)
*/
define('COMPLETION_INCOMPLETE', 0);
/**
* The user has completed this activity. It is not specified whether they have
* passed or failed it.
* This is a completion state value (course_modules_completion/completionstate)
*/
define('COMPLETION_COMPLETE', 1);
/**
* The user has completed this activity with a grade above the pass mark.
* This is a completion state value (course_modules_completion/completionstate)
*/
define('COMPLETION_COMPLETE_PASS', 2);
/**
* The user has completed this activity but their grade is less than the pass mark
* This is a completion state value (course_modules_completion/completionstate)
*/
define('COMPLETION_COMPLETE_FAIL', 3);
/**
* Indicates that the user has received a failing grade for a hidden grade item.
*/
define('COMPLETION_COMPLETE_FAIL_HIDDEN', 4);
注意:如果
course_modules_completion
中有记录,并不代表用户已经浏览过该模块
我很确定当用户注册或创建活动时(例如,在用户查看模块之前)会自动创建记录。
编辑:
course_modules_completion.viewed
已替换为新表course_modules_viewed