sql查询获取scorm完成状态

问题描述 投票:0回答:1

我必须获得学生完成 scrom 包的状态,我写了一个代码,只显示完成和不完整的学生数据,但我也希望那些已经注册但没有尝试过的学生,帮助我。

这是我的查询:

select u.id as userid,u.firstname as firstname,u.lastname as lastname,c.fullname as coursename,s.name as scormname,sst.attempt as attempt,sst.value as status,
    CASE
        when s.timeopen=0 then 'not enabled'
        when s.timeopen<>0 then from_unixtime(s.timeopen,'%d-%b-%Y') 
    end 
    as starttime,
    CASE
        when s.timeclose=0 then 'not enabled'
        when s.timeclose<>0 then from_unixtime(s.timeclose,'%d-%b-%Y') 
    end 
    as enddate
from mdl_scorm_scoes_track sst

join mdl_scorm s on s.id=sst.scormid

join mdl_course c on c.id=s.course

join mdl_user u on sst.userid=u.id

where sst.value in ('incomplete','completed')

--给我一些有用的代码

mysql moodle
1个回答
0
投票

如果我理解正确的话,我认为你需要

Left Join
并从用户表开始

select u.id as userid,u.firstname as firstname,u.lastname as lastname,c.fullname as coursename,s.name as scormname,sst.attempt as attempt,sst.value as status,
    CASE
        when s.timeopen=0 then 'not enabled'
        when s.timeopen<>0 then from_unixtime(s.timeopen,'%d-%b-%Y') 
    end 
    as starttime,
    CASE
        when s.timeclose=0 then 'not enabled'
        when s.timeclose<>0 then from_unixtime(s.timeclose,'%d-%b-%Y') 
    end 
    as enddate
from mdl_user u

left join mdl_scorm_scoes_track sst on sst.userid=u.id

left join mdl_scorm s on s.id=sst.scormid

left join mdl_course c on c.id=s.course

where sst.value in ('incomplete','completed') 
    OR sst.value IS NULL
© www.soinside.com 2019 - 2024. All rights reserved.