<?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.ruoyi.system.mapper.ElExamRepoMapper">

    <resultMap id="BaseResultMap" type="com.ruoyi.system.domain.exam.ElExamRepo">
            <id property="id" column="id" jdbcType="VARCHAR"/>
            <result property="examId" column="exam_id" jdbcType="VARCHAR"/>
            <result property="repoId" column="repo_id" jdbcType="VARCHAR"/>
            <result property="radioCount" column="radio_count" jdbcType="INTEGER"/>
            <result property="radioScore" column="radio_score" jdbcType="INTEGER"/>
            <result property="multiCount" column="multi_count" jdbcType="INTEGER"/>
            <result property="multiScore" column="multi_score" jdbcType="INTEGER"/>
            <result property="judgeCount" column="judge_count" jdbcType="INTEGER"/>
            <result property="judgeScore" column="judge_score" jdbcType="INTEGER"/>
            <result property="saqCount" column="saq_count" jdbcType="INTEGER"/>
            <result property="saqScore" column="saq_score" jdbcType="INTEGER"/>
    </resultMap>

    <sql id="Base_Column_List">
        id,exam_id,repo_id,
        radio_count,radio_score,multi_count,
        multi_score,judge_count,judge_score,
        saq_count,saq_score
    </sql>
    <select id="listByExam" resultType="com.ruoyi.system.domain.exam.dto.ext.ExamRepoExtDTO">
        SELECT ep.*,
               (SELECT COUNT(0) FROM el_qu_repo WHERE repo_id=ep.repo_id AND qu_type=1) AS total_radio,
               (SELECT COUNT(0) FROM el_qu_repo WHERE repo_id=ep.repo_id AND qu_type=2) AS total_multi,
               (SELECT COUNT(0) FROM el_qu_repo WHERE repo_id=ep.repo_id AND qu_type=3) AS total_judge
        FROM el_exam_repo ep
        WHERE ep.exam_id=#{examId}
    </select>


</mapper>
