From a39e023677a9c5c68ba3b6577f0d7da24b9dc65e Mon Sep 17 00:00:00 2001
From: kongzy <kongzy>
Date: Wed, 30 Oct 2024 11:14:08 +0800
Subject: [PATCH] update
---
exam-system/src/main/resources/mapper/system/ExPaperStudentMapper.xml | 139 ++++++++++++++++++++++++++++++++++++++--------
1 files changed, 115 insertions(+), 24 deletions(-)
diff --git a/exam-system/src/main/resources/mapper/system/ExPaperStudentMapper.xml b/exam-system/src/main/resources/mapper/system/ExPaperStudentMapper.xml
index d87acb8..f2c2602 100644
--- a/exam-system/src/main/resources/mapper/system/ExPaperStudentMapper.xml
+++ b/exam-system/src/main/resources/mapper/system/ExPaperStudentMapper.xml
@@ -8,23 +8,53 @@
<result property="score" column="score" />
<result property="passed" column="passed" />
<result property="useTime" column="use_time" />
- <result property="completed" column="completed" />
+ <result property="state" column="state" />
<result property="version" column="version" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="remark" column="remark" />
- <result property="studentName" column="student_name" />
- <result property="studentPhone" column="student_phone" />
- <result property="paperName" column="paper_name" />
- <collection property="singleQuestions" ofType="com.gkhy.exam.system.domain.ExQuestion" select="getQuestionByPaperId" column="{paperId=paper_id,studentId=student_id,completed=completed,questionType=1}"/>
- <collection property="multiQuestions" ofType="com.gkhy.exam.system.domain.ExQuestion" select="getQuestionByPaperId" column="{paperId=paper_id,studentId=student_id,completed=completed,questionType=2}"/>
- <collection property="judgeQuestions" ofType="com.gkhy.exam.system.domain.ExQuestion" select="getQuestionByPaperId" column="{paperId=paper_id,studentId=student_id,completed=completed,questionType=3}"/>
+ <result property="createName" column="create_name" />
+ <association property="student" javaType="com.gkhy.exam.system.domain.ExStudent" resultMap="exStudentResult" />
+ <association property="examPaper" javaType="com.gkhy.exam.system.domain.ExExamPaper" resultMap="exExamPaperResult" />
+ <collection property="questions" ofType="com.gkhy.exam.system.domain.ExQuestion" select="getQuestionByPaperId" column="{paperId=paper_id,studentId=student_id,state=state}"/>
+ </resultMap>
+
+
+ <resultMap type="com.gkhy.exam.system.domain.ExPaperStudent" id="SimplePaperStudentResult">
+ <result property="id" column="id" />
+ <result property="paperId" column="paper_id" />
+ <result property="studentId" column="student_id" />
+ <result property="score" column="score" />
+ <result property="passed" column="passed" />
+ <result property="useTime" column="use_time" />
+ <result property="startTime" column="start_time" />
+ <result property="state" column="state" />
+ <result property="version" column="version" />
+ <result property="createBy" column="create_by" />
+ <result property="createTime" column="create_time" />
+ <result property="updateBy" column="update_by" />
+ <result property="updateTime" column="update_time" />
+ <result property="remark" column="remark" />
+ <result property="createName" column="create_name" />
+ <result property="companyId" column="company_id" />
+ <result property="companyName" column="company_name" />
+ <association property="student" javaType="com.gkhy.exam.system.domain.ExStudent" resultMap="exStudentResult" />
+ <association property="examPaper" javaType="com.gkhy.exam.system.domain.ExExamPaper" resultMap="exExamPaperResult" />
</resultMap>
<resultMap type="com.gkhy.exam.system.domain.ExQuestion" id="ExQuestionResult">
<result property="id" column="id" />
+ <result property="questionType" column="question_type" />
+ <result property="bankId" column="bank_id" />
+ <result property="status" column="status" />
+ <result property="companyId" column="company_id" />
+ <result property="status" column="status" />
+ <result property="answer" column="answer" />
+ <result property="title" column="title" />
+ <result property="privatize" column="privatize" />
+ <result property="content" column="content" />
<association property="studentAnswer" javaType="com.gkhy.exam.system.domain.ExStudentAnswer" resultMap="studentAnswerResult" />
</resultMap>
@@ -35,14 +65,47 @@
<result property="questionId" column="answer_question_id" />
<result property="answer" column="answer_answer" />
<result property="passed" column="answer_passed" />
+ <result property="score" column="answer_score" />
+ </resultMap>
+
+ <resultMap id="exExamPaperResult" type="com.gkhy.exam.system.domain.ExExamPaper">
+ <result property="id" column="paper_id" />
+ <result property="code" column="paper_code" />
+ <result property="name" column="paper_name" />
+ <result property="categoryName" column="category_name" />
+ <result property="limited" column="limited" />
+ <result property="limitTime" column="limit_time" />
+ <result property="deadline" column="deadline" />
+ <result property="singleNum" column="single_num" />
+ <result property="multiNum" column="multi_num" />
+ <result property="judgeNum" column="judge_num" />
+ <result property="easyNum" column="easy_num" />
+ <result property="singleScore" column="single_score" />
+ <result property="multiScore" column="multi_score" />
+ <result property="judgeScore" column="judge_score" />
+ <result property="easyScore" column="easy_score" />
+ </resultMap>
+
+ <resultMap id="exStudentResult" type="com.gkhy.exam.system.domain.ExStudent">
+ <result property="id" column="student_id" />
+ <result property="name" column="student_name" />
+ <result property="phone" column="student_phone" />
</resultMap>
<insert id="batchInsert">
- insert into ex_paper_student(paper_id,student_id) values
+ insert into ex_paper_student(paper_id,student_id,create_id) values
<foreach collection="list" item="item" index="index" separator=",">
- (#{item.paperId},#{item.studentId})
+ (#{item.paperId},#{item.studentId},#{item.createId})
</foreach>
</insert>
+
+ <update id="batchUpdateComplete">
+ update ex_paper_student set completed=#{completed}
+ where id in
+ <foreach collection="paperStudentIds" item="item" open="(" separator="," close=")">
+ #{item}
+ </foreach>
+ </update>
<select id="countByPaperId" resultType="java.lang.Integer">
select count(1) from ex_paper_student where paper_id=#{paperId}
@@ -52,30 +115,46 @@
select count(1) from ex_paper_student where paper_id=#{paperId} and student_id=#{studentId}
</select>
- <select id="selectPaperStudentList" resultType="com.gkhy.exam.system.domain.ExPaperStudent">
- select a.*,b.id as student_id,b.phone as student_phone,b.name as student_name,c.name as paperName from ex_paper_student a
+ <select id="selectPaperStudentList" resultMap="SimplePaperStudentResult">
+ select a.*,e.name as create_name,b.phone as student_phone,b.name as student_name,c.name as paper_name,c.code as paper_code,c.limited,c.limit_time,c.deadline,d.name as category_name
+ <if test="studentId!=null">
+ ,(select question_id from ex_student_answer where paper_id=a.paper_id and student_id=#{studentId} order by id desc limit 1) as question_id
+ </if>
+ from ex_paper_student a
left join ex_student b on a.student_id=b.id
left join ex_exam_paper c on c.id=a.paper_id
+ left join sys_category d on d.id=c.category_id
+ left join sys_user e on e.id =a.create_id
<where>
and c.del_flag=0
- <if test="paperId!=null'">
+ <if test="paperId!=null">
and a.paper_id=#{paperId}
</if>
<if test="studentName!=null and studentName!=''">
and b.name like concat('%',#{studentName},'%')
</if>
- <if test="phone!=null and phone!=''">
- and b.phone like concat('%',#{phone},'%')
+ <if test="studentPhone!=null and studentPhone!=''">
+ and b.phone like concat('%',#{studentPhone},'%')
</if>
<if test="studentId!=null">
and a.student_id = #{studentId}
</if>
+ <if test="state!=null">
+ and a.state = #{state}
+ </if>
</where>
- order by a.id desc
+ order by a.passed desc,a.id desc
</select>
<select id="selectPaperStudentById" resultMap="ExPaperStudentResult">
- select a.*,b.id as student_id,b.phone as student_phone,b.name as student_name,c.name as paperName from ex_paper_student a
+ select a.*,b.id as student_id,b.phone as student_phone,b.name as student_name,c.name as paper_name,c.single_num,c.multi_num,c.judge_num,c.easy_num,c.single_score,c.multi_score,c.judge_score,c.easy_score from ex_paper_student a
+ left join ex_student b on a.student_id=b.id
+ left join ex_exam_paper c on c.id=a.paper_id
+ where a.id=#{paperStudentId}
+ </select>
+
+ <select id="selectSimplePaperStudentById" resultMap="SimplePaperStudentResult">
+ select a.*,b.id as student_id,b.phone as student_phone,b.name as student_name,c.name as paper_name from ex_paper_student a
left join ex_student b on a.student_id=b.id
left join ex_exam_paper c on c.id=a.paper_id
where a.id=#{paperStudentId}
@@ -88,19 +167,31 @@
where a.paper_id=#{paperId} and a.student_id=#{studentId}
</select>
- <select id="getQuestionByPaperId" resultType="com.gkhy.exam.system.domain.ExQuestion">
+ <select id="getQuestionByPaperId" resultMap="ExQuestionResult">
select a.id,a.question_type,a.bank_id,a.company_id,a.status,
- <if test="completed!=null and completed=1">
- a.answer,
+ <if test="state!=null and state!=0">
+ a.answer,c.passed as answer_passed,c.score as answer_score,
</if>
a.title,a.privatize,a.content,
- c.id as answer_id,c.paper_id as answer_paper_id,c.student_id as answer_student_id,c.question_id as answer_question_id,c.answer as answer_answer,
- <if test="completed!=null and completed=1">
- c.passed as answer_passed
- </if>
+ c.id as answer_id,c.paper_id as answer_paper_id,c.student_id as answer_student_id,c.question_id as answer_question_id,c.answer as answer_answer
+
from ex_question a
inner join ex_paper_question b on a.id=b.question_id
left join ex_student_answer c on c.question_id=a.id and c.student_id=#{studentId} and c.paper_id=#{paperId}
- where b.paper_id=#{paperId} and a.question_type=#{questionType}
+ where b.paper_id=#{paperId}
+ order by a.question_type asc,a.id desc
+ </select>
+
+ <select id="selectByStudentId" resultMap="SimplePaperStudentResult">
+ select a.*,b.name as paper_name,c.id as company_id,c.name as company_name from ex_paper_student a
+ left join ex_exam_paper b on b.id=a.paper_id
+ left join sys_company c on c.id=b.company_id
+ </select>
+
+ <select id="selectNoCompleteStudent" resultMap="SimplePaperStudentResult">
+ select a.*, b.name as paper_name,b.limited,b.limit_time,b.deadline,b.single_num,b.multi_num,b.judge_num,b.easy_num
+ from ex_paper_student a
+ inner join ex_exam_paper b on b.id=a.paper_id
+ where a.state=0 limit #{startIndex},#{pageSize}
</select>
</mapper>
--
Gitblit v1.9.2