| | |
| | | GROUP BY user_id) d ON a.user_id = d.user_id |
| | | </select> |
| | | |
| | | <insert id="insertDefault"> |
| | | INSERT INTO t_exam_paper_answer(exam_paper_id, paper_name, paper_type, system_score, user_score, paper_score, question_correct, question_count, do_time, status, |
| | | create_user, create_time, invalid) |
| | | SELECT |
| | | a.id, a.name, a.paper_type, 0, 0, a.score, 0, a.question_count, 0, 2, b.user_id, NOW(), 0 |
| | | FROM t_exam_paper a |
| | | left join t_exam_paper_user b on a.id = b.exam_paper_id and b.deleted = 0 |
| | | left join t_exam_paper_answer c on a.id = c.exam_paper_id and c.create_user = b.user_id |
| | | WHERE a.id = #{examPaperId} |
| | | and c.id is null |
| | | and b.user_id not in |
| | | <foreach collection="userIds" item="item" open="(" close=")" separator=","> |
| | | #{item} |
| | | </foreach> |
| | | </insert> |
| | | <insert id="insertDefault"> |
| | | INSERT INTO t_exam_paper_answer(exam_paper_id, paper_name, paper_type, system_score, user_score, paper_score, question_correct, question_count, do_time, status, |
| | | create_user, create_time, invalid) |
| | | SELECT |
| | | a.id, a.name, a.paper_type, 0, 0, a.score, 0, a.question_count, 0, 2, b.user_id, NOW(), 0 |
| | | FROM t_exam_paper a |
| | | left join t_exam_paper_user b on a.id = b.exam_paper_id and b.deleted = 0 |
| | | left join t_exam_paper_answer c on a.id = c.exam_paper_id and c.create_user = b.user_id |
| | | WHERE a.id = #{examPaperId} |
| | | and c.id is null |
| | | and b.user_id not in |
| | | <foreach collection="userIds" item="item" open="(" close=")" separator=","> |
| | | #{item} |
| | | </foreach> |
| | | </insert> |
| | | |
| | | <select id="dataByTemplate" resultType="java.util.Map" parameterType="com.mindskip.xzs.domain.vo.ExamPaperDataVO"> |
| | | SELECT |
| | | a.id, |
| | | a.name, |
| | | COUNT(DISTINCT c.create_user) as factPeopleTotal, -- 参考人数 |
| | | IFNULL(ROUND(AVG(c.user_score), 2), 0) as averageScore, -- 平均成绩 |
| | | IFNULL(ROUND((COUNT(DISTINCT c.create_user) * 100.0 / COUNT(DISTINCT d.user_id)), 2), 0) AS referencePercentage -- 参考百分比 |
| | | FROM |
| | | t_department a |
| | | LEFT JOIN t_user_department b ON a.id = b.department_id |
| | | LEFT JOIN t_exam_templates_user d ON d.user_id = b.user_id AND d.templates_id = #{id} |
| | | LEFT JOIN t_exam_templates_user_count e ON d.templates_id = e.exam_templates_id |
| | | LEFT JOIN t_exam_paper_answer c ON d.user_id = c.create_user AND e.exam_paper_id = c.exam_paper_id AND (c.invalid = 0 OR c.invalid IS NULL) |
| | | GROUP BY |
| | | a.id, a.name |
| | | </select> |
| | | |
| | | <select id="totalByTemplate" resultType="java.util.Map" parameterType="com.mindskip.xzs.domain.vo.ExamPaperDataVO"> |
| | | SELECT |
| | | (SELECT (SELECT count(*) FROM t_exam_paper) + (SELECT count(*) FROM t_exam_templates)) as examTotal, -- 总考试次数 |
| | | COUNT(DISTINCT c.create_user) as factPeopleTotal, -- 参考人数 |
| | | IFNULL(ROUND(AVG(c.user_score), 2), 0) as averageScore, -- 平均成绩 |
| | | IFNULL(ROUND((COUNT(DISTINCT c.create_user) * 100.0 / COUNT(DISTINCT d.user_id)), 2), 0) AS referencePercentage -- 参考百分比 |
| | | FROM |
| | | t_exam_templates a |
| | | LEFT JOIN t_exam_templates_user d ON d.templates_id = a.id |
| | | LEFT JOIN t_exam_templates_user_count e ON d.templates_id = e.exam_templates_id |
| | | LEFT JOIN t_exam_paper_answer c ON d.user_id = c.create_user AND e.exam_paper_id = c.exam_paper_id AND (c.invalid = 0 OR c.invalid IS NULL) |
| | | WHERE a.id = #{id} |
| | | GROUP BY |
| | | a.id |
| | | </select> |
| | | |
| | | <select id="dataByPaper" resultType="java.util.Map" parameterType="com.mindskip.xzs.domain.vo.ExamPaperDataVO"> |
| | | SELECT |
| | | a.id, |
| | | a.name, |
| | | COUNT(DISTINCT c.create_user) as factPeopleTotal, -- 参考人数 |
| | | IFNULL(ROUND(AVG(c.user_score), 2), 0) as averageScore, -- 平均成绩 |
| | | IFNULL(ROUND((COUNT(DISTINCT c.create_user) * 100.0 / COUNT(DISTINCT d.user_id)), 2), 0) AS referencePercentage -- 参考百分比 |
| | | FROM |
| | | t_department a |
| | | LEFT JOIN t_user_department b ON a.id = b.department_id |
| | | LEFT JOIN t_exam_paper_answer c ON b.user_id = c.create_user AND (c.invalid = 0 OR c.invalid IS NULL) AND c.exam_paper_id = #{id} |
| | | LEFT JOIN t_exam_paper_user d ON c.exam_paper_id = d.exam_paper_id and b.user_id = d.user_id |
| | | GROUP BY |
| | | a.id, a.name |
| | | </select> |
| | | |
| | | <select id="totalByPaper" resultType="java.util.Map" parameterType="com.mindskip.xzs.domain.vo.ExamPaperDataVO"> |
| | | SELECT |
| | | (SELECT (SELECT count(*) FROM t_exam_paper) + (SELECT count(*) FROM t_exam_templates)) as examTotal, -- 总考试次数 |
| | | count(DISTINCT b.create_user) AS factPeopleTotal, -- 参考数 |
| | | IFNULL(ROUND(avg(user_score), 2), 0) as averageScore, -- 平均分 |
| | | IFNULL(ROUND((COUNT(DISTINCT b.create_user) * 100.0 / COUNT(DISTINCT c.user_id)), 2), 0) AS referencePercentage -- 参考百分比 |
| | | FROM t_exam_paper a |
| | | LEFT JOIN t_exam_paper_answer b ON a.id = b.exam_paper_id AND (b.invalid = 0 OR b.invalid IS NULL) |
| | | LEFT JOIN t_exam_paper_user c ON a.id = c.exam_paper_id |
| | | WHERE a.id = #{id} |
| | | GROUP BY a.id |
| | | </select> |
| | | |
| | | </mapper> |