<?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.stupaper.MsPaperStudentQuestionScoreMapper">

    <!--修改分数-修改记录-->
    <select id="listStuQuestionScore" resultType="java.util.Map">
        select distinct q.* ,s.subjectname,u.username as studentname,u.usersex,u.examno,c.classname
        from ms_paper_student_question_score q
        left join ms_subject s on q.examid=s.examid and q.subjectid=s.subjectid
        left join t_user u on q.studentid=u.userid
        left join ms_class_student cs on q.examid=cs.examid and q.subjectid=cs.subjectid and q.studentid=cs.studentid
        left join ms_class c on q.examid=c.examid and q.subjectid=c.subjectid and cs.classid=c.classid
        where q.examid=#{stu.examid}
        <if test="stu.subjectid!=null and stu.subjectid!=''">
            and q.subjectid=#{stu.subjectid}
        </if>
        <if test="stu.classid!=null and stu.classid!=0">
            and cs.classid=#{stu.classid}
        </if>
        <if test="stu.studentname!=null and stu.studentname!=''">
            and (u.username like concat('%', #{stu.studentname}, '%') or u.examno like concat('%',#{stu.studentname},'%')
        </if>
        order by q.createtime desc,c.classtype
    </select>

    <!--修改分数-班级学生-->
    <select id="listClassStudentScores" resultType="java.util.Map">
        select distinct ps.mpsid,ps.studentid,ps.stuscore,c.classname,u.username studentname,u.usersex,u.examno,e.gradeid
        from ms_paper_student ps
        left join ms_class_student cs on ps.examid=cs.examid and ps.subjectid=cs.subjectid
        left join ms_class c on ps.examid=c.examid and ps.subjectid=c.subjectid and cs.classid=c.classid
        left join t_user u on ps.studentid=u.userid
        left join ms_exam e on ps.examid=e.examid
        where ps.examid=#{stu.examid} and ps.subjectid=#{stu.subjectid} and cs.classid=#{stu.classid} order by cs.mcsid
    </select>

    <!--修改分数-学生试卷-->
    <select id="listStudentQuestions" resultType="com.xhkjedu.smarking.model.stupaper.MsPaperStudentQuestion">
        select mpsqid,studentid,examid,mpid,subjectid,qn,qscore,stuscore from ms_paper_student_question where mpsid=#{mpsid} order by qorder
    </select>



</mapper>
