774 lines
33 KiB
XML
774 lines
33 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="FinishAssignStat">
|
|
|
|
|
|
<insert id="insertFinishAssignStat" parameterType="FinishAssignStat">
|
|
INSERT INTO FinishAssignStat ( uid, assignmentId, content, lessonCount,
|
|
completeCount, created , howmuch, maxScore, avgScore , areaid,uuid,isSign)
|
|
Values ( #{uid}, #{assignmentId}, #{content}, #{lessonCount},
|
|
#{completeCount},#{created} , #{howmuch}, #{maxScore}, #{avgScore} , #{areaid}, #{uuid}, #{isSign})
|
|
|
|
on conflict(assignmentid,uid,areaid) do update
|
|
|
|
set created=excluded.created,completeCount=excluded.completeCount,howmuch=excluded.howmuch,maxScore=excluded.maxScore,avgScore=excluded.avgScore,
|
|
uuid=excluded.uuid
|
|
</insert>
|
|
|
|
<update id="updateFinishAssignStat" parameterType="FinishAssignStat">
|
|
|
|
UPDATE FinishAssignStat
|
|
SET uid = #{uid}, assignmentId = #{assignmentId}, content = #{content},
|
|
lessonCount = #{lessonCount}, completeCount = #{completeCount},
|
|
created = #{created} , howmuch = #{howmuch}, maxScore = #{maxScore},
|
|
avgScore = #{avgScore} , areaid = #{areaid} ,isSign = #{isSign}
|
|
where uid=#{uid}
|
|
and assignmentId=#{assignmentId}
|
|
|
|
</update>
|
|
|
|
<select id="getFinishAssignStatByKey" parameterType="java.util.Map" resultType="FinishAssignStat">
|
|
|
|
SELECT uid , assignmentId , content , lessonCount , completeCount , created ,
|
|
howmuch , maxScore , avgScore ,areaid , uuid, isSign
|
|
FROM FinishAssignStat
|
|
WHERE uid=#{uid}
|
|
AND assignmentId=#{assignmentId} and areaId=#{areaId}
|
|
|
|
</select>
|
|
|
|
<select id="getFinishAssignStatsCountByUid" parameterType="java.util.Map" resultType="Integer">
|
|
|
|
SELECT count(*) as howmuch
|
|
from FinishAssignStat
|
|
WHERE uid=#{uid} and areaid = #{areaid}
|
|
|
|
</select>
|
|
|
|
<select id="getFinishAssignStatsByUid" parameterType="java.util.Map" resultType="FinishAssignStat">
|
|
|
|
SELECT uid , assignmentId , content , lessonCount , completeCount ,
|
|
created , howmuch , maxScore , avgScore , areaid
|
|
FROM FinishAssignStat
|
|
WHERE uid=#{uid} and areaid = #{areaid}
|
|
<if test="pageSize!=null">
|
|
limit #{pageSize}
|
|
</if>
|
|
<if test="offset!=null">
|
|
offset #{offset}
|
|
</if>
|
|
|
|
</select>
|
|
|
|
<select id="getFinishAssignStatsCountByAssignmentId" parameterType="java.lang.Integer" resultType="Integer">
|
|
|
|
SELECT count(*) as howmuch
|
|
from FinishAssignStat
|
|
WHERE assignmentId=#{assignmentId}
|
|
|
|
</select>
|
|
|
|
<select id="getFinishAssignStatsByAssignmentId" parameterType="java.util.Map" resultType="FinishAssignStat">
|
|
|
|
SELECT uid , assignmentId , content , lessonCount , completeCount
|
|
, created , howmuch , maxScore , avgScore , areaid
|
|
FROM FinishAssignStat
|
|
WHERE assignmentId=#{assignmentId}
|
|
ORDER BY created desc
|
|
<if test="pageSize!=null">
|
|
limit #{pageSize}
|
|
</if>
|
|
<if test="offset!=null">
|
|
offset #{offset}
|
|
</if>
|
|
|
|
</select>
|
|
|
|
<delete id="deleteOldFinishAssigns">
|
|
|
|
delete from FinishAssignStat m
|
|
using
|
|
( select a.uid , c.assignmentId , count( distinct c.lessonId ) as finishCount
|
|
from Achivement a
|
|
inner join AssignDetail c
|
|
|
|
on a.objectId = c.lessonId and c.assignType in ( 'U' , 'L' )
|
|
and a.achiveType = 'L' and a.pointCaseType in ( 5, 6 ,7 , 8 )
|
|
inner join Assignment m
|
|
on c.assignmentId = m.assignmentId and a.created <= m.endtime and a.created >= m.starttime
|
|
group by a.uid , c.assignmentId ) n
|
|
where m.uid = n.uid and m.assignmentId = n.assignmentId ;
|
|
|
|
</delete>
|
|
|
|
<insert id="insertNewFinishAssigns">
|
|
|
|
Insert into FinishAssignStat ( uid , assignmentId , content , lessonCount ,
|
|
completeCount , created , howmuch , maxScore , avgScore , areaid )
|
|
select l.uid , l.assignmentId , left(m.content,200) , n.lessonCount ,
|
|
l.finishCount , current_timestamp , l.howmuch , l.maxScore , l.avgScore , l.areaid
|
|
from
|
|
( select a.uid , c.assignmentId , count( distinct c.lessonId ) as finishCount ,
|
|
count(*) as howmuch , max( score ) as maxScore , avg( score ) as avgScore , a.areaid
|
|
from Achivement a
|
|
|
|
|
|
inner join AssignDetail c
|
|
on a.objectId = c.lessonId and c.assignType in ( 'U' , 'L' ) and a.achiveType = 'L' and a.pointCaseType in ( 5, 6 ,7 , 8 )
|
|
inner join Assignment m
|
|
on c.assignmentId = m.assignmentId and a.created <= m.endtime and a.created >= m.starttime
|
|
group by a.uid , c.assignmentId , a.areaid) l
|
|
inner join Assignment m
|
|
on l.assignmentId = m.assignmentId
|
|
inner join ( select assignmentId , count(distinct(assigntype,unitid,lessonid)) as lessonCount
|
|
from assignDetail
|
|
group by assignmentId ) n
|
|
on l.assignmentId = n.assignmentId ;
|
|
|
|
</insert>
|
|
|
|
<select id="assignQueryStatForUser" parameterType="java.util.Map" resultType="AssignStatItemDto">
|
|
|
|
with base as(select a.assignmentid from AssignToClass a inner join assignment b on a.assignmentid=b.assignmentid and status=1
|
|
where classesId = #{classesId} order by a.assignmentid desc
|
|
<if test="pageSize!=null">
|
|
limit #{pageSize}
|
|
</if>
|
|
<if test="offset!=null">
|
|
offset #{offset}
|
|
</if> )
|
|
|
|
SELECT * FROM
|
|
( (select a.assignmentId , b.content , b.created , b.startTime , b.endTime,
|
|
count(distinct(c.assigndetailId)) as lessonCount ,
|
|
count(distinct(d.objectid)) as completeCount ,
|
|
count(d.objectid) as howmuch , max(d.score) as maxScore ,
|
|
round(avg(d.score)) as avgScore , b.description,null as finishWords
|
|
from base a
|
|
inner join Assignment b
|
|
on a.assignmentId = b.assignmentId and b.assignType='L' and b.status = 1
|
|
left join AssignDetail c on b.assignmentid = c.assignmentid
|
|
left join Achivement d on d.objectid = c.lessonid
|
|
|
|
and d.created > b.starttime and d.created < b.endtime
|
|
and d.areaId=#{areaId}
|
|
and d.uid = #{uid}
|
|
group by a.assignmentid , b.content ,b.created , b.starttime ,b.endtime ,b.description)
|
|
|
|
UNION
|
|
|
|
(with temp1 as(select w.lessonid,w.wordsId,a.assignmentId
|
|
from words w inner join assigndetail a on a.unitid=w.lessonid
|
|
inner join base c on a.assignmentId=c.assignmentId
|
|
inner join assignment d on d.assignmentId=a.assignmentId and d.assigntype='W' and d.status = 1
|
|
group by w.lessonid,w.wordsId,a.assignmentId),
|
|
|
|
temp2 as (
|
|
select b.assignmentid,wordsid
|
|
from wordAchive d inner join assignment b
|
|
|
|
on d.created > b.starttime and d.created < b.endtime
|
|
and d.areaId=#{areaId}
|
|
inner join base c on b.assignmentId=c.assignmentId
|
|
where uid = #{uid} ),
|
|
temp3 as ( select t1.assignmentid,count(distinct(t2.wordsId))||'/'||count(distinct(t1.wordsId)) as finishWords
|
|
from temp1 t1 left join temp2 t2 on t1.assignmentid=t2.assignmentid and t1.wordsId=t2.wordsId
|
|
group by t1.assignmentid)
|
|
|
|
select a.assignmentId , b.content , b.created , b.startTime , b.endTime, null as lessonCount,null as completeCount,
|
|
null as howmuch, null as maxScore,null as avgScore, b.description,finishWords
|
|
from temp3 a inner join assignment b on a.assignmentId = b.assignmentId))
|
|
|
|
AS A order by a.assignmentId desc
|
|
|
|
<!-- <![CDATA[
|
|
select a.assignmentId , b.content , b.created , b.startTime , b.endTime,
|
|
count(distinct(c.assigndetailId)) as lessonCount ,
|
|
count(distinct(d.objectid)) as completeCount ,
|
|
count(d.objectid) as howmuch , max(d.score) as maxScore ,
|
|
round(avg(d.score)) as avgScore , b.description
|
|
from AssignToClass a
|
|
inner join Assignment b
|
|
on a.classesId = #{classesId} and a.assignmentId = b.assignmentId and b.status = 1
|
|
left join AssignDetail c on b.assignmentid = c.assignmentid
|
|
left join Achivement d on d.objectid = c.lessonid
|
|
and d.created > b.starttime and d.created < b.endtime
|
|
and d.uid = #{uid}
|
|
|
|
group by a.assignmentid , b.content ,b.created , b.starttime ,b.endtime ,b.description
|
|
order by a.assignmentId desc
|
|
]]>
|
|
<dynamic>
|
|
<isNotEmpty prepend=" LIMIT " property="pageSize">
|
|
#{pageSize}
|
|
</isNotEmpty>
|
|
|
|
<isNotEmpty prepend=" OFFSET " property="offset">
|
|
#{offset}
|
|
</isNotEmpty>
|
|
</dynamic> -->
|
|
</select>
|
|
|
|
<select id="assignQueryStatForSingle" parameterType="java.util.Map" resultType="AssignStatItemDto">
|
|
|
|
<!-- select b.assignmentId , b.content , b.created , b.startTime , b.endTime,
|
|
count(distinct(c.assigndetailId)) as lessonCount ,
|
|
count(distinct(d.objectid)) as completeCount ,
|
|
count(d.objectid) as howmuch ,case when max(d.score) is null then 0 else max(d.score) end as maxScore ,
|
|
case when round( avg(d.score)) is null then 0 else round( avg(d.score)) end
|
|
as avgScore , b.description
|
|
from Assignment b
|
|
left join AssignDetail c on b.assignmentid = c.assignmentid
|
|
left join Achivement d on d.objectid = c.lessonid
|
|
and d.created > b.starttime and d.created < b.endtime
|
|
and d.uid = #{uid}
|
|
and d.achiveType in ('L','W') AND d.pointCaseType in (3, 5, 6 , 7 ,8 )
|
|
where b.assignmentId = #{assignmentId} and b.status = 1
|
|
group by b.assignmentid , b.content ,b.created , b.starttime ,b.endtime ,b.description
|
|
order by b.assignmentId desc -->
|
|
|
|
with temp as(select assignmentId,count (distinct(assigndetailId)) lessonCount
|
|
from AssignDetail where assignmentId = #{assignmentId} group by assignmentId)
|
|
select b.assignmentId , b.content , b.created , b.startTime , b.endTime,
|
|
c.lessonCount ,
|
|
case when a.completeCount is null then 0 else a.completeCount end as completeCount,
|
|
case when a.howmuch is null then 0 else a.howmuch end as howmuch ,
|
|
case when a.maxScore is null then 0 else a.maxScore end as maxScore ,
|
|
case when a.avgScore is null then 0 else a.avgScore end as avgScore ,
|
|
b.description,
|
|
coalesce(a.isSign,0) as isSign
|
|
from Assignment b
|
|
left join temp c on b.assignmentid = c.assignmentid
|
|
left join finishassignstat a
|
|
|
|
on b.assignmentId = a.assignmentId and a.uid = #{uid}
|
|
where b.assignmentId = #{assignmentId} and b.status = 1
|
|
</select>
|
|
|
|
<select id="assignQueryStatForSingleOfWord" parameterType="java.util.Map" resultType="AssignStatItemDto">
|
|
|
|
<!-- with temp1 as(select w.lessonid,w.wordsId
|
|
from words w inner join assigndetail a on a.unitid=w.lessonid and assignmentid=#{assignmentId}
|
|
group by w.lessonid,w.wordsId),
|
|
|
|
temp2 as (
|
|
select assignmentid,wordsid,score
|
|
from wordAchive d inner join assignment b
|
|
on assignmentid = #{assignmentId}
|
|
|
|
and d.created > b.starttime and d.created < b.endtime
|
|
|
|
where uid = #{uid} ),
|
|
temp3 as (
|
|
select t1.lessonid,case when count(distinct(t2.wordsid))>0 then 1 else 0 end as howmuch,count(t2.wordsid) as total,
|
|
count(distinct(t2.wordsid)) as finishWords,count(distinct(t1.wordsid)) as totalWords,
|
|
round( avg(t2.score)) as avgScore,max(t2.score) as maxScore
|
|
from temp1 t1 left join temp2 t2 on t1.wordsid=t2.wordsid group by t1.lessonid)
|
|
|
|
select b.assignmentId , b.content,b.created ,b.startTime ,b.endTime,b.description,
|
|
count(distinct(c.assigndetailId)) as lessonCount,
|
|
sum(howmuch) as completeCount,sum(total) as howmuch ,
|
|
case when max(maxScore) is null then 0 else max(maxScore) end as maxScore ,
|
|
case when round( avg(avgScore)) is null then 0 else round( avg(avgScore)) end as avgScore,
|
|
sum(finishWords)||'/'||sum(totalWords) as finishWords
|
|
|
|
from assignment b left join AssignDetail c
|
|
on b.assignmentid = c.assignmentid
|
|
left join temp3 t3 on c.unitid=t3.lessonid
|
|
where b.assignmentId=#{assignmentId}
|
|
group by b.assignmentid , b.content ,b.created , b.starttime ,b.endtime ,b.description -->
|
|
|
|
with temp as(select a.assignmentId,count(distinct(w.wordsId )) lessonCount
|
|
from words w inner join assigndetail a on a.unitid=w.lessonid and assignmentid=#{assignmentId}
|
|
group by a.assignmentId )
|
|
select b.assignmentId , b.content,b.created ,b.startTime ,b.endTime,b.description,
|
|
c.lessonCount,
|
|
case when a.completeCount is null then 0 else a.completeCount end as completeCount,
|
|
case when a.howmuch is null then 0 else a.howmuch end as howmuch ,
|
|
case when a.maxScore is null then 0 else a.maxScore end as maxScore ,
|
|
case when a.avgScore is null then 0 else a.avgScore end as avgScore ,
|
|
case when a.completeCount is null then 0 else a.completeCount end||'/'||c.lessonCount as finishWords ,
|
|
coalesce(a.isSign,0) as isSign
|
|
|
|
from assignment b left join temp c
|
|
on b.assignmentid = c.assignmentid
|
|
left join finishassignstat a
|
|
on b.assignmentId = a.assignmentId and a.uid = #{uid}
|
|
where b.assignmentId=#{assignmentId}
|
|
|
|
</select>
|
|
|
|
<select id="assignQueryStat_classAvgOfWord" parameterType="java.util.Map" resultType="java.lang.Double">
|
|
WITH temp1 as ( SELECT studentId
|
|
FROM StudentOwnClass
|
|
WHERE classesId = #{classesId} and areaid=#{areaid} and status = 1) ,
|
|
temp2 as ( SELECT m.startTime , m.endTime , n.lessonId
|
|
FROM Assignment m
|
|
INNER JOIN AssignDetail n
|
|
on m.assignmentId = #{assignmentId} and m.assignmentId = n.assignmentId )
|
|
SELECT case when avg( b.avgScore ) is null then 0 else avg( b.avgScore ) end
|
|
FROM ( SELECT d.uid , avg(d.score) as avgScore
|
|
FROM temp2 as c
|
|
INNER JOIN wordachive d
|
|
on d.uid in ( select studentid from temp1 ) and d.areaid=#{areaid}
|
|
and d.wordsid in
|
|
(select wordsid from words w inner join assigndetail a on a.unitid=w.lessonid
|
|
and assignmentid=#{assignmentId})
|
|
|
|
and d.created > c.starttime and d.created < c.endtime
|
|
|
|
GROUP BY d.uid ) as b
|
|
|
|
|
|
|
|
</select>
|
|
|
|
<select id="assignQueryStat_classAvg" parameterType="java.util.Map" resultType="java.lang.Double">
|
|
<!-- WITH temp1 as ( SELECT studentId
|
|
FROM StudentOwnClass
|
|
WHERE classesId = #{classesId} ) ,
|
|
temp2 as ( SELECT m.startTime , m.endTime , n.lessonId
|
|
FROM Assignment m
|
|
INNER JOIN AssignDetail n
|
|
on m.assignmentId = #{assignmentId} and m.assignmentId = n.assignmentId )
|
|
|
|
SELECT case when round( avg( b.avgScore ) ) is null then 0 else round( avg( b.avgScore ) ) end
|
|
FROM ( SELECT d.uid , avg(d.score) as avgScore
|
|
FROM temp2 as c
|
|
INNER JOIN Achivement d
|
|
on d.uid in ( select studentid from temp1 )
|
|
and d.objectid = c.lessonid
|
|
<![CDATA[
|
|
and d.created > c.starttime and d.created < c.endtime
|
|
]]>
|
|
GROUP BY d.uid ) as b -->
|
|
|
|
with temp as ( select * from studentownClass
|
|
where classesid = #{classesId} and status = 1 )
|
|
select case when avg( b.avgScore ) is null then 0 else avg( b.avgScore ) end
|
|
from temp stu
|
|
left join finishAssignStat b
|
|
on stu.studentId = b.uid and b.assignmentid = #{assignmentId}
|
|
<!-- 性能问题,不再使用
|
|
<![CDATA[
|
|
select round( avg( b.avgScore ) )
|
|
from StudentOwnClass a
|
|
inner join (
|
|
select d.uid , avg(d.score) as avgScore , b.assignmentid
|
|
from AssignToClass a
|
|
inner join Assignment b
|
|
on a.classesId = #{classesId} and a.assignmentId = b.assignmentId and b.status = 1
|
|
inner join AssignDetail c on b.assignmentid = c.assignmentid
|
|
inner join Achivement d on d.objectid = c.lessonid
|
|
and d.created > b.starttime and d.created < b.endtime
|
|
where b.assignmentid = #{assignmentId}
|
|
|
|
group by d.uid , b.assignmentid
|
|
order by d.uid desc
|
|
) b
|
|
on a.studentId = b.uid and b.assignmentId = #{assignmentId}
|
|
where a.classesId = #{classesId} and a.status = 1
|
|
]]> -->
|
|
</select>
|
|
|
|
<!-- 班级该次作业排名在自己之前的 -->
|
|
<select id="assignQueryStat_classRank" parameterType="java.util.Map" resultType="Integer">
|
|
WITH temp1 as ( select studentId
|
|
from StudentOwnClass
|
|
where classesId = #{classesId} and status = 1 ) ,
|
|
temp2 as ( select uid ,score , objectId , created
|
|
from temp1 m
|
|
inner join Achivement n
|
|
ON m.studentId = n.uid
|
|
AND n.achiveType in ('L','W') AND n.pointCaseType in (3, 5, 6 , 7 ,8 )
|
|
AND n.objectId in
|
|
( select lessonId from AssignDetail where assignmentid = #{assignmentId} ) ) ,
|
|
temp3 as ( select p.uid , round(avg(p.score)) as avgScore
|
|
from temp2 p
|
|
inner join Assignment q
|
|
on q.assignmentId = #{assignmentId}
|
|
|
|
and p.created > q.startTime and p.created < q.endTime
|
|
|
|
group by p.uid )
|
|
SELECT count(*)
|
|
FROM temp3
|
|
|
|
WHERE avgScore > #{avgScore}
|
|
|
|
<!--
|
|
<![CDATA[
|
|
select count( * )
|
|
from StudentOwnClass a
|
|
inner join (
|
|
select d.uid , round(avg(d.score)) as avgScore , b.assignmentid
|
|
from AssignToClass a
|
|
inner join Assignment b
|
|
on a.classesId = #{classesId} and a.assignmentId = b.assignmentId and b.status = 1
|
|
inner join AssignDetail c on b.assignmentid = c.assignmentid
|
|
inner join Achivement d on d.objectid = c.lessonid
|
|
and d.created > b.starttime and d.created < b.endtime
|
|
where b.assignmentid = #{assignmentId}
|
|
|
|
group by d.uid , b.assignmentid
|
|
order by d.uid desc
|
|
) b on b.uid = a.studentid
|
|
where a.classesId = #{classesId} and a.status = 1
|
|
|
|
and b.avgScore >= #{avgScore}
|
|
]]> -->
|
|
</select>
|
|
|
|
<select id="assignQueryStat_classRankOfWord" parameterType="java.util.Map" resultType="Integer">
|
|
<!-- WITH temp1 as ( select studentId
|
|
from StudentOwnClass
|
|
where classesId = #{classesId} and status = 1 ) ,
|
|
temp2 as (select w.lessonid,w.wordsId from words w inner join assigndetail a on
|
|
a.unitid=w.lessonid and assignmentid=#{assignmentId}
|
|
group by w.lessonid,w.wordsId),
|
|
|
|
temp3 as (select uid,round(avg(score))as score,lessonid from wordachive w inner join temp1 t1 on uid= t1.studentId
|
|
inner join Assignment q
|
|
on q.assignmentId = #{assignmentId}
|
|
<![CDATA[
|
|
and w.created > q.startTime and w.created < q.endTime
|
|
]]>
|
|
inner join temp2 t2 on t2.wordsid=w.wordsid
|
|
group by uid,lessonid)
|
|
select count(uid) from
|
|
(select uid ,round(avg(t3.score)) as avgScore from temp3 t3 group by uid) as temp4
|
|
<![CDATA[
|
|
where avgScore > #{avgScore}
|
|
]]> -->
|
|
|
|
WITH temp1 as ( select studentId
|
|
from StudentOwnClass where classesId = #{classesId} and status = 1 )
|
|
select count(b.uid)
|
|
from temp1 a
|
|
inner join FinishAssignstat b
|
|
on a.studentid = b.uid and b.assignmentid = #{assignmentId}
|
|
where b.avgScore > #{avgScore}
|
|
</select>
|
|
<select id="getFinishAssignStatWordByUid" parameterType="java.util.Map" resultType="FinishAssignStat">
|
|
with temp as(select count( distinct wordsId) wordsCount, assignmentid
|
|
from assigndetail a inner join words w on
|
|
a.unitid=w.lessonid and w.status = 1 and assignmentid in
|
|
<foreach collection="assignmentIds" item="item" open="(" close=")" separator=",">
|
|
#{item}
|
|
</foreach>
|
|
group by assignmentid
|
|
)
|
|
|
|
select wordsCount lessonCount,case when f.lessonCount is null then 0 else f.lessonCount end as finLessonCount,case when completeCount is null then 0 else completeCount end as completeCount,t.assignmentId ,f.jcontent as jcontent,
|
|
case when howmuch is null then 0 else howmuch end as howmuch,case when avgScore is null then 0 else avgScore end as avgScore,
|
|
case when maxScore is null then 0 else maxScore end as maxScore,created
|
|
from temp t left join finishassignstat f on
|
|
t.assignmentid=f.assignmentid and f.uid=#{uid} and f.areaid=#{areaId}
|
|
</select>
|
|
|
|
<select id="getFinishAssignStatLessonByUid" parameterType="java.util.Map" resultType="FinishAssignStat">
|
|
with temp as(select count( distinct a.assigndetailid) lessonCount, a.assignmentid
|
|
from assigndetail as a inner join lesson as ls on a.lessonid = ls.lessonid and ls.status =1 where a.assignmentid in
|
|
<foreach collection="assignmentIds" item="item" open="(" close=")" separator=",">
|
|
#{item}
|
|
</foreach>
|
|
group by a.assignmentid
|
|
)
|
|
select t.lessonCount,case when f.lessonCount is null then 0 else f.lessonCount end as finLessonCount,case when completeCount is null then 0 else completeCount end as completeCount,t.assignmentId ,f.jcontent as jcontent,
|
|
case when howmuch is null then 0 else howmuch end as howmuch,case when avgScore is null then 0 else avgScore end as avgScore,
|
|
case when maxScore is null then 0 else maxScore end as maxScore,created
|
|
from temp t left join
|
|
finishassignstat f on t.assignmentid=f.assignmentid and f.uid=#{uid} and f.areaid=#{areaId}
|
|
</select>
|
|
|
|
|
|
<select id="getFinishAssignStatExamByUid" parameterType="java.util.Map" resultType="FinishAssignStat">
|
|
|
|
with temp as (
|
|
SELECT e.userid,examid,score,truescore,created,
|
|
rank() over (partition by examid order by score desc , examanswerid desc ) as mm
|
|
FROM examanswer e where userid=#{uid} and areaId=#{areaId} and examId in
|
|
<foreach collection="assignmentIds" item="item" open="(" close=")" separator=",">
|
|
#{item}
|
|
</foreach>
|
|
),
|
|
temp1 as(select max(mm) completeCount,examId from temp group by examid)
|
|
select t.score avgScore,t.truescore maxScore,t.created,t.examId as assignmentId ,t1.completeCount
|
|
from temp t inner join temp1 t1 on t.examid=t1.examid and t.mm=1
|
|
<!-- select count(examanswerId) as completeCount,examId as assignmentId
|
|
from examanswer where userid=#{uid} and score>0 and areaId=#{areaId} and
|
|
examId in
|
|
<foreach collection="assignmentIds" item="item" open="(" close=")" separator=",">
|
|
#{item}
|
|
</foreach>
|
|
group by examId -->
|
|
</select>
|
|
|
|
<select id="getFinishAssignStatHearByUid" parameterType="java.util.Map" resultType="FinishAssignStat">
|
|
|
|
|
|
with temp as (
|
|
SELECT e.userid,examid,score,truescore,created,
|
|
rank() over (partition by examid order by score desc , examanswerid desc ) as mm
|
|
FROM hearanswer e where userid=#{uid} and score>0 and areaId=#{areaId} and examId in
|
|
<foreach collection="assignmentIds" item="item" open="(" close=")" separator=",">
|
|
#{item}
|
|
</foreach>
|
|
),
|
|
temp1 as(select max(mm) completeCount,examId from temp group by examid)
|
|
select t.score avgScore,t.truescore maxScore,t.created,t.examId as assignmentId ,t1.completeCount
|
|
from temp t inner join temp1 t1 on t.examid=t1.examid and t.mm=1
|
|
<!-- select count(examanswerid) as completeCount,examId as assignmentId
|
|
from hearanswer where userid=#{uid} and score>0 and areaId=#{areaId} and
|
|
examId in
|
|
<foreach collection="assignmentIds" item="item" open="(" close=")" separator=",">
|
|
#{item}
|
|
</foreach>
|
|
group by examId -->
|
|
</select>
|
|
|
|
|
|
<select id="assignQueryStatForUserTwo" parameterType="java.util.Map" resultType="AssignStatItemDto">
|
|
|
|
select distinct (e.examid) assignmentId,title as content,e.description,isOral,e.created,starttime,endtime,'E' as assignType,e.examType,e.type from exam e
|
|
inner join
|
|
classownexam c on e.examid=c.examid
|
|
<if test="examType!=null">
|
|
and examtype=#{examType}
|
|
</if>
|
|
<if test="!isAll">
|
|
and endtime>now()
|
|
</if>
|
|
and c.classesid=#{classesId}
|
|
|
|
union all
|
|
select distinct (e.examid) assignmentId ,title as content,e.description,-1 as isOral,e.created,startTime,endTime,'E' as assignType,e.examType,0 as type from hearexam e
|
|
inner join
|
|
classownhear c on e.examid=c.examid
|
|
<if test="examType!=null">
|
|
and examtype=#{examType}
|
|
</if>
|
|
<if test="!isAll">
|
|
and endtime>now()
|
|
</if>
|
|
and c.classesId=#{classesId}
|
|
union all
|
|
SELECT a.assignmentId , a.content , a.description ,null as isOral, a.created , a.startTime , a.endTime , a.assignType,null as examType ,0 as type from assignment a
|
|
inner join
|
|
assigntoclass b on a.assignmentid=b.assignmentid and a.status=1
|
|
and b.classesid=#{classesId} and a.assignType in ('W','L')
|
|
<if test="!isAll">
|
|
and a.endtime>now()
|
|
</if>
|
|
order by created desc,assignmentid desc LIMIT #{pageSize} OFFSET #{offset}
|
|
</select>
|
|
|
|
<select id="assignQueryStatForUserCountTwo" parameterType="java.util.Map" resultType="java.lang.Integer">
|
|
|
|
with temp as( select count(distinct e.examid) howmuch from exam e
|
|
inner join
|
|
classownexam c on e.examid=c.examid
|
|
<if test="examType!=null">
|
|
and examtype=#{examType}
|
|
</if>
|
|
<if test="!isAll">
|
|
and endtime>now()
|
|
</if>
|
|
and c.classesid=#{classesId}
|
|
|
|
),
|
|
temp1 as(
|
|
select count(distinct e.examid) howmuch from hearexam e
|
|
inner join
|
|
classownhear c on e.examid=c.examid
|
|
<if test="examType!=null">
|
|
and examtype=#{examType}
|
|
</if>
|
|
<if test="!isAll">
|
|
and endtime>now()
|
|
</if>
|
|
and c.classesId=#{classesId}
|
|
),
|
|
temp2 as(
|
|
SELECT count(a.assignmentId) howmuch from assignment a
|
|
inner join
|
|
assigntoclass b on a.assignmentid=b.assignmentid and a.status=1
|
|
and b.classesid=#{classesId}
|
|
<if test="!isAll">
|
|
and a.endtime>now()
|
|
</if>
|
|
)
|
|
select temp.howmuch+temp1.howmuch+temp2.howmuch from temp,temp1,temp2
|
|
</select>
|
|
<select id="assignQueryStatForSingleOfExam" parameterType="java.util.Map" resultType="AssignStatItemDto">
|
|
with temp as(SELECT userId ,last_value( examAnswerId ) OVER (PARTITION BY userId order by score desc , created asc ) as examAnswerId ,
|
|
row_number() OVER (PARTITION BY userId order by score desc , created asc ) as rn
|
|
FROM EXAMANSWER n
|
|
where n.userId =#{uid} AND examId = #{examId} and n.areaid=#{areaId})
|
|
select score maxScore,created,examId,case when e.score >= 85 then 'A'
|
|
when e.score >= 80 then 'B'
|
|
when e.score >= 70 then 'C'
|
|
when e.score >= 60 then 'D'
|
|
else 'E' end as level from examanswer e inner join temp t on
|
|
e.examanswerid = t.examAnswerId and t.rn=1
|
|
</select>
|
|
|
|
|
|
<select id="assignQueryStat_classRankOfExam" parameterType="java.util.Map" resultType="java.lang.Integer">
|
|
with temp as( SELECT userId , examId ,
|
|
last_value( examAnswerId ) OVER (PARTITION BY userId order by score desc , created asc ) as examAnswerId ,
|
|
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 n.areaid=#{areaId})
|
|
select count(*) from examanswer e inner join
|
|
temp t on t.rn=1 and e.examAnswerId = t.examAnswerId and e.score>#{score}
|
|
</select>
|
|
|
|
<select id="assignQueryStatForSingleOfHear" parameterType="java.util.Map" resultType="AssignStatItemDto">
|
|
with temp as(SELECT userId ,last_value( examAnswerId ) OVER (PARTITION BY userId order by score desc , created asc ) as examAnswerId ,
|
|
row_number() OVER (PARTITION BY userId order by score desc , created asc ) as rn
|
|
FROM HearANSWER n
|
|
where n.userId =#{uid} AND examId = #{examId} and n.areaid=#{areaId})
|
|
select score maxScore,created,examId,case when e.score >= 85 then 'A'
|
|
when e.score >= 80 then 'B'
|
|
when e.score >= 70 then 'C'
|
|
when e.score >= 60 then 'D'
|
|
else 'E' end as level from Hearanswer e inner join temp t on
|
|
e.examAnswerId = t.examAnswerId and t.rn=1
|
|
</select>
|
|
|
|
|
|
<select id="assignQueryStat_classRankOfHear" parameterType="java.util.Map" resultType="java.lang.Integer">
|
|
with temp as( SELECT userId , examId ,
|
|
last_value( examAnswerId ) OVER (PARTITION BY userId order by score desc , created asc ) as examAnswerId ,
|
|
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 n.areaid=#{areaId})
|
|
select count(*) from Hearanswer e inner join
|
|
temp t on t.rn=1 and e.examAnswerId = t.examAnswerId and e.score>#{score}
|
|
</select>
|
|
|
|
|
|
<select id="getFinishAssignStatExamByClassesId" parameterType="java.util.Map" resultType="FinishAssignStat">
|
|
|
|
with stu as(select studentid from studentownclass where classesId=#{classesId} and status=1)
|
|
select count(distinct e.userId) as howmuch,avg(e.score) avgScore,examId as assignmentId
|
|
from examanswer e
|
|
inner join stu s on e.userid = s.studentid and score>0
|
|
and e.areaId=#{areaId} and
|
|
e.examId in
|
|
<foreach collection="examIds" item="item" open="(" close=")" separator=",">
|
|
#{item}
|
|
</foreach>
|
|
group by examId
|
|
</select>
|
|
|
|
<select id="getFinishAssignStatHearByClassesId" parameterType="java.util.Map" resultType="FinishAssignStat">
|
|
with stu as(select studentid from studentownclass where classesId=#{classesId} and status=1)
|
|
select count(distinct e.userId) as howmuch,avg(e.score) avgScore ,examId as assignmentId
|
|
from hearanswer e
|
|
inner join stu s on e.userid = s.studentid and score>0
|
|
and e.areaId=#{areaId} and
|
|
e.examId in
|
|
<foreach collection="examIds" item="item" open="(" close=")" separator=",">
|
|
#{item}
|
|
</foreach>
|
|
group by examId
|
|
</select>
|
|
<select id="getAssignStatisticsByClassesId" 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.maxscore >= 85 then 1 else null end) "A",
|
|
count(case when a.maxscore >= 75 and a.maxscore<85 then 1 else null end) "B",
|
|
count(case when a.maxscore >= 65 and a.maxscore<75 then 1 else null end) "C",
|
|
count(case when a.maxscore >= 55 and a.maxscore<65 then 1 else null end) "D",
|
|
count(case when a.maxscore >= 0 and a.maxscore<55 then 1 else null end) "E",
|
|
count(case when a.maxscore is null then 1 else null end) "N"
|
|
|
|
FROM finishassignstat a
|
|
right join stu on stu.userId = a.uid and a.assignmentId=#{assignmentId} and a.areaId=#{areaid}
|
|
</select>
|
|
|
|
|
|
|
|
<select id="getFinishAssignStatByLessonIds" parameterType="java.util.Map" resultType="FinishAssignStat">
|
|
|
|
|
|
|
|
select a.uid , count( distinct a.objectId ) as completeCount ,
|
|
count(a.objectId) as howmuch , max( score ) as maxScore , avg( score ) as avgScore , a.areaid , max(a.created) created
|
|
from Achivement a
|
|
where a.achiveType = 'L' and a.pointCaseType in
|
|
|
|
<foreach collection="pointcasetypes" item="item" open="(" close=")" separator=",">
|
|
#{item}
|
|
</foreach>
|
|
and objectId in
|
|
<foreach collection="lessonIds" item="item" open="(" close=")" separator=",">
|
|
#{item}
|
|
</foreach>
|
|
and a.uid=#{uid}
|
|
and a.areaId=#{areaId}
|
|
<![CDATA[
|
|
and a.created <= #{endTime} and a.created >= #{startTime}
|
|
]]>
|
|
group by a.uid , a.areaid
|
|
</select>
|
|
<select id="getFinishAssignStatsUUIDByLessonIds" parameterType="java.util.Map" resultType="java.lang.String">
|
|
select uuid from achivement where uid=#{uid} and areaId=#{areaId}
|
|
|
|
and objectId in
|
|
<foreach collection="lessonIds" item="item" open="(" close=")" separator=",">
|
|
#{item}
|
|
</foreach>
|
|
<![CDATA[
|
|
and achiveType='L' and pointCaseType in (4, 5, 6 , 7 ,8 ) and length( trim( uuid ))>0
|
|
and created <= #{endTime} and created >= #{startTime}
|
|
]]>
|
|
order by score desc,created desc
|
|
limit 1
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="getFinishAssignStatByWordsIds" parameterType="java.util.Map" resultType="FinishAssignStat">
|
|
|
|
|
|
select w.uid , count( distinct w.wordsid ) as completeCount ,
|
|
count(w.wordsid) as howmuch , max( score ) as maxScore , avg( score ) as avgScore , w.areaid,max( w.created ) as created
|
|
from Wordachive w
|
|
where w.uid=#{uid}
|
|
|
|
and wordsId in
|
|
<foreach collection="wordsIds" item="item" open="(" close=")" separator=",">
|
|
#{item}
|
|
</foreach>
|
|
<if test="areaId!=null">
|
|
and w.areaId=#{areaId}
|
|
</if>
|
|
<![CDATA[
|
|
and w.created <= #{endTime} and w.created >= #{startTime}
|
|
]]>
|
|
group by w.uid , w.areaid
|
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
<select id="getAssignWordsIdByAssignmentId" parameterType="java.lang.Integer" resultType="java.lang.Integer">
|
|
select distinct w.wordsid from words w inner join assigndetail ad
|
|
on w.lessonid=ad.unitid
|
|
and ad.assignmentid=#{assignmentId}
|
|
</select>
|
|
<select id="getAssignLessonIdByAssignmentId" parameterType="java.lang.Integer" resultType="java.lang.Integer">
|
|
select distinct lessonid from assigndetail
|
|
where assignmentid=#{assignmentId}
|
|
</select>
|
|
</mapper> |