<?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.sstudy.mapper.paper.PaperQtypeMapper">
    <!-- 根据试卷id删除题型信息 -->
    <delete id="deleteByPaperid">
        DELETE FROM t_paper_qtype WHERE paperid=#{paperid}
    </delete>

    <resultMap id="qtypesQuestions" type="com.xhkjedu.sstudy.vo.paper.PaperQtypeVo">
        <result column="ptid" property="ptid"></result>
        <result column="qtypeid" property="qtypeid"></result>
        <result column="qtypename" property="qtypename"></result>
        <result column="ptorder" property="ptorder"></result>
        <result column="ptscore" property="ptscore"></result>
        <result column="ptnum" property="ptnum"></result>
        <collection property="quelist" ofType="com.xhkjedu.sstudy.vo.paper.PaperQtypeQuesVo" javaType="java.util.List">
            <result column="ptqid" property="ptqid"></result>
            <result column="questionid" property="questionid"></result>
            <result column="qtypeid" property="qtypeid"></result>
            <result column="qtypename" property="qtypename"></result>
            <result column="ctype" property="ctype"></result>
            <result column="qlevel" property="qlevel"></result>
            <result column="sorder" property="sorder"></result>
            <result column="snum" property="snum"></result>
            <result column="complexity" property="complexity"></result>
            <result column="ptqscore" property="ptqscore"></result>
            <result column="ptqorder" property="ptqorder"></result>
            <result column="qn" property="qn"></result>
            <result column="questionpid" property="questionpid"></result>
            <result column="mscore" property="mscore"></result>
            <result column="mqtypeid" property="mqtypeid"></result>
            <result column="mqtypename" property="mqtypename"></result>
            <result column="mctype" property="mctype"></result>
            <result column="mqlevel" property="mqlevel"></result>
            <result column="mcomplexity" property="mcomplexity"></result>
            <collection property="points" ofType="java.util.Map" javaType="java.util.List"
                        column="{questionid=questionid,qlevel=qlevel,questionpid=questionpid" select="listQuestionPoints">
                <result column="pointid" property="pointid"></result>
                <result column="pointname" property="pointname"></result>
            </collection>
        </collection>
    </resultMap>

    <!--试题详情-->
    <select id="listPaperQtypeQuestions" resultMap="qtypesQuestions">
        select t.ptid,t.qtypeid,t.qtypename,t.ptorder,t.ptscore,t.ptnum,tq.ptqid,tq.questionid,q.qtypeid,q.qtypename,q.ctype,
               q.qlevel,q.sorder,q.snum,q.complexity,tq.ptqscore,tq.ptqorder,tq.qn,tq.questionpid,tq.mscore,tq.mqtypeid,
               tq.mqtypename,q1.ctype mctype,q1.qlevel mqlevel,q1.complexity mcomplexity
                from t_paper_qtype_question tq left join t_paper_qtype t on t.ptid=tq.ptid
                left join t_question q on tq.questionid=q.questionid
                left JOIN t_question q1 on tq.questionpid=q1.questionid
         where t.paperid=#{paperid} order by t.ptorder,tq.ptqorder,q.sorder
    </select>
    <!--试题关联知识点-->
    <select id="listQuestionPoints" resultType="java.util.Map">
        select qp.pointid,p.pointname from t_question_point qp
        left join t_point p on qp.pointid=p.pointid
        where qp.questionid=#{questionpid} group by qp.pointid order by p.pointorder,p.pointid
    </select>

</mapper>
