Commit d5eeb4b1 authored by wujipeng's avatar wujipeng
Browse files

bug修复

parent af8007ec
...@@ -105,13 +105,13 @@ ...@@ -105,13 +105,13 @@
FROM theoretical_paper_student_detail d FROM theoretical_paper_student_detail d
WHERE d.exam_id = es.exam_id WHERE d.exam_id = es.exam_id
AND d.student_id = es.student_id AND d.student_id = es.student_id
AND d.is_problem = 1 AND COALESCE(d.is_problem, 1) = 1
AND d.type = '主观题') AS subjectiveCount, AND d.type = '主观题') AS subjectiveCount,
(SELECT COUNT(*) (SELECT COUNT(*)
FROM theoretical_paper_student_detail d FROM theoretical_paper_student_detail d
WHERE d.exam_id = es.exam_id WHERE d.exam_id = es.exam_id
AND d.student_id = es.student_id AND d.student_id = es.student_id
AND d.is_problem = 1 AND COALESCE(d.is_problem, 1) = 1
AND d.type = '主观题' AND d.type = '主观题'
AND d.actual_score IS NOT NULL) AS scoredSubjectiveCount, AND d.actual_score IS NOT NULL) AS scoredSubjectiveCount,
CASE WHEN IFNULL(es.mark_flag, 0) = 1 THEN TRUE ELSE FALSE END AS published CASE WHEN IFNULL(es.mark_flag, 0) = 1 THEN TRUE ELSE FALSE END AS published
...@@ -148,13 +148,13 @@ ...@@ -148,13 +148,13 @@
FROM theoretical_paper_student_detail d FROM theoretical_paper_student_detail d
WHERE d.exam_id = es.exam_id WHERE d.exam_id = es.exam_id
AND d.student_id = es.student_id AND d.student_id = es.student_id
AND d.is_problem = 1 AND COALESCE(d.is_problem, 1) = 1
AND d.type = '主观题') AS subjectiveCount, AND d.type = '主观题') AS subjectiveCount,
(SELECT COUNT(*) (SELECT COUNT(*)
FROM theoretical_paper_student_detail d FROM theoretical_paper_student_detail d
WHERE d.exam_id = es.exam_id WHERE d.exam_id = es.exam_id
AND d.student_id = es.student_id AND d.student_id = es.student_id
AND d.is_problem = 1 AND COALESCE(d.is_problem, 1) = 1
AND d.type = '主观题' AND d.type = '主观题'
AND d.actual_score IS NOT NULL) AS scoredSubjectiveCount, AND d.actual_score IS NOT NULL) AS scoredSubjectiveCount,
CASE WHEN IFNULL(es.mark_flag, 0) = 1 THEN TRUE ELSE FALSE END AS published CASE WHEN IFNULL(es.mark_flag, 0) = 1 THEN TRUE ELSE FALSE END AS published
...@@ -179,6 +179,9 @@ ...@@ -179,6 +179,9 @@
<!-- <!--
客观题得分根据交卷时的判题结果实时换算;主观题读取教师暂存的 actual_score。 客观题得分根据交卷时的判题结果实时换算;主观题读取教师暂存的 actual_score。
因此保存阶段无需改写考生正式总分,只有发布事务才落最终总分。 因此保存阶段无需改写考生正式总分,只有发布事务才落最终总分。
历史个人试卷的 is_problem 可能为空。学员作答、交卷及成绩查询均将空值按题目处理,
阅卷侧必须保持同一口径,否则会把已经交卷的历史试卷误判为“尚未生成明细”。
--> -->
<select id="queryQuestions" resultType="com.platform.business.model.vo.ExamReviewQuestionVO"> <select id="queryQuestions" resultType="com.platform.business.model.vo.ExamReviewQuestionVO">
SELECT SELECT
...@@ -209,7 +212,7 @@ ...@@ -209,7 +212,7 @@
FROM theoretical_paper_student_detail d FROM theoretical_paper_student_detail d
WHERE d.exam_id = #{examId} WHERE d.exam_id = #{examId}
AND d.student_id = #{studentId} AND d.student_id = #{studentId}
AND d.is_problem = 1 AND COALESCE(d.is_problem, 1) = 1
ORDER BY FIELD(d.type, '判断题', '单选题', '多选题', '主观题'), d.sequence, d.id ORDER BY FIELD(d.type, '判断题', '单选题', '多选题', '主观题'), d.sequence, d.id
</select> </select>
...@@ -237,7 +240,7 @@ ...@@ -237,7 +240,7 @@
FROM theoretical_paper_student_detail d FROM theoretical_paper_student_detail d
WHERE d.exam_id = #{examId} WHERE d.exam_id = #{examId}
AND d.student_id = #{studentId} AND d.student_id = #{studentId}
AND d.is_problem = 1 AND COALESCE(d.is_problem, 1) = 1
AND d.id IN AND d.id IN
<foreach collection="questionIds" item="questionId" open="(" separator="," close=")"> <foreach collection="questionIds" item="questionId" open="(" separator="," close=")">
#{questionId} #{questionId}
...@@ -302,7 +305,7 @@ ...@@ -302,7 +305,7 @@
FROM theoretical_paper_student_detail d FROM theoretical_paper_student_detail d
WHERE d.exam_id = es.exam_id WHERE d.exam_id = es.exam_id
AND d.student_id = es.student_id AND d.student_id = es.student_id
AND d.is_problem = 1 AND COALESCE(d.is_problem, 1) = 1
) )
</select> </select>
...@@ -327,7 +330,7 @@ ...@@ -327,7 +330,7 @@
WHERE es.exam_id = #{examId} WHERE es.exam_id = #{examId}
AND es.submit = 1 AND es.submit = 1
AND IFNULL(es.mark_flag, 0) = 0 AND IFNULL(es.mark_flag, 0) = 0
AND d.is_problem = 1 AND COALESCE(d.is_problem, 1) = 1
AND d.type = '主观题' AND d.type = '主观题'
AND d.actual_score IS NULL AND d.actual_score IS NULL
</select> </select>
...@@ -343,7 +346,7 @@ ...@@ -343,7 +346,7 @@
FROM theoretical_paper_student_detail d FROM theoretical_paper_student_detail d
WHERE d.exam_id = #{examId} WHERE d.exam_id = #{examId}
AND d.student_id = #{studentId} AND d.student_id = #{studentId}
AND d.is_problem = 1 AND COALESCE(d.is_problem, 1) = 1
</select> </select>
<select id="calculatePracticeScore" resultType="double"> <select id="calculatePracticeScore" resultType="double">
......
package com.platform.business.mapper; package com.platform.business.mapper;
import com.platform.business.model.dto.ExamReviewStudentQueryDTO;
import com.platform.business.model.dto.ScoreAdminExamQueryDTO; import com.platform.business.model.dto.ScoreAdminExamQueryDTO;
import org.apache.ibatis.builder.xml.XMLMapperBuilder; import org.apache.ibatis.builder.xml.XMLMapperBuilder;
import org.apache.ibatis.io.Resources; import org.apache.ibatis.io.Resources;
...@@ -7,6 +8,7 @@ import org.apache.ibatis.session.Configuration; ...@@ -7,6 +8,7 @@ import org.apache.ibatis.session.Configuration;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import java.io.InputStream; import java.io.InputStream;
import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
...@@ -111,6 +113,36 @@ class ScoreAdminMapperXmlTest { ...@@ -111,6 +113,36 @@ class ScoreAdminMapperXmlTest {
"com.platform.business.mapper.ExamReviewMapper.calculatePracticeScore")); "com.platform.business.mapper.ExamReviewMapper.calculatePracticeScore"));
} }
@Test
void examReviewQueriesShouldIncludeLegacyQuestionsWithNullProblemFlag() throws Exception {
Configuration configuration = parse("com/platform/business/mapper/ExamReviewMapper.xml");
String namespace = "com.platform.business.mapper.ExamReviewMapper.";
ExamReviewStudentQueryDTO studentQuery = new ExamReviewStudentQueryDTO();
studentQuery.setExamId(100);
studentQuery.setClassId(10);
Map<String, Object> studentParameters = new HashMap<>();
studentParameters.put("teacherId", "teacher-1");
studentParameters.put("query", studentQuery);
Map<String, Object> paperParameters = new HashMap<>();
paperParameters.put("examId", 100);
paperParameters.put("studentId", "student-1");
Map<String, Object> lockParameters = new HashMap<>(paperParameters);
lockParameters.put("questionIds", Collections.singletonList("question-1"));
// 历史个人试卷允许 is_problem 为空;教师端的列表、阅卷、保存和发布 SQL
// 必须全部沿用学员考试中心的兼容口径,避免入口修复后在后续操作中再次失败。
assertUsesNullableProblemFlag(configuration, namespace + "queryStudents", studentParameters);
assertUsesNullableProblemFlag(configuration, namespace + "findStudent", 10);
assertUsesNullableProblemFlag(configuration, namespace + "queryQuestions", paperParameters);
assertUsesNullableProblemFlag(configuration, namespace + "lockQuestions", lockParameters);
assertUsesNullableProblemFlag(configuration, namespace + "countSubmittedWithoutPaper", 100);
assertUsesNullableProblemFlag(configuration, namespace + "countUnscoredSubjective", 100);
assertUsesNullableProblemFlag(configuration, namespace + "calculateStudentScore", paperParameters);
}
private Configuration parse(String resource) throws Exception { private Configuration parse(String resource) throws Exception {
Configuration configuration = new Configuration(); Configuration configuration = new Configuration();
try (InputStream input = Resources.getResourceAsStream(resource)) { try (InputStream input = Resources.getResourceAsStream(resource)) {
...@@ -124,4 +156,12 @@ class ScoreAdminMapperXmlTest { ...@@ -124,4 +156,12 @@ class ScoreAdminMapperXmlTest {
private String normalizeSql(String sql) { private String normalizeSql(String sql) {
return sql.replaceAll("\\s+", " ").trim().toLowerCase(); return sql.replaceAll("\\s+", " ").trim().toLowerCase();
} }
private void assertUsesNullableProblemFlag(Configuration configuration,
String statement, Object parameters) {
String sql = normalizeSql(configuration.getMappedStatement(statement)
.getBoundSql(parameters).getSql());
assertTrue(sql.contains("coalesce(d.is_problem, 1) = 1"));
assertFalse(sql.contains("d.is_problem = 1"));
}
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment