927 lines
41 KiB
XML
927 lines
41 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="com.univ3e.dao.UnivExamDao">
|
|
<select id= "getNextSeq" resultType="int">
|
|
SELECT NEXTVAL('seq_univexamid')
|
|
</select>
|
|
|
|
<!-- 全网非听力考试列表 -->
|
|
<select id="findMockIsNetExam" parameterType="map" resultType="com.univ3e.entity.UnivExam" >
|
|
SELECT examid, examtype, isrecommend, title, description, exampapercount,
|
|
exampapers, created, starttime, endtime, teacherid, isoral
|
|
FROM univexam
|
|
WHERE isNetExam=1 AND examType = #{_3EReqExamInfo.examType} AND isoral = #{_3EReqExamInfo.isoral}
|
|
AND startTime < now() AND endTime > now()
|
|
ORDER BY created DESC,title DESC,examid DESC
|
|
<if test="page != null">
|
|
LIMIT #{page.limit} OFFSET #{page.offset}
|
|
</if>
|
|
</select>
|
|
|
|
<!-- 全网听力考试列表 -->
|
|
<select id="findHearIsNetExam" parameterType="map" resultType="com.univ3e.entity.UnivExam" >
|
|
SELECT examid, examtype, isrecommend, title, description, exampapercount,
|
|
exampapers, created, starttime, endtime, teacherid, isoral
|
|
FROM v_univhearexam
|
|
WHERE isNetExam=1 AND examType = #{_3EReqExamInfo.examType}
|
|
AND startTime < now() AND endTime > now()
|
|
ORDER BY created DESC,title DESC, isoral
|
|
<if test="page != null">
|
|
LIMIT #{page.limit} OFFSET #{page.offset}
|
|
</if>
|
|
</select>
|
|
|
|
<!-- 区域非听力考试列表 -->
|
|
<select id="findMockExam" parameterType="map" resultType="com.univ3e.entity.UnivExam" >
|
|
SELECT e.examid, e.examtype, e.isrecommend, e.title, e.description, e.exampapercount,
|
|
e.exampapers, e.created, e.starttime, e.endtime, e.teacherid, e.isoral
|
|
FROM univExam e
|
|
RIGHT JOIN univClassOwnExam c ON c.examid = e.examid AND e.isoral = #{_3EReqExamInfo.isoral}
|
|
WHERE e.examType = #{_3EReqExamInfo.examType}
|
|
AND e.startTime < now() AND e.endTime > now()
|
|
AND c.areaid = #{areaId} AND objectType = #{_3EReqExamInfo.objType}
|
|
ORDER BY created DESC,title DESC
|
|
<if test="page != null">
|
|
LIMIT #{page.limit} OFFSET #{page.offset}
|
|
</if>
|
|
</select>
|
|
|
|
<!-- 区域听力考试列表 -->
|
|
<select id="findHearExam" parameterType="map" resultType="com.univ3e.entity.UnivExam" >
|
|
SELECT e.examid, e.examtype, e.isrecommend, e.title, e.description, e.exampapercount,
|
|
e.exampapers, e.created, e.starttime, e.endtime, e.teacherid, e.isoral
|
|
FROM v_univhearexam e
|
|
RIGHT JOIN univClassOwnExam c ON c.examid = e.examid AND e.isoral = 2
|
|
WHERE e.examType = #{_3EReqExamInfo.examType}
|
|
AND e.startTime < now() AND e.endTime > now()
|
|
AND c.areaid = #{areaId} AND objectType = #{_3EReqExamInfo.objType}
|
|
|
|
UNION
|
|
|
|
SELECT e.examid, e.examtype, e.isrecommend, e.title, e.description, e.exampapercount,
|
|
e.exampapers, e.created, e.starttime, e.endtime, e.teacherid, e.isoral
|
|
FROM v_univhearexam e
|
|
RIGHT JOIN univClassOwnHear c ON c.examid = e.examid AND e.isoral = -1
|
|
WHERE e.examType = #{_3EReqExamInfo.examType}
|
|
AND e.startTime < now() AND e.endTime > now()
|
|
AND c.areaid = #{areaId} AND objectType = #{_3EReqExamInfo.objType}
|
|
|
|
ORDER BY created DESC,title DESC, isoral
|
|
<if test="page != null">
|
|
LIMIT #{page.limit} OFFSET #{page.offset}
|
|
</if>
|
|
</select>
|
|
|
|
<!-- 校园非听力考试列表 -->
|
|
<select id= "findMockSchoolExam" parameterType="map" resultType="com.univ3e.entity.UnivExam" >
|
|
<bind name="objecteType" value="_3EReqExamInfo.objType" />
|
|
SELECT e.examid, e.examtype, e.isrecommend, e.title, e.description, e.exampapercount,
|
|
e.exampapers, e.created, e.starttime, e.endtime, e.teacherid, e.isoral
|
|
FROM univexam e
|
|
INNER JOIN univClassOwnExam c ON c.examid = e.examid AND c.objecttype = #{objecteType} AND e.isoral = #{_3EReqExamInfo.isoral}
|
|
WHERE e.examType = #{_3EReqExamInfo.examType}
|
|
AND e.startTime < now() AND e.endTime > now()
|
|
AND c.classesid = #{objid}
|
|
ORDER BY created DESC,title DESC
|
|
<if test="page != null">
|
|
LIMIT #{page.limit} OFFSET #{page.offset}
|
|
</if>
|
|
</select>
|
|
|
|
<!-- 校园听力考试列表 -->
|
|
<select id= "findSchoolHearExam" parameterType="map" resultType="com.univ3e.entity.UnivExam" >
|
|
<bind name="objecteType" value="_3EReqExamInfo.objType" />
|
|
SELECT e.examid, e.examtype, e.isrecommend, e.title, e.description, e.exampapercount,
|
|
e.exampapers, e.created, e.starttime, e.endtime, e.teacherid, e.isoral
|
|
FROM v_univhearexam e
|
|
INNER JOIN univClassOwnExam c ON c.examid = e.examid AND c.objecttype = #{objecteType} AND e.isoral = 2
|
|
WHERE e.examType = #{_3EReqExamInfo.examType}
|
|
AND e.startTime < now() AND e.endTime > now()
|
|
AND c.classesid = #{objid}
|
|
UNION
|
|
|
|
SELECT e.examid, e.examtype, e.isrecommend, e.title, e.description, e.exampapercount,
|
|
e.exampapers, e.created, e.starttime, e.endtime, e.teacherid, e.isoral
|
|
FROM v_univhearexam e
|
|
RIGHT JOIN univClassOwnHear c ON c.examid = e.examid AND c.objecttype = #{objecteType} AND e.isoral = -1
|
|
WHERE e.examType = #{_3EReqExamInfo.examType}
|
|
AND e.startTime < now() AND e.endTime > now()
|
|
AND c.classesid = #{objid}
|
|
ORDER BY created DESC,title DESC, isoral
|
|
<if test="page != null">
|
|
LIMIT #{page.limit} OFFSET #{page.offset}
|
|
</if>
|
|
</select>
|
|
|
|
<!-- 班级非听力考试列表 -->
|
|
<select id= "findMockUserExam" parameterType="map" resultType="com.univ3e.entity.UnivExam" >
|
|
<bind name="objecteType" value="_3EReqExamInfo.objType" />
|
|
<bind name="examType" value="_3EReqExamInfo.examType" />
|
|
<bind name="isoral" value="_3EReqExamInfo.isoral" />
|
|
<!-- SELECT examId , examType , isRecommend , title , description ,
|
|
examPaperCount , examPapers , created , startTime , endTime, isoral
|
|
FROM V_UserOwnExam
|
|
WHERE studentId= #{objid} AND isoral = #{isoral}
|
|
AND examType = #{examType} and startTime < now() and endTime > now()
|
|
ORDER BY created DESC,title DESC -->
|
|
|
|
|
|
SELECT e.examId , e.examType , e.isRecommend , e.title , e.description ,
|
|
e.examPaperCount , e.examPapers , e.created , e.startTime , e.endTime ,e.isOral
|
|
FROM UnivExam e
|
|
inner join UnivclassownExam c
|
|
on e.examid = c.examid
|
|
inner join Univstudentownclass s
|
|
on s.classesid = c.classesid and s.status = 1
|
|
WHERE s.studentId=#{objid}
|
|
AND e.examType = #{examType} and e.startTime < now()
|
|
and e.endTime > now() and e.isOral=#{isoral}
|
|
union
|
|
SELECT e.examId , e.examType , e.isRecommend , e.title , e.description ,
|
|
e.examPaperCount , e.examPapers , e.created , e.startTime , e.endTime ,e.isOral
|
|
FROM UnivExam e
|
|
inner join UnivTeacherOwnExam te
|
|
on e.examid = te.examid
|
|
WHERE te.teacherId=#{objid}
|
|
AND e.examType = #{examType} and e.startTime < now()
|
|
and e.endTime > now() and e.isOral=#{isoral}
|
|
ORDER BY created DESC,title DESC
|
|
<if test="page != null">
|
|
LIMIT #{page.limit} OFFSET #{page.offset}
|
|
</if>
|
|
|
|
</select>
|
|
|
|
<!-- 班级听力考试列表 -->
|
|
<select id= "findMockUserHearExam" parameterType="map" resultType="com.univ3e.entity.UnivExam" >
|
|
<bind name="objecteType" value="_3EReqExamInfo.objType" />
|
|
<bind name="examType" value="_3EReqExamInfo.examType" />
|
|
<bind name="isoral" value="_3EReqExamInfo.isoral" />
|
|
SELECT h.examId , h.examType , h.isRecommend , h.title , h.description ,
|
|
h.examPaperCount , h.examPapers , h.created , h.startTime , h.endTime, h.isoral
|
|
FROM v_univhearexam h inner join univclassownhear c on c.examid = h.examid and h.isoral=-1
|
|
inner join univstudentownclass s on s.classesid = c.classesid and s.status = 1
|
|
WHERE s.studentId=#{objid} and c.objectType = #{objecteType}
|
|
AND h.examType = #{examType} and h.startTime < now() and h.endTime > now()
|
|
|
|
union
|
|
|
|
SELECT h.examId , h.examType , h.isRecommend , h.title , h.description ,
|
|
h.examPaperCount , h.examPapers , h.created , h.startTime , h.endTime, h.isoral
|
|
FROM v_univhearexam h
|
|
WHERE h.teacherId=#{objid} and h.examType = #{examType} and
|
|
h.startTime < now() and h.endTime > now()
|
|
|
|
union
|
|
|
|
select h.examId , h.examType , h.isRecommend , h.title , h.description ,
|
|
h.examPaperCount , h.examPapers , h.created , h.startTime , h.endTime, h.isoral
|
|
FROM v_univhearexam h inner join univclassownexam c on c.examid = h.examid and isoral=2
|
|
inner join univstudentownclass s on s.classesid = c.classesid and s.status = 1
|
|
WHERE s.studentId=#{objid} and c.objectType = #{objecteType}
|
|
and h.examType = #{examType} and h.startTime < now() and h.endTime > now()
|
|
|
|
order by created DESC,title DESC ,isoral
|
|
<if test="page != null">
|
|
LIMIT #{page.limit} OFFSET #{page.offset}
|
|
</if>
|
|
</select>
|
|
|
|
<select id= "findExamPaper" parameterType="int" resultType="com.univ3e.entity.UnivExam" >
|
|
SELECT exampaperid, authortype, teacherid, examlevel, title, totalscore, status,
|
|
machinescore, humanscore, paperfile, md5code, content, isoral
|
|
FROM ExamPaper WHERE exampaperid = #{exampaperid}
|
|
</select>
|
|
|
|
<insert id= "doSaveExamAnswer" parameterType="com.univ3e.entity.UnivExamAnswer" >
|
|
INSERT INTO univexamanswer(
|
|
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 (
|
|
<if test="examanswerid == 0">
|
|
(SELECT NEXTVAL('seq_univexamanswerid')),
|
|
</if>
|
|
<if test="examanswerid != 0">
|
|
#{examanswerid},
|
|
</if>
|
|
#{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})
|
|
</insert>
|
|
|
|
<update id= "doUpdateById" parameterType="com.univ3e.entity.UnivExamAnswer">
|
|
UPDATE univexamanswer
|
|
<set>
|
|
<if test="userid != null">userid=#{userid},</if>
|
|
<if test="examid != null"> examid=#{examid},</if>
|
|
<if test="examtype != null"> examtype=#{examtype},</if>
|
|
<if test="exampaperid != null"> exampaperid=#{exampaperid},</if>
|
|
<if test="part1origiscore != null"> part1origiscore=#{part1origiscore},</if>
|
|
<if test="part1score != null"> part1score=#{part1score},</if>
|
|
<if test="part1truescore != null"> part1truescore=#{part1truescore},</if>
|
|
<if test="accuracy != null"> accuracy=#{accuracy},</if>
|
|
<if test="fluent != null"> fluent=#{fluent},</if>
|
|
<if test="integrity != null"> integrity=#{integrity},</if>
|
|
<if test="part1content != null"> part1content=#{part1content},</if>
|
|
<if test="part2origiscore != null"> part2origiscore=#{part2origiscore},</if>
|
|
<if test="part2score != null"> part2score=#{part2score},</if>
|
|
<if test="part2truescore != null"> part2truescore=#{part2truescore},</if>
|
|
<if test="part2content != null"> part2content=#{part2content},</if>
|
|
<if test="origiscore != null"> origiscore=#{origiscore},</if>
|
|
<if test="score != null"> score=#{score},</if>
|
|
<if test="truescore != null"> truescore=#{truescore},</if>
|
|
<if test="created != null"> created=#{created},</if>
|
|
<if test="areaid != null"> areaid=#{areaId},</if>
|
|
<if test="machinescore != null"> machinescore=#{machinescore},</if>
|
|
<if test="humanscore != null"> humanscore=#{humanscore},</if>
|
|
<if test="paperfile != null"> paperfile=#{paperfile},</if>
|
|
<if test="md5code != null"> md5code=#{md5code},</if>
|
|
<if test="content != null"> content=#{content}</if>
|
|
</set>
|
|
WHERE examanswerid = #{examanswerid}
|
|
</update>
|
|
|
|
<select id="findExamAnswerByExaminfo" parameterType="map" resultType="com.univ3e.entity.UnivExamAnswer" >
|
|
SELECT examanswerid FROM UnivexamAnswer WHERE userid = #{uid} AND examtype = #{examType} AND examid = #{examId}
|
|
</select>
|
|
|
|
<select id= "findMyExamAnswerHistor" parameterType="map" resultType="com._3e.http.exam.dto._3EResMyExamHistory" >
|
|
SELECT a.title, a.examtype, e.score, e.created, a.isoral as isoral,
|
|
CASE WHEN a.isoral = 1 THEN 'E'
|
|
WHEN a.isoral = 0 THEN 'R'
|
|
END AS fenlei, a.starttime
|
|
FROM examanswer e
|
|
INNER JOIN exam a ON e.examId = a.examId
|
|
WHERE e.created > '${begintime} 00:00:00' AND e.created < '${endTime} 23:59:59'
|
|
AND e.userid = #{userId}
|
|
UNION
|
|
SELECT a.title, a.examtype, e.score, e.created, 0 as isoral, 'H' AS fenlei,a.starttime
|
|
FROM hearanswer e
|
|
INNER JOIN hearexam a ON e.examId = a.examId
|
|
WHERE e.created > '${begintime} 00:00:00' AND e.created < '${endTime} 23:59:59'
|
|
AND e.userid = #{userId}
|
|
ORDER BY score DESC, created DESC
|
|
<if test="page != null">
|
|
LIMIT #{page.limit} OFFSET #{page.offset}
|
|
</if>
|
|
</select>
|
|
|
|
<select id= "findMyExamAnswerHistorV2" parameterType="map" resultType="com._3e.http.exam.dto._3EResMyExamHistory" >
|
|
SELECT a.title, a.examtype, e.score, e.created, a.isoral, a.starttime
|
|
FROM univexamanswer e
|
|
INNER JOIN univexam a ON e.examId = a.examId
|
|
WHERE e.created > '${begintime} 00:00:00' AND e.created < '${endTime} 23:59:59'
|
|
AND e.userid = #{userId}
|
|
UNION
|
|
SELECT a.title, a.examtype, e.score, e.created, -1 AS isoral,a.starttime
|
|
FROM univhearanswer e
|
|
INNER JOIN univhearexam a ON e.examId = a.examId
|
|
WHERE e.created > '${begintime} 00:00:00' AND e.created < '${endTime} 23:59:59'
|
|
AND e.userid = #{userId}
|
|
ORDER BY score DESC, created DESC
|
|
<if test="page != null">
|
|
LIMIT #{page.limit} OFFSET #{page.offset}
|
|
</if>
|
|
</select>
|
|
|
|
<select id= "findMyMAXExamAnswerHistor" parameterType="map" resultType="com._3e.http.exam.dto._3EResMyExamHistory" >
|
|
SELECT a.title, a.examtype, e.score, e.created, a.isoral as isoral,
|
|
CASE WHEN a.isoral = 1 THEN 'E'
|
|
WHEN a.isoral = 0 THEN 'R'
|
|
END AS fenlei, a.starttime
|
|
FROM (
|
|
SELECT examId,score , created , rank() over (partition by examId order by score desc , created desc ) as mm
|
|
FROM examanswer
|
|
WHERE created > '${begintime} 00:00:00' AND created < '${endTime} 23:59:59'
|
|
AND userid = #{userId}
|
|
) e
|
|
INNER JOIN exam a ON e.examId = a.examId
|
|
WHERE e.mm = 1
|
|
UNION
|
|
SELECT a.title, a.examtype, e.score, e.created, 0 as isoral, 'H' AS fenlei,a.starttime
|
|
FROM (
|
|
SELECT examId, score , created , rank() over (partition by examId order by score desc , created desc ) as mm
|
|
FROM hearanswer
|
|
WHERE created > '${begintime} 00:00:00' AND created < '${endTime} 23:59:59'
|
|
AND userid = #{userId}
|
|
) e
|
|
INNER JOIN hearexam a ON e.examId = a.examId
|
|
WHERE e.mm = 1
|
|
ORDER BY score DESC, created DESC
|
|
<if test="page != null">
|
|
LIMIT #{page.limit} OFFSET #{page.offset}
|
|
</if>
|
|
</select>
|
|
|
|
<select id= "findMyMAXExamAnswerHistorV2" parameterType="map" resultType="com._3e.http.exam.dto._3EResMyExamHistory" >
|
|
SELECT a.title, a.examtype, e.score, e.created, a.isoral, a.starttime
|
|
FROM (
|
|
SELECT examId,score , created , rank() over (partition by examId order by score desc , created desc ) as mm
|
|
FROM univexamanswer
|
|
WHERE created > '${begintime} 00:00:00' AND created < '${endTime} 23:59:59'
|
|
AND userid = #{userId}
|
|
) e
|
|
INNER JOIN univexam a ON e.examId = a.examId
|
|
WHERE e.mm = 1
|
|
UNION
|
|
SELECT a.title, a.examtype, e.score, e.created, -1 AS isoral,a.starttime
|
|
FROM (
|
|
SELECT examId, score , created , rank() over (partition by examId order by score desc , created desc ) as mm
|
|
FROM univhearanswer
|
|
WHERE created > '${begintime} 00:00:00' AND created < '${endTime} 23:59:59'
|
|
AND userid = #{userId}
|
|
) e
|
|
INNER JOIN univhearexam a ON e.examId = a.examId
|
|
WHERE e.mm = 1
|
|
ORDER BY score DESC, created DESC
|
|
<if test="page != null">
|
|
LIMIT #{page.limit} OFFSET #{page.offset}
|
|
</if>
|
|
</select>
|
|
|
|
<select id= "findExamAnswerHistorClassify" parameterType="map" resultType="com._3e.http.exam.dto._3EResExamHistory" >
|
|
<!-- <bind name="objecteType" value="_3EReqExamInfo.objType" /> -->
|
|
<!-- <bind name="userId" value="_3eReqUserInfo.studentid" /> -->
|
|
<!-- <bind name="schoolId" value="_3eReqUserInfo.schoolid" /> -->
|
|
WITH temp AS (
|
|
<choose>
|
|
<when test="objectType == 0"><!-- 全网 -->
|
|
SELECT examid,title,isOral from exam where isnetexam = 1
|
|
</when>
|
|
<when test="objectType==1 or objectType==2"><!--我的或学校 -->
|
|
SELECT e.examid, e.title, e.isOral
|
|
FROM Exam e
|
|
INNER JOIN ClassOwnExam c ON c.examid = e.examid
|
|
<if test="objectType==2"><!-- 学校 -->
|
|
INNER JOIN Classes s ON s.classesid = c.classesid
|
|
WHERE s.schoolid = #{schoolId}
|
|
AND c.objectType = #{objectType}
|
|
</if>
|
|
<if test="objectType == 1"><!-- 班级或学习小组 -->
|
|
INNER JOIN studentownclass s on s.classesid = c.classesid and s.status = 1
|
|
WHERE s.studentid = #{userId}
|
|
AND c.objectType = #{objectType}
|
|
UNION
|
|
SELECT e.examid, e.title,e.isoral
|
|
FROM Exam e
|
|
RIGHT JOIN ClassOwnExam c ON c.examid = e.examid
|
|
INNER JOIN classes s ON s.classesid = c.classesid AND s.status = 1
|
|
WHERE s.teacherid = #{userId}
|
|
AND c.objectType = #{objectType}
|
|
</if>
|
|
</when>
|
|
<otherwise><!-- 行政级别分类 -->
|
|
SELECT e.examid,e.title, e.isOral
|
|
FROM Exam e
|
|
RIGHT JOIN ClassOwnExam c ON c.examid = e.examid
|
|
WHERE c.areaid = #{areaId}
|
|
AND c.objectType = #{objectType}
|
|
</otherwise>
|
|
</choose>
|
|
),
|
|
<!-- 以下是合并听力用,细节需测试 -->
|
|
temp1 AS (
|
|
<choose>
|
|
<when test="objectType == 0"><!-- 全网 -->
|
|
SELECT examid,title FROM hearexam where isnetexam = 1
|
|
</when>
|
|
<when test="objectType==1 or objectType==2"><!--我的或学校 -->
|
|
SELECT e.examid, e.title
|
|
FROM HearExam e
|
|
RIGHT JOIN ClassOwnHear c ON c.examid = e.examid
|
|
<if test="objectType==2"><!-- 学校 -->
|
|
INNER JOIN Classes s ON s.classesid = c.classesid
|
|
WHERE s.schoolid = #{schoolid}
|
|
AND c.objectType = #{objectType}
|
|
</if>
|
|
<if test="objectType == 1"><!-- 班级或学习小组 -->
|
|
INNER JOIN studentownclass s on s.classesid = c.classesid and s.status = 1
|
|
WHERE s.studentid = #{userId}
|
|
AND c.objectType = #{objectType}
|
|
UNION
|
|
SELECT e.examid, e.title
|
|
FROM HearExam e
|
|
RIGHT JOIN ClassOwnHear c ON c.examid = e.examid
|
|
WHERE e.teacherid = #{userId}
|
|
AND c.objectType = #{objectType}
|
|
</if>
|
|
</when>
|
|
<otherwise><!-- 行政级别分类 -->
|
|
SELECT e.examid,e.title
|
|
FROM HearExam e
|
|
RIGHT JOIN ClassOwnHear c ON c.examid = e.examid
|
|
WHERE c.areaid = #{areaId}
|
|
AND c.objectType = #{objectType}
|
|
</otherwise>
|
|
</choose>
|
|
)
|
|
|
|
SELECT e.examid,e.title,e.isoral,avg(a.score) AS avgScore,max(a.created) AS lastTime,'E' AS fenlei
|
|
FROM temp e
|
|
INNER JOIN examanswer a ON e.examid = a.examid
|
|
WHERE a.userid = #{userId}
|
|
GROUP BY e.examid,e.title,e.isoral
|
|
|
|
UNION
|
|
|
|
SELECT e.examid,e.title,0 AS isoral, avg(a.score) AS avgScore,max(a.created) AS lastTime,'H' AS fenlei
|
|
FROM temp1 e
|
|
INNER JOIN hearanswer a ON e.examid = a.examid
|
|
WHERE a.userid = #{userId}
|
|
GROUP BY e.examid,e.title
|
|
ORDER BY lastTime DESC
|
|
<if test="page != null">
|
|
LIMIT #{page.limit} OFFSET #{page.offset}
|
|
</if>
|
|
</select>
|
|
|
|
<select id= "findExamPersons" parameterType="map" resultType="int" >
|
|
SELECT count(distinct userid)
|
|
<if test="fenlei == 'H'.toString()">
|
|
FROM hearanswer
|
|
</if>
|
|
<if test="fenlei != 'H'.toString()">
|
|
FROM examanswer
|
|
</if>
|
|
WHERE examid = #{examId} AND score != 0
|
|
</select>
|
|
|
|
<select id= "findExamRankList" parameterType="map" resultType="com._3e.http.exam.dto._3EResExamRank" >
|
|
WITH temp AS(
|
|
SELECT examid,score AS maxScore,userid, created,
|
|
ROW_NUMBER() OVER(PARTITION BY userid ORDER BY score DESC,created DESC ) AS rank
|
|
<if test="fenlei == 'H'.toString()">
|
|
FROM hearanswer
|
|
</if>
|
|
<if test="fenlei != 'H'.toString()">
|
|
FROM examanswer
|
|
</if>
|
|
WHERE examid = #{examId} AND score != 0
|
|
),
|
|
temp2 AS (SELECT examid,maxScore,userid, created FROM temp WHERE rank = 1 ),
|
|
temp3 AS (SELECT maxScore, userid, created,RANK() OVER(ORDER BY maxScore DESC,created DESC) AS rn FROM temp2 )
|
|
SELECT maxScore,userid,created,rn,
|
|
COALESCE((SELECT rn FROM temp3 WHERE userid = #{userId} LIMIT 1),0) AS myrn,
|
|
COALESCE((SELECT COALESCE(maxScore,0) FROM temp3 WHERE userid = #{userId} LIMIT 1),0) AS myMaxScore
|
|
FROM temp3
|
|
WHERE rn <= 10
|
|
ORDER BY maxScore DESC,rn ASC
|
|
</select>
|
|
|
|
<select id="findAssignExam" parameterType="map" resultType="com.univ3e.entity.UnivExam" >
|
|
SELECT b.examid, b.examtype, b.title, b.description, b.exampapers,b.created,
|
|
b.starttime, b.endtime, b.isnetexam, b.teacherId, b.isoral
|
|
FROM univClassOwnExam a
|
|
INNER join univExam b
|
|
ON a.classesId = #{classesId} and a.examId = b.examId
|
|
AND b.isoral = #{isOral}
|
|
<if test="examType != null">
|
|
AND b.examType = #{examType}
|
|
</if>
|
|
<if test="startTime != null">
|
|
and b.startTime >= #{startTime}
|
|
</if>
|
|
<if test="endTime != null">
|
|
and b.endTime <= #{endTime}
|
|
</if>
|
|
ORDER BY b.examId DESC
|
|
<if test="page != null">
|
|
LIMIT #{page.limit} OFFSET #{page.offset}
|
|
</if>
|
|
</select>
|
|
|
|
<select id="findAssignHearExam" parameterType="map" resultType="com.univ3e.entity.UnivExam" >
|
|
SELECT b.examid, b.examtype, b.title, b.description, b.exampapers,b.created,
|
|
b.starttime, b.endtime, b.isnetexam, b.teacherId, b.isoral
|
|
FROM univClassOwnExam a
|
|
INNER join v_univhearExam b
|
|
ON a.classesId = #{classesId} and a.examId = b.examId
|
|
AND b.isoral = #{isOral}
|
|
<if test="examType != null">
|
|
AND b.examType = #{examType}
|
|
</if>
|
|
<if test="startTime != null">
|
|
and b.startTime >= #{startTime}
|
|
</if>
|
|
<if test="endTime != null">
|
|
and b.endTime <= #{endTime}
|
|
</if>
|
|
|
|
UNION
|
|
|
|
SELECT b.examid, b.examtype, b.title, b.description, b.exampapers,b.created,
|
|
b.starttime, b.endtime, b.isnetexam, b.teacherId, b.isoral
|
|
FROM univClassOwnHear a
|
|
INNER join v_univhearExam b
|
|
ON a.classesId = #{classesId} and a.examId = b.examId
|
|
AND b.isoral = -1
|
|
<if test="examType != null">
|
|
AND b.examType = #{examType}
|
|
</if>
|
|
<if test="startTime != null">
|
|
and b.startTime >= #{startTime}
|
|
</if>
|
|
<if test="endTime != null">
|
|
and b.endTime <= #{endTime}
|
|
</if>
|
|
|
|
ORDER BY created DESC
|
|
<if test="page != null">
|
|
LIMIT #{page.limit} OFFSET #{page.offset}
|
|
</if>
|
|
</select>
|
|
|
|
<select id= "findExam" parameterType="int" resultType="com.univ3e.entity.UnivExam" >
|
|
SELECT * FROM univexam WHERE examid = #{examId}
|
|
</select>
|
|
|
|
<select id= "findClassExamMaxScore" parameterType="map" resultType="com._3e.dto.ExamScoreDto" >
|
|
WITH temp AS (
|
|
SELECT b.userId AS studentId , b.examAnswerId , b.examId , b.examType ,
|
|
b.examPaperId as examPaperId , b.score , b.created ,
|
|
case when b.score >= 85 then 'A'
|
|
when b.score >= 73 then 'B'
|
|
when b.score >= 60 then 'C'
|
|
when b.score >= 45 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, created ASC) as tempId ,
|
|
row_number() OVER (PARTITION BY userId order by score desc, created ASC ) as rn
|
|
FROM univStudentOwnClass m
|
|
inner join univstudent o on m.studentId=o.studentId and o.status=1 and m.status=1
|
|
INNER JOIN univExamAnswer n
|
|
ON m.classesId = #{classesId} AND m.studentId = n.userId AND m.status = 1 AND examId = #{examId}
|
|
) a
|
|
INNER JOIN univExamAnswer b
|
|
ON a.tempId = b.examAnswerId and a.rn = 1 and b.areaid = #{areaId}
|
|
inner join univExam e on e.examId = b.examId
|
|
left join univstudent s on b.userId = s.studentid
|
|
)
|
|
SELECT t.studentId , COALESCE(t.examAnswerId,0) AS examAnswerId, COALESCE(t.examId,0) AS examId,
|
|
t.examType , COALESCE(t.examPaperId,0) AS examPaperId , COALESCE(t.score,0) AS score, t.created ,
|
|
t.level, t.title,s.truename, s.recognizecode,s.studentId AS userId,COALESCE(t.truescore,0) AS truescore
|
|
FROM temp t
|
|
RIGHT JOIN univStudentOwnClass o ON t.studentId = o.studentId
|
|
INNER JOIN univstudent s ON s.studentId = o.studentId and s.status=1
|
|
WHERE o.classesId = #{classesId} AND o.status = 1
|
|
ORDER BY score DESC, t.created ASC nulls last, userId ASC
|
|
<if test="page != null">
|
|
LIMIT #{page.limit} OFFSET #{page.offset}
|
|
</if>
|
|
</select>
|
|
|
|
<insert id= "doSave" parameterType="com.univ3e.entity.UnivExam">
|
|
INSERT INTO univexam(examid,examtype,title,description,exampapercount,exampapers,created,starttime,endtime,isnetexam,isrecommend,isoral,teacherid)
|
|
VALUES (
|
|
<if test="examid == 0">
|
|
(SELECT NEXTVAL('seq_examid')),
|
|
</if>
|
|
<if test="examid != 0">
|
|
#{examid},
|
|
</if>
|
|
#{examtype},#{title},#{description},#{exampapercount},#{exampapers},#{created},#{starttime},#{endtime},#{isnetexam},#{isrecommend},#{isoral},#{teacherid})
|
|
</insert>
|
|
|
|
<update id="doSaveUpdate" parameterType="com.univ3e.entity.UnivExam" >
|
|
UPDATE univexam
|
|
<set>
|
|
<if test="examtype != null">
|
|
examtype = #{examtype},
|
|
</if>
|
|
<if test="isrecommend != null">
|
|
isrecommend = #{isrecommend},
|
|
</if>
|
|
<if test="title != null">
|
|
title = #{title},
|
|
</if>
|
|
<if test="description != null">
|
|
description = #{description},
|
|
</if>
|
|
<if test="exampapercount != null">
|
|
exampapercount = #{exampapercount},
|
|
</if>
|
|
<if test="exampapers != null">
|
|
exampapers = #{exampapers},
|
|
</if>
|
|
<if test="created != null">
|
|
created = #{created},
|
|
</if>
|
|
<if test="starttime != null">
|
|
starttime = #{starttime},
|
|
</if>
|
|
<if test="endtime != null">
|
|
endtime = #{endtime},
|
|
</if>
|
|
<if test="isnetexam != null">
|
|
isnetexam = #{isnetexam},
|
|
</if>
|
|
<if test="teacherid != null">
|
|
teacherid = #{teacherid},
|
|
</if>
|
|
<if test="isoral != null">
|
|
isoral = #{isoral}
|
|
</if>
|
|
</set>
|
|
WHERE examid = #{examid}
|
|
</update>
|
|
|
|
<insert id="doExamToClasses" parameterType="com.univ3e.entity.UnivClassOwnExam" >
|
|
INSERT INTO univclassownexam(classesid,examid,areaid,objecttype)
|
|
VALUES (#{classesid},#{examid},#{areaid},#{objecttype})
|
|
</insert>
|
|
|
|
<select id= "findExamPapers" parameterType="map" resultType="com._3e.entity.ExamPaper" >
|
|
SELECT distinct exampaperid, teacherid, examlevel, title,
|
|
status, areaid ,isOral
|
|
FROM V_UnivExamPaper WHERE teacherid = #{teacherId} and status = 1 AND isoral = #{isoral}
|
|
AND (exampaperid > 112 or exampaperid < 0)
|
|
<if test="title != null">
|
|
and title like '%'||#{title}||'%'
|
|
</if>
|
|
order by examPaperId desc
|
|
<if test="page != null">
|
|
LIMIT #{page.limit} OFFSET #{page.offset}
|
|
</if>
|
|
</select>
|
|
|
|
<select id= "findExam_v1" parameterType="map" resultType="com.univ3e.entity.UnivExam" >
|
|
select DISTINCT cl.teacherid,cl.classname,e.examid,e.examtype,e.examtype,e.title,e.description,e.exampapercount
|
|
,e.exampapers,e.created,e.starttime,e.endtime,e.isoral from univclassownexam ce inner join
|
|
univexam e on ce.examid=e.examid inner join univclasses cl on ce.classesid=cl.classesid
|
|
where cl.teacherid=e.teacherid and cl.teacherid IN
|
|
<foreach item="teacherid" index="index" collection="teacherlist"
|
|
open="(" separator="," close=")">
|
|
#{teacherid}
|
|
</foreach>
|
|
<if test="status== '2'.toString()">
|
|
and e.endtime < NOW()
|
|
</if>
|
|
<if test="status== '1'.toString()">
|
|
and e.endtime > NOW()
|
|
</if>
|
|
and ce.classesid=#{classesid}
|
|
<if test="title != null">
|
|
and title like '%'||#{title}||'%'
|
|
</if>
|
|
and e.examtype='S'
|
|
order by e.created desc,e.title desc
|
|
<if test="page != null">
|
|
LIMIT #{page.limit} OFFSET #{page.offset}
|
|
</if>
|
|
</select>
|
|
<select id= "findExam_v2" parameterType="map" resultType="com.univ3e.entity.UnivExam" >
|
|
select cl.teacherid,cl.classname,e.examid,e.examtype,e.examtype,e.title,e.description,e.exampapercount
|
|
,e.exampapers,e.created,e.starttime,e.endtime,e.isoral from univclassownexam ce inner join
|
|
univexam e on ce.examid=e.examid inner join univclasses cl on ce.classesid=cl.classesid
|
|
where cl.teacherid=e.teacherid and cl.classesid IN
|
|
<foreach item="item" index="index" collection="classids"
|
|
open="(" separator="," close=")">
|
|
#{item}
|
|
</foreach>
|
|
<if test="status== '2'.toString()">
|
|
and e.endtime < NOW()
|
|
</if>
|
|
<if test="status== '1'.toString()">
|
|
and e.endtime > NOW()
|
|
</if>
|
|
<if test="title != null">
|
|
and title like '%'||#{title}||'%'
|
|
</if>
|
|
and e.examtype='S'
|
|
order by e.created desc,e.title desc
|
|
<if test="page != null">
|
|
LIMIT #{page.limit} OFFSET #{page.offset}
|
|
</if>
|
|
</select>
|
|
|
|
<insert id="doSaveHearAnswer" parameterType="com.univ3e.entity.UnivHearAnswer" >
|
|
INSERT INTO univHearAnswer(examanswerid,userid,examid,examtype,hearpaperid,score,answerdetail,created,areaid,origiscore,truescore)
|
|
VALUES (
|
|
<if test="examanswerid == 0">
|
|
(SELECT NEXTVAL('seq_univhearanswerid')),
|
|
</if>
|
|
<if test="examanswerid != 0">
|
|
#{examanswerid},
|
|
</if>
|
|
#{userid},#{examid},#{examtype},#{hearpaperid},#{score},#{answerdetail},#{created},#{areaid},#{origiscore},#{truescore})
|
|
</insert>
|
|
|
|
<select id= "findMockhearexam" parameterType="map" resultType="com._3e.dto.HearexamDto" >
|
|
select * from (
|
|
SELECT h.* FROM hearexam h
|
|
inner join classownhear c
|
|
on c.examid = h.examid
|
|
inner join studentownclass s
|
|
on s.classesid = c.classesid and s.status = 1
|
|
WHERE s.studentId= #{uid}
|
|
AND h.examType = 'S'
|
|
and h.startTime < now() and h.endTime > now()
|
|
union
|
|
SELECT h.* FROM hearexam h
|
|
inner join classownhear c
|
|
on c.examid = h.examid
|
|
inner join classes co
|
|
on c.classesid = co.classesid and co.status = 1
|
|
WHERE co.teacherId = #{uid}
|
|
AND h.examType = 'S'
|
|
and h.startTime < now() and h.endTime > now()
|
|
UNION
|
|
SELECT h.* FROM hearexam h
|
|
WHERE isNetExam = 1 AND examType = 'S'
|
|
and startTime < now() and endTime > now()
|
|
) t
|
|
<if test="page != null">
|
|
LIMIT #{page.limit} OFFSET #{page.offset}
|
|
</if>
|
|
</select>
|
|
|
|
<select id="findHearexam" parameterType="int" resultType="com.univ3e.entity.UnivHearExam" >
|
|
SELECT * FROM univhearexam WHERE examid = #{examId}
|
|
</select>
|
|
<select id="findHearexam_1" parameterType="map" resultType="com.univ3e.entity.UnivHearExam" >
|
|
select cl.teacherid,e.examid,e.examtype,e.examtype,e.title,e.description,e.exampapercount
|
|
,e.exampapers,e.created,e.starttime,e.endtime,e.isoral,cl.classname from univclassownhear ce
|
|
inner join v_univhearexam e on ce.examid=e.examid inner join univclasses cl on ce.classesid=cl.classesid
|
|
where cl.teacherid=e.teacherid and cl.teacherid IN
|
|
<foreach item="teacherid" index="index" collection="teacherlist"
|
|
open="(" separator="," close=")">
|
|
#{teacherid}
|
|
</foreach>
|
|
and e.endtime >NOW()
|
|
and ce.classesid=#{classesid}
|
|
and e.isoral=-1
|
|
|
|
and e.examtype='S'
|
|
order by created desc,title desc
|
|
</select>
|
|
<select id="findHearexam_2" parameterType="map" resultType="com.univ3e.entity.UnivHearExam" >
|
|
select cl.teacherid,e.examid,e.examtype,e.examtype,e.title,e.description,e.exampapercount
|
|
,e.exampapers,e.created,e.starttime,e.endtime,e.isoral,cl.classname from univclassownhear ce
|
|
inner join v_univhearexam e on ce.examid=e.examid inner join univclasses cl on ce.classesid=cl.classesid
|
|
where cl.teacherid=e.teacherid and cl.classesid IN
|
|
<foreach item="item" index="index" collection="classids"
|
|
open="(" separator="," close=")">
|
|
#{item}
|
|
</foreach>
|
|
and e.endtime >NOW()
|
|
and e.isoral=-1
|
|
|
|
and e.examtype='S'
|
|
order by created desc,title desc
|
|
</select>
|
|
|
|
<select id= "findFormalhearexam" parameterType="map" resultType="com._3e.dto.HearexamDto" >
|
|
SELECT h.* FROM hearexam h
|
|
inner join classownhear c
|
|
on c.examid = h.examid
|
|
inner join studentownclass s
|
|
on s.classesid = c.classesid and s.status = 1
|
|
WHERE s.studentId = #{uid}
|
|
AND h.examType = 'O'
|
|
and h.startTime < now() and h.endTime > now()
|
|
union
|
|
SELECT h.* FROM hearexam h
|
|
inner join classownhear c
|
|
on c.examid = h.examid
|
|
inner join classes co
|
|
on c.classesid = co.classesid and co.status = 1
|
|
WHERE co.teacherId = #{uid}
|
|
AND h.examType = 'O'
|
|
and h.startTime < now() and h.endTime > now()
|
|
<if test="page != null">
|
|
LIMIT #{page.limit} OFFSET #{page.offset}
|
|
</if>
|
|
</select>
|
|
|
|
<select id= "findHearAnswer" parameterType="map" resultType="com.univ3e.entity.UnivHearAnswer" >
|
|
select * from univhearanswer where userid = #{userId} and examid = #{examId}
|
|
<if test="examtype != null">
|
|
and examtype = #{examType}
|
|
</if>
|
|
|
|
<if test="page != null">
|
|
LIMIT #{page.limit} OFFSET #{page.offset}
|
|
</if>
|
|
</select>
|
|
|
|
<!-- <select id= "findAssignHearexam" parameterType="map" resultType="com._3e.entity.Hearexam" > -->
|
|
<!-- SELECT b.* -->
|
|
<!-- FROM ClassOwnHear a -->
|
|
<!-- INNER join HearExam b -->
|
|
<!-- ON a.classesId = #{classesId} and a.examId = b.examId -->
|
|
<!-- AND b.examType = #{examType} -->
|
|
<!-- <if test="startTime != null"> -->
|
|
<!-- and b.startTime >= #{startTime} -->
|
|
<!-- </if> -->
|
|
<!-- <if test="endTime != null"> -->
|
|
<!-- and b.endtime >= #{endTime} -->
|
|
<!-- </if> -->
|
|
<!-- ORDER BY b.examId DESC -->
|
|
<!-- <if test="page != null"> -->
|
|
<!-- LIMIT #{page.limit} OFFSET #{page.offset} -->
|
|
<!-- </if> -->
|
|
<!-- </select> -->
|
|
|
|
<select id= "findClassHearexamMaxScore" parameterType="map" resultType="com._3e.dto.ExamScoreDto" >
|
|
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 >= 73 then 'B'
|
|
when b.score >= 60 then 'C'
|
|
when b.score >= 45 then 'D'
|
|
else 'E' end as level
|
|
, e.title
|
|
, s.truename, s.recognizecode
|
|
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 StudentOwnClass m
|
|
INNER JOIN HearAnswer n
|
|
ON m.classesId = #{classesId} AND m.studentId = n.userId AND examId = #{examId}
|
|
) a
|
|
INNER JOIN HearAnswer b
|
|
ON a.tempId = b.examAnswerId and a.rn = 1 and b.areaid = #{areaId}
|
|
inner join HearExam e on e.examId = b.examId
|
|
left join student s on b.userId = s.studentid
|
|
ORDER BY b.score desc
|
|
<if test="page != null">
|
|
LIMIT #{page.limit} OFFSET #{page.offset}
|
|
</if>
|
|
</select>
|
|
|
|
<select id="findClassHearexamAllScore" parameterType="map" resultType="com._3e.dto.ExamScoreDto" >
|
|
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 >= 73 then 'B'
|
|
when b.score >= 60 then 'C'
|
|
when b.score >= 45 then 'D'
|
|
else 'E' end as level
|
|
, e.title
|
|
FROM StudentOwnClass a
|
|
INNER JOIN hearAnswer b
|
|
ON a.classesId = #{classesId} AND a.studentId = b.userId AND b.examId = #{examId}
|
|
inner join hearExam e on e.examId = b.examId
|
|
ORDER BY b.examAnswerId desc
|
|
<if test="page != null">
|
|
LIMIT #{page.limit} OFFSET #{page.offset}
|
|
</if>
|
|
</select>
|
|
|
|
<select id= "findHearexamPaperByID" parameterType="int" resultType="com._3e.entity.Hearpaper" >
|
|
SELECT * FROM hearpaper WHERE hearpaperid = #{paperId}
|
|
</select>
|
|
|
|
<select id= "findIsExamToClass" parameterType="map" resultType="boolean" >
|
|
SELECT CASE WHEN (COUNT(*) > 0) THEN true ELSE false END AS isFlag
|
|
FROM univclassOwnExam
|
|
WHERE examid = #{examId} and classesid =#{classesId}
|
|
</select>
|
|
|
|
<select id= "findHearPapersV2" parameterType="map" resultType="com._3e.entity.Hearpaper" >
|
|
SELECT hearpaperid, teacherid, examlevel, title,
|
|
status, areaid ,isOral
|
|
FROM V_UnivHearPaper WHERE teacherid = #{teacherId} and status = 1
|
|
<if test="title != null">
|
|
and title like '%'||#{title}||'%'
|
|
</if>
|
|
order by hearpaperid desc
|
|
<if test="page != null">
|
|
LIMIT #{page.limit} OFFSET #{page.offset}
|
|
</if>
|
|
</select>
|
|
|
|
|
|
<select id="findExamPaperNamesByPaperIds" parameterType="java.util.List" resultType="com._3e.http.teachercenter.dto.manageexam._3EResPaper">
|
|
select exampaperid as paperId ,title from exampaper where exampaperid
|
|
in
|
|
<foreach collection="list" index="index" item="item" separator="," close=")" open="(">
|
|
#{item}
|
|
</foreach>
|
|
|
|
</select>
|
|
|
|
<select id="findHearPaperNamesByPaperIds" parameterType="java.util.List" resultType="com._3e.http.teachercenter.dto.manageexam._3EResPaper">
|
|
select hearpaperid as paperId ,title from hearpaper where hearpaperid
|
|
in
|
|
<foreach collection="list" index="index" item="item" separator="," close=")" open="(">
|
|
#{item}
|
|
</foreach>
|
|
|
|
</select>
|
|
|
|
|
|
<insert id= "doSaveUnivTeacherOwnExam" parameterType="com.univ3e.entity.UnivTeacherOwnExam" >
|
|
insert INTO univteacherownexam(teacherid,examid,areaid)
|
|
VALUES (#{teacherid},#{examid},#{areaid})
|
|
</insert>
|
|
</mapper>
|