<?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.yida.data.school.exam.mapper.CoreExaminationPublishRecordMapper">
    <resultMap id="BaseResultMap" type="com.yida.data.common.core.entity.exam.CoreExaminationPublishRecord">
        <id column="id" property="id" jdbcType="INTEGER"/>
        <result column="create_id" property="createId" jdbcType="VARCHAR"/>
        <result column="create_date" property="createDate" jdbcType="TIMESTAMP"/>
        <result column="update_id" property="updateId" jdbcType="VARCHAR"/>
        <result column="update_date" property="updateDate" jdbcType="TIMESTAMP"/>
        <result column="del_flag" property="delFlag" jdbcType="CHAR"/>
        <result column="core_examination_id" property="coreExaminationId" jdbcType="INTEGER"/>
        <result column="core_examination_publish_id" property="coreExaminationPublishId" jdbcType="INTEGER"/>
        <result column="core_student_id" property="coreStudentId" jdbcType="INTEGER"/>
        <result column="core_examination_student_id" property="coreExaminationStudentId" jdbcType="INTEGER"/>
        <result column="core_examination_course_id" property="coreExaminationCourseId" jdbcType="INTEGER"/>
        <result column="core_examination_course_name" property="coreExaminationCourseName"
                jdbcType="VARCHAR"/>
        <result column="school_id" property="schoolId" jdbcType="INTEGER"/>
        <result column="school_name" property="schoolName" jdbcType="VARCHAR"/>
        <result column="grade_id" property="gradeId" jdbcType="INTEGER"/>
        <result column="grade_name" property="gradeName" jdbcType="VARCHAR"/>
        <result column="class_id" property="classId" jdbcType="INTEGER"/>
        <result column="class_name" property="className" jdbcType="VARCHAR"/>
        <result column="examination_room" property="examinationRoom" jdbcType="VARCHAR"/>
        <result column="examination_number" property="examinationNumber" jdbcType="VARCHAR"/>
        <result column="seat_number" property="seatNumber" jdbcType="INTEGER"/>
        <result column="score" property="score" jdbcType="INTEGER"/>
        <result column="course_score" property="courseScore" jdbcType="INTEGER"/>
        <result column="miss" property="miss" jdbcType="CHAR"/>
        <result column="class_rank" property="classRank" jdbcType="INTEGER"/>
        <result column="grade_rank" property="gradeRank" jdbcType="INTEGER"/>
        <result column="back" property="back" jdbcType="CHAR"/>
        <result column="grade_level" property="gradeLevel" jdbcType="VARCHAR"/>
    </resultMap>

    <select id="findScoreTrend" resultType="com.yida.data.school.vo.exam.ScoreTrendVO">
        select a.start_date date,b.score*100/b.course_score scoreRate,b.score,b.course_score examScore
        from core_examination a
        left join core_examination_publish_record b on a.id=b.core_examination_id
        <where>
            b.miss=0
            and a.del_flag=0
            and b.del_flag=0
            and a.start_date between #{startDate} and #{endDate}
            and b.core_student_id=#{studentId}
            and b.core_examination_course_id=#{courseId}
        </where>
        order by a.start_date
    </select>

    <select id="findStudentScore"
            resultType="com.yida.data.common.core.entity.exam.CoreExaminationStudent">
        select a.core_student_id,
        a.core_examination_id,
        b.student_name,
        a.class_name,
        a.score,
        a.grade_rank,
        a.class_rank,
        a.class_id
        from core_examination_publish_record a left join core_examination_student b on
        a.core_examination_student_id=b.id
        where a.del_flag=0 and b.del_flag=0
        and a.core_examination_id=#{examId}
        and a.core_examination_course_id=#{courseId}
        <if test="classId != null and classId.size() != 0">
            and a.class_id in
            <foreach collection="classId" separator="," open="(" close=")" item="item">
                #{item}
            </foreach>
        </if>
        <if test="studentName != null and studentName != ''">
            and b.student_name like concat('%',#{studentName},'%')
        </if>
        order by a.grade_rank
    </select>
</mapper>