From 8458e64aab474c0fc2f49ae4ff22fb11ce5cf6e2 Mon Sep 17 00:00:00 2001
From: “djh” <“3298565835@qq.com”>
Date: Mon, 11 Nov 2024 16:55:28 +0800
Subject: [PATCH] 批次新增学员查询条件,新增题目导入接口
---
exam-system/src/main/resources/mapper/system/ExQuestionMapper.xml | 78 +++++++++++++++++++++++++++------------
1 files changed, 54 insertions(+), 24 deletions(-)
diff --git a/exam-system/src/main/resources/mapper/system/ExQuestionMapper.xml b/exam-system/src/main/resources/mapper/system/ExQuestionMapper.xml
index dc2acc3..132c1fd 100644
--- a/exam-system/src/main/resources/mapper/system/ExQuestionMapper.xml
+++ b/exam-system/src/main/resources/mapper/system/ExQuestionMapper.xml
@@ -18,6 +18,7 @@
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="remark" column="remark" />
+ <result property="bankName" column="bank_name" />
<association property="exExerciseAnswer" javaType="com.gkhy.exam.system.domain.ExExerciseAnswer" resultMap="ExerciseAnswerResult" />
<association property="studentAnswer" javaType="com.gkhy.exam.system.domain.ExStudentAnswer" resultMap="StudentAnswerResult" />
</resultMap>
@@ -44,6 +45,18 @@
select id, question_type, bank_id, status, company_id,answer,title,privatize,content,version, create_by, create_time, update_by, update_time, remark
from ex_course
</sql>
+ <insert id="saveBatch">
+ INSERT INTO
+ `train_exam`.`ex_question`
+ ( `question_type`, `bank_id`, `company_id`, `status`, `answer`, `title`, `content`, `privatize`, `create_time`,
+ `create_by`, `update_time`, `update_by`, `remark`, `version`)
+ VALUES
+ <foreach collection="exQuestions" item="question" separator=",">
+ (#{question.questionType}, #{question.bankId}, #{question.companyId}, #{question.status}, #{question.answer},
+ #{question.title}, #{question.content}, #{question.privatize}, #{question.createTime}, #{question.createBy},
+ #{question.updateTime}, #{question.updateBy}, #{question.remark}, #{question.version})
+ </foreach>
+ </insert>
<select id="selectCountByBankId" resultType="integer">
@@ -51,32 +64,33 @@
</select>
<select id="selectQuestionWithLimit" resultType="com.gkhy.exam.system.domain.ExQuestion">
- select id,title from ex_question where bank_id=#{bankId} and question_type=#{questionType} and (company_id=#{companyId} or privatize=1) limit #{startIndex},{questionCount}
+ select id,title from ex_question where bank_id=#{bankId} and question_type=#{questionType} and (company_id=#{companyId} or privatize=1) limit #{startIndex},#{questionCount}
</select>
<select id="selectRandomQuestion" resultType="com.gkhy.exam.system.domain.ExQuestion">
select id,title from ex_question where bank_id=#{bankId} and question_type=#{questionType} and (company_id=#{companyId} or privatize=1) order by RAND()
- limit {questionCount}
+ limit #{questionCount}
</select>
<select id="selectQuestionList" resultType="com.gkhy.exam.system.domain.ExQuestion">
- select id,question_type, bank_id, status, company_id,answer,title,privatize from ex_question
+ select a.id,a.question_type, a.bank_id, a.status, a.company_id,a.title,a.privatize,b.name as bank_name from ex_question a
+ left join ex_question_bank b on b.id=a.bank_id
<where>
<if test="title!=null and title!=''">
- title like concat(#{title},"%")
+ and a.title like concat(#{title},"%")
</if>
<if test="bankId!=null">
- bank_id=#{bankId}
+ and a.bank_id=#{bankId}
</if>
<if test="companyId!=null">
- company_id=#{companyId}
+ and (a.company_id=#{companyId} or a.privatize=1)
</if>
<if test="questionType!=null">
- question_type=#{questionType}
+ and a.question_type=#{questionType}
</if>
- <if test="privatize!=null">
- privatize=#{privatize}
- </if>
+<!-- <if test="privatize!=null">-->
+<!-- and privatize=#{privatize}-->
+<!-- </if>-->
</where>
order by id desc
</select>
@@ -85,12 +99,7 @@
select a.id,b.passed from ex_question a
left join ex_exercise_answer b on b.question_id=a.id and b.student_id=#{studentId}
where a.bank_id=#{bankId}
- <if test="exerciseType=2">
- order by a.question_type asc,a.id asc
- </if>
- <if test="exerciseType=1">
- order by a.id asc
- </if>
+ order by a.question_type asc,a.id asc
</select>
<select id="getExeriseQuestionById" resultMap="ExQuestionResult">
@@ -106,18 +115,25 @@
<foreach collection="questionIds" item="questionId" open="(" separator="," close=")">
#{questionId}
</foreach>
+ ORDER BY FIELD(a.id, <foreach collection="questionIds" item="questionId" separator=",">#{questionId}</foreach>)
</select>
<select id="getPaperQuestionList" resultType="java.util.Map">
select a.id
- <if test="completed=1">
- ,c.passed
+ <if test="viewType==1">
+ ,
+ case when c.answer is null then 0
+ else 1
+ end as state
</if>
+ <if test="viewType==2">
+ <if test="state!=0">
+ ,c.passed
+ </if>
+ </if>
from ex_question a
inner join ex_paper_question b on b.question_id=a.id
- <if test="completed=1">
left join ex_student_answer c on c.question_id=a.id and c.student_id=#{studentId} and c.paper_id=#{paperId}
- </if>
where b.paper_id=#{paperId}
order by a.question_type asc,a.id asc
</select>
@@ -125,7 +141,7 @@
<select id="getPaperQuestionById" resultMap="ExQuestionResult">
select a.id,a.question_type,a.bank_id,a.company_id,a.title,a.content,a.privatize,
b.id as student_answer_id, b.answer as student_answer,b.question_id,b.student_id
- <if test="completed=1">
+ <if test="state!=0">
,a.answer,b.passed as student_passed
</if>
from ex_question a
@@ -133,10 +149,10 @@
where a.id=#{questionId}
</select>
- <select id="getPaperQuestionByIds" resultType="com.gkhy.exam.system.domain.ExQuestion">
+ <select id="getPaperQuestionByIds" resultMap="ExQuestionResult">
select a.id,a.question_type,a.bank_id,a.company_id,a.title,a.content,a.privatize,
b.id as student_answer_id, b.answer as student_answer,b.question_id,b.student_id
- <if test="completed=1">
+ <if test="state!=0">
,a.answer,b.passed as student_passed
</if>
from ex_question a
@@ -145,14 +161,28 @@
<foreach collection="questionIds" item="questionId" open="(" separator="," close=")">
#{questionId}
</foreach>
+ ORDER BY FIELD(a.id, <foreach collection="questionIds" item="questionId" separator=",">#{questionId}</foreach>)
</select>
<select id="getExerciseErrorQuestionList" resultType="java.lang.Long">
select a.id from ex_question a
inner join ex_exercise_answer b on b.question_id=a.id
- where a.bank_id=#{bankId} and b.student_id=#{studentId}
+ where a.bank_id=#{bankId} and b.student_id=#{studentId} and b.passed=0
order by a.question_type asc,a.id asc
</select>
+ <select id="selectByQuestionId" resultType="com.gkhy.exam.system.domain.ExQuestion">
+ select a.*,b.name as bank_name from ex_question a
+ left join ex_question_bank b on b.id=a.bank_id
+ where a.id=#{questionId}
+ </select>
+
+ <select id="selectQuestionByPaperId" resultType="com.gkhy.exam.system.domain.ExQuestion"
+ parameterType="java.lang.Long">
+ select a.* from ex_question a
+ inner join ex_paper_question b on b.question_id=a.id
+ where b.paper_id=#{paperId}
+ </select>
+
</mapper>
--
Gitblit v1.9.2