Moodle Student list with Groups and Course

萝らか妹 提交于 2019-12-25 04:22:16

问题


I am using moodle2.4.6. I want a list of user with their groups and their courses.


回答1:


You will need to do an SQL query to get this information.

Assuming you are using the default 'mdl_' prefix for tables, you will need to join together the following tables:

  • mdl_user - the details of the users
  • mdl_user_enrolments - (user_enrolments.userid = user.id) which course enrolments the user has
  • mdl_enrol - (enrol.id = user_enrolments.enrolid) details of which enrolment instances these are
  • mdl_course - (course.id = enrol.courseid) details of the courses these users are enroled in
  • mdl_groups_members - (groups_members.userid = user.id) details of the groups these users are in
  • mdl_groups - (groups.id = groups_members.groupid AND groups.courseid = course.id) name and description of the groups the user is in (for each course)

Please comment if you need help turning that pseudo code into actual SQL, or if you need help with the Moodle database access API ( http://docs.moodle.org/dev/Data_manipulation_API )




回答2:


SELECT
  mdl_user.username,
  mdl_user.firstname,
  mdl_user.lastname,
  mdl_course.fullname,
  mdl_course.idnumber,
  mdl_groups_members.groupid,
  mdl_groups.name
FROM (mdl_groups_members
  INNER JOIN ((mdl_course
    INNER JOIN (mdl_user_enrolments
      INNER JOIN mdl_enrol ON mdl_user_enrolments.enrolid = mdl_enrol.id)
      ON mdl_course.id = mdl_enrol.courseid) INNER JOIN mdl_user ON mdl_user_enrolments.userid = mdl_user.id)
    ON mdl_groups_members.userid = mdl_user.id) INNER JOIN mdl_groups
    ON (mdl_groups.courseid = mdl_course.id) AND (mdl_groups_members.groupid = mdl_groups.id)
WHERE (((mdl_user.username) = "102993") AND ((mdl_course.category) = "36"))


来源:https://stackoverflow.com/questions/24158121/moodle-student-list-with-groups-and-course

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!