<?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.qmth.teachcloud.report.business.mapper.TBPaperStructMapper">

    <select id="findQuestionInfo" resultType="com.qmth.teachcloud.report.business.bean.result.TBPaperStructResult">
        SELECT
            tbp.paper_type AS paperType,
            tbps.big_question_number AS mainNumber,
            tbps.small_question_number AS subNumber,
            tbps.full_score AS fullScore,
            tbps.knowledge_dimension AS knowledgeDimension,
            tbps.ability_dimension AS abilityDimension,
            round(convert(taps.score_rate * 100,decimal(10,4)),2) AS scoreRate,
            taps.difficult,
            convert(taps.validity,decimal(10,4)) AS validity
        FROM
            t_b_paper_struct tbps
            join t_a_paper_struct taps
            on taps.paper_struct_id = tbps.id
            join t_b_paper tbp
            on tbp.id = tbps.paper_id
        <where>
            <if test="examId != null and examId != ''">
                and tbp.exam_id = #{examId}
            </if>
            <if test="courseCode != null and courseCode != ''">
                and tbp.course_code = #{courseCode}
            </if>
        </where>
    </select>
</mapper>
