572 lines
21 KiB
XML
572 lines
21 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="ExamAnswer">
|
||
|
|
|
||
|
|
<insert id="insertExamAnswer" parameterType="ExamAnswer">
|
||
|
|
INSERT INTO ExamAnswer ( examAnswerId, userId, examId, examType, examPaperId,
|
||
|
|
part1OrigiScore, part1Score, part1TrueScore, accuracy, fluent, integrity, part1Content,
|
||
|
|
part2OrigiScore, part2Score, part2TrueScore, part2Content, origiScore, score,
|
||
|
|
trueScore, created , areaid ,
|
||
|
|
machineScore , humanScore , paperFile , md5Code , content ) Values (
|
||
|
|
#{examAnswerId}, #{userId}, #{examId}, #{examType}, #{examPaperId},
|
||
|
|
#{part1OrigiScore}, #{part1Score}, #{part1TrueScore}, #{accuracy}, #{fluent}, #{integrity}, #{part1Content},
|
||
|
|
#{part2OrigiScore}, #{part2Score}, #{part2TrueScore}, #{part2Content}, #{origiScore}, #{score},
|
||
|
|
#{trueScore},current_timestamp , #{areaid} ,
|
||
|
|
#{machineScore} , #{humanScore} , #{paperFile} , #{md5Code} , #{content} )
|
||
|
|
|
||
|
|
</insert>
|
||
|
|
|
||
|
|
<update id="updateExamAnswer" parameterType="ExamAnswer">
|
||
|
|
|
||
|
|
UPDATE ExamAnswer
|
||
|
|
SET examAnswerId = #{examAnswerId}, userId = #{userId}, examId = #{examId}, examType = #{examType},
|
||
|
|
examPaperId = #{examPaperId}, part1OrigiScore = #{part1OrigiScore}, part1Score = #{part1Score},
|
||
|
|
part1TrueScore = #{part1TrueScore}, accuracy = #{accuracy}, fluent = #{fluent},
|
||
|
|
integrity = #{integrity}, part1Content = #{part1Content},
|
||
|
|
part2OrigiScore = #{part2OrigiScore}, part2Score = #{part2Score}, part2TrueScore = #{part2TrueScore},
|
||
|
|
part2Content = #{part2Content}, origiScore = #{origiScore}, score = #{score}, trueScore = #{trueScore},
|
||
|
|
created = #{created} , areaid = #{areaid} ,
|
||
|
|
machineScore = #{machineScore} , humanScore = #{humanScore} ,
|
||
|
|
paperFile = #{paperFile} , md5Code = #{md5Code} , content = #{content}
|
||
|
|
where examAnswerId=#{examAnswerId}
|
||
|
|
|
||
|
|
</update>
|
||
|
|
|
||
|
|
<select id="getExamAnswerByKey" parameterType="java.lang.Long" resultType="ExamAnswer">
|
||
|
|
|
||
|
|
SELECT examAnswerId , userId , examId , examType , examPaperId ,
|
||
|
|
part1OrigiScore , part1Score , part1TrueScore , accuracy , fluent , integrity , part1Content ,
|
||
|
|
part2OrigiScore , part2Score , part2TrueScore , part2Content , origiScore , score ,
|
||
|
|
trueScore , created , areaid ,
|
||
|
|
machineScore , humanScore , paperFile , md5Code , content
|
||
|
|
FROM ExamAnswer
|
||
|
|
WHERE examAnswerId=#{examAnswerId}
|
||
|
|
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="getSeqExamAnswer" resultType="Long" useCache="false" flushCache="true">
|
||
|
|
|
||
|
|
SELECT nextval('seq_examAnswerId') ;
|
||
|
|
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="getExamAnswersCountByUserId" parameterType="java.util.Map" resultType="Integer">
|
||
|
|
|
||
|
|
SELECT count(*) as howmuch from ExamAnswer
|
||
|
|
WHERE userId=#{userId} and areaid = #{areaid}
|
||
|
|
AND created > #{startTime} and created <= #{endTime}
|
||
|
|
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="getExamAnswersByUserId" parameterType="java.util.Map" resultType="ExamAnswer">
|
||
|
|
|
||
|
|
SELECT examAnswerId , userId , examId , examType , examPaperId ,
|
||
|
|
part1OrigiScore , part1Score , part1TrueScore , accuracy , fluent , integrity , part1Content ,
|
||
|
|
part2OrigiScore , part2Score , part2TrueScore , part2Content ,
|
||
|
|
origiScore , score , trueScore , created , areaid ,
|
||
|
|
machineScore , humanScore , paperFile , md5Code , content
|
||
|
|
FROM ExamAnswer
|
||
|
|
WHERE userId=#{userId} and areaid = #{areaid}
|
||
|
|
AND created > #{startTime} and created <= #{endTime}
|
||
|
|
ORDER BY examAnswerId desc
|
||
|
|
LIMIT #{pageSize} OFFSET #{offset}
|
||
|
|
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="getMaxExamAnswersCountByClassesId" parameterType="java.util.Map" resultType="Integer">
|
||
|
|
|
||
|
|
<!-- SELECT count(*)
|
||
|
|
FROM StudentOwnClass
|
||
|
|
|
||
|
|
where classesId = #{classesId} and status=1 -->
|
||
|
|
select count(soc.studentId ) from studentownclass soc inner join ExamAnswer as ea on ea.userId = soc.studentId
|
||
|
|
inner join exam as e on e.examid = ea.examId inner join student s on soc.studentid=s.studentid and s.status=1
|
||
|
|
where soc.classesId=#{classesId} and s.areaid=#{areaid} and soc.areaid=#{areaid} and soc.status=1
|
||
|
|
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="getMaxExamAnswersByClassesId" parameterType="java.util.Map" resultType="ExamAchive">
|
||
|
|
|
||
|
|
with stu as(select soc.studentId userId from studentownclass soc
|
||
|
|
inner join student s on soc.studentid=s.studentid and s.status=1
|
||
|
|
where soc.classesId=#{classesId} and s.areaid=#{areaid} and soc.areaid=#{areaid} and soc.status=1 )
|
||
|
|
SELECT stu.userId , b.examAnswerId , b.examId , b.examType ,
|
||
|
|
b.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 , b.machineScore , b.humanScore,
|
||
|
|
b.origiScore
|
||
|
|
FROM ( SELECT n.userId , examId ,
|
||
|
|
last_value( examAnswerId ) OVER (PARTITION BY n.userId order by score desc , created asc ) as tempId ,
|
||
|
|
row_number() OVER (PARTITION BY n.userId order by score desc , created asc ) as rn
|
||
|
|
FROM stu m
|
||
|
|
INNER JOIN EXAMANSWER n
|
||
|
|
on m.userId = n.userId AND examId = #{examId} and n.areaId=#{areaid}
|
||
|
|
<if test="examPaperId!=null">
|
||
|
|
and n.examPaperId = #{examPaperId}
|
||
|
|
</if>
|
||
|
|
) a
|
||
|
|
INNER JOIN ExamAnswer b
|
||
|
|
ON a.tempId = b.examAnswerId and a.rn = 1 and b.areaid = #{areaid}
|
||
|
|
inner join Exam e on e.examId = b.examId
|
||
|
|
right join stu on stu.userId = b.userId
|
||
|
|
ORDER BY b.score desc nulls last, b.created asc nulls last,stu.userId
|
||
|
|
<if test="pageSize!=null">
|
||
|
|
limit #{pageSize}
|
||
|
|
</if>
|
||
|
|
|
||
|
|
<if test="offset!=null">
|
||
|
|
|
||
|
|
offset #{offset}
|
||
|
|
|
||
|
|
</if>
|
||
|
|
|
||
|
|
</select>
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
<select id="getMaxExamAnswersCountByClassesIdFilter" parameterType="java.util.Map" resultType="Integer">
|
||
|
|
with temp as(SELECT userId , score,
|
||
|
|
row_number() OVER (PARTITION BY userId order by score desc , created asc ) as rn
|
||
|
|
FROM StudentOwnClass m
|
||
|
|
INNER JOIN EXAMANSWER n
|
||
|
|
ON m.classesId = #{classesId}
|
||
|
|
AND m.studentId = n.userId AND n.examId = #{examId}
|
||
|
|
and m.areaId=#{areaid} and n.areaId=#{areaid}
|
||
|
|
|
||
|
|
)
|
||
|
|
|
||
|
|
select count(userId) from temp where rn=1
|
||
|
|
<if test="upperScore!=null">
|
||
|
|
and score<#{upperScore}
|
||
|
|
</if>
|
||
|
|
<if test="lowerScore!=null">
|
||
|
|
and score>#{lowerScore}
|
||
|
|
</if>
|
||
|
|
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="getMaxExamAnswersByClassesIdFilter" parameterType="java.util.Map" resultType="ExamAchive">
|
||
|
|
|
||
|
|
with stu as(select soc.studentId userId from studentownclass soc
|
||
|
|
inner join student s on soc.studentid=s.studentid and s.status=1
|
||
|
|
where soc.classesId=#{classesId} and s.areaid=#{areaid} and soc.areaid=#{areaid} and soc.status=1 ) ,
|
||
|
|
SELECT stu.userId , b.examAnswerId , b.examId , b.examType ,
|
||
|
|
b.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 , b.machineScore , b.humanScore,
|
||
|
|
b.origiScore
|
||
|
|
FROM ( SELECT userId , examId ,
|
||
|
|
examAnswerId as tempId ,
|
||
|
|
row_number() OVER (PARTITION BY userId order by score desc , created asc ) as rn
|
||
|
|
FROM StudentOwnClass m
|
||
|
|
INNER JOIN EXAMANSWER n
|
||
|
|
ON m.classesId = #{classesId} AND m.studentId = n.userId AND examId = #{examId} and m.areaId=#{areaid} and n.areaId=#{areaid}
|
||
|
|
) a
|
||
|
|
INNER JOIN ExamAnswer b
|
||
|
|
ON a.tempId = b.examAnswerId and a.rn = 1 and b.areaid = #{areaid}
|
||
|
|
<if test="upperScore!=null">
|
||
|
|
and b.score<#{upperScore}
|
||
|
|
</if>
|
||
|
|
<if test="lowerScore!=null">
|
||
|
|
and b.score>#{lowerScore}
|
||
|
|
</if>
|
||
|
|
inner join stu on stu.userId = b.userId
|
||
|
|
ORDER BY b.score desc nulls last, b.created asc nulls last,stu.userId
|
||
|
|
<if test="pageSize!=null">
|
||
|
|
limit #{pageSize}
|
||
|
|
</if>
|
||
|
|
<if test="offset!=null">
|
||
|
|
offset #{offset}
|
||
|
|
</if>
|
||
|
|
|
||
|
|
</select>
|
||
|
|
<select id="getExamAnswersCountByClassesId" parameterType="java.util.Map" resultType="Integer">
|
||
|
|
|
||
|
|
SELECT count(*)
|
||
|
|
FROM StudentOwnClass a
|
||
|
|
|
||
|
|
INNER JOIN EXAMANSWER b
|
||
|
|
ON a.classesId = #{classesId} AND a.studentId = b.userId AND b.examId = #{examId} and b.areaid = #{areaid}
|
||
|
|
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="getExamAnswersByClassesId" parameterType="java.util.Map" resultType="ExamAchive">
|
||
|
|
|
||
|
|
SELECT b.userId , b.examAnswerId , b.examId , b.examType ,
|
||
|
|
b.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 , b.machineScore , b.humanScore
|
||
|
|
FROM StudentOwnClass a
|
||
|
|
INNER JOIN EXAMANSWER b
|
||
|
|
ON a.classesId = #{classesId} AND a.studentId = b.userId AND b.examId = #{examId} and b.areaId=#{areaid}
|
||
|
|
inner join Exam 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="getMaxExamAchivesCountByUserId" parameterType="java.util.Map" resultType="Integer">
|
||
|
|
SELECT count( distinct e.examid )
|
||
|
|
FROM ExamAnswer e inner join exam em on e.examId=em.examId and em.isOral=#{isOral}
|
||
|
|
<if test="type == 1">
|
||
|
|
and (em.type = 1 or em.type = 2)
|
||
|
|
</if>
|
||
|
|
<if test="type != 1">
|
||
|
|
and em.type = #{type}
|
||
|
|
</if>
|
||
|
|
WHERE e.userId = #{userId}
|
||
|
|
|
||
|
|
AND e.created > #{startTime} and e.created <= #{endTime}
|
||
|
|
and e.areaid=#{areaid}
|
||
|
|
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="getMaxExamAchivesByUserId" parameterType="java.util.Map" resultType="ExamAchive">
|
||
|
|
SELECT b.userId , b.examAnswerId , b.examId , b.examType ,
|
||
|
|
b.examPaperId , b.score , b.created ,e.type,
|
||
|
|
|
||
|
|
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 , b.machineScore , b.humanScore
|
||
|
|
FROM ( SELECT userId , examAnswerId , examId , examType ,
|
||
|
|
examPaperId , score , created ,
|
||
|
|
rank() over (partition by examId order by score desc , created desc ) as mm ,
|
||
|
|
trueScore , machineScore , humanScore
|
||
|
|
FROM EXAMANSWER
|
||
|
|
WHERE userId = #{userId}
|
||
|
|
and areaid=#{areaid}
|
||
|
|
AND created > #{startTime} and created <= #{endTime}
|
||
|
|
|
||
|
|
) b
|
||
|
|
INNER JOIN Exam e
|
||
|
|
on b.examId = e.examId and e.isOral=#{isOral}
|
||
|
|
<if test="type == 1">
|
||
|
|
and (e.type = 1 or e.type = 2)
|
||
|
|
</if>
|
||
|
|
<if test="type != 1">
|
||
|
|
and e.type = #{type}
|
||
|
|
</if>
|
||
|
|
|
||
|
|
WHERE b.mm = 1
|
||
|
|
ORDER BY b.created desc
|
||
|
|
<if test="pageSize!=null">
|
||
|
|
limit #{pageSize}
|
||
|
|
</if>
|
||
|
|
|
||
|
|
<if test="offset!=null">
|
||
|
|
|
||
|
|
offset #{offset}
|
||
|
|
|
||
|
|
</if>
|
||
|
|
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="getExamAchivesCountByUserId" parameterType="java.util.Map" resultType="Integer">
|
||
|
|
|
||
|
|
SELECT count(*)
|
||
|
|
FROM ExamAnswer b inner join exam e on b.examId = e.examid and e.isOral=#{isOral}
|
||
|
|
<if test="type == 1">
|
||
|
|
and (e.type = 1 or e.type = 2)
|
||
|
|
</if>
|
||
|
|
<if test="type != 1">
|
||
|
|
and e.type = #{type}
|
||
|
|
</if>
|
||
|
|
WHERE b.userId = #{userId} and b.areaid = #{areaid}
|
||
|
|
AND b.created > #{startTime} and b.created <= #{endTime}
|
||
|
|
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="getExamAchivesByUserId" parameterType="java.util.Map" resultType="ExamAchive">
|
||
|
|
|
||
|
|
SELECT b.userId , b.examAnswerId , b.examId , b.examType ,
|
||
|
|
b.examPaperId , b.score , b.created ,e.type,
|
||
|
|
|
||
|
|
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 , b.machineScore , b.humanScore
|
||
|
|
FROM ExamAnswer b inner join Exam e on e.examId = b.examId and e.isOral=#{isOral}
|
||
|
|
|
||
|
|
<if test="type == 1">
|
||
|
|
and (e.type = 1 or e.type = 2)
|
||
|
|
</if>
|
||
|
|
<if test="type != 1">
|
||
|
|
and e.type = #{type}
|
||
|
|
</if>
|
||
|
|
|
||
|
|
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="getExamCountByExamIdByUserId" parameterType="java.util.Map" resultType="Integer">
|
||
|
|
select count(*)
|
||
|
|
from examanswer
|
||
|
|
where examid = #{examId} and userid = #{userId} and areaid=#{areaId}
|
||
|
|
|
||
|
|
</select>
|
||
|
|
|
||
|
|
|
||
|
|
<select id="getNewMaxHearAchivesCountByUserId" parameterType="java.util.Map" resultType="Integer">
|
||
|
|
|
||
|
|
with
|
||
|
|
temp as( SELECT count( distinct examid ) howmuch
|
||
|
|
FROM hearAnswer
|
||
|
|
WHERE userId = #{userId}
|
||
|
|
AND created > #{startTime} and created <= #{endTime}
|
||
|
|
and areaId=#{areaid}
|
||
|
|
) ,
|
||
|
|
temp1 as (
|
||
|
|
SELECT count( distinct e.examid ) howmuch
|
||
|
|
FROM ExamAnswer e inner join exam em on e.examId=em.examId and em.isOral=2
|
||
|
|
|
||
|
|
<if test="type == 1">
|
||
|
|
and (em.type = 1 or em.type = 2)
|
||
|
|
</if>
|
||
|
|
<if test="type != 1">
|
||
|
|
and em.type = #{type}
|
||
|
|
</if>
|
||
|
|
|
||
|
|
|
||
|
|
WHERE e.userId = #{userId}
|
||
|
|
AND e.created > #{startTime} and e.created <= #{endTime}
|
||
|
|
and e.areaId=#{areaid}
|
||
|
|
)
|
||
|
|
select t.howmuch+t1.howmuch from temp t,temp1 t1
|
||
|
|
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="getNewMaxHearAchivesByUserId" parameterType="java.util.Map" resultType="ExamAchive">
|
||
|
|
|
||
|
|
SELECT b.userId , b.examAnswerId , b.examId , b.examType ,
|
||
|
|
b.hearPaperId as examPaperId , b.score , b.created ,0 as type,
|
||
|
|
|
||
|
|
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
|
||
|
|
FROM ( SELECT userId , examAnswerId , examId , examType ,
|
||
|
|
hearPaperId , score , created ,
|
||
|
|
rank() over (partition by examId order by score desc , created desc ) as mm
|
||
|
|
FROM hearANSWER
|
||
|
|
WHERE userId = #{userId} and areaid=#{areaid}
|
||
|
|
|
||
|
|
AND created > #{startTime} and created <= #{endTime}
|
||
|
|
|
||
|
|
) b
|
||
|
|
INNER JOIN HearExam e
|
||
|
|
on b.examId = e.examId
|
||
|
|
WHERE b.mm = 1
|
||
|
|
|
||
|
|
union
|
||
|
|
|
||
|
|
SELECT b.userId , b.examAnswerId , b.examId , b.examType ,
|
||
|
|
b.examPaperId , b.score , b.created ,e.type,
|
||
|
|
|
||
|
|
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
|
||
|
|
FROM ( SELECT userId , examAnswerId , examId , examType ,
|
||
|
|
examPaperId , score , created ,
|
||
|
|
rank() over (partition by examId order by score desc , created desc ) as mm ,
|
||
|
|
trueScore , machineScore , humanScore
|
||
|
|
FROM EXAMANSWER
|
||
|
|
WHERE userId = #{userId} and areaid=#{areaid}
|
||
|
|
|
||
|
|
AND created > #{startTime} and created <= #{endTime}
|
||
|
|
|
||
|
|
) b
|
||
|
|
INNER JOIN Exam e
|
||
|
|
on b.examId = e.examId and e.isOral=2
|
||
|
|
<if test="type == 1">
|
||
|
|
and (e.type = 1 or e.type = 2)
|
||
|
|
</if>
|
||
|
|
<if test="type != 1">
|
||
|
|
and e.type = #{type}
|
||
|
|
</if>
|
||
|
|
|
||
|
|
WHERE b.mm = 1
|
||
|
|
|
||
|
|
ORDER BY created desc
|
||
|
|
<if test="pageSize!=null">
|
||
|
|
limit #{pageSize}
|
||
|
|
</if>
|
||
|
|
|
||
|
|
<if test="offset!=null">
|
||
|
|
offset #{offset}
|
||
|
|
</if>
|
||
|
|
|
||
|
|
</select>
|
||
|
|
|
||
|
|
|
||
|
|
<select id="getNewHearAchivesCountByUserId" parameterType="java.util.Map" resultType="Integer">
|
||
|
|
|
||
|
|
with temp as (
|
||
|
|
SELECT count(*) howmuch FROM hearAnswer b
|
||
|
|
WHERE b.userId = #{userId} and b.areaid = #{areaid}
|
||
|
|
AND b.created > #{startTime} and b.created <= #{endTime}
|
||
|
|
),
|
||
|
|
temp1 as(
|
||
|
|
SELECT count(*) howmuch
|
||
|
|
FROM ExamAnswer b inner join exam e on b.examId = e.examid and e.isOral=2
|
||
|
|
<if test="type == 1">
|
||
|
|
and (e.type = 1 or e.type = 2)
|
||
|
|
</if>
|
||
|
|
<if test="type != 1">
|
||
|
|
and e.type = #{type}
|
||
|
|
</if>
|
||
|
|
|
||
|
|
WHERE b.userId = #{userId} and b.areaid = #{areaid}
|
||
|
|
AND b.created > #{startTime} and b.created <= #{endTime})
|
||
|
|
select t.howmuch+t1.howmuch from temp t,temp1 t1
|
||
|
|
</select>
|
||
|
|
|
||
|
|
|
||
|
|
<select id="getNewHearAchivesByUserId" parameterType="java.util.Map" resultType="ExamAchive">
|
||
|
|
|
||
|
|
SELECT b.userId , b.examAnswerId , b.examId , b.examType ,
|
||
|
|
b.hearPaperId as examPaperId , b.score , b.created ,0 as type ,
|
||
|
|
|
||
|
|
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
|
||
|
|
FROM hearAnswer b inner join hearExam e on e.examId = b.examId
|
||
|
|
WHERE b.userId = #{userId} and b.areaid = #{areaid}
|
||
|
|
|
||
|
|
AND b.created > #{startTime} and b.created <= #{endTime}
|
||
|
|
union
|
||
|
|
|
||
|
|
SELECT b.userId , b.examAnswerId , b.examId , b.examType ,
|
||
|
|
b.examPaperId , b.score , b.created ,e.type,
|
||
|
|
|
||
|
|
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
|
||
|
|
FROM ExamAnswer b inner join Exam e on e.examId = b.examId and e.isOral=2
|
||
|
|
<if test="type == 1">
|
||
|
|
and (e.type = 1 or e.type = 2)
|
||
|
|
</if>
|
||
|
|
<if test="type != 1">
|
||
|
|
and e.type = #{type}
|
||
|
|
</if>
|
||
|
|
|
||
|
|
|
||
|
|
WHERE b.userId = #{userId} and b.areaid = #{areaid}
|
||
|
|
|
||
|
|
AND b.created > #{startTime} and b.created <= #{endTime}
|
||
|
|
ORDER BY created desc
|
||
|
|
<if test="pageSize!=null">
|
||
|
|
limit #{pageSize}
|
||
|
|
</if>
|
||
|
|
|
||
|
|
<if test="offset!=null">
|
||
|
|
offset #{offset}
|
||
|
|
</if>
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="getExamAnswerStatisticsByClassesId" parameterType="java.util.Map" resultType="java.util.Map">
|
||
|
|
|
||
|
|
with stu as(select soc.studentId userId from studentownclass soc
|
||
|
|
inner join student s on soc.studentid=s.studentid and s.status=1
|
||
|
|
where soc.classesId=#{classesId} and s.areaid=#{areaid} and soc.areaid=#{areaid} and soc.status=1 )
|
||
|
|
SELECT count(case when a.score >= 85 then 1 else null end) "A",
|
||
|
|
count(case when a.score >= 75 and a.score<85 then 1 else null end) "B",
|
||
|
|
count(case when a.score >= 65 and a.score<75 then 1 else null end) "C",
|
||
|
|
count(case when a.score >= 55 and a.score<65 then 1 else null end) "D",
|
||
|
|
count(case when a.score >= 0 and a.score<55 then 1 else null end) "E",
|
||
|
|
count(case when a.score is null then 1 else null end) "N"
|
||
|
|
|
||
|
|
|
||
|
|
FROM ( SELECT userId , examId ,
|
||
|
|
score,
|
||
|
|
row_number() OVER (PARTITION BY userId order by score desc , created asc ) as rn
|
||
|
|
FROM StudentOwnClass m
|
||
|
|
INNER JOIN EXAMANSWER n
|
||
|
|
ON m.classesId = #{classesId} AND m.studentId = n.userId AND examId = #{examId} and m.areaId=#{areaid} and n.areaId=#{areaid}
|
||
|
|
) a
|
||
|
|
|
||
|
|
right join stu on stu.userId = a.userId and rn=1
|
||
|
|
|
||
|
|
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="getHearAnswerStatisticsByClassesId" parameterType="java.util.Map" resultType="java.util.Map">
|
||
|
|
|
||
|
|
with stu as(select soc.studentId userId from studentownclass soc
|
||
|
|
inner join student s on soc.studentid=s.studentid and s.status=1
|
||
|
|
where soc.classesId=#{classesId} and s.areaid=#{areaid} and soc.areaid=#{areaid} and soc.status=1 )
|
||
|
|
SELECT count(case when a.score >= 85 then 1 else null end) "A",
|
||
|
|
count(case when a.score >= 75 and a.score<85 then 1 else null end) "B",
|
||
|
|
count(case when a.score >= 65 and a.score<75 then 1 else null end) "C",
|
||
|
|
count(case when a.score >= 55 and a.score<65 then 1 else null end) "D",
|
||
|
|
count(case when a.score >= 0 and a.score<55 then 1 else null end) "E",
|
||
|
|
count(case when a.score is null then 1 else null end) "N"
|
||
|
|
|
||
|
|
|
||
|
|
FROM ( SELECT userId , examId ,
|
||
|
|
score,
|
||
|
|
row_number() OVER (PARTITION BY userId order by score desc , created asc ) as rn
|
||
|
|
FROM StudentOwnClass m
|
||
|
|
INNER JOIN hearanswer n
|
||
|
|
ON m.classesId = #{classesId} AND m.studentId = n.userId AND examId = #{examId} and m.areaId=#{areaid} and n.areaId=#{areaid}
|
||
|
|
) a
|
||
|
|
|
||
|
|
right join stu on stu.userId = a.userId and rn=1
|
||
|
|
|
||
|
|
|
||
|
|
</select>
|
||
|
|
</mapper>
|