<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.xhkjedu.smarking.mapper.report.reportclass.MsrClassActionMapper">
    <!--违纪行为-->
    <select id="listBadActionByExamId" resultType="java.util.Map">
        select sb.studentid,sb.msid,count(sb.msbsid)num,u.username as studentname
        from ms_subject_badstudent sb inner join t_user u on sb.studentid=u.userid
        where sb.msid in(#{msids})
        group by studentid,sb.msid
    </select>
    <!--优秀试卷-->
    <select id="listGoodActionByExamId" resultType="java.util.Map">
        select psq.studentid,psq.subjectid,count(distinct psq.qorder)num,u.username as studentname
        from ms_paper_student_question psq inner join t_user u on psq.studentid=u.userid
        where psq.examid=#{examid} and psq.subjectid in(#{subjectids}) and hasgood=1
        group by psq.studentid, psq.subjectid
    </select>
    <!--违规试卷-->
    <select id="listBadQuesActionByExamId" resultType="java.util.Map">
        select psq.studentid,psq.subjectid,count(distinct psq.qorder)num,u.username as studentname
        from ms_paper_student_question psq inner join t_user u on psq.studentid=u.userid
        where psq.examid=#{examid} and psq.subjectid in(#{subjectids}) and hasbad=1
        group by psq.studentid, psq.subjectid
    </select>
    <!--行为分析-班级-->
    <select id="listXwBj" resultType="java.util.Map">
        select c.classname,ca.classid,ca.subjectjson
        from msr_class_action ca left join t_class c on ca.classid = c.classid
        where ca.examid=#{action.examid} and ca.actiontype=#{action.actiontype}
        <if test="action.classid!=null and action.classid!=0">
            and ca.classid=#{action.classid}
        </if>
        <foreach collection="action.classids" item="classid" open="and ca.classid in(0," separator="," close=")">
            ${classid}
        </foreach>
        order by c.classtype,c.classorder,c.classid
    </select>
</mapper>
