<?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.yanzhu.exam.onlineexam.mapper.ExamQuestionsListDataMapper">
    
    <resultMap type="com.yanzhu.exam.onlineexam.domain.dto.ExamQuestionsListData" id="ExamQuestionsListDataResult">
        <result property="examCode"    column="exam_code"    />
        <result property="userCode"    column="user_code"    />
        <result property="questionsCode"    column="questions_code"    />
        <result property="questionsNumber"    column="questions_number"    />
        <result property="questionsType"    column="questions_type"    />
        <result property="questionsScore"    column="questions_score"    />
        <result property="questionsAnswer"    column="questions_answer"    />
        <result property="isMark"    column="is_mark"    />
        <result property="isCurrent"    column="is_current"    />
     </resultMap>

    <select id="selectQuestionsList" parameterType="com.yanzhu.exam.onlineexam.domain.dto.ExamQuestionsListData" resultMap="ExamQuestionsListDataResult">
SELECT
                    a.exam_code,
                    a.questions_code,
                    a.questions_number,
                    b.questions_type,
                    b.questions_score,
                    c.questions_answer,
                    IFNULL(c.is_mark, 1) AS is_mark,
                    IFNULL(c.is_current, 1) AS is_current
FROM
    exam_task_questions a
LEFT JOIN
    exam_questions_property b ON b.questions_code = a.questions_code
LEFT JOIN
    exam_task_answer c ON c.exam_code = a.exam_code
    AND c.questions_code = a.questions_code
    AND c.user_code = #{examCode}
WHERE
    a.exam_code =  #{examCode}
ORDER BY
    questions_number

    </select>

</mapper>