<?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.sclass.mapper.classroom.ClassroomPaperStudentScantronMapper">
    <!--批量更新试题批改信息-->
    <update id="updateScantronQuestionBatch" parameterType="java.util.List">
        UPDATE t_classroom_paper_student_scantron
        <trim prefix="set" suffixOverrides=",">
            <trim prefix="stuscore = CASE " suffix="END,">
                <foreach collection="list" index="index" item="item">
                    when pssid = #{item.pssid} then #{item.stuscore}
                </foreach>
            </trim>
            <trim prefix="checked = CASE " suffix="END,">
                <foreach collection="list" index="index" item="item" >
                    when pssid = #{item.pssid} then #{item.checked}
                </foreach>
            </trim>
            <trim prefix="checkid = CASE " suffix="END,">
                <foreach collection="list" index="index" item="item" >
                    when pssid = #{item.pssid} then #{item.checkid}
                </foreach>
            </trim>
            <trim prefix="checktime = CASE " suffix="END,">
                <foreach collection="list" index="index" item="item" >
                    when pssid = #{item.pssid} then #{item.checktime}
                </foreach>
            </trim>
        </trim>
        where
        <foreach collection="list" item="item" index="index" separator="or">
            pssid =#{item.pssid}
        </foreach>
    </update>

    <!-- 获取考试学生待批改试题列表- -->
    <select id="listCorrectQuestion" resultType="java.util.Map">
        SELECT pss.pssid,pss.paperid,pss.studentid,pss.psid,pss.qorder,pss.answered,pss.useranswer,
        pss.answertime,pss.costtime,pss.checked,pss.stuscore,pss.qscore,pss.pscaid,
        psc.ctypename qtypename,psc.ctype,psc.psanswer,u.username studentname
        FROM t_classroom_paper_student_scantron pss LEFT JOIN t_user u ON pss.studentid=u.userid
        LEFT JOIN t_classroom_paper_scantron psc ON pss.pscaid = psc.pscaid
        WHERE pss.psid=#{psid} and psc.ctype=3 order by pss.qorder
    </select>
    <!--修改学生作答记录（教师添加批注）-->
    <update id="updateScantronUseranswer">
        update t_classroom_paper_student_scantron set useranswer=#{useranswer} where pssid=#{pssid}
    </update>
</mapper>
