<?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.sexam.mapper.report.EReportGenerateMapper">
    <!--考试科目-->
    <select id="listSubject" resultType="java.util.Map">
        select s.subjectid,s.subjectname,p.epid,p.ptype,p.pscore from e_subject s left join e_paper p on s.esid=p.esid
        where s.examid=#{examid} order by s.esid
    </select>
    <!--考试试卷-->
    <select id="listPaper" resultType="com.xhkjedu.sexam.vo.report.ERPaperVo">
        select ep.subjectid,ep.pscore from e_paper ep where ep.examid=#{examid}
    </select>
    <!--删除考试报告-->
    <delete id="deleteExamReport">
        delete from e_rbase where examid=#{examid};
        delete from e_rclass where examid=#{examid};
        delete from e_rclass_qtype where examid=#{examid};
        delete from e_rclass_question where examid=#{examid};
        delete from e_rclass_question_point where examid=#{examid};
        delete from e_rclass_rank where examid=#{examid};
        delete from e_rgrade_rank where examid=#{examid};
        delete from e_rrank where examid=#{examid};
        delete from e_rstudent where examid=#{examid};
        delete from e_rstudent_point where examid=#{examid};
        delete from e_rsubject where examid=#{examid};
    </delete>
    <!--学生上次考试排名及目标-->
    <select id="listStuRankAndGoal" resultType="com.xhkjedu.sexam.model.reportstu.ERstudent">
        select er.studentid,er.subjectid,er.schoolrank,er.nextgoal
        from(select max(er.rsid)rsid from e_class_student ecs left join e_rstudent er on ecs.studentid = er.studentid
        where ecs.examid=#{examid} group by er.studentid,er.subjectid)a left join e_rstudent er on a.rsid=er.rsid
    </select>
</mapper>
