<?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.sexam.mapper.exam.ESubjectBadstudentMapper">
    <!--试卷学生-->
    <select id="listStu" resultType="java.util.Map">
        select es.classid,es.sstate,u.username,es.studentid,ec.classname
        from e_paper_student es left join t_user u on es.studentid = u.userid
        left join e_class ec on es.examid = ec.examid and es.classid = ec.classid
        where es.esid=#{ei.esid}
        <if test="ei.sstate!=null">
            and es.sstate=#{ei.sstate}
        </if>
        <if test="ei.classid!=null and ei.classid!=0">
            and es.classid=#{ei.classid}
        </if>
        <if test="ei.classids!=null and ei.classids!=''">
            and es.classid in(${ei.classids})
        </if>
        <if test="ei.createname!=null and ei.createname!=''">
            and u.username like '%${ei.createname}%'
        </if>
    </select>
    <!--学生进场概况-->
    <select id="getPaperRate" resultType="java.util.Map">
        select count(*)examnum
             ,count(case when sstate!=0 then epsid else null end)jcnum
             ,count(case when sstate=0 then epsid else null end)wjcnum
             ,count(case when sstate=2 then epsid else null end)tjcnum
             ,truncate(count(case when sstate!=0 then epsid else null end)*100/count(*),2)jcrate
        from e_paper_student where esid=#{ei.esid}
        <if test="ei.classid!=null and ei.classid!=0">
            and classid=#{ei.classid}
        </if>
        <if test="ei.classids!=null and ei.classids!=''">
            and classid in(${ei.classids})
        </if>
    </select>
    <!--教师监考班级-->
    <select id="getClass" resultType="java.util.Map">
        select max(majored)majored,group_concat(classid)classids
        from e_subject_invigilate where esid=#{esid} and teacherid=#{teacherid}
    </select>
    <!--试卷学生异常记录-->
    <select id="listBadStu" resultType="java.util.Map">
        select es.classid,u.username,es.studentid,es.badtype,es.picpath,es.createtime,ec.classname
        from e_subject_badstudent es left join t_user u on es.studentid = u.userid
        left join e_class ec on es.examid = ec.examid and es.classid = ec.classid
        where esid=#{ei.esid}
        <if test="ei.classid!=null and ei.classid!=0">
            and es.classid=#{ei.classid}
        </if>
        <if test="ei.classids!=null and ei.classids!=''">
            and es.classid in(${ei.classids})
        </if>
        order by es.esbsid desc
    </select>
</mapper>
