智慧保安后台管理-外网
Administrator
2022-06-16 8b375fe00a241b3a769b82fe3dac8d1c9dce8a02
src/main/java/org/springblade/modules/exam/mapper/ExamPaperMapper.xml
@@ -534,14 +534,79 @@
        ) aa,(select @i:=0) bb
    </select>
    <select id="queryRandomSubjectList" resultType="org.springblade.modules.exam.vo.ExamSubjectChoicesVO">
        select * from (
    <!--ExamSubjectChoicesInfoMap 多表联查 一对多查询 -->
    <resultMap id="ExamSubjectChoicesInfoMap" type="org.springblade.modules.exam.vo.ExamSubjectChoicesVO">
        <id property="id" column="id"/>
        <id property="categoryId" column="category_id"/>
        <id property="subjectName" column="subject_name"/>
        <id property="choicesType" column="choices_type"/>
        <id property="answer" column="answer"/>
        <id property="score" column="score"/>
        <id property="level" column="level"/>
        <result column="id" property="id"/>
        <collection property="examSubjectOptions" javaType="java.util.List" ofType="org.springblade.modules.exam.entity.ExamSubjectOption" autoMapping="true">
            <id property="id" column="eso_id"/>
        </collection>
    </resultMap>
    <!--已缴费人员题目查询-->
    <select id="queryRandomSubjectList" resultMap="ExamSubjectChoicesInfoMap">
        select
        esc.id,esc.category_id,esc.subject_name,esc.choices_type,esc.score,esc.answer,
        eso.id eso_id,eso.subject_choices_id,eso.option_name,eso.option_content,eso.creator,
        eso.create_date,eso.modifier,eso.modify_date,eso.del_flag,eso.application_code,eso.tenant_code
        from (
            select
            id,
            category_id,
            subject_name,
            choices_type,
            score,
            answer,
            analysis,
            tktype
            from (
            select * from exam_subject_choices
            where id in
            <foreach collection="list" index="index" item="item" open="(" separator="," close=")">
                #{item}
            </foreach>
        ) a ORDER BY RAND() LIMIT #{number}
            ) a ORDER BY RAND() LIMIT #{number}
        ) esc
        left join
        exam_subject_option eso
        on
        esc.id = eso.subject_choices_id
    </select>
    <!--模拟考试随机抽题-->
    <select id="simulateQueryRandomSubjectList" resultMap="ExamSubjectChoicesInfoMap">
        SELECT
            esc.id,
            esc.category_id,
            esc.subject_name,
            esc.choices_type,
            esc.score,
            esc.answer,
            eso.id eso_id,
            eso.subject_choices_id,
            eso.option_name,
            eso.option_content,
            eso.creator,
            eso.create_date,
            eso.modifier,
            eso.modify_date,
            eso.del_flag,
            eso.application_code,
            eso.tenant_code
        FROM
            (
                SELECT * FROM ( SELECT * FROM exam_subject_choices WHERE choices_type = 0 ORDER BY RAND( ) LIMIT 25 ) a UNION ALL
                SELECT * FROM ( SELECT * FROM exam_subject_choices WHERE choices_type = 1 ORDER BY RAND( ) LIMIT 10 ) b UNION ALL
                SELECT * FROM ( SELECT * FROM exam_subject_choices WHERE choices_type = 2 ORDER BY RAND( ) LIMIT 20 ) c UNION ALL
                SELECT * FROM ( SELECT * FROM exam_subject_choices WHERE choices_type = 3 ORDER BY RAND( ) LIMIT 5 ) d
            ) esc
            LEFT JOIN exam_subject_option eso ON esc.id = eso.subject_choices_id
    </select>