I can't insert the values of the third interaction of a scorm. I see the values of the second interaction reported. Where am I wrong? thank you
this is the code
SELECT scc.userid AS User, sct.name AS Name, scc.scoid AS SCORM_ID, sct.module AS Module, scc.value AS Touch_1, sct.value AS touch_2, sct.value AS Touch_3
FROM
(SELECT u.id AS userid, st.scoid AS scoid, st.value AS value
FROM prefix_course AS c
LEFT JOIN prefix_scorm AS sc ON sc.course=c.id
LEFT JOIN prefix_scorm_scoes_track AS st ON st.scormid=sc.id
LEFT JOIN prefix_user AS u ON u.id=st.userid
WHERE st.element='cmi.interactions_0.time') AS scc
LEFT JOIN
(SELECT c.fullname Course, sc.name AS module, st.scoid AS scoid, u.id AS userid, u.firstname name, st.attempt as Attempt, st.value AS value
FROM prefix_course AS c
LEFT JOIN prefix_scorm AS sc ON sc.course=c.id
LEFT JOIN prefix_scorm_scoes_track AS st ON st.scormid=sc.id
LEFT JOIN prefix_user AS u ON u.id=st.userid
WHERE st.element='cmi.interactions_1.time') AS sct
ON sct.scoid=scc.scoid
AND sct.userid=scc.userid
ORDER BY scc.userid
this is the wrong result
You haven't got a 3rd element in the SQL:)
Rather than using sub queries, I would probably use a GROUP BY
if you want to put the values in columns.
SELECT u.id AS userid, u.firstname,
c.id AS courseid, c.fullname AS coursename,
s.id AS scormid, s.name AS scormname,
MAX(CASE WHEN sst.element = 'cmi.interactions_0.time' THEN sst.value ELSE '' END) AS time0,
MAX(CASE WHEN sst.element = 'cmi.interactions_1.time' THEN sst.value ELSE '' END) AS time1,
MAX(CASE WHEN sst.element = 'cmi.interactions_2.time' THEN sst.value ELSE '' END) AS time2
FROM mdl_course c
JOIN mdl_scorm s ON s.course = c.id
JOIN mdl_scorm_scoes_track sst ON sst.scormid = s.id
AND sst.element IN ('cmi.interactions_0.time', 'cmi.interactions_1.time', 'cmi.interactions_2.time')
JOIN mdl_user u ON u.id = sst.userid
GROUP BY u.id, u.firstname, c.id, c.fullname, s.id, s.name
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.