Examination_system/Examination_system-1/.svn/pristine/bf/bf49a682b11b2d7db9044c7b817...

562 lines
18 KiB
Plaintext
Raw Normal View History

2023-10-30 13:10:40 +08:00
<?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.bonus.question.dao.QuestionDao">
<resultMap type="com.bonus.question.beans.QuestionBean" id="baseMap">
<id column="questionId" property="questionId"></id>
<result column="content" property="content"/>
<result column="operation" property="operation"/>
<result column="questionType" property="questionType"/>
<result column="questionTypeName" property="questionTypeName"/>
<result column="answer" property="answer"/>
<result column="picUrl" property="picUrl"/>
<result column="classification" property="classification"/>
<result column="caseId" property="caseId"/>
<result column="uploadTime" property="uploadTime"/>
<result column="questionGrade" property="questionGrade"/>
<result column="questionLevel" property="questionLevel"/>
<result column="material" property="material"/>
<result column="examId" property="examId"/>
<result column="userId" property="user.id"/>
<result column="selectAnswer" property="selectAnswer"/>
<result column="teamzy" property="teamzy"/>
<result column="standardAnswer" property="standardAnswer"/>
</resultMap>
<sql id="baseSQL">
SELECT
sq.question_id AS questionId,
sq.content AS content,
sq.operation AS operation,
sq.question_type AS questionType,
sq.answer AS answer,
sq.standard_answer as standAnswer,
sq.pic_url AS picUrl,
sq.classification AS classification,
sq.case_id AS caseId,
sq.upload_time AS uploadTime,
sq.question_grade AS questionGrade,
sq.question_level AS questionLevel,
sq.standard_answer as standardAnswer,
CONCAT(pooo.`NAME`,'/',poo.`NAME`,'/',po.`NAME`) as questionTypeName
FROM
sz_question sq
LEFT JOIN pm_organization po ON po.ID = sq.question_type
LEFT JOIN pm_organization poo ON poo.ID = po.PARENT_ID
LEFT JOIN pm_organization pooo ON pooo.ID = poo.PARENT_ID
</sql>
<sql id="examSQL">
SELECT
sq.question_id AS questionId,
sq.content AS content,
sq.operation AS operation,
sq.question_type AS questionType,
sq.answer AS answer,
sq.pic_url AS picUrl,
sq.classification AS classification,
sq.case_id AS caseId,
sq.upload_time AS uploadTime,
sq.question_grade AS questionGrade,
sq.question_level AS questionLevel,
CONCAT(pooo.`NAME`,'/',poo.`NAME`,'/',po.`NAME`) as questionTypeName
FROM
sz_question sq
LEFT JOIN pm_organization po ON po.ID = sq.question_type
LEFT JOIN pm_organization poo ON poo.ID = po.PARENT_ID
LEFT JOIN pm_organization pooo ON pooo.ID = poo.PARENT_ID
LEFT JOIN exam_question eq ON eq.question_id = sq.question_id
LEFT JOIN exam_paper ep ON ep.exam_id = eq.exam_id
</sql>
<select id="findCaseId" resultMap="baseMap" parameterType="com.bonus.question.beans.QuestionBean">
SELECT
sq.question_id as questionId,
eq.case_id as caseId
FROM
exam_question eq
LEFT JOIN sz_question sq on sq.case_id = eq.case_id
WHERE
exam_id = #{examId}
AND exam_user = #{user.id}
AND
sq.classification = #{classification}
</select>
<select id="findCaseQuest" resultMap="baseMap" parameterType="com.bonus.question.beans.QuestionBean">
SELECT
eq.exam_id AS examId,
sc.material as material,
eq.exam_user AS userId,
sq.question_id AS questionId,
sq.content AS content,
sq.question_type AS questionType,
sq.answer AS answer,
sq.pic_url AS picUrl,
sq.classification AS classification,
sq.case_id AS caseId,
sq.upload_time AS uploadTime,
sq.question_grade AS questionGrade,
sq.question_level AS questionLevel
FROM
exam_question eq
LEFT JOIN sz_case sc on sc.case_id = eq.case_id
LEFT JOIN sz_question sq ON sq.case_id = sc.case_id
WHERE
eq.exam_id = #{examId}
AND eq.exam_user = #{user.id}
AND sc.case_id = #{caseId}
</select>
<select id="findExamPage" resultMap="baseMap" parameterType="com.bonus.question.beans.QuestionBean">
SELECT
eq.exam_id AS examId,
eq.question_option AS operation,
eq.exam_user AS userId,
eq.answer as selectAnswer,
sq.question_id AS questionId,
sq.content AS content,
sq.question_type AS questionType,
sq.answer AS answer,
sq.pic_url AS picUrl,
sq.classification AS classification,
sq.case_id AS caseId,
sq.upload_time AS uploadTime,
sq.question_grade AS questionGrade,
sq.standard_answer as standardAnswer,
sq.question_level AS questionLevel
FROM
exam_question eq
LEFT JOIN sz_question sq ON sq.question_id = eq.question_id
WHERE
eq.exam_id = #{examId}
<if test="classification != null and classification != '' ">
AND sq.classification = #{classification}
</if>
AND eq.exam_user = #{user.id}
</select>
<select id="findSelfExamPage" resultMap="baseMap" parameterType="com.bonus.question.beans.QuestionBean">
SELECT
eq.exam_id AS examId,
eq.question_option AS operation,
eq.exam_user AS userId,
eq.answer as selectAnswer,
sq.question_id AS questionId,
sq.content AS content,
sq.question_type AS questionType,
sq.answer AS answer,
sq.pic_url AS picUrl,
sq.classification AS classification,
sq.case_id AS caseId,
sq.upload_time AS uploadTime,
sq.question_grade AS questionGrade,
sq.question_level AS questionLevel
FROM
exam_question_self eq
LEFT JOIN sz_question sq ON sq.question_id = eq.question_id
WHERE
eq.exam_id = #{examId}
AND
sq.classification = #{classification}
AND eq.exam_user = #{user.id}
</select>
<select id="findUserExamPage" resultMap="baseMap" parameterType="com.bonus.question.beans.QuestionBean">
SELECT
eq.exam_id as examId,
eq.question_id as questionId,
eq.question_option as operation,
eq.exam_user as userId
FROM
exam_question eq
WHERE
eq.exam_id = #{examId}
AND
eq.exam_user = #{user.id}
</select>
<select id="findById" resultMap="baseMap" parameterType="com.bonus.question.beans.QuestionBean">
<include refid="baseSQL"/>
WHERE
sq.question_id = #{questionId}
</select>
<select id="findIdbyequ" parameterType="com.bonus.question.beans.QuestionBean" resultType="int" >
select eq_id as eqId from exam_question
where
exam_id = #{examId}
AND
question_id = #{questionId}
AND
exam_user = #{user.id}
</select>
<select id="findIdbyequ1" parameterType="com.bonus.question.beans.QuestionBean" resultType="int" >
select eq_id as eqId from exam_question_self
where
exam_id = #{examId}
AND
question_id = #{questionId}
AND
exam_user = #{user.id}
</select>
<select id="findtitleby" parameterType="com.bonus.question.beans.QuestionBean" resultType="String" >
select question_title as questionTitle from exam_question
where
exam_id = #{examId}
AND
question_id = #{questionId}
AND
exam_user = #{user.id}
</select>
<select id="getSetInfoById" resultMap="baseMap">
SELECT
subject_num as teamzy
FROM
org_subject_type_score ep
WHERE org_id = #{0} and subject_type =#{1}
</select>
<select id="findByPage" resultMap="baseMap" parameterType="com.bonus.question.beans.QuestionBean">
<include refid="baseSQL"/>
where
1 = 1
<if test="param.keyWord != null and param.keyWord != '' ">
and (
sq.content LIKE CONCAT("%",#{param.keyWord},"%") or
sq.operation LIKE CONCAT("%",#{param.keyWord},"%")
)
</if>
<if test="param.questionType != null and param.questionType != '' ">
and sq.question_type = #{param.questionType}
</if>
<if test="param.classification != null and param.classification != '' ">
and sq.classification = #{param.classification}
</if>
<if test="param.startTime != null and param.startTime !='' ">
AND sq.upload_time &gt;= #{param.startTime}
</if>
<if test="param.endTime != null and param.endTime !='' ">
AND sq.upload_time &lt;= #{param.endTime}
</if>
<if test="param.questionLevel != null and param.questionLevel != '' ">
and sq.question_level = #{param.questionLevel}
</if>
order by sq.question_id DESC
</select>
<select id="caseQuestion" parameterType="com.bonus.question.beans.QuestionBean" resultMap="baseMap">
SELECT
sc.case_id AS caseId
FROM
sz_case sc
JOIN (
SELECT
ROUND(
RAND() * ( ( SELECT MAX( case_id ) FROM `sz_case` ) - ( SELECT MIN( case_id ) FROM `sz_case` ) ) + ( SELECT MIN( case_id ) FROM `sz_case` )
) AS id
) AS t2
WHERE
sc.case_id >= t2.id
AND sc.question_type = 116
AND sc.question_level = 2
ORDER BY
sc.case_id
LIMIT 1
</select>
<select id="generateQuestion" parameterType="com.bonus.question.beans.QuestionBean" resultMap="baseMap">
SELECT
sq.question_id as questionId,
sq.operation as operation
FROM
sz_question sq
JOIN (
SELECT
ROUND(
RAND() * (
(SELECT MAX(question_id) FROM `sz_question`) - (SELECT MIN(question_id) FROM `sz_question`)
) + (SELECT MIN(question_id) FROM `sz_question`)
) AS id
) AS t2
WHERE
sq.question_id >= t2.id
AND
sq.classification = #{classification}题目类型1单选2多选3判断4填空5简单6案例分析
AND
sq.question_type = #{questionType}专业
AND
sq.question_level = #{questionLevel}题目难度1.简单2.一般3.困难;
order BY sq.question_id LIMIT 1
</select>
<select id="getRandomQuestion" parameterType="com.bonus.question.beans.QuestionBean" resultMap="baseMap">
select
question_id as questionId,
operation as operation
from
sz_question
where
question_type = #{param.questionType} and classification = #{param.classification} and question_level = #{param.questionLevel}
<if test="param.classification != null and param.classification == '1'.toString() ">
ORDER BY RAND() LIMIT #{param.teamzy}
</if>
<if test="param.classification != null and param.classification == '2'.toString() ">
ORDER BY RAND() LIMIT #{param.teamzy}
</if>
<if test="param.classification != null and param.classification == '3'.toString() ">
ORDER BY RAND() LIMIT #{param.teamzy}
</if>
<if test="param.classification != null and param.classification == '4'.toString() ">
ORDER BY RAND() LIMIT 5
</if>
<if test="param.classification != null and param.classification == '5'.toString() ">
ORDER BY RAND() LIMIT 2
</if>
<if test="param.classification != null and param.classification == '6'.toString() ">
ORDER BY RAND() LIMIT 1
</if>
</select>
<select id="getRandomSelfQuestion" parameterType="com.bonus.question.beans.QuestionBean" resultMap="baseMap">
select
question_id as questionId,
operation as operation,
standard_answer as standAnswer
from
sz_question
where
question_type = #{questionType} and classification = #{classification} and question_level = #{questionLevel}
<if test="classification != null and classification == '1'.toString() ">
ORDER BY RAND() LIMIT #{teamzy}
</if>
<if test="classification != null and classification == '2'.toString() ">
ORDER BY RAND() LIMIT #{teamzy}
</if>
<if test="classification != null and classification == '3'.toString() ">
ORDER BY RAND() LIMIT #{teamzy}
</if>
<if test="classification != null and classification == '4'.toString() ">
ORDER BY RAND() LIMIT #{teamzy}
</if>
<if test="classification != null and classification == '5'.toString() ">
ORDER BY RAND() LIMIT #{teamzy}
</if>
<if test="classification != null and classification == '6'.toString() ">
ORDER BY RAND() LIMIT #{teamzy}
</if>
</select>
<select id="findStandAnswer" parameterType="com.bonus.question.beans.QuestionBean" resultMap="baseMap">
SELECT standard_answer as standAnswer FROM sz_question WHERE question_id = #{questionId}
</select>
<insert id="insert" parameterType="com.bonus.question.beans.QuestionBean" useGeneratedKeys="true" keyProperty="question_id">
insert into
sz_question (
content
<if test="operation != null and operation != ''">
,operation
</if>
<if test="answer != null and answer != ''">
,answer
</if>
<if test="keyword != null and keyword != ''">
,standard_answer
</if>
<if test="questionType != null and questionType != ''">
,question_type
</if>
<if test="classification != null and classification != ''">
,classification
</if>
<if test="uploadTime != null and uploadTime != ''">
,upload_time
</if>
<if test="questionGrade != null and questionGrade != ''">
,question_grade
</if>
<if test="questionLevel != null and questionLevel != ''">
,question_level
</if>
)
values (
#{content}
<if test="operation != null and operation != ''">
,#{operation}
</if>
<if test="answer != null and answer != ''">
,#{answer}
</if>
<if test="keyword != null and keyword != ''">
,#{keyword}
</if>
<if test="questionType != null and questionType != ''">
,#{questionType}
</if>
<if test="classification != null and classification != ''">
,#{classification}
</if>
<if test="uploadTime != null and uploadTime != ''">
,#{uploadTime}
</if>
<if test="questionGrade != null and questionGrade != ''">
,#{questionGrade}
</if>
<if test="questionLevel != null and questionLevel != ''">
,#{questionLevel}
</if>
)
</insert>
<insert id="addCaseQuestion" parameterType="com.bonus.question.beans.QuestionBean" useGeneratedKeys="true" keyProperty="caseId">
insert into
sz_case (
material
<if test="questionType != null and questionType != ''">
,question_type
</if>
<if test="questionLevel != null and questionLevel != ''">
,question_level
</if>
)
values (
#{material}
<if test="questionType != null and questionType != ''">
,#{questionType}
</if>
<if test="questionLevel != null and questionLevel != ''">
,#{questionLevel}
</if>
)
</insert>
<insert id="inputExamPageRecord" parameterType="com.bonus.question.beans.QuestionBean">
insert into
exam_question (
<if test="examId != null and examId != ''">
exam_id,
</if>
<if test="questionId != null and questionId != ''">
question_id,
</if>
<if test="operation != null and operation != ''">
question_option,
</if>
<if test="caseId != null and caseId != ''">
case_id,
</if>
<if test="standAnswer != null">
stand_answer,
</if>
<if test="user.id != null">
exam_user
</if>
)
values (
<if test="examId != null and examId != ''">
#{examId},
</if>
<if test="questionId != null and questionId != ''">
#{questionId},
</if>
<if test="operation != null and operation != ''">
#{operation},
</if>
<if test="caseId != null and caseId != ''">
#{caseId},
</if>
<if test="standAnswer != null and standAnswer != ''">
#{standAnswer},
</if>
<if test="user.id != null">
#{user.id}
</if>
)
</insert>
<insert id="insertSelfQuestion" parameterType="com.bonus.question.beans.QuestionBean">
insert into
exam_question_self (
<if test="examId != null and examId != ''">
exam_id,
</if>
<if test="questionId != null and questionId != ''">
question_id,
</if>
<if test="operation != null and operation != ''">
question_option,
</if>
<if test="caseId != null and caseId != ''">
case_id,
</if>
<if test="standAnswer != null and standAnswer != ''">
standard_answer,
</if>
<if test="user.id != null">
exam_user
</if>
)
values (
<if test="examId != null and examId != ''">
#{examId},
</if>
<if test="questionId != null and questionId != ''">
#{questionId},
</if>
<if test="operation != null and operation != ''">
#{operation},
</if>
<if test="caseId != null and caseId != ''">
#{caseId},
</if>
<if test="standAnswer != null and standAnswer != ''">
#{standAnswer},
</if>
<if test="user.id != null">
#{user.id}
</if>
)
</insert>
<update id="update" parameterType="com.bonus.question.beans.QuestionBean">
update
sz_question
<set>
<if test="content != null and content != ''">
content = #{content},
</if>
<if test="operation != null and operation != ''">
operation = #{operation},
</if>
<if test="questionType != null and questionType != ''">
question_type = #{questionType},
</if>
<if test="answer != null and answer != ''">
answer = #{answer},
</if>
<if test="classification != null and classification != ''">
classification = #{classification},
</if>
<if test="questionGrade != null and questionGrade != ''">
question_grade = #{questionGrade},
</if>
<if test="questionLevel != null and questionLevel != ''">
question_level = #{questionLevel}
</if>
</set>
where
question_id = #{questionId}
</update>
<update id="deleteApply" parameterType="java.util.List">
delete from sz_question
where question_id in
<foreach collection="idss" item="id" open="(" close=")" separator=",">
#{id}
</foreach>
</update>
</mapper>