235 lines
8.3 KiB
XML
235 lines
8.3 KiB
XML
|
|
<?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="UnivHearAnswer">
|
||
|
|
|
||
|
|
|
||
|
|
<insert id="insertUnivHearAnswer" parameterType="UnivHearAnswer">
|
||
|
|
INSERT INTO UnivHearAnswer ( examAnswerId, userId, examId, examType,
|
||
|
|
hearPaperId, score, answerDetail, created, areaId , origiScore ,trueScore)
|
||
|
|
Values ( #{examAnswerId}, #{userId}, #{examId}, #{examType}, #{hearPaperId},
|
||
|
|
#{score}, #{answerDetail},current_timestamp, #{areaId} , #{origiScore} ,#{trueScore})
|
||
|
|
</insert>
|
||
|
|
|
||
|
|
<update id="updateUnivHearAnswer" parameterType="UnivHearAnswer">
|
||
|
|
UPDATE UnivHearAnswer
|
||
|
|
SET examAnswerId = #{examAnswerId}, userId = #{userId}, examId = #{examId},
|
||
|
|
examType = #{examType}, hearPaperId = #{hearPaperId}, score = #{score},
|
||
|
|
answerDetail = #{answerDetail}, created = #{created},
|
||
|
|
areaId = #{areaId} , origiScore = #{origiScore}
|
||
|
|
WHERE examAnswerId=#{examAnswerId}
|
||
|
|
</update>
|
||
|
|
|
||
|
|
<select id="getUnivHearAnswerByKey" parameterType="java.lang.Integer" resultType="UnivHearAnswer">
|
||
|
|
SELECT examAnswerId , userId , examId , examType , hearPaperId , score ,
|
||
|
|
answerDetail , created , areaId , origiScore
|
||
|
|
FROM UnivHearAnswer
|
||
|
|
WHERE examAnswerId=#{examAnswerId}
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="getSeqUnivHearAnswer" resultType="Integer" useCache="false" flushCache="true">
|
||
|
|
SELECT nextval('seq_UnivhearAnswerId')
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="getUnivHearAnswersCountByUserId" parameterType="java.lang.Long" resultType="Integer">
|
||
|
|
SELECT count(*) as howmuch
|
||
|
|
FROM UnivHearAnswer
|
||
|
|
WHERE userId=#{userId}
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="getUnivHearAnswersByUserId" parameterType="java.util.Map" resultType="UnivHearAnswer">
|
||
|
|
|
||
|
|
SELECT examAnswerId , userId , examId , examType , hearPaperId ,
|
||
|
|
score , answerDetail , created , areaId , origiScore ,trueScore
|
||
|
|
FROM UnivHearAnswer
|
||
|
|
WHERE userId=#{userId}
|
||
|
|
AND created > #{startTime} and created <= #{endTime}
|
||
|
|
ORDER BY examAnswerId desc
|
||
|
|
<if test="pageSize!=null">
|
||
|
|
LIMIT #{pageSize}
|
||
|
|
</if>
|
||
|
|
|
||
|
|
<if test="offset!=null">
|
||
|
|
OFFSET #{offset}
|
||
|
|
</if>
|
||
|
|
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="getMaxUnivHearAnswersCountByClassesId" parameterType="java.util.Map" resultType="Integer">
|
||
|
|
SELECT count(*)
|
||
|
|
FROM ( SELECT userId , max( score ) as maxScore
|
||
|
|
FROM UnivStudentOwnClass m
|
||
|
|
INNER JOIN UnivhearAnswer n
|
||
|
|
ON m.classesId = #{classesId} AND m.studentId = n.userId
|
||
|
|
AND examId = #{examId}
|
||
|
|
GROUP BY userId ) as a
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="getMaxUnivHearAnswersByClassesId" parameterType="java.util.Map" resultType="ExamAchive">
|
||
|
|
|
||
|
|
SELECT b.userId , b.examAnswerId , b.examId , b.examType ,
|
||
|
|
b.hearPaperId as examPaperId , b.score , b.created ,
|
||
|
|
|
||
|
|
case when b.score >= 85 then 'A'
|
||
|
|
when b.score >= 80 then 'B'
|
||
|
|
when b.score >= 70 then 'C'
|
||
|
|
when b.score >= 60 then 'D'
|
||
|
|
else 'E' end as level
|
||
|
|
, e.title ,b.trueScore
|
||
|
|
FROM ( SELECT userId , examId ,
|
||
|
|
last_value( examAnswerId ) OVER (PARTITION BY userId
|
||
|
|
order by score desc ) as tempId ,
|
||
|
|
row_number() OVER (PARTITION BY userId
|
||
|
|
order by score desc ) as rn
|
||
|
|
FROM UnivStudentOwnClass m
|
||
|
|
INNER JOIN UnivHearAnswer n
|
||
|
|
ON m.classesId = #{classesId} AND m.studentId = n.userId
|
||
|
|
AND examId = #{examId}
|
||
|
|
) a
|
||
|
|
INNER JOIN UnivHearAnswer b
|
||
|
|
ON a.tempId = b.examAnswerId and a.rn = 1 and b.areaid = #{areaid}
|
||
|
|
inner join UnivHearExam e on e.examId = b.examId
|
||
|
|
ORDER BY b.score desc
|
||
|
|
<if test="pageSize!=null">
|
||
|
|
LIMIT #{pageSize}
|
||
|
|
</if>
|
||
|
|
|
||
|
|
<if test="offset!=null">
|
||
|
|
OFFSET #{offset}
|
||
|
|
</if>
|
||
|
|
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="getUnivHearAnswersCountByClassesId" parameterType="java.util.Map" resultType="Integer">
|
||
|
|
|
||
|
|
SELECT count(*)
|
||
|
|
FROM UnivStudentOwnClass a
|
||
|
|
INNER JOIN UnivhearAnswer b
|
||
|
|
ON a.classesId = #{classesId} AND a.studentId = b.userId
|
||
|
|
AND b.examId = #{examId} and b.areaid = #{areaid}
|
||
|
|
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="getUnivHearAnswersByClassesId" parameterType="java.util.Map" resultType="ExamAchive">
|
||
|
|
SELECT b.userId , b.examAnswerId , b.examId , b.examType ,
|
||
|
|
b.hearPaperId as examPaperId , b.score , b.created ,
|
||
|
|
|
||
|
|
case when b.score >= 85 then 'A'
|
||
|
|
when b.score >= 80 then 'B'
|
||
|
|
when b.score >= 70 then 'C'
|
||
|
|
when b.score >= 60 then 'D'
|
||
|
|
else 'E' end as level
|
||
|
|
, e.title ,b.trueScore
|
||
|
|
FROM UnivStudentOwnClass a
|
||
|
|
|
||
|
|
INNER JOIN UnivhearAnswer b
|
||
|
|
ON a.classesId = #{classesId} AND a.studentId = b.userId
|
||
|
|
AND b.examId = #{examId}
|
||
|
|
inner join UnivhearExam e on e.examId = b.examId
|
||
|
|
ORDER BY b.examAnswerId desc
|
||
|
|
<if test="pageSize!=null">
|
||
|
|
LIMIT #{pageSize}
|
||
|
|
</if>
|
||
|
|
|
||
|
|
<if test="offset!=null">
|
||
|
|
OFFSET #{offset}
|
||
|
|
</if>
|
||
|
|
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="getMaxUnivHearAchivesCountByUserId" parameterType="java.util.Map" resultType="Integer">
|
||
|
|
|
||
|
|
SELECT count(*)
|
||
|
|
FROM ( SELECT examId , max( score ) as maxScore
|
||
|
|
FROM UnivhearAnswer n
|
||
|
|
WHERE n.userId = #{userId}
|
||
|
|
GROUP BY examId ) a
|
||
|
|
INNER JOIN UnivhearAnswer b
|
||
|
|
ON b.userId = #{userId} and a.examId = b.examId
|
||
|
|
and a.maxScore = b.score and b.areaid = #{areaid}
|
||
|
|
AND b.created > #{startTime} and b.created <= #{endTime}
|
||
|
|
|
||
|
|
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="getMaxUnivHearAchivesByUserId" parameterType="java.util.Map" resultType="ExamAchive">
|
||
|
|
|
||
|
|
SELECT b.userId , b.examAnswerId , b.examId , b.examType ,
|
||
|
|
b.hearPaperId as examPaperId , b.score , b.created ,
|
||
|
|
|
||
|
|
case when b.score >= 85 then 'A'
|
||
|
|
when b.score >= 80 then 'B'
|
||
|
|
when b.score >= 70 then 'C'
|
||
|
|
when b.score >= 60 then 'D'
|
||
|
|
else 'E' end as level
|
||
|
|
, e.title ,b.trueScore
|
||
|
|
FROM ( SELECT examId , max( score ) as maxScore
|
||
|
|
FROM UnivhearAnswer n
|
||
|
|
WHERE n.userId = #{userId}
|
||
|
|
GROUP BY examId ) a
|
||
|
|
INNER JOIN UnivhearAnswer b
|
||
|
|
ON b.userId = #{userId} and a.examId = b.examId
|
||
|
|
and a.maxScore = b.score
|
||
|
|
and b.areaid = #{areaid}
|
||
|
|
inner join UnivHearExam e on e.examId = b.examId
|
||
|
|
|
||
|
|
AND b.created > #{startTime} and b.created <= #{endTime}
|
||
|
|
|
||
|
|
|
||
|
|
ORDER BY a.examId desc
|
||
|
|
<if test="pageSize!=null">
|
||
|
|
LIMIT #{pageSize}
|
||
|
|
</if>
|
||
|
|
|
||
|
|
<if test="offset!=null">
|
||
|
|
OFFSET #{offset}
|
||
|
|
</if>
|
||
|
|
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="getUnivHearAchivesCountByUserId" parameterType="java.util.Map" resultType="Integer">
|
||
|
|
|
||
|
|
SELECT count(*)
|
||
|
|
FROM UnivhearAnswer b
|
||
|
|
WHERE b.userId = #{userId} and b.areaid = #{areaid}
|
||
|
|
AND b.created > #{startTime} and b.created <= #{endTime}
|
||
|
|
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="getUnivHearAchivesByUserId" parameterType="java.util.Map" resultType="ExamAchive">
|
||
|
|
|
||
|
|
SELECT b.userId , b.examAnswerId , b.examId , b.examType ,
|
||
|
|
b.hearPaperId as examPaperId , b.score , b.created ,
|
||
|
|
|
||
|
|
case when b.score >= 85 then 'A'
|
||
|
|
when b.score >= 80 then 'B'
|
||
|
|
when b.score >= 70 then 'C'
|
||
|
|
when b.score >= 60 then 'D'
|
||
|
|
else 'E' end as level
|
||
|
|
, e.title ,b.trueScore
|
||
|
|
FROM UnivhearAnswer b
|
||
|
|
inner join UnivhearExam e on e.examId = b.examId
|
||
|
|
WHERE b.userId = #{userId} and b.areaid = #{areaid}
|
||
|
|
|
||
|
|
AND b.created > #{startTime} and b.created <= #{endTime}
|
||
|
|
|
||
|
|
ORDER BY b.examAnswerId desc
|
||
|
|
<if test="pageSize!=null">
|
||
|
|
LIMIT #{pageSize}
|
||
|
|
</if>
|
||
|
|
|
||
|
|
<if test="offset!=null">
|
||
|
|
OFFSET #{offset}
|
||
|
|
</if>
|
||
|
|
|
||
|
|
</select>
|
||
|
|
|
||
|
|
|
||
|
|
<select id="getUnivHearCountByExamIdByUserId" parameterType="java.util.Map" resultType="Integer">
|
||
|
|
|
||
|
|
select count(*) from Univhearanswer where examid = #{examId}
|
||
|
|
and userid = #{userId}
|
||
|
|
|
||
|
|
</select>
|
||
|
|
|
||
|
|
</mapper>
|