[sql] test
Viewer
*** This page was generated with the meta tag "noindex, nofollow". This happened because you selected this option before saving or the system detected it as spam. This means that this page will never get into the search engines and the search bot will not crawl it. There is nothing to worry about, you can still share it with anyone.
- SELECT
- course.fullname AS course_courselink,
- DATE_FORMAT(FROM_UNIXTIME(course_completion.timeenrolled), '%Y-%m-%d') AS 'Course Enrolled Date',
- DATE_FORMAT(FROM_UNIXTIME(course_completion.timecompleted), '%Y-%m-%d') AS 'Course Completed Date'
- FROM
- (
- SELECT
- id,
- userid,
- instanceid AS courseid
- FROM
- {dp_record_of_learning}
- WHERE
- TYPE = 1
- ) base
- INNER JOIN {course} course ON course.id = base.courseid
- LEFT JOIN {course_completions} course_completion ON (
- base.courseid = course_completion.course
- AND base.userid = course_completion.userid
- )
- INNER JOIN {context} ctx ON ctx.instanceid = course.id
- AND ctx.contextlevel = 50
- WHERE
- base.userid = 1124
- AND (
- course_completion.status > 10
- OR (
- (
- (
- EXISTS (
- SELECT
- 1
- FROM
- (
- SELECT
- map.courseid AS id,
- COUNT(map.roleid) AS roles
- FROM
- {totara_core_course_vis_map} map
- JOIN (
- SELECT
- DISTINCT vh_ctx.instanceid AS id,
- vh_ra.roleid
- FROM
- {context} vh_ctx
- JOIN {context_map} vh_cm ON vh_cm.childid = vh_ctx.id
- JOIN (
- SELECT
- 7 AS roleid,
- 1 AS contextid
- UNION
- SELECT
- 6 AS roleid,
- 2 AS contextid
- UNION
- SELECT
- roleid,
- contextid
- FROM
- {role_assignments} uq_role_ass_alias_1
- WHERE
- uq_role_ass_alias_1.userid = 1124
- ) vh_ra ON vh_ra.contextid = vh_cm.parentid
- WHERE
- vh_ctx.contextlevel = 50
- ) vh_x ON vh_x.id = map.courseid
- AND vh_x.roleid = map.roleid
- GROUP BY
- map.courseid
- HAVING
- COUNT(map.roleid) > 0
- ) vh_r
- WHERE
- vh_r.id = course.id
- )
- OR (
- (
- course.audiencevisible <> 3
- AND (
- course.audiencevisible = 2
- OR (
- course.audiencevisible = 1
- AND EXISTS (
- SELECT
- 1
- FROM
- {cohort_visibility} vw_cv
- JOIN {cohort_members} vw_cm ON vw_cv.cohortid = vw_cm.cohortid
- WHERE
- vw_cm.userid = 1124
- AND vw_cv.instanceid = course.id
- AND vw_cv.instancetype = 50
- )
- )
- OR (
- course.audiencevisible IN (1, 0)
- AND EXISTS (
- SELECT
- 1
- FROM
- {user_enrolments} ua_ue
- JOIN {enrol} ua_e ON ua_e.id = ua_ue.enrolid
- WHERE
- ua_e.courseid = course.id
- AND ua_ue.userid = 1124
- )
- )
- )
- )
- )
- )
- )
- )
- )
- ORDER BY
- course_completion.timecompleted ASC,
- base.id
Editor
You can edit this paste and save as new:
File Description
- test
- Paste Code
- 28 Mar-2024
- 3.71 Kb
You can Share it: