<?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.smarking.mapper.report.reportsubject.MsrSubjectPointMapper">

    <!--获取科目对应知识点-->
    <select id="listSubjectPoints" resultType="com.xhkjedu.smarking.vo.report.reportsubject.PointVo">
        select p.pointid,p.pointname,p.pointorder,p.pointpid
        from t_point p where p.subjectid=#{subjectid} and (p.belong=1 or (p.belong=3
        and p.schoolid=(select schoolid from ms_exam where examid=#{examid} limit 1))) order by p.pointlevel,p.pointorder
    </select>

    <!--学科素养-标定知识点-试题知识点-->
    <resultMap id="questionPoints" type="java.util.Map">
        <result property="mptqid" column="mptqid"/>
        <result property="fullscore" column="fullscore"/>
        <result property="schoolavgscore" column="schoolavgscore"/>
        <result property="schoolavgrate" column="schoolavgrate"/>
        <result property="questionid" column="questionid"/>
        <result property="questionpid" column="questionpid"/>
        <collection property="points" ofType="java.util.Map" javaType="java.util.ArrayList">
            <result property="pointid" column="pointid"/>
            <result property="pointname" column="pointname"/>
            <result property="mpid" column="mpid"/>
        </collection>
    </resultMap>
    <select id="listQuestionPointsForXhsy" resultMap="questionPoints">
        select distinct cq.mptqid,cq.fullscore,cq.schoolavgscore,cq.schoolavgrate,q.questionid,
        q.questionpid,qp.pointid,qp.pointname,qp.mpid
        from msr_class_question cq
        left join ms_paper_qtype_question q on cq.mptqid=q.mptqid
        left join ms_paper_qtype_question_point qp on cq.mptqid=qp.mptqid
        where cq.examid=#{param.examid} and cq.subjectid=#{param.subjectid} and cq.classid=0 order by cq.qorder
    </select>

    <!--学科素养-知识点整体分析-级别下知识点-->
    <select id="listXksyPointsZt" resultType="com.xhkjedu.smarking.model.report.reportsubject.MsrSubjectPoint">
        select * from msr_subject_point where examid=#{param.examid} and subjectid=#{param.subjectid} and pointlevel=#{param.pointlevel} order by spid
    </select>

    <!--学科素养-单个知识点分析-所有知识点-->
    <select id="listXksyPointsAll" resultType="java.util.Map">
        select spid,pointid,pointname,pointlevel from msr_subject_point
        where examid=#{param.examid} and subjectid=#{param.subjectid} and classid=0 order by pointlevel,spid
    </select>

    <!--学科素养-单个知识点分析-知识点详情-->
    <select id="getXksyPointByPointid" resultType="com.xhkjedu.smarking.model.report.reportsubject.MsrSubjectPoint">
        select spid,fullscore,avgscore,avgrate,mptqids,mfnum,lfnum from msr_subject_point where examid=#{param.examid} and subjectid=#{param.subjectid} and classid=0
        and pointlevel=#{param.pointlevel} and pointid=#{param.pointid} limit 1
    </select>

    <!--学科素养-单个知识点分析-各班知识点对比-->
    <select id="listXksyPointsForAllClass" resultType="java.util.Map">
        select p.classid,p.fullscore,p.maxscore,p.minscore,p.avgscore,p.avgrate,
        p.bzc,p.cyxs,c.classname from msr_subject_point p
        left join ms_class c on p.examid=c.examid and p.subjectid=c.subjectid and p.classid=c.classid
        where p.examid=#{param.examid} and p.subjectid=#{param.subjectid} and p.pointid=#{param.pointid} and p.pointlevel=#{param.pointlevel}
        order by p.spid
    </select>

    <!--删除知识点相关报告-->
    <delete id="deletePointAnalyze">
        delete from msr_student_point where examid = #{examid} and subjectid=#{subjectid};
        delete from msr_subject_point where examid = #{examid} and subjectid=#{subjectid};
        delete from msr_subject_point_section where examid = #{examid} and subjectid=#{subjectid};
        delete from msr_subject_question_rankgroup where examid = #{examid} and subjectid=#{subjectid};
        delete from msr_subject_question_section where examid = #{examid} and subjectid=#{subjectid};
    </delete>

</mapper>
