<?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.PaperScantronQtypeMapper">
    <!-- 根据试卷id删除答题卡信息 -->
    <delete id="deleteByPaperid">
        DELETE FROM t_paper_scantron_qtype WHERE paperid=#{paperid}
    </delete>

    <resultMap id="qtypeSacn" type="com.xhkjedu.sstudy.vo.paper.PaperScantronQtypeVo">
        <result property="psqtypeid" column="psqtypeid"></result>
        <result property="qtypeid" column="qtypeid"></result>
        <result property="qtypename" column="qtypename"></result>
        <result property="pstorder" column="pstorder"></result>
        <result property="pstscore" column="pstscore"></result>
        <result property="pstnum" column="pstnum"></result>
        <collection property="scantrons" ofType="com.xhkjedu.sstudy.vo.paper.ScantronVo" javaType="java.util.List">
            <result property="pscaid" column="pscaid"></result>
            <result property="qtypeid" column="qtypeid"></result>
            <result property="qtypename" column="qtypename"></result>
            <result property="ctype" column="ctype"></result>
            <result property="psorder" column="psorder"></result>
            <result property="psscore" column="psscore"></result>
            <result property="psanswer" column="psanswer"></result>
            <result property="optionnum" column="optionnum"></result>
        </collection>
    </resultMap>

    <!-- 获取题型以及题型下试题 -->
    <select id="listQtypeScans" resultMap="qtypeSacn">
        SELECT psq.psqtypeid,psq.qtypeid,psq.qtypename,psq.pstorder,psq.pstscore,psq.pstnum,ps.pscaid,
        ps.qtypeid,ps.qtypename,ps.ctype,ps.psorder,ps.psscore,ps.psanswer,ps.optionnum
        FROM t_paper_scantron_qtype psq LEFT JOIN t_paper_scantron ps ON psq.psqtypeid=ps.psqtypeid
        WHERE psq.paperid=#{paperid} ORDER BY psq.pstorder,ps.psorder
    </select>
</mapper>
