571 lines
27 KiB
XML
571 lines
27 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._3e.dao.PracticeDao">
|
||
|
|
|
||
|
|
<resultMap id="gradeBookListMap" type="com._3e.http.practice.dto.ResXKWGradeBook">
|
||
|
|
<result column="grade" property="grade" />
|
||
|
|
<result column="id" property="id" />
|
||
|
|
<collection property="bookList" ofType="com._3e.http.practice.dto.XKWBook">
|
||
|
|
<result column="bookName" property="bookName"/>
|
||
|
|
<result column="bookId" property="bookId"/>
|
||
|
|
<result column="versionId" property="versionId"/>
|
||
|
|
</collection>
|
||
|
|
</resultMap>
|
||
|
|
<resultMap id="getUnitLessonMap" type="com._3e.http.practice.dto.ResXKWUnitLesson">
|
||
|
|
<result column="unitName" property="unitName" />
|
||
|
|
<result column="unitId" property="unitId" />
|
||
|
|
<collection property="lessonList" ofType="com._3e.http.practice.dto.XKWLesson">
|
||
|
|
<result column="lessonName" property="lessonName"/>
|
||
|
|
<result column="lessonId" property="lessonId"/>
|
||
|
|
</collection>
|
||
|
|
</resultMap>
|
||
|
|
|
||
|
|
<resultMap id="lessonResultMap" type="com._3e.http.practice.dto.ResXKWLesson">
|
||
|
|
<id property="lessonId" column="lessonId"/>
|
||
|
|
<result property="lessonName" column="lessonName"/>
|
||
|
|
<collection property="questionList" ofType="com._3e.http.practice.dto.ResXKWQuestion_1">
|
||
|
|
<id property="questionId" column="questionId"/>
|
||
|
|
<result property="status" column="status"/>
|
||
|
|
</collection>
|
||
|
|
</resultMap>
|
||
|
|
|
||
|
|
<resultMap id="unitResultMap" type="com._3e.http.practice.dto.ResXKWUnit">
|
||
|
|
<id property="unitId" column="unitId"/>
|
||
|
|
<result property="unitName" column="unitName"/>
|
||
|
|
<collection property="lessonList" resultMap="lessonResultMap"/>
|
||
|
|
</resultMap>
|
||
|
|
|
||
|
|
<resultMap id="ResBookMap" type="com._3e.http.practice.dto.ResXKWBook">
|
||
|
|
<id property="bookId" column="bookId"/>
|
||
|
|
<result property="bookName" column="bookName"/>
|
||
|
|
<collection property="unitList" resultMap="unitResultMap"/>
|
||
|
|
</resultMap>
|
||
|
|
<select id="getGradeAndBooksV1" resultMap="gradeBookListMap">
|
||
|
|
select CASE
|
||
|
|
WHEN b.term = 'LAST' THEN -(g.id * 10 + 1)
|
||
|
|
WHEN b.term = 'NEXT' THEN -(g.id * 10 + 2)
|
||
|
|
WHEN b.term = '' THEN -(g.id * 10 + 3)
|
||
|
|
ELSE g.id
|
||
|
|
END AS id,
|
||
|
|
CONCAT(g.name, COALESCE(CASE
|
||
|
|
WHEN b.term = 'LAST' THEN '上册'
|
||
|
|
WHEN b.term = 'NEXT' THEN '下册'
|
||
|
|
WHEN b.term in ('','ALL') THEN '全册'
|
||
|
|
ELSE b.term
|
||
|
|
END, '')) AS grade,b.name bookName,b.id AS bookId,ve.targetid AS versionId from xkw_parameter g
|
||
|
|
INNER JOIN xkw_parameter b on g.id = b.grade_id
|
||
|
|
inner join parameter b1 on b.id = b1.paraint and b1.paratype = 41
|
||
|
|
INNER JOIN xkw_parameter v on b.version_id = v.id
|
||
|
|
INNER JOIN (select CAST(sourceid AS INTEGER),targetid from Contrast where source=15 and type=7) ve on v.id = ve.sourceid
|
||
|
|
where g.paratype = 'grades' order by g.id,b.term,b.version_id,b.id
|
||
|
|
</select>
|
||
|
|
<select id="getUnitLessonByBookId" resultMap="getUnitLessonMap">
|
||
|
|
select u.id AS unitId,u.name AS unitName,l.id AS lessonId,l.name AS lessonName from xkw_parameter u left JOIN xkw_parameter l on u.id = l.parent_id
|
||
|
|
where u.textbook_id =#{bookId} and u.paratype = 'catalog' and u.parent_id = 0 order by u.ordinal,l.ordinal
|
||
|
|
</select>
|
||
|
|
<select id="getUnitLessonByBookId_1" resultMap="getUnitLessonMap">
|
||
|
|
select u.id AS unitId,u.name AS unitName,
|
||
|
|
CASE WHEN EXISTS (SELECT 1 FROM xkw_quescatalogs qcl INNER JOIN xkw_question q ON qcl.questionid = q.id
|
||
|
|
WHERE qcl.id = l.id AND q.status = 1)
|
||
|
|
THEN l.id
|
||
|
|
ELSE NULL
|
||
|
|
END AS lessonId,
|
||
|
|
CASE WHEN EXISTS (SELECT 1 FROM xkw_quescatalogs qcl INNER JOIN xkw_question q ON qcl.questionid = q.id
|
||
|
|
WHERE qcl.id = l.id AND q.status = 1)
|
||
|
|
THEN l.name
|
||
|
|
ELSE NULL
|
||
|
|
END AS lessonName
|
||
|
|
from xkw_parameter u left JOIN xkw_parameter l on u.id = l.parent_id
|
||
|
|
where u.textbook_id =#{bookId} and u.paratype = 'catalog' and u.parent_id = 0
|
||
|
|
AND (EXISTS (SELECT 1 FROM xkw_quescatalogs qcl INNER JOIN xkw_question q ON qcl.questionid = q.id
|
||
|
|
WHERE qcl.id = u.id AND q.status = 1)
|
||
|
|
OR
|
||
|
|
(l.id IS NOT NULL AND EXISTS (SELECT 1 FROM xkw_quescatalogs qcl INNER JOIN xkw_question q ON qcl.questionid = q.id
|
||
|
|
WHERE qcl.id = l.id AND q.status = 1)
|
||
|
|
)
|
||
|
|
)
|
||
|
|
order by u.ordinal,l.ordinal
|
||
|
|
</select>
|
||
|
|
<select id="getUnitLessonByBookId_delete" resultMap="getUnitLessonMap">
|
||
|
|
select u.id AS unitId,u.name AS unitName,
|
||
|
|
CASE WHEN EXISTS (SELECT 1 FROM xkw_quescatalogs qcl INNER JOIN xkw_question q ON qcl.questionid = q.id
|
||
|
|
WHERE qcl.id in(SELECT id FROM xkw_parameter WHERE (id = l.id OR parent_id = l.id) AND paratype = 'catalog') AND q.status = 1)
|
||
|
|
THEN l.id
|
||
|
|
ELSE NULL
|
||
|
|
END AS lessonId,
|
||
|
|
CASE WHEN EXISTS (SELECT 1 FROM xkw_quescatalogs qcl INNER JOIN xkw_question q ON qcl.questionid = q.id
|
||
|
|
WHERE qcl.id in(SELECT id FROM xkw_parameter WHERE (id = l.id OR parent_id = l.id) AND paratype = 'catalog') AND q.status = 1)
|
||
|
|
THEN l.name
|
||
|
|
ELSE NULL
|
||
|
|
END AS lessonName
|
||
|
|
from xkw_parameter u left JOIN xkw_parameter l on u.id = l.parent_id
|
||
|
|
where u.textbook_id = #{bookId} and u.paratype = 'catalog' and u.parent_id = 0
|
||
|
|
AND (EXISTS (SELECT 1 FROM xkw_quescatalogs qcl INNER JOIN xkw_question q ON qcl.questionid = q.id
|
||
|
|
WHERE qcl.id = u.id AND q.status = 1)
|
||
|
|
OR
|
||
|
|
(l.id IS NOT NULL AND EXISTS (SELECT 1 FROM xkw_quescatalogs qcl INNER JOIN xkw_question q ON qcl.questionid = q.id
|
||
|
|
WHERE qcl.id in(SELECT id FROM xkw_parameter WHERE (id = l.id OR parent_id = l.id) AND paratype = 'catalog') AND q.status = 1)
|
||
|
|
)
|
||
|
|
)
|
||
|
|
order by u.ordinal,l.ordinal
|
||
|
|
</select>
|
||
|
|
<select id="getUnitLessonByBookId_2" resultMap="getUnitLessonMap">
|
||
|
|
WITH CatalogQuestions AS (
|
||
|
|
SELECT DISTINCT qc.id
|
||
|
|
FROM xkw_quescatalogs qc
|
||
|
|
INNER JOIN xkw_question q ON qc.questionid = q.id
|
||
|
|
WHERE q.status = 1
|
||
|
|
),
|
||
|
|
ValidCatalogs AS (
|
||
|
|
SELECT DISTINCT
|
||
|
|
p.id AS original_id,
|
||
|
|
p2.id AS valid_catalog_id
|
||
|
|
FROM xkw_parameter p
|
||
|
|
INNER JOIN xkw_parameter p2 ON (p2.id = p.id OR p2.parent_id = p.id)
|
||
|
|
WHERE p.paratype = 'catalog'
|
||
|
|
),
|
||
|
|
UnitValidLessons AS (
|
||
|
|
SELECT DISTINCT
|
||
|
|
u.id AS unit_id,
|
||
|
|
CASE
|
||
|
|
WHEN EXISTS (SELECT 1 FROM ValidCatalogs vc
|
||
|
|
INNER JOIN CatalogQuestions cq ON vc.valid_catalog_id = cq.id
|
||
|
|
WHERE vc.original_id = l.id)
|
||
|
|
THEN l.id
|
||
|
|
END AS lesson_id
|
||
|
|
FROM xkw_parameter u
|
||
|
|
LEFT JOIN xkw_parameter l ON u.id = l.parent_id AND l.paratype = 'catalog'
|
||
|
|
WHERE u.textbook_id = #{bookId}
|
||
|
|
AND u.paratype = 'catalog'
|
||
|
|
AND u.parent_id = 0
|
||
|
|
AND (
|
||
|
|
EXISTS (SELECT 1 FROM CatalogQuestions cq WHERE cq.id = u.id)
|
||
|
|
OR
|
||
|
|
EXISTS (SELECT 1 FROM ValidCatalogs vc
|
||
|
|
INNER JOIN CatalogQuestions cq ON vc.valid_catalog_id = cq.id
|
||
|
|
WHERE vc.original_id = l.id)
|
||
|
|
)
|
||
|
|
)
|
||
|
|
SELECT
|
||
|
|
u.id AS unitId,
|
||
|
|
u.name AS unitName,
|
||
|
|
uvl.lesson_id AS lessonId,
|
||
|
|
CASE WHEN uvl.lesson_id IS NOT NULL THEN l.name END AS lessonName
|
||
|
|
FROM xkw_parameter u
|
||
|
|
INNER JOIN UnitValidLessons uvl ON u.id = uvl.unit_id
|
||
|
|
LEFT JOIN xkw_parameter l ON uvl.lesson_id = l.id
|
||
|
|
ORDER BY u.ordinal, l.ordinal;
|
||
|
|
</select>
|
||
|
|
|
||
|
|
|
||
|
|
<select id="getAllQuestionByUnitIdOrLessonId" resultType="com._3e.http.practice.dto.XKWQuestion">
|
||
|
|
select q.* from xkw_quescatalogs qcl INNER JOIN xkw_question q on qcl.questionid = q.id
|
||
|
|
where qcl.id = #{id} and q.status = 1
|
||
|
|
</select>
|
||
|
|
<select id="getAllQuestionByUnitIdOrLessonId_1" resultType="com._3e.http.practice.dto.XKWQuestion">
|
||
|
|
SELECT DISTINCT q.*
|
||
|
|
FROM xkw_quescatalogs qcl
|
||
|
|
INNER JOIN xkw_question q ON qcl.questionid = q.id
|
||
|
|
WHERE qcl.id IN (
|
||
|
|
SELECT id FROM xkw_parameter
|
||
|
|
WHERE (id = #{id} OR parent_id = #{id})
|
||
|
|
AND paratype = 'catalog'
|
||
|
|
)
|
||
|
|
AND q.status = 1
|
||
|
|
</select>
|
||
|
|
<select id="getHearingAndReadByUnitIdOrLessonId" resultType="com._3e.http.practice.dto.HearAndReadQuestion">
|
||
|
|
select p.paraint AS paraInt,TO_CHAR(p.paraint,'FM99999') AS pointIds ,q.* from xkw_quescatalogs qcl INNER JOIN xkw_question q on qcl.questionid = q.id
|
||
|
|
inner join parameter p on q.type_id = p.valueint and p.paratype = 37 and p.status = 1
|
||
|
|
where qcl.id = #{id} and q.status = 1
|
||
|
|
</select>
|
||
|
|
<select id="getHearingAndReadByUnitIdOrLessonId_1" resultType="com._3e.http.practice.dto.HearAndReadQuestion">
|
||
|
|
with temp AS(
|
||
|
|
select DISTINCT qcl.questionId from xkw_quescatalogs qcl where qcl.id IN (
|
||
|
|
SELECT id FROM xkw_parameter
|
||
|
|
WHERE (id = #{id} OR parent_id = #{id})
|
||
|
|
AND paratype = 'catalog')
|
||
|
|
)
|
||
|
|
select p.paraint AS paraInt,TO_CHAR(p.paraint,'FM99999') AS pointIds ,q.* from temp t INNER JOIN xkw_question q on t.questionid = q.id
|
||
|
|
inner join parameter p on q.type_id = p.valueint and p.paratype = 37 and p.status = 1
|
||
|
|
where q.status = 1
|
||
|
|
</select>
|
||
|
|
<select id="getHearingAndReadByUnitIdOrLessonIdAndAnswer" resultType="com._3e.http.practice.dto.ResQuestionAnswer">
|
||
|
|
select q.id AS questionId,
|
||
|
|
ROW_NUMBER() OVER (ORDER BY q.created desc) AS orderId,
|
||
|
|
COALESCE(l.isRight, 0) AS isRight,
|
||
|
|
CASE WHEN l.isRight IS NULL THEN 0 ELSE 1 END AS isDone from xkw_quescatalogs qcl INNER JOIN xkw_question q on qcl.questionid = q.id
|
||
|
|
inner join parameter p on q.type_id = p.valueint and p.paratype = 37 and p.status = 1 and p.paraint = #{pointId}
|
||
|
|
left join xkw_lastanswer l on q.id = l.questionId and l.uid = #{uid}
|
||
|
|
where qcl.id = #{id} and q.status = 1
|
||
|
|
</select>
|
||
|
|
<select id="getHearingAndReadByUnitIdOrLessonIdAndAnswer_1" resultType="com._3e.http.practice.dto.ResQuestionAnswer">
|
||
|
|
with temp AS(
|
||
|
|
select DISTINCT qcl.questionId from xkw_quescatalogs qcl where qcl.id IN (
|
||
|
|
SELECT id FROM xkw_parameter
|
||
|
|
WHERE (id = #{id} OR parent_id = #{id})
|
||
|
|
AND paratype = 'catalog')
|
||
|
|
)
|
||
|
|
select q.id AS questionId,
|
||
|
|
ROW_NUMBER() OVER (ORDER BY q.created desc) AS orderId,
|
||
|
|
COALESCE(l.isRight, 0) AS isRight,
|
||
|
|
CASE WHEN l.isRight IS NULL THEN 0 ELSE 1 END AS isDone from temp qcl INNER JOIN xkw_question q on qcl.questionid = q.id
|
||
|
|
inner join parameter p on q.type_id = p.valueint and p.paratype = 37 and p.status = 1 and p.paraint = #{pointId}
|
||
|
|
left join xkw_lastanswer l on q.id = l.questionId and l.uid = #{uid}
|
||
|
|
where q.status = 1
|
||
|
|
</select>
|
||
|
|
<select id="getHearingAndReadByUnitIdOrLessonId_student" resultType="com._3e.http.practice.dto.HearAndReadQuestion">
|
||
|
|
select CASE
|
||
|
|
WHEN l.questionId IS NOT NULL THEN 1
|
||
|
|
ELSE 0
|
||
|
|
END AS isDone,p.paraint AS paraInt,TO_CHAR(p.paraint,'FM99999') AS pointIds ,q.* from xkw_quescatalogs qcl INNER JOIN xkw_question q on qcl.questionid = q.id
|
||
|
|
inner join parameter p on q.type_id = p.valueint and p.paratype = 37 and p.status = 1
|
||
|
|
LEFT JOIN xkw_lastanswer l on q.id = l.questionid and l.uid = #{uid}
|
||
|
|
where qcl.id = #{id} and q.status = 1
|
||
|
|
</select>
|
||
|
|
<select id="getHearingAndReadByUnitIdOrLessonId_student_1" resultType="com._3e.http.practice.dto.HearAndReadQuestion">
|
||
|
|
with temp As (
|
||
|
|
select DISTINCT questionId from xkw_quescatalogs where id IN (
|
||
|
|
SELECT id FROM xkw_parameter
|
||
|
|
WHERE (id = #{id} OR parent_id = #{id})
|
||
|
|
AND paratype = 'catalog'
|
||
|
|
) )
|
||
|
|
select CASE
|
||
|
|
WHEN l.questionId IS NOT NULL THEN 1
|
||
|
|
ELSE 0
|
||
|
|
END AS isDone,p.paraint AS paraInt,TO_CHAR(p.paraint,'FM99999') AS pointIds ,q.*
|
||
|
|
from temp qcl INNER JOIN xkw_question q on qcl.questionid = q.id
|
||
|
|
inner join parameter p on q.type_id = p.valueint and p.paratype = 37 and p.status = 1
|
||
|
|
LEFT JOIN xkw_lastanswer l on q.id = l.questionid and l.uid = #{uid}
|
||
|
|
where q.status = 1
|
||
|
|
</select>
|
||
|
|
<select id="getPointByIds" resultType="com._3e.http.practice.dto.ResQuestion">
|
||
|
|
WITH RECURSIVE hierarchy AS (
|
||
|
|
SELECT qt.id AS questionId,qt.assignTime,p.id,p.parent_id,p.depth
|
||
|
|
FROM xkw_question qt INNER JOIN xkw_queskpoints q on qt.id = q.questionid inner JOIN xkw_parameter p ON q.id = p.id
|
||
|
|
WHERE p.paratype = 'knowledge-points' and qt.status = 1 and
|
||
|
|
qt.id IN
|
||
|
|
<foreach item="id" index="index" collection="ids" open="(" separator="," close=")">
|
||
|
|
#{id}
|
||
|
|
</foreach>
|
||
|
|
UNION ALL
|
||
|
|
SELECT
|
||
|
|
h.questionId,h.assignTime,p.id,p.parent_id,p.depth FROM xkw_parameter p INNER JOIN hierarchy h ON h.parent_id = p.id
|
||
|
|
WHERE h.parent_id != 0 AND p.paratype = 'knowledge-points'
|
||
|
|
),
|
||
|
|
temp1 As(
|
||
|
|
SELECT h.questionId,h.assignTime,STRING_AGG(CAST(x.id AS TEXT), ',') AS pointIds -- 这里使用GROUP_CONCAT来合并x.id
|
||
|
|
FROM xkw_parameter x
|
||
|
|
JOIN (SELECT questionId, assignTime, id FROM hierarchy WHERE parent_id = 0 AND depth = 1) AS h ON x.id = h.id
|
||
|
|
WHERE x.paratype = 'knowledge-points'
|
||
|
|
GROUP BY h.questionId, h.assignTime )
|
||
|
|
SELECT h.questionId,h.assignTime,x.id,x.name,temp1.pointIds FROM xkw_parameter x JOIN (SELECT questionId,assignTime,id FROM hierarchy WHERE parent_id = 0 AND depth = 1 group by questionId,assignTime,id) AS h ON x.id = h.id
|
||
|
|
INNER JOIN temp1 on h.questionId = temp1.questionId
|
||
|
|
where x.paratype = 'knowledge-points'
|
||
|
|
order by x.ordinal
|
||
|
|
</select>
|
||
|
|
<select id="getPointByIds_student" resultType="com._3e.http.practice.dto.ResQuestion_1">
|
||
|
|
WITH RECURSIVE hierarchy AS (
|
||
|
|
SELECT qt.id AS questionId,qt.assignTime,p.id,p.parent_id,p.depth
|
||
|
|
FROM xkw_question qt INNER JOIN xkw_queskpoints q on qt.id = q.questionid inner JOIN xkw_parameter p ON q.id = p.id
|
||
|
|
WHERE p.paratype = 'knowledge-points' and qt.status = 1 and
|
||
|
|
qt.id IN
|
||
|
|
<foreach item="id" index="index" collection="ids" open="(" separator="," close=")">
|
||
|
|
#{id}
|
||
|
|
</foreach>
|
||
|
|
UNION ALL
|
||
|
|
SELECT
|
||
|
|
h.questionId,h.assignTime,p.id,p.parent_id,p.depth FROM xkw_parameter p INNER JOIN hierarchy h ON h.parent_id = p.id
|
||
|
|
WHERE h.parent_id != 0 AND p.paratype = 'knowledge-points'
|
||
|
|
),
|
||
|
|
temp1 As(
|
||
|
|
SELECT h.questionId,h.assignTime,STRING_AGG(CAST(x.id AS TEXT), ',') AS pointIds -- 这里使用GROUP_CONCAT来合并x.id
|
||
|
|
FROM xkw_parameter x
|
||
|
|
JOIN (SELECT questionId, assignTime, id FROM hierarchy WHERE parent_id = 0 AND depth = 1) AS h ON x.id = h.id
|
||
|
|
WHERE x.paratype = 'knowledge-points'
|
||
|
|
GROUP BY h.questionId, h.assignTime )
|
||
|
|
SELECT CASE
|
||
|
|
WHEN l.questionId IS NOT NULL THEN 1
|
||
|
|
ELSE 0
|
||
|
|
END AS isDone,h.questionId,h.assignTime,x.id,x.name,temp1.pointIds FROM xkw_parameter x JOIN (SELECT questionId,assignTime,id FROM hierarchy WHERE parent_id = 0 AND depth = 1 group by questionId,assignTime,id) AS h ON x.id = h.id
|
||
|
|
INNER JOIN temp1 on h.questionId = temp1.questionId
|
||
|
|
LEFT JOIN xkw_lastanswer l on temp1.questionId = l.questionid and l.uid = #{uid}
|
||
|
|
where x.paratype = 'knowledge-points'
|
||
|
|
order by x.ordinal
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="getAllQuestionType" resultType="com._3e.http.practice.dto.ResQuestionType">
|
||
|
|
select p.id AS typeId,p.name AS typeName from xkw_quescatalogs qcl INNER JOIN xkw_question q on qcl.questionid = q.id inner join xkw_parameter p on q.type_id = p.id and p.paratype = 'question-types'
|
||
|
|
where qcl.id = #{id} and q.status = 1 group by p.id,p.name
|
||
|
|
</select>
|
||
|
|
<select id="getAllQuestionType_1" resultType="com._3e.http.practice.dto.ResQuestionType">
|
||
|
|
select p.id AS typeId,p.name AS typeName from xkw_quescatalogs qcl INNER JOIN xkw_question q on qcl.questionid = q.id inner join xkw_parameter p on q.type_id = p.id and p.paratype = 'question-types'
|
||
|
|
where qcl.id IN (
|
||
|
|
SELECT id FROM xkw_parameter
|
||
|
|
WHERE (id = #{id} OR parent_id = #{id})
|
||
|
|
AND paratype = 'catalog'
|
||
|
|
) and q.status = 1 group by p.id,p.name
|
||
|
|
</select>
|
||
|
|
<select id="getAllDifficulty" resultType="com._3e.http.practice.dto.ResQuestionDifficulty">
|
||
|
|
select q.difficulty_level AS difficultyId,
|
||
|
|
CASE q.difficulty_level
|
||
|
|
WHEN 17 THEN '容易'
|
||
|
|
WHEN 18 THEN '较易'
|
||
|
|
WHEN 19 THEN '一般'
|
||
|
|
WHEN 20 THEN '较难'
|
||
|
|
WHEN 21 THEN '困难'
|
||
|
|
ELSE '未知难度'
|
||
|
|
END AS difficultyName
|
||
|
|
from xkw_quescatalogs qcl INNER JOIN xkw_question q on qcl.questionid = q.id
|
||
|
|
where qcl.id = #{id} and q.status = 1 group by q.difficulty_level
|
||
|
|
</select>
|
||
|
|
<select id="getAllDifficulty_1" resultType="com._3e.http.practice.dto.ResQuestionDifficulty">
|
||
|
|
select q.difficulty_level AS difficultyId,
|
||
|
|
CASE q.difficulty_level
|
||
|
|
WHEN 17 THEN '容易'
|
||
|
|
WHEN 18 THEN '较易'
|
||
|
|
WHEN 19 THEN '一般'
|
||
|
|
WHEN 20 THEN '较难'
|
||
|
|
WHEN 21 THEN '困难'
|
||
|
|
ELSE '未知难度'
|
||
|
|
END AS difficultyName
|
||
|
|
from xkw_quescatalogs qcl INNER JOIN xkw_question q on qcl.questionid = q.id
|
||
|
|
where qcl.id IN (
|
||
|
|
SELECT id FROM xkw_parameter
|
||
|
|
WHERE (id = #{id} OR parent_id = #{id})
|
||
|
|
AND paratype = 'catalog'
|
||
|
|
) and q.status = 1 group by q.difficulty_level
|
||
|
|
</select>
|
||
|
|
<select id="getAllQuestionByTypeIdAndDifficultyId" resultType="java.lang.String">
|
||
|
|
select q.id from xkw_quescatalogs qcl INNER JOIN xkw_question q on qcl.questionid = q.id
|
||
|
|
where qcl.id = #{id} and q.status = 1
|
||
|
|
<if test="difficultyId != 0">
|
||
|
|
and q.difficulty_level = #{difficultyId}
|
||
|
|
</if>
|
||
|
|
<if test="typeId != 0">
|
||
|
|
and q.type_id = #{typeId}
|
||
|
|
</if>
|
||
|
|
<if test="alreadyArranged == 0">
|
||
|
|
AND NOT EXISTS (
|
||
|
|
SELECT 1
|
||
|
|
FROM xkw_assignment a
|
||
|
|
INNER JOIN xkw_assigndetail ad ON a.assignmentId = ad.assignmentId
|
||
|
|
WHERE a.teacherId = #{uid}
|
||
|
|
AND ad.questionId = q.id
|
||
|
|
)
|
||
|
|
</if>
|
||
|
|
<if test="alreadyArranged == 1">
|
||
|
|
AND EXISTS (
|
||
|
|
SELECT 1
|
||
|
|
FROM xkw_assignment a
|
||
|
|
INNER JOIN xkw_assigndetail ad ON a.assignmentId = ad.assignmentId
|
||
|
|
WHERE a.teacherId = #{uid}
|
||
|
|
AND ad.questionId = q.id
|
||
|
|
)
|
||
|
|
</if>
|
||
|
|
group by q.id
|
||
|
|
</select>
|
||
|
|
<select id="getAllQuestionByTypeIdAndDifficultyId_1" resultType="java.lang.String">
|
||
|
|
select DISTINCT q.id from xkw_quescatalogs qcl INNER JOIN xkw_question q on qcl.questionid = q.id
|
||
|
|
where qcl.id IN (
|
||
|
|
SELECT id FROM xkw_parameter
|
||
|
|
WHERE (id = #{id} OR parent_id = #{id})
|
||
|
|
AND paratype = 'catalog'
|
||
|
|
) and q.status = 1
|
||
|
|
<if test="difficultyId != 0">
|
||
|
|
and q.difficulty_level = #{difficultyId}
|
||
|
|
</if>
|
||
|
|
<if test="typeId != 0">
|
||
|
|
and q.type_id = #{typeId}
|
||
|
|
</if>
|
||
|
|
<if test="alreadyArranged == 0">
|
||
|
|
AND NOT EXISTS (
|
||
|
|
SELECT 1
|
||
|
|
FROM xkw_assignment a
|
||
|
|
INNER JOIN xkw_assigndetail ad ON a.assignmentId = ad.assignmentId
|
||
|
|
WHERE a.teacherId = #{uid}
|
||
|
|
AND ad.questionId = q.id
|
||
|
|
)
|
||
|
|
</if>
|
||
|
|
<if test="alreadyArranged == 1">
|
||
|
|
AND EXISTS (
|
||
|
|
SELECT 1
|
||
|
|
FROM xkw_assignment a
|
||
|
|
INNER JOIN xkw_assigndetail ad ON a.assignmentId = ad.assignmentId
|
||
|
|
WHERE a.teacherId = #{uid}
|
||
|
|
AND ad.questionId = q.id
|
||
|
|
)
|
||
|
|
</if>
|
||
|
|
group by q.id
|
||
|
|
</select>
|
||
|
|
<select id="getQuestionById" resultType="com._3e.http.practice.dto.ResXKWQuestion">
|
||
|
|
select * from xkw_question where id = #{id}
|
||
|
|
</select>
|
||
|
|
<select id="getHearingAndReadByQuestionId" resultType="com._3e.http.practice.dto.HearAndReadQuestion">
|
||
|
|
select p.paraint AS paraInt ,q.* from xkw_question q
|
||
|
|
inner join parameter p on q.type_id = p.valueint and p.paratype = 37 and p.status = 1
|
||
|
|
where q.id = #{id} and q.status = 1
|
||
|
|
</select>
|
||
|
|
<select id="getPointByQuestionId" resultType="java.lang.Integer">
|
||
|
|
WITH RECURSIVE hierarchy AS (
|
||
|
|
SELECT qt.id AS questionId,qt.assignTime,p.id,p.parent_id,p.depth
|
||
|
|
FROM xkw_question qt INNER JOIN xkw_queskpoints q on qt.id = q.questionid inner JOIN xkw_parameter p ON q.id = p.id
|
||
|
|
WHERE p.paratype = 'knowledge-points' and qt.status = 1 and
|
||
|
|
qt.id = #{id}
|
||
|
|
UNION ALL
|
||
|
|
SELECT
|
||
|
|
h.questionId,h.assignTime,p.id,p.parent_id,p.depth FROM xkw_parameter p INNER JOIN hierarchy h ON h.parent_id = p.id
|
||
|
|
WHERE h.parent_id != 0 AND p.paratype = 'knowledge-points'
|
||
|
|
)
|
||
|
|
SELECT
|
||
|
|
x.id FROM xkw_parameter x JOIN (SELECT questionId,assignTime,id FROM hierarchy WHERE parent_id = 0 AND depth = 1 group by questionId,assignTime,id) AS h ON x.id = h.id
|
||
|
|
where x.paratype = 'knowledge-points'
|
||
|
|
order by x.ordinal
|
||
|
|
</select>
|
||
|
|
<select id="getXKWAssignCountByQuestionId" resultType="java.lang.Integer">
|
||
|
|
select count(1) from xkw_assigndetail where questionId = #{id}
|
||
|
|
</select>
|
||
|
|
<select id="getAllQuestionByUnitIdOrLessonIdAndPointId" resultType="com._3e.http.practice.dto.ResQuestionAnswer">
|
||
|
|
WITH RECURSIVE hierarchy AS (
|
||
|
|
SELECT qt.id AS questionId,qt.assignTime,p.id,p.parent_id,p.depth
|
||
|
|
FROM xkw_quescatalogs qcl INNER JOIN xkw_question qt on qcl.questionId = qt.id INNER JOIN xkw_queskpoints q on qt.id = q.questionid inner JOIN xkw_parameter p ON q.id = p.id
|
||
|
|
WHERE qcl.id = #{id} and p.paratype = 'knowledge-points' and qt.status = 1
|
||
|
|
UNION ALL
|
||
|
|
SELECT
|
||
|
|
h.questionId,h.assignTime,p.id,p.parent_id,p.depth FROM xkw_parameter p INNER JOIN hierarchy h ON h.parent_id = p.id
|
||
|
|
WHERE h.parent_id != 0 AND p.paratype = 'knowledge-points'
|
||
|
|
)
|
||
|
|
SELECT
|
||
|
|
q.id AS questionId,
|
||
|
|
ROW_NUMBER() OVER (ORDER BY q.created desc) AS orderId,
|
||
|
|
COALESCE(l.isRight, 0) AS isRight,
|
||
|
|
CASE WHEN l.isRight IS NULL THEN 0 ELSE 1 END AS isDone
|
||
|
|
FROM xkw_parameter x JOIN (SELECT questionId,assignTime,id FROM hierarchy WHERE parent_id = 0 AND depth = 1 group by questionId,assignTime,id) AS h ON x.id = h.id
|
||
|
|
INNER JOIN xkw_question q on h.questionId = q.id
|
||
|
|
left join xkw_lastanswer l on q.id = l.questionId and l.uid = #{uid}
|
||
|
|
where x.paratype = 'knowledge-points' and x.id = #{pointId} and q.status = 1
|
||
|
|
order by q.created desc
|
||
|
|
</select>
|
||
|
|
<select id="getAllQuestionByUnitIdOrLessonIdAndPointId_1" resultType="com._3e.http.practice.dto.ResQuestionAnswer">
|
||
|
|
WITH RECURSIVE hierarchy AS (
|
||
|
|
SELECT qt.id AS questionId,qt.assignTime,p.id,p.parent_id,p.depth
|
||
|
|
FROM (select DISTINCT qcl.questionId from xkw_quescatalogs qcl where qcl.id IN (
|
||
|
|
SELECT id FROM xkw_parameter
|
||
|
|
WHERE (id = #{id} OR parent_id = #{id})
|
||
|
|
AND paratype = 'catalog')
|
||
|
|
) qcl INNER JOIN xkw_question qt on qcl.questionId = qt.id INNER JOIN xkw_queskpoints q on qt.id = q.questionid inner JOIN xkw_parameter p ON q.id = p.id
|
||
|
|
WHERE p.paratype = 'knowledge-points' and qt.status = 1
|
||
|
|
UNION ALL
|
||
|
|
SELECT
|
||
|
|
h.questionId,h.assignTime,p.id,p.parent_id,p.depth FROM xkw_parameter p INNER JOIN hierarchy h ON h.parent_id = p.id
|
||
|
|
WHERE h.parent_id != 0 AND p.paratype = 'knowledge-points'
|
||
|
|
)
|
||
|
|
SELECT
|
||
|
|
q.id AS questionId,
|
||
|
|
ROW_NUMBER() OVER (ORDER BY q.created desc) AS orderId,
|
||
|
|
COALESCE(l.isRight, 0) AS isRight,
|
||
|
|
CASE WHEN l.isRight IS NULL THEN 0 ELSE 1 END AS isDone
|
||
|
|
FROM xkw_parameter x JOIN (SELECT questionId,assignTime,id FROM hierarchy WHERE parent_id = 0 AND depth = 1 group by questionId,assignTime,id) AS h ON x.id = h.id
|
||
|
|
INNER JOIN xkw_question q on h.questionId = q.id
|
||
|
|
left join xkw_lastanswer l on q.id = l.questionId and l.uid = #{uid}
|
||
|
|
where x.paratype = 'knowledge-points' and x.id = #{pointId} and q.status = 1
|
||
|
|
order by q.created desc
|
||
|
|
|
||
|
|
</select>
|
||
|
|
<select id="getWrongBookByTime" resultType="com._3e.http.practice.dto.ResQuestionBookUnitLesson">
|
||
|
|
select bookId,unitId,lessonId,questionId,a.status from (
|
||
|
|
select * ,row_number() OVER (PARTITION BY uid,bookId,unitId,lessonId,questionId ORDER BY created DESC ) AS rn
|
||
|
|
from xkw_wrongbook where uid =#{uid} and status = #{status} and created between #{startTime} and #{endTime}) a
|
||
|
|
INNER JOIN xkw_question q on a.questionId = q.id and q.status = 1
|
||
|
|
where a.rn = 1 order by a.created desc
|
||
|
|
</select>
|
||
|
|
<select id="getAllWrongBook" resultMap="ResBookMap">
|
||
|
|
select b.id AS bookId,b.name AS bookName,u.id AS unitId,u.name AS unitName,
|
||
|
|
COALESCE(l.id, 0) AS lessonId,
|
||
|
|
COALESCE(l.name, '') AS lessonName,w.questionId,w.status from xkw_wrongbook w
|
||
|
|
INNER JOIN xkw_question q on w.questionId = q.id and q.status = 1
|
||
|
|
INNER JOIN xkw_parameter b on w.bookId = b.id and b.paraType = 'textbooks'
|
||
|
|
INNER JOIN xkw_parameter u on w.unitId = u.id and u.paratype = 'catalog'
|
||
|
|
left JOIN xkw_parameter l on w.lessonId = l.id and l.paratype = 'catalog'
|
||
|
|
where w.uid = #{uid}
|
||
|
|
</select>
|
||
|
|
<select id="getMyPracticeAssignGrades" resultType="com._3e.http.practice.dto.ResMyPracticeGrade">
|
||
|
|
select fa.*,a.endtime AS assignEndTime from finishxkw_assignstat fa inner join xkw_assignment a on fa.assignmentId = a.assignmentId
|
||
|
|
where fa.uid = #{uid} and fa.areaId = #{areaId} and fa.created between #{startTime} and #{endTime} and a.status = 1 order by fa.created desc
|
||
|
|
<if test="page != null">
|
||
|
|
LIMIT #{page.limit} OFFSET #{page.offset}
|
||
|
|
</if>
|
||
|
|
</select>
|
||
|
|
<select id="getMyPracticeOwnGrades" resultType="com._3e.http.practice.dto.ResMyPracticeGrade">
|
||
|
|
WITH ranked_answers AS (
|
||
|
|
SELECT
|
||
|
|
DATE(created) AS day,bookid,unitid,lessonid,questionid,isright,created,
|
||
|
|
ROW_NUMBER() OVER (PARTITION BY DATE(created), bookid, unitid, lessonid, questionid ORDER BY created DESC) AS rn
|
||
|
|
FROM xkw_answer
|
||
|
|
where uid = #{uid} and areaId = #{areaId} and created BETWEEN #{startTime} and #{endTime}
|
||
|
|
)
|
||
|
|
SELECT
|
||
|
|
ra.day AS created, ra.bookId,b.name AS bookName, ra.unitId,u.name AS unitName,
|
||
|
|
COALESCE(ra.lessonId, 0) AS lessonId,
|
||
|
|
COALESCE(l.name, '') AS lessonName,
|
||
|
|
COUNT(*) FILTER (WHERE isright = 1) AS rightCount,COUNT(*) FILTER (WHERE isright = 0) AS wrongCount
|
||
|
|
FROM ranked_answers ra
|
||
|
|
INNER JOIN xkw_parameter b on ra.bookId = b.id and b.paraType = 'textbooks'
|
||
|
|
INNER JOIN xkw_parameter u on ra.unitId = u.id and u.paratype = 'catalog'
|
||
|
|
left JOIN xkw_parameter l on ra.lessonId = l.id and l.paratype = 'catalog'
|
||
|
|
WHERE ra.rn = 1
|
||
|
|
GROUP BY ra.day,ra.bookId, b.name,ra.unitId,u.name, ra.lessonId,l.name
|
||
|
|
ORDER BY ra.day DESC
|
||
|
|
<if test="page != null">
|
||
|
|
LIMIT #{page.limit} OFFSET #{page.offset}
|
||
|
|
</if>
|
||
|
|
</select>
|
||
|
|
<select id="getXKWWrongBookAnswerList" resultType="com._3e.http.practice.dto.ResWrongBookAnswer">
|
||
|
|
select w.questionId,w.status from xkw_wrongbook w
|
||
|
|
INNER JOIN xkw_question q on w.questionId = q.id and q.status = 1
|
||
|
|
where w.uid = #{uid} and w.bookId = #{bookId} and w.unitId = #{unitId} and w.lessonId = #{lessonId} order by w.created desc
|
||
|
|
</select>
|
||
|
|
<select id="getXKWMyGradeWrongBookAnswerList" resultType="com._3e.http.practice.dto.ResWrongBookAnswer">
|
||
|
|
select wb.questionId,wb.status from xkw_assignanswer aa inner join xkw_wrongbook wb on aa.questionId = wb.questionId
|
||
|
|
and wb.uid = #{uid} and wb.bookId = #{bookId} and wb.unitId = #{unitId} and wb.lessonId = #{lessonId}
|
||
|
|
where aa.uid = #{uid} and aa.assignmentId = #{assignmentId} and aa.isRight = #{isRight}
|
||
|
|
group by wb.questionId,wb.status
|
||
|
|
</select>
|
||
|
|
<select id="getXKWMyGradeWrongBookAnswerList_1" resultType="com._3e.http.practice.dto.ResWrongBookAnswer">
|
||
|
|
WITH ranked_answers AS (
|
||
|
|
SELECT
|
||
|
|
DATE(created) AS day,bookid,unitid,lessonid,questionid,isright,created,
|
||
|
|
ROW_NUMBER() OVER (PARTITION BY DATE(created), bookid, unitid, lessonid, questionid ORDER BY created DESC) AS rn
|
||
|
|
FROM xkw_answer
|
||
|
|
where uid = #{uid} and areaId = #{areaId} and TO_CHAR(DATE(created), 'YYYY-MM-DD') = #{created}
|
||
|
|
),
|
||
|
|
temp2 AS(
|
||
|
|
select questionId,isRight AS status from ranked_answers
|
||
|
|
where rn=1 and isRight = #{isRight})
|
||
|
|
select w.questionId,w.status from temp2 t inner join xkw_wrongbook w on t.questionId = w.questionId and w.uid = #{uid} and w.bookId = #{bookId} and w.unitId = #{unitId} and w.lessonId = #{lessonId}
|
||
|
|
group by w.questionId,w.status
|
||
|
|
</select>
|
||
|
|
<select id="getXKWMyGradeDayAnswerList" resultType="com._3e.http.practice.dto.ResQuestionAnswer_1">
|
||
|
|
WITH ranked_answers AS (
|
||
|
|
SELECT
|
||
|
|
DATE(created) AS day,bookid,unitid,lessonid,questionid,isright,created,answer,
|
||
|
|
ROW_NUMBER() OVER (PARTITION BY DATE(created), bookid, unitid, lessonid, questionid ORDER BY created DESC) AS rn
|
||
|
|
FROM xkw_answer
|
||
|
|
where uid = #{uid} and areaId = #{areaId} and TO_CHAR(DATE(created), 'YYYY-MM-DD') = #{created}
|
||
|
|
)
|
||
|
|
select questionId,isRight,answer AS userAnswer from ranked_answers
|
||
|
|
where rn=1
|
||
|
|
</select>
|
||
|
|
<select id="getXKWParameterById" resultType="int">
|
||
|
|
select parent_id from xkw_parameter where id = #{id} and paratype = 'catalog'
|
||
|
|
</select>
|
||
|
|
<select id="findXKWAssignAnaly" resultType="com._3e.http.practice.dto.XKWAssignAnaly">
|
||
|
|
select * from xkw_assignanaly where classesId = #{classesId} and assignmentId = #{assignmentId}
|
||
|
|
</select>
|
||
|
|
<select id="getXKWQuestionByQuestionId" resultType="com._3e.http.practice.dto.ResXKWQuestionAndAnswers">
|
||
|
|
select * from xkw_question where id = #{questionId}
|
||
|
|
</select>
|
||
|
|
|
||
|
|
|
||
|
|
</mapper>
|