Moodle3.8中角色教师的id号是多少

wfsdck30  于 2021-07-26  发布在  Java
关注(0)|答案(1)|浏览(317)
SELECT c.fullname, c.shortname, g.name, u.firstname, u.lastname, r.shortname
FROM prefix_course AS c
JOIN prefix_role_assignments AS ra
JOIN prefix_groups AS g ON c.id = g.courseid
JOIN prefix_role AS r
JOIN prefix_user AS u 
WHERE c.groupmode > 0 AND WHERE ra.roleid > 6

我想输入角色教师的id号而不是6。

jfgube3f

jfgube3f1#

为什么不简单:

SELECT c.fullname, c.shortname, g.name, u.firstname, u.lastname, r.shortname
FROM prefix_course AS c
JOIN prefix_context ctx ON ctx.instanceid = c.id AND ctx.contextlevel = 50
JOIN prefix_role_assignments AS ra ON ra.contextid = ctx.id
JOIN prefix_groups AS g ON c.id = g.courseid
JOIN prefix_role AS r ON r.id = ra.roleid
JOIN prefix_user AS u ON u.id = ra.userid
WHERE c.groupmode > 0 AND r.shortname = 'teacher'

其中“50”是“course”的上下文级别。这将显示在课程级别具有“教师”角色的所有用户,给出教师的姓名、课程的名称以及课程中存在的所有组的列表(每个组都有一个完整的行,并且不考虑教师是否是该组的成员)。
请注意,列表中只包含“非编辑教师”,如果您同时需要“教师”和“非编辑教师”,则需要将最后一行更改为:

WHERE c.groupmode > 0 AND (r.shortname = 'teacher' OR r.shortname = 'editingteacher')

相关问题