<?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.gkhy.exam.system.mapper.ExQuestionMapper">
|
<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" />
|
<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="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>
|
|
<resultMap id="ExerciseAnswerResult" type="com.gkhy.exam.system.domain.ExExerciseAnswer">
|
<id property="id" column="exercise_answer_id" />
|
<result property="bankId" column="bank_id" />
|
<result property="studentId" column="student_id" />
|
<result property="questionId" column="question_id" />
|
<result property="answer" column="exercise_answer" />
|
<result property="passed" column="exercise_passed" />
|
</resultMap>
|
|
<resultMap id="StudentAnswerResult" type="com.gkhy.exam.system.domain.ExStudentAnswer">
|
<id property="id" column="student_answer_id" />
|
<result property="paperId" column="paper_id" />
|
<result property="studentId" column="student_id" />
|
<result property="questionId" column="question_id" />
|
<result property="answer" column="student_answer" />
|
<result property="passed" column="student_passed" />
|
</resultMap>
|
|
<sql id="selectQuestionVo">
|
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>
|
|
|
<select id="selectCountByBankId" resultType="integer">
|
select count(1) from ex_question where bank_id=#{bankId} and question_type=#{questionType} and (company_id=#{companyId} or privatize=1)
|
</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>
|
|
<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}
|
</select>
|
|
<select id="selectQuestionList" resultType="com.gkhy.exam.system.domain.ExQuestion">
|
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!=''">
|
and a.title like concat(#{title},"%")
|
</if>
|
<if test="bankId!=null">
|
and a.bank_id=#{bankId}
|
</if>
|
<if test="companyId!=null">
|
and (a.company_id=#{companyId} or a.privatize=1)
|
</if>
|
<if test="questionType!=null">
|
and a.question_type=#{questionType}
|
</if>
|
<!-- <if test="privatize!=null">-->
|
<!-- and privatize=#{privatize}-->
|
<!-- </if>-->
|
</where>
|
order by id desc
|
</select>
|
|
<select id="getExerciseQuestionList" resultType="java.util.Map">
|
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}
|
order by a.question_type asc,a.id asc
|
</select>
|
|
<select id="getExeriseQuestionById" resultMap="ExQuestionResult">
|
select a.*,b.id as exercise_id, b.answer as exercise_answer,b.question_id,b.student_id,b.passed as exercise_passed from ex_question a
|
left join ex_exercise_answer b on b.question_id=a.id and b.student_id=#{studentId}
|
where a.id=#{questionId}
|
</select>
|
|
<select id="getExeriseQuestionByIds" resultMap="ExQuestionResult">
|
select a.*,b.id as exercise_answer_id, b.answer as exercise_answer,b.question_id,b.student_id,b.passed as exercise_passed from ex_question a
|
left join ex_exercise_answer b on b.question_id=a.id and b.student_id=#{studentId}
|
where a.id in
|
<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="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
|
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}
|
order by a.question_type asc,a.id asc
|
</select>
|
|
<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="state!=0">
|
,a.answer,b.passed as student_passed
|
</if>
|
from ex_question a
|
left join ex_student_answer b on b.question_id=a.id and b.student_id=#{studentId} and b.paper_id=#{paperId}
|
where a.id=#{questionId}
|
</select>
|
|
<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="state!=0">
|
,a.answer,b.passed as student_passed
|
</if>
|
from ex_question a
|
left join ex_student_answer b on b.question_id=a.id and b.student_id=#{studentId} and b.paper_id=#{paperId}
|
where a.id in
|
<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} 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>
|