Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
邬吉朋
practical_train
Commits
fe41c7d2
"...platform/git@gitlab.ruzhoukj.com:wujipeng/relation.git" did not exist on "aa13e53aabaffa3eaa868a7b8258a4eb0738404c"
Commit
fe41c7d2
authored
Sep 16, 2026
by
王蔡翾
Browse files
Merge remote-tracking branch 'origin/dev-v1.0' into dev-v1.0
parents
90069e99
98561b99
Changes
14
Hide whitespace changes
Inline
Side-by-side
practical-api/practical-business-api/src/main/java/com/platform/business/model/vo/ScoreAdminStudentDetailVO.java
View file @
fe41c7d2
...
@@ -24,6 +24,12 @@ public class ScoreAdminStudentDetailVO {
...
@@ -24,6 +24,12 @@ public class ScoreAdminStudentDetailVO {
private
String
examName
;
private
String
examName
;
private
String
examType
;
private
String
examType
;
@ApiModelProperty
(
"理论试卷ID或实训组卷规则ID"
)
private
String
paperId
;
@ApiModelProperty
(
"理论试卷名称或实训组卷规则名称"
)
private
String
paperName
;
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
,
timezone
=
"GMT+8"
)
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
,
timezone
=
"GMT+8"
)
private
Date
examTime
;
private
Date
examTime
;
...
@@ -39,6 +45,18 @@ public class ScoreAdminStudentDetailVO {
...
@@ -39,6 +45,18 @@ public class ScoreAdminStudentDetailVO {
private
Boolean
submitted
;
private
Boolean
submitted
;
private
Boolean
published
;
private
Boolean
published
;
/**
* 弹窗顶部“正确率”卡片及题号导航所需的聚合数据。
*
* <p>理论考试按答对/部分对/答错统计;实训考试按通过/部分通过/未通过统计,
* correctRate统一按“完全正确 + 部分正确×0.5”计算,便于前端复用同一套布局。</p>
*/
private
Integer
totalQuestionCount
;
private
Integer
rightCount
;
private
Integer
wrongCount
;
private
Integer
partiallyRightCount
;
private
BigDecimal
correctRate
;
@ApiModelProperty
(
"理论考试答题详情;实训考试返回空数组"
)
@ApiModelProperty
(
"理论考试答题详情;实训考试返回空数组"
)
private
List
<
ExamReviewQuestionVO
>
theoryQuestions
=
Collections
.
emptyList
();
private
List
<
ExamReviewQuestionVO
>
theoryQuestions
=
Collections
.
emptyList
();
...
...
practical-api/practical-business-api/src/main/java/com/platform/business/model/vo/ScoreAdminStudentVO.java
View file @
fe41c7d2
...
@@ -27,6 +27,19 @@ public class ScoreAdminStudentVO {
...
@@ -27,6 +27,19 @@ public class ScoreAdminStudentVO {
private
Boolean
submitted
;
private
Boolean
submitted
;
private
Boolean
published
;
private
Boolean
published
;
/**
* 是否允许展示“查看试卷”按钮。
*
* <p>只有已经交卷、成绩已经正式发布且确有个人试卷明细时才为true。前端直接使用
* 该字段控制按钮状态,不再重复推断发布状态或考试类型。</p>
*/
@ApiModelProperty
(
"是否可以查看学员试卷"
)
private
Boolean
paperAvailable
;
/** paperAvailable为false时的不可查看原因,可直接用于禁用按钮提示。 */
@ApiModelProperty
(
"试卷不可查看原因;可以查看时返回null"
)
private
String
paperUnavailableReason
;
@ApiModelProperty
(
"未发布时固定返回null"
)
@ApiModelProperty
(
"未发布时固定返回null"
)
private
BigDecimal
score
;
private
BigDecimal
score
;
...
...
practical-business/src/main/java/com/platform/business/controller/ScoreAdminController.java
View file @
fe41c7d2
...
@@ -91,6 +91,20 @@ public class ScoreAdminController extends BaseController {
...
@@ -91,6 +91,20 @@ public class ScoreAdminController extends BaseController {
return
Result
.
data
(
scoreAdminService
.
student
(
examStudentId
));
return
Result
.
data
(
scoreAdminService
.
student
(
examStudentId
));
}
}
/**
* “查看试卷”按钮使用的语义化入口。
*
* <p>保留上方旧详情地址以兼容已经接入的客户端;两个地址共享同一套发布校验和
* 响应结构,避免后续维护时出现两种试卷口径。</p>
*/
@ApiOperation
(
"查看单个学员已发布试卷"
)
@GetMapping
(
"/exam-students/{examStudentId}/paper"
)
public
Result
<
ScoreAdminStudentDetailVO
>
paper
(
@PathVariable
Integer
examStudentId
,
HttpServletRequest
request
)
{
requireAdmin
(
request
);
return
Result
.
data
(
scoreAdminService
.
student
(
examStudentId
));
}
@ApiOperation
(
"单场考试按题目统计"
)
@ApiOperation
(
"单场考试按题目统计"
)
@GetMapping
(
"/exams/{examId}/questions/statistics"
)
@GetMapping
(
"/exams/{examId}/questions/statistics"
)
public
Result
<
List
<
ScoreAdminQuestionStatisticsVO
>>
questionStatistics
(
public
Result
<
List
<
ScoreAdminQuestionStatisticsVO
>>
questionStatistics
(
...
...
practical-business/src/main/java/com/platform/business/service/impl/ScoreAdminServiceImpl.java
View file @
fe41c7d2
...
@@ -36,6 +36,7 @@ import javax.servlet.http.HttpServletResponse;
...
@@ -36,6 +36,7 @@ import javax.servlet.http.HttpServletResponse;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.InputStream
;
import
java.math.BigDecimal
;
import
java.math.BigDecimal
;
import
java.math.RoundingMode
;
import
java.net.URLEncoder
;
import
java.net.URLEncoder
;
import
java.nio.charset.StandardCharsets
;
import
java.nio.charset.StandardCharsets
;
import
java.text.SimpleDateFormat
;
import
java.text.SimpleDateFormat
;
...
@@ -124,7 +125,14 @@ public class ScoreAdminServiceImpl implements ScoreAdminService {
...
@@ -124,7 +125,14 @@ public class ScoreAdminServiceImpl implements ScoreAdminService {
requireExam
(
examId
);
requireExam
(
examId
);
normalizeStudentQuery
(
query
);
normalizeStudentQuery
(
query
);
List
<
ScoreAdminStudentVO
>
result
=
scoreAdminMapper
.
queryStudents
(
examId
,
query
);
List
<
ScoreAdminStudentVO
>
result
=
scoreAdminMapper
.
queryStudents
(
examId
,
query
);
return
result
==
null
?
Collections
.
emptyList
()
:
result
;
if
(
result
==
null
||
result
.
isEmpty
())
{
return
Collections
.
emptyList
();
}
// 不可查看原因由服务层统一生成,前端只负责按钮展示和提示文案。
for
(
ScoreAdminStudentVO
student
:
result
)
{
fillPaperAvailability
(
student
);
}
return
result
;
}
}
@Override
@Override
...
@@ -135,24 +143,143 @@ public class ScoreAdminServiceImpl implements ScoreAdminService {
...
@@ -135,24 +143,143 @@ public class ScoreAdminServiceImpl implements ScoreAdminService {
if
(
detail
==
null
)
{
if
(
detail
==
null
)
{
throw
new
BusinessException
(
"考生考试记录不存在或已删除"
);
throw
new
BusinessException
(
"考生考试记录不存在或已删除"
);
}
}
if
(!
Boolean
.
TRUE
.
equals
(
detail
.
getSubmitted
()))
{
throw
new
BusinessException
(
"该学员尚未交卷,不能查看试卷"
);
}
if
(!
Boolean
.
TRUE
.
equals
(
detail
.
getPublished
()))
{
if
(!
Boolean
.
TRUE
.
equals
(
detail
.
getPublished
()))
{
throw
new
BusinessException
(
"
本名
学员成绩尚未正式发布,不能查看答题详情"
);
throw
new
BusinessException
(
"
该
学员成绩尚未正式发布,不能查看答题详情"
);
}
}
if
(
isPractice
(
detail
.
getExamType
()))
{
if
(
isPractice
(
detail
.
getExamType
()))
{
List
<
com
.
platform
.
business
.
model
.
entity
.
FzGradesEntity
>
items
=
List
<
com
.
platform
.
business
.
model
.
entity
.
FzGradesEntity
>
items
=
scoreAdminMapper
.
queryPracticeItems
(
detail
.
getExamId
(),
detail
.
getStudentId
());
scoreAdminMapper
.
queryPracticeItems
(
detail
.
getExamId
(),
detail
.
getStudentId
());
detail
.
setPracticeItems
(
items
==
null
?
Collections
.
emptyList
()
:
items
);
items
=
items
==
null
?
Collections
.
emptyList
()
:
items
;
if
(
items
.
isEmpty
())
{
throw
new
BusinessException
(
"该学员实训试卷明细不存在,请检查成绩上报数据"
);
}
detail
.
setPracticeItems
(
items
);
detail
.
setTheoryQuestions
(
Collections
.
emptyList
());
detail
.
setTheoryQuestions
(
Collections
.
emptyList
());
fillPracticePaperStatistics
(
detail
,
items
);
}
else
{
}
else
{
List
<
com
.
platform
.
business
.
model
.
vo
.
ExamReviewQuestionVO
>
questions
=
List
<
com
.
platform
.
business
.
model
.
vo
.
ExamReviewQuestionVO
>
questions
=
scoreAdminMapper
.
queryTheoryQuestions
(
detail
.
getExamId
(),
detail
.
getStudentId
());
scoreAdminMapper
.
queryTheoryQuestions
(
detail
.
getExamId
(),
detail
.
getStudentId
());
detail
.
setTheoryQuestions
(
questions
==
null
?
Collections
.
emptyList
()
:
questions
);
questions
=
questions
==
null
?
Collections
.
emptyList
()
:
questions
;
if
(
questions
.
isEmpty
())
{
throw
new
BusinessException
(
"该学员理论试卷明细不存在,请检查个人试卷数据"
);
}
fillTheoryPaperStatistics
(
detail
,
questions
);
detail
.
setTheoryQuestions
(
questions
);
detail
.
setPracticeItems
(
Collections
.
emptyList
());
detail
.
setPracticeItems
(
Collections
.
emptyList
());
}
}
return
detail
;
return
detail
;
}
}
/**
* 根据列表查询返回的发布状态和明细存在性生成稳定的按钮状态。
*
* <p>paperAvailable由SQL使用EXISTS一次性计算,避免分页结果逐行查询形成N+1问题;
* 这里仅负责输出面向用户的原因文案。</p>
*/
private
void
fillPaperAvailability
(
ScoreAdminStudentVO
student
)
{
if
(
student
==
null
)
{
return
;
}
if
(!
Boolean
.
TRUE
.
equals
(
student
.
getSubmitted
()))
{
student
.
setPaperAvailable
(
false
);
student
.
setPaperUnavailableReason
(
"学员尚未交卷"
);
}
else
if
(!
Boolean
.
TRUE
.
equals
(
student
.
getPublished
()))
{
student
.
setPaperAvailable
(
false
);
student
.
setPaperUnavailableReason
(
"成绩尚未正式发布"
);
}
else
if
(!
Boolean
.
TRUE
.
equals
(
student
.
getPaperAvailable
()))
{
student
.
setPaperAvailable
(
false
);
student
.
setPaperUnavailableReason
(
"试卷明细不存在"
);
}
else
{
student
.
setPaperAvailable
(
true
);
student
.
setPaperUnavailableReason
(
null
);
}
}
/** 理论试卷按页面展示顺序重新连续编号,并一次性计算弹窗摘要卡片数据。 */
private
void
fillTheoryPaperStatistics
(
ScoreAdminStudentDetailVO
detail
,
List
<
com
.
platform
.
business
.
model
.
vo
.
ExamReviewQuestionVO
>
questions
)
{
int
right
=
0
;
int
wrong
=
0
;
int
partial
=
0
;
for
(
int
index
=
0
;
index
<
questions
.
size
();
index
++)
{
com
.
platform
.
business
.
model
.
vo
.
ExamReviewQuestionVO
question
=
questions
.
get
(
index
);
if
(
question
==
null
)
{
continue
;
}
// 历史试卷可能保存空序号、非数字序号或按字符串错排的10/2,接口统一返回1..N。
question
.
setSequence
(
String
.
valueOf
(
index
+
1
));
if
(
Boolean
.
TRUE
.
equals
(
question
.
getPartiallyRight
()))
{
partial
++;
}
else
if
(
Boolean
.
TRUE
.
equals
(
question
.
getResult
()))
{
right
++;
}
else
{
wrong
++;
}
}
fillPaperStatistics
(
detail
,
questions
.
size
(),
right
,
wrong
,
partial
);
}
/** 实训结果文本兼容中英文上报值,并映射为与理论试卷相同的摘要统计。 */
private
void
fillPracticePaperStatistics
(
ScoreAdminStudentDetailVO
detail
,
List
<
com
.
platform
.
business
.
model
.
entity
.
FzGradesEntity
>
items
)
{
int
right
=
0
;
int
wrong
=
0
;
int
partial
=
0
;
for
(
com
.
platform
.
business
.
model
.
entity
.
FzGradesEntity
item
:
items
)
{
String
status
=
normalizePracticeResult
(
item
==
null
?
null
:
item
.
getResult
());
if
(
"PASS"
.
equals
(
status
))
{
right
++;
}
else
if
(
"PARTIAL"
.
equals
(
status
))
{
partial
++;
}
else
{
wrong
++;
}
}
fillPaperStatistics
(
detail
,
items
.
size
(),
right
,
wrong
,
partial
);
}
/** 汇总两类试卷共用的题目数量与加权正确率,统一保留两位小数。 */
private
void
fillPaperStatistics
(
ScoreAdminStudentDetailVO
detail
,
int
total
,
int
right
,
int
wrong
,
int
partial
)
{
detail
.
setTotalQuestionCount
(
total
);
detail
.
setRightCount
(
right
);
detail
.
setWrongCount
(
wrong
);
detail
.
setPartiallyRightCount
(
partial
);
BigDecimal
rate
=
total
==
0
?
BigDecimal
.
ZERO
:
BigDecimal
.
valueOf
(
right
+
partial
*
0.5
D
)
.
multiply
(
BigDecimal
.
valueOf
(
100
D
))
.
divide
(
BigDecimal
.
valueOf
(
total
),
2
,
RoundingMode
.
HALF_UP
);
detail
.
setCorrectRate
(
rate
);
}
/**
* 兼容仿真平台可能上报的中文、英文结果;否定词优先判断,避免“未通过”被识别成通过。
*/
private
String
normalizePracticeResult
(
String
result
)
{
if
(!
hasText
(
result
))
{
return
"FAIL"
;
}
String
normalized
=
result
.
trim
().
toUpperCase
(
Locale
.
ROOT
);
if
(
normalized
.
contains
(
"部分"
)
||
normalized
.
contains
(
"PARTIAL"
))
{
return
"PARTIAL"
;
}
if
(
normalized
.
contains
(
"未通过"
)
||
normalized
.
contains
(
"不通过"
)
||
normalized
.
contains
(
"失败"
)
||
normalized
.
contains
(
"FAIL"
))
{
return
"FAIL"
;
}
if
(
normalized
.
contains
(
"通过"
)
||
normalized
.
contains
(
"合格"
)
||
normalized
.
contains
(
"成功"
)
||
normalized
.
contains
(
"PASS"
))
{
return
"PASS"
;
}
return
"FAIL"
;
}
@Override
@Override
@Transactional
(
readOnly
=
true
)
@Transactional
(
readOnly
=
true
)
public
List
<
ScoreAdminQuestionStatisticsVO
>
questionStatistics
(
Integer
examId
)
{
public
List
<
ScoreAdminQuestionStatisticsVO
>
questionStatistics
(
Integer
examId
)
{
...
...
practical-business/src/main/java/com/platform/business/service/impl/StudentScoreServiceImpl.java
View file @
fe41c7d2
...
@@ -309,13 +309,20 @@ public class StudentScoreServiceImpl implements StudentScoreService {
...
@@ -309,13 +309,20 @@ public class StudentScoreServiceImpl implements StudentScoreService {
}
}
private
boolean
isTheory
(
String
type
)
{
private
boolean
isTheory
(
String
type
)
{
return
ExamAdminConstants
.
TYPE_THEORY
.
equals
(
type
)
String
normalized
=
trimToNull
(
type
);
||
"THEORY"
.
equalsIgnoreCase
(
type
==
null
?
""
:
type
.
trim
());
// 历史考试记录使用“理论”,新管理端统一保存“理论考试”,部分对接数据使用英文值。
// 三种取值代表同一业务类型;这里只做分支识别,不改写响应中的数据库原始值。
return
normalized
!=
null
&&
(
ExamAdminConstants
.
TYPE_THEORY
.
equals
(
normalized
)
||
"理论"
.
equals
(
normalized
)
||
"THEORY"
.
equalsIgnoreCase
(
normalized
));
}
}
private
boolean
isPractice
(
String
type
)
{
private
boolean
isPractice
(
String
type
)
{
return
ExamAdminConstants
.
TYPE_PRACTICE
.
equals
(
type
)
String
normalized
=
trimToNull
(
type
);
||
"PRACTICE"
.
equalsIgnoreCase
(
type
==
null
?
""
:
type
.
trim
());
// 与理论考试保持相同兼容口径,确保历史“实训”记录也能加载步骤详情和导出数据。
return
normalized
!=
null
&&
(
ExamAdminConstants
.
TYPE_PRACTICE
.
equals
(
normalized
)
||
"实训"
.
equals
(
normalized
)
||
"PRACTICE"
.
equalsIgnoreCase
(
normalized
));
}
}
private
double
round
(
double
value
)
{
private
double
round
(
double
value
)
{
...
...
practical-business/src/main/resources/com/platform/business/mapper/ScoreAdminMapper.xml
View file @
fe41c7d2
...
@@ -161,6 +161,24 @@
...
@@ -161,6 +161,24 @@
WHEN IFNULL(e.mark_flag, 0) = 1 AND IFNULL(es.mark_flag, 0) = 1
WHEN IFNULL(e.mark_flag, 0) = 1 AND IFNULL(es.mark_flag, 0) = 1
THEN TRUE ELSE FALSE
THEN TRUE ELSE FALSE
END AS published,
END AS published,
CASE
WHEN IFNULL(es.submit, 0) = 0
OR IFNULL(e.mark_flag, 0) = 0
OR IFNULL(es.mark_flag, 0) = 0 THEN FALSE
WHEN UPPER(TRIM(e.type)) IN ('实训考试', '实训', 'PRACTICE') THEN EXISTS (
SELECT 1
FROM fz_grades paper_item
WHERE paper_item.exam_id = es.exam_id
AND paper_item.user_id = es.student_id
)
ELSE EXISTS (
SELECT 1
FROM theoretical_paper_student_detail paper_question
WHERE paper_question.exam_id = es.exam_id
AND paper_question.student_id = es.student_id
AND COALESCE(paper_question.is_problem, 1) = 1
)
END AS paperAvailable,
CASE
CASE
WHEN IFNULL(e.mark_flag, 0) = 1 AND IFNULL(es.mark_flag, 0) = 1
WHEN IFNULL(e.mark_flag, 0) = 1 AND IFNULL(es.mark_flag, 0) = 1
THEN es.score ELSE NULL
THEN es.score ELSE NULL
...
@@ -218,6 +236,12 @@
...
@@ -218,6 +236,12 @@
c.name AS className,
c.name AS className,
e.name AS examName,
e.name AS examName,
e.type AS examType,
e.type AS examType,
CASE
WHEN UPPER(TRIM(e.type)) IN ('实训考试', '实训', 'PRACTICE')
THEN CAST(e.practice_rule_id AS CHAR)
ELSE e.paper_id
END AS paperId,
COALESCE(theory_paper.name, practice_rule.name, CONCAT(e.name, '试卷')) AS paperName,
e.exam_time AS examTime,
e.exam_time AS examTime,
e.total_score AS totalScore,
e.total_score AS totalScore,
e.pass_score AS passScore,
e.pass_score AS passScore,
...
@@ -254,6 +278,9 @@
...
@@ -254,6 +278,9 @@
INNER JOIN exam e ON e.id = es.exam_id
INNER JOIN exam e ON e.id = es.exam_id
LEFT JOIN user u ON u.id = es.student_id
LEFT JOIN user u ON u.id = es.student_id
LEFT JOIN class c ON c.id = es.class_id
LEFT JOIN class c ON c.id = es.class_id
LEFT JOIN theoretical_paper theory_paper ON theory_paper.id = e.paper_id
LEFT JOIN practice_paper_rule_definition practice_rule
ON practice_rule.id = e.practice_rule_id
WHERE es.id = #{examStudentId}
WHERE es.id = #{examStudentId}
</select>
</select>
...
@@ -273,6 +300,7 @@
...
@@ -273,6 +300,7 @@
d.score AS maxScore,
d.score AS maxScore,
CASE
CASE
WHEN d.type = '主观题' THEN d.actual_score
WHEN d.type = '主观题' THEN d.actual_score
WHEN d.actual_score IS NOT NULL THEN d.actual_score
WHEN d.result = 1 THEN d.score
WHEN d.result = 1 THEN d.score
ELSE 0
ELSE 0
END AS actualScore,
END AS actualScore,
...
@@ -284,7 +312,14 @@
...
@@ -284,7 +312,14 @@
WHERE d.exam_id = #{examId}
WHERE d.exam_id = #{examId}
AND d.student_id = #{studentId}
AND d.student_id = #{studentId}
AND IFNULL(d.is_problem, 1) = 1
AND IFNULL(d.is_problem, 1) = 1
ORDER BY d.sequence, d.id
ORDER BY
CASE WHEN TRIM(d.sequence) REGEXP '^[0-9]+$' THEN 0 ELSE 1 END,
CASE
WHEN TRIM(d.sequence) REGEXP '^[0-9]+$'
THEN CAST(TRIM(d.sequence) AS UNSIGNED)
ELSE NULL
END,
NULLIF(TRIM(d.sequence), ''), d.id
</select>
</select>
<!-- 历史重复明细按雪花ID最大值视为最新记录,不在查询过程中删除原始数据。 -->
<!-- 历史重复明细按雪花ID最大值视为最新记录,不在查询过程中删除原始数据。 -->
...
@@ -292,7 +327,8 @@
...
@@ -292,7 +327,8 @@
SELECT
SELECT
g.id, g.exam_id AS examId, g.user_id AS userId, g.code, g.lev,
g.id, g.exam_id AS examId, g.user_id AS userId, g.code, g.lev,
g.start_time AS startTime, g.submission_time AS submissionTime,
g.start_time AS startTime, g.submission_time AS submissionTime,
g.title, g.type, g.options, g.mark, g.text, g.result, g.file, g.score
g.title, g.type, g.options, g.mark, g.text, g.result, g.file,
g.file_format AS fileFormat, g.score, g.basic_score AS basicScore
FROM fz_grades g
FROM fz_grades g
INNER JOIN (
INNER JOIN (
SELECT MAX(id) AS id
SELECT MAX(id) AS id
...
...
practical-business/src/main/resources/com/platform/business/mapper/StudentScoreMapper.xml
View file @
fe41c7d2
...
@@ -123,7 +123,18 @@
...
@@ -123,7 +123,18 @@
AND e.name LIKE CONCAT('%', #{query.keyword}, '%')
AND e.name LIKE CONCAT('%', #{query.keyword}, '%')
</if>
</if>
<if
test=
"query.type != null and query.type != '' and query.type != 'ALL'"
>
<if
test=
"query.type != null and query.type != '' and query.type != 'ALL'"
>
AND e.type = #{query.type}
<!--
服务层把筛选值规范为“理论考试”或“实训考试”,这里同时匹配历史短值和
第三方英文值。只在查询时做兼容,不修改数据库原始考试类型。
-->
<choose>
<when
test=
"query.type == '理论考试'"
>
AND UPPER(TRIM(e.type)) IN ('理论考试', '理论', 'THEORY')
</when>
<otherwise>
AND UPPER(TRIM(e.type)) IN ('实训考试', '实训', 'PRACTICE')
</otherwise>
</choose>
</if>
</if>
ORDER BY e.exam_time DESC, e.id DESC
ORDER BY e.exam_time DESC, e.id DESC
</select>
</select>
...
...
practical-business/src/main/resources/student-score-api.md
View file @
fe41c7d2
...
@@ -10,7 +10,8 @@
...
@@ -10,7 +10,8 @@
-
`GET /overview`
:平均分、最高分、考试次数和当前/最近班级综合排名。
-
`GET /overview`
:平均分、最高分、考试次数和当前/最近班级综合排名。
-
`POST /page`
:正式成绩分页;请求体支持
`pageNum/pageSize/keyword/type`
,
`type`
为
-
`POST /page`
:正式成绩分页;请求体支持
`pageNum/pageSize/keyword/type`
,
`type`
为
`ALL/THEORY/PRACTICE`
。
`ALL/THEORY/PRACTICE`
。查询时兼容数据库中的历史短值
`理论/实训`
、规范值
`理论考试/实训考试`
和英文值;响应中的
`type`
保留数据库原始值。
-
`GET /{examStudentId}`
:单场聚合详情,一次返回公共摘要以及理论或实训分支。
-
`GET /{examStudentId}`
:单场聚合详情,一次返回公共摘要以及理论或实训分支。
-
`GET /{examStudentId}/export`
:导出当前学员单场正式成绩CSV。
-
`GET /{examStudentId}/export`
:导出当前学员单场正式成绩CSV。
...
@@ -19,6 +20,8 @@
...
@@ -19,6 +20,8 @@
-
理论考试从
`theoretical_paper_student_detail`
返回题目、作答、正确答案、实际得分、判定结果,
-
理论考试从
`theoretical_paper_student_detail`
返回题目、作答、正确答案、实际得分、判定结果,
并按题型计算个人得分率和班级平均得分率。
并按题型计算个人得分率和班级平均得分率。
-
实训考试只读取
`fz_grades`
,同一
`exam_id + user_id + code`
按最大雪花ID取最新记录。
-
实训考试只读取
`fz_grades`
,同一
`exam_id + user_id + code`
按最大雪花ID取最新记录。
-
详情分支同时识别
`理论/理论考试/THEORY`
和
`实训/实训考试/PRACTICE`
,用于兼容历史数据,
不对已有考试记录执行类型迁移。
-
实训现有协议没有步骤满分、扣分维度和教师评语,因此接口不会构造这些字段;仅根据
`result`
-
实训现有协议没有步骤满分、扣分维度和教师评语,因此接口不会构造这些字段;仅根据
`result`
文本归一化
`PASS/PARTIAL/FAIL`
并计算步骤数量及加权通过率。
文本归一化
`PASS/PARTIAL/FAIL`
并计算步骤数量及加权通过率。
-
详情和导出均使用
`examStudentId + JWT学员ID`
查询,不能访问其他学员成绩。
-
详情和导出均使用
`examStudentId + JWT学员ID`
查询,不能访问其他学员成绩。
practical-business/src/main/resources/student-score-management-api.md
View file @
fe41c7d2
...
@@ -60,12 +60,25 @@ JWT解析当前用户并校验 `phone_role.role_name=管理员`。本模块只
...
@@ -60,12 +60,25 @@ JWT解析当前用户并校验 `phone_role.role_name=管理员`。本模块只
-
`PASS`
:60~79.99分
-
`PASS`
:60~79.99分
-
`FAIL`
:60分以下
-
`FAIL`
:60分以下
未发布考试仍返回应考学员和交卷状态,但
`score/grade/passed`
为
`null`
。
未发布考试仍返回应考学员和交卷状态,但
`score/grade/passed`
为
`null`
。列表额外返回:
-
`paperAvailable`
:只有学员已交卷、成绩已正式发布且个人试卷明细存在时为
`true`
,前端据此
展示或启用“查看试卷”按钮。
-
`paperUnavailableReason`
:按钮不可用时返回“学员尚未交卷”“成绩尚未正式发布”或
“试卷明细不存在”,可直接作为禁用态提示;可以查看时返回
`null`
。
## 4. 学员详情与题目统计
## 4. 学员详情与题目统计
-
`GET /exam/admin/scores/exam-students/{examStudentId}`
:只允许读取正式发布成绩。理论考试返回
-
`GET /exam/admin/scores/exam-students/{examStudentId}/paper`
:成绩明细列表“查看试卷”按钮的
推荐接口,只允许读取已交卷且正式发布的个人试卷。一次返回弹窗所需的学员、考试、试卷名称、
成绩、题目总数、答对/部分对/答错数量、加权正确率及完整逐题明细。理论考试返回
`theoryQuestions`
;实训考试返回
`practiceItems`
。
`theoryQuestions`
;实训考试返回
`practiceItems`
。
-
`GET /exam/admin/scores/exam-students/{examStudentId}`
:兼容旧客户端的详情地址,响应和校验与
上述
`/paper`
接口完全一致。
`correctRate`
按
`(答对数 + 部分对数 × 0.5) / 总题数 × 100`
计算并保留两位小数。理论试卷的
`sequence`
由后端按稳定题目顺序统一重编号为
`1..N`
,避免历史空序号或字符串序号导致导航错乱。
实训结果兼容中文及英文的通过、部分通过和失败文本。
-
`GET /exam/admin/scores/exams/{examId}/questions/statistics`
:理论题返回满分、平均分、得分率、
-
`GET /exam/admin/scores/exams/{examId}/questions/statistics`
:理论题返回满分、平均分、得分率、
答对人数和难度,
`sequence`
为从
`1`
开始的全卷连续题号;实训题使用
答对人数和难度,
`sequence`
为从
`1`
开始的全卷连续题号;实训题使用
`questionCode`
,且实训协议没有每题满分,因此
`maxScore/scoreRate/difficulty`
为
`null`
。
`questionCode`
,且实训协议没有每题满分,因此
`maxScore/scoreRate/difficulty`
为
`null`
。
...
...
practical-business/src/test/java/com/platform/business/controller/ScoreAdminControllerTest.java
View file @
fe41c7d2
...
@@ -58,16 +58,18 @@ class ScoreAdminControllerTest {
...
@@ -58,16 +58,18 @@ class ScoreAdminControllerTest {
controller
.
exam
(
11
,
request
);
controller
.
exam
(
11
,
request
);
controller
.
students
(
11
,
studentQuery
,
request
);
controller
.
students
(
11
,
studentQuery
,
request
);
controller
.
student
(
22
,
request
);
controller
.
student
(
22
,
request
);
controller
.
paper
(
22
,
request
);
controller
.
questionStatistics
(
11
,
request
);
controller
.
questionStatistics
(
11
,
request
);
controller
.
exportExam
(
11
,
request
,
response
);
controller
.
exportExam
(
11
,
request
,
response
);
controller
.
exportClass
(
33
,
request
,
response
);
controller
.
exportClass
(
33
,
request
,
response
);
verify
(
authenticatedUserService
,
times
(
8
)).
requireAdmin
(
administrator
);
verify
(
authenticatedUserService
,
times
(
9
)).
requireAdmin
(
administrator
);
assertEquals
(
100
,
examQuery
.
getPageSize
());
assertEquals
(
100
,
examQuery
.
getPageSize
());
assertEquals
(
10
,
studentQuery
.
getPageSize
());
assertEquals
(
10
,
studentQuery
.
getPageSize
());
verify
(
scoreAdminService
).
tree
(
"污水"
);
verify
(
scoreAdminService
).
tree
(
"污水"
);
verify
(
scoreAdminService
).
exam
(
11
);
verify
(
scoreAdminService
).
exam
(
11
);
verify
(
scoreAdminService
).
student
(
22
);
// 旧详情入口和新增“查看试卷”语义化入口必须复用同一套服务逻辑。
verify
(
scoreAdminService
,
times
(
2
)).
student
(
22
);
verify
(
scoreAdminService
).
exportClass
(
33
,
response
);
verify
(
scoreAdminService
).
exportClass
(
33
,
response
);
}
}
...
...
practical-business/src/test/java/com/platform/business/mapper/ScoreAdminMapperXmlTest.java
View file @
fe41c7d2
...
@@ -2,6 +2,7 @@ package com.platform.business.mapper;
...
@@ -2,6 +2,7 @@ package com.platform.business.mapper;
import
com.platform.business.model.dto.ExamReviewStudentQueryDTO
;
import
com.platform.business.model.dto.ExamReviewStudentQueryDTO
;
import
com.platform.business.model.dto.ScoreAdminExamQueryDTO
;
import
com.platform.business.model.dto.ScoreAdminExamQueryDTO
;
import
com.platform.business.model.dto.ScoreAdminStudentQueryDTO
;
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
;
import
org.apache.ibatis.session.Configuration
;
import
org.apache.ibatis.session.Configuration
;
...
@@ -101,6 +102,44 @@ class ScoreAdminMapperXmlTest {
...
@@ -101,6 +102,44 @@ class ScoreAdminMapperXmlTest {
assertTrue
(
detailSql
.
contains
(
"as `rank`"
));
assertTrue
(
detailSql
.
contains
(
"as `rank`"
));
// 同时显式排除旧写法,防止后续整理SQL时误删反引号而令线上问题回归。
// 同时显式排除旧写法,防止后续整理SQL时误删反引号而令线上问题回归。
assertFalse
(
detailSql
.
matches
(
".*\\bas\\s+rank\\b.*"
));
assertFalse
(
detailSql
.
matches
(
".*\\bas\\s+rank\\b.*"
));
// 查看试卷弹窗需要试卷名称;理论卷与实训规则分别关联后再统一回填。
assertTrue
(
detailSql
.
contains
(
"left join theoretical_paper theory_paper"
));
assertTrue
(
detailSql
.
contains
(
"left join practice_paper_rule_definition practice_rule"
));
assertTrue
(
detailSql
.
contains
(
"as papername"
));
}
@Test
void
studentRowsShouldCalculatePaperAvailabilityWithoutNPlusOneQueries
()
throws
Exception
{
Configuration
configuration
=
parse
(
"com/platform/business/mapper/ScoreAdminMapper.xml"
);
ScoreAdminStudentQueryDTO
query
=
new
ScoreAdminStudentQueryDTO
();
Map
<
String
,
Object
>
parameters
=
new
HashMap
<>();
parameters
.
put
(
"examId"
,
1
);
parameters
.
put
(
"query"
,
query
);
String
sql
=
normalizeSql
(
configuration
.
getMappedStatement
(
"com.platform.business.mapper.ScoreAdminMapper.queryStudents"
)
.
getBoundSql
(
parameters
).
getSql
());
assertTrue
(
sql
.
contains
(
"as paperavailable"
));
assertTrue
(
sql
.
contains
(
"from fz_grades paper_item"
));
assertTrue
(
sql
.
contains
(
"from theoretical_paper_student_detail paper_question"
));
assertTrue
(
sql
.
contains
(
"coalesce(paper_question.is_problem, 1) = 1"
));
}
@Test
void
studentTheoryPaperShouldUseNumericSequenceAndStableLegacyFallbackOrder
()
throws
Exception
{
Configuration
configuration
=
parse
(
"com/platform/business/mapper/ScoreAdminMapper.xml"
);
Map
<
String
,
Object
>
parameters
=
new
HashMap
<>();
parameters
.
put
(
"examId"
,
1
);
parameters
.
put
(
"studentId"
,
"student-1"
);
String
sql
=
normalizeSql
(
configuration
.
getMappedStatement
(
"com.platform.business.mapper.ScoreAdminMapper.queryTheoryQuestions"
)
.
getBoundSql
(
parameters
).
getSql
());
assertTrue
(
sql
.
contains
(
"regexp '^[0-9]+$'"
));
assertTrue
(
sql
.
contains
(
"cast(trim(d.sequence) as unsigned)"
));
assertTrue
(
sql
.
contains
(
"nullif(trim(d.sequence), '')"
));
}
}
@Test
@Test
...
...
practical-business/src/test/java/com/platform/business/mapper/StudentLearningMapperXmlTest.java
View file @
fe41c7d2
package
com.platform.business.mapper
;
package
com.platform.business.mapper
;
import
com.platform.business.model.dto.StudentExamCenterQueryDTO
;
import
com.platform.business.model.dto.StudentExamCenterQueryDTO
;
import
com.platform.business.model.dto.StudentScoreQueryDTO
;
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
;
import
org.apache.ibatis.session.Configuration
;
import
org.apache.ibatis.session.Configuration
;
...
@@ -103,6 +104,25 @@ class StudentLearningMapperXmlTest {
...
@@ -103,6 +104,25 @@ class StudentLearningMapperXmlTest {
assertFalse
(
UNQUOTED_RANK_ALIAS
.
matcher
(
xml
).
find
());
assertFalse
(
UNQUOTED_RANK_ALIAS
.
matcher
(
xml
).
find
());
// 分页和详情都需要返回rank字段;两处必须保留转义后的别名,避免修复时遗漏任一路径。
// 分页和详情都需要返回rank字段;两处必须保留转义后的别名,避免修复时遗漏任一路径。
assertEquals
(
2
,
xml
.
split
(
"as `rank`"
,
-
1
).
length
-
1
);
assertEquals
(
2
,
xml
.
split
(
"as `rank`"
,
-
1
).
length
-
1
);
Map
<
String
,
Object
>
parameters
=
new
HashMap
<>();
StudentScoreQueryDTO
query
=
new
StudentScoreQueryDTO
();
parameters
.
put
(
"query"
,
query
);
parameters
.
put
(
"studentId"
,
"student-1"
);
// 理论筛选必须覆盖历史短值、新规范值和第三方英文值,避免旧成绩从列表中消失。
query
.
setType
(
"理论考试"
);
String
theorySql
=
compact
(
configuration
.
getMappedStatement
(
"com.platform.business.mapper.StudentScoreMapper.selectPage"
)
.
getBoundSql
(
parameters
).
getSql
());
assertTrue
(
theorySql
.
contains
(
"upper(trim(e.type)) in ('理论考试', '理论', 'theory')"
));
// 实训筛选采用完全相同的兼容策略,保证详情入口可以从筛选后的列表正常进入。
query
.
setType
(
"实训考试"
);
String
practiceSql
=
compact
(
configuration
.
getMappedStatement
(
"com.platform.business.mapper.StudentScoreMapper.selectPage"
)
.
getBoundSql
(
parameters
).
getSql
());
assertTrue
(
practiceSql
.
contains
(
"upper(trim(e.type)) in ('实训考试', '实训', 'practice')"
));
}
}
private
Configuration
parse
(
String
resource
)
throws
Exception
{
private
Configuration
parse
(
String
resource
)
throws
Exception
{
...
...
practical-business/src/test/java/com/platform/business/service/impl/ScoreAdminServiceImplTest.java
View file @
fe41c7d2
...
@@ -4,6 +4,8 @@ import com.platform.business.constant.ExamAdminConstants;
...
@@ -4,6 +4,8 @@ import com.platform.business.constant.ExamAdminConstants;
import
com.platform.business.mapper.ScoreAdminMapper
;
import
com.platform.business.mapper.ScoreAdminMapper
;
import
com.platform.business.model.dto.ScoreAdminExamQueryDTO
;
import
com.platform.business.model.dto.ScoreAdminExamQueryDTO
;
import
com.platform.business.model.dto.ScoreAdminStudentQueryDTO
;
import
com.platform.business.model.dto.ScoreAdminStudentQueryDTO
;
import
com.platform.business.model.entity.FzGradesEntity
;
import
com.platform.business.model.vo.ExamReviewQuestionVO
;
import
com.platform.business.model.vo.ScoreAdminExportExamVO
;
import
com.platform.business.model.vo.ScoreAdminExportExamVO
;
import
com.platform.business.model.vo.ScoreAdminExportPracticeItemVO
;
import
com.platform.business.model.vo.ScoreAdminExportPracticeItemVO
;
import
com.platform.business.model.vo.ScoreAdminExamVO
;
import
com.platform.business.model.vo.ScoreAdminExamVO
;
...
@@ -30,6 +32,7 @@ import java.util.Date;
...
@@ -30,6 +32,7 @@ import java.util.Date;
import
java.util.List
;
import
java.util.List
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertEquals
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertEquals
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertFalse
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertNull
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertNull
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertThrows
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertThrows
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertTrue
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertTrue
;
...
@@ -201,12 +204,86 @@ class ScoreAdminServiceImplTest {
...
@@ -201,12 +204,86 @@ class ScoreAdminServiceImplTest {
@Test
@Test
void
studentDetailShouldRejectDraftScore
()
{
void
studentDetailShouldRejectDraftScore
()
{
ScoreAdminStudentDetailVO
detail
=
new
ScoreAdminStudentDetailVO
();
ScoreAdminStudentDetailVO
detail
=
new
ScoreAdminStudentDetailVO
();
detail
.
setSubmitted
(
true
);
detail
.
setPublished
(
false
);
detail
.
setPublished
(
false
);
when
(
scoreAdminMapper
.
findStudent
(
2
)).
thenReturn
(
detail
);
when
(
scoreAdminMapper
.
findStudent
(
2
)).
thenReturn
(
detail
);
assertThrows
(
BusinessException
.
class
,
()
->
service
.
student
(
2
));
assertThrows
(
BusinessException
.
class
,
()
->
service
.
student
(
2
));
}
}
@Test
void
studentListShouldExposeStableViewPaperButtonStateAndReason
()
{
when
(
scoreAdminMapper
.
findExam
(
1
)).
thenReturn
(
endedExam
(
true
));
ScoreAdminStudentVO
available
=
studentPaperState
(
true
,
true
,
true
);
ScoreAdminStudentVO
notSubmitted
=
studentPaperState
(
false
,
false
,
false
);
ScoreAdminStudentVO
missingDetail
=
studentPaperState
(
true
,
true
,
false
);
when
(
scoreAdminMapper
.
queryStudents
(
org
.
mockito
.
ArgumentMatchers
.
eq
(
1
),
org
.
mockito
.
ArgumentMatchers
.
any
()))
.
thenReturn
(
Arrays
.
asList
(
available
,
notSubmitted
,
missingDetail
));
List
<
ScoreAdminStudentVO
>
result
=
service
.
students
(
1
,
new
ScoreAdminStudentQueryDTO
());
assertTrue
(
result
.
get
(
0
).
getPaperAvailable
());
assertNull
(
result
.
get
(
0
).
getPaperUnavailableReason
());
assertFalse
(
result
.
get
(
1
).
getPaperAvailable
());
assertEquals
(
"学员尚未交卷"
,
result
.
get
(
1
).
getPaperUnavailableReason
());
assertFalse
(
result
.
get
(
2
).
getPaperAvailable
());
assertEquals
(
"试卷明细不存在"
,
result
.
get
(
2
).
getPaperUnavailableReason
());
}
@Test
void
theoryStudentPaperShouldReturnContinuousSequenceAndModalSummary
()
{
ScoreAdminStudentDetailVO
detail
=
publishedStudentDetail
(
ExamAdminConstants
.
TYPE_THEORY
);
when
(
scoreAdminMapper
.
findStudent
(
2
)).
thenReturn
(
detail
);
ExamReviewQuestionVO
right
=
theoryQuestion
(
"10"
,
true
,
false
);
ExamReviewQuestionVO
partial
=
theoryQuestion
(
"legacy"
,
false
,
true
);
ExamReviewQuestionVO
wrong
=
theoryQuestion
(
null
,
false
,
false
);
when
(
scoreAdminMapper
.
queryTheoryQuestions
(
1
,
"student-1"
))
.
thenReturn
(
Arrays
.
asList
(
right
,
partial
,
wrong
));
ScoreAdminStudentDetailVO
result
=
service
.
student
(
2
);
assertEquals
(
Arrays
.
asList
(
"1"
,
"2"
,
"3"
),
Arrays
.
asList
(
result
.
getTheoryQuestions
().
get
(
0
).
getSequence
(),
result
.
getTheoryQuestions
().
get
(
1
).
getSequence
(),
result
.
getTheoryQuestions
().
get
(
2
).
getSequence
()));
assertEquals
(
3
,
result
.
getTotalQuestionCount
());
assertEquals
(
1
,
result
.
getRightCount
());
assertEquals
(
1
,
result
.
getPartiallyRightCount
());
assertEquals
(
1
,
result
.
getWrongCount
());
assertEquals
(
new
BigDecimal
(
"50.00"
),
result
.
getCorrectRate
());
assertTrue
(
result
.
getPracticeItems
().
isEmpty
());
}
@Test
void
practiceStudentPaperShouldNormalizePositivePartialAndNegativeResultTexts
()
{
ScoreAdminStudentDetailVO
detail
=
publishedStudentDetail
(
ExamAdminConstants
.
TYPE_PRACTICE
);
when
(
scoreAdminMapper
.
findStudent
(
2
)).
thenReturn
(
detail
);
when
(
scoreAdminMapper
.
queryPracticeItems
(
1
,
"student-1"
)).
thenReturn
(
Arrays
.
asList
(
practiceResult
(
"通过"
),
practiceResult
(
"部分通过"
),
practiceResult
(
"未通过"
)));
ScoreAdminStudentDetailVO
result
=
service
.
student
(
2
);
assertEquals
(
3
,
result
.
getTotalQuestionCount
());
assertEquals
(
1
,
result
.
getRightCount
());
assertEquals
(
1
,
result
.
getPartiallyRightCount
());
assertEquals
(
1
,
result
.
getWrongCount
());
assertEquals
(
new
BigDecimal
(
"50.00"
),
result
.
getCorrectRate
());
assertTrue
(
result
.
getTheoryQuestions
().
isEmpty
());
}
@Test
void
publishedStudentWithoutPaperDetailShouldReturnExplicitDataError
()
{
ScoreAdminStudentDetailVO
detail
=
publishedStudentDetail
(
ExamAdminConstants
.
TYPE_THEORY
);
when
(
scoreAdminMapper
.
findStudent
(
2
)).
thenReturn
(
detail
);
when
(
scoreAdminMapper
.
queryTheoryQuestions
(
1
,
"student-1"
))
.
thenReturn
(
Collections
.
emptyList
());
BusinessException
error
=
assertThrows
(
BusinessException
.
class
,
()
->
service
.
student
(
2
));
assertEquals
(
"该学员理论试卷明细不存在,请检查个人试卷数据"
,
error
.
getMessage
());
}
@Test
@Test
void
studentScoreBandShouldDefaultToAll
()
{
void
studentScoreBandShouldDefaultToAll
()
{
when
(
scoreAdminMapper
.
findExam
(
1
)).
thenReturn
(
endedExam
(
false
));
when
(
scoreAdminMapper
.
findExam
(
1
)).
thenReturn
(
endedExam
(
false
));
...
@@ -275,6 +352,44 @@ class ScoreAdminServiceImplTest {
...
@@ -275,6 +352,44 @@ class ScoreAdminServiceImplTest {
10
,
ExamAdminConstants
.
TYPE_PRACTICE
);
10
,
ExamAdminConstants
.
TYPE_PRACTICE
);
}
}
/** 构造列表行的试卷状态,分别覆盖可查看、未交卷和明细缺失三种按钮状态。 */
private
ScoreAdminStudentVO
studentPaperState
(
boolean
submitted
,
boolean
published
,
boolean
paperAvailable
)
{
ScoreAdminStudentVO
student
=
new
ScoreAdminStudentVO
();
student
.
setSubmitted
(
submitted
);
student
.
setPublished
(
published
);
student
.
setPaperAvailable
(
paperAvailable
);
return
student
;
}
/** 构造已经交卷并发布的个人成绩,供理论与实训试卷详情测试复用。 */
private
ScoreAdminStudentDetailVO
publishedStudentDetail
(
String
examType
)
{
ScoreAdminStudentDetailVO
detail
=
new
ScoreAdminStudentDetailVO
();
detail
.
setExamStudentId
(
2
);
detail
.
setExamId
(
1
);
detail
.
setStudentId
(
"student-1"
);
detail
.
setExamType
(
examType
);
detail
.
setSubmitted
(
true
);
detail
.
setPublished
(
true
);
return
detail
;
}
/** 构造理论题判题状态;服务层会覆盖历史sequence并生成连续展示题号。 */
private
ExamReviewQuestionVO
theoryQuestion
(
String
sequence
,
boolean
result
,
boolean
partial
)
{
ExamReviewQuestionVO
question
=
new
ExamReviewQuestionVO
();
question
.
setSequence
(
sequence
);
question
.
setResult
(
result
);
question
.
setPartiallyRight
(
partial
);
return
question
;
}
/** 构造第三方仿真平台返回的实训结果文本。 */
private
FzGradesEntity
practiceResult
(
String
result
)
{
FzGradesEntity
item
=
new
FzGradesEntity
();
item
.
setResult
(
result
);
return
item
;
}
@Test
@Test
void
exportExamShouldAllowMissingOppositeExamAndKeepAbsentStudent
()
throws
Exception
{
void
exportExamShouldAllowMissingOppositeExamAndKeepAbsentStudent
()
throws
Exception
{
ScoreAdminExportExamVO
theoryExam
=
endedExportExam
(
1
,
10
,
"理论"
);
ScoreAdminExportExamVO
theoryExam
=
endedExportExam
(
1
,
10
,
"理论"
);
...
...
practical-business/src/test/java/com/platform/business/service/impl/StudentScoreServiceImplTest.java
View file @
fe41c7d2
package
com.platform.business.service.impl
;
package
com.platform.business.service.impl
;
import
com.platform.business.mapper.StudentScoreMapper
;
import
com.platform.business.mapper.StudentScoreMapper
;
import
com.platform.business.model.dto.StudentScoreQueryDTO
;
import
com.platform.business.model.vo.StudentScoreVO
;
import
com.platform.business.model.vo.StudentScoreVO
;
import
com.platform.exception.BusinessException
;
import
com.platform.exception.BusinessException
;
import
org.junit.jupiter.api.BeforeEach
;
import
org.junit.jupiter.api.BeforeEach
;
import
org.junit.jupiter.api.Test
;
import
org.junit.jupiter.api.Test
;
import
org.junit.jupiter.api.extension.ExtendWith
;
import
org.junit.jupiter.api.extension.ExtendWith
;
import
org.junit.jupiter.params.ParameterizedTest
;
import
org.junit.jupiter.params.provider.ValueSource
;
import
org.mockito.Mock
;
import
org.mockito.Mock
;
import
org.mockito.junit.jupiter.MockitoExtension
;
import
org.mockito.junit.jupiter.MockitoExtension
;
import
org.springframework.mock.web.MockHttpServletResponse
;
import
org.springframework.mock.web.MockHttpServletResponse
;
...
@@ -52,9 +55,36 @@ class StudentScoreServiceImplTest {
...
@@ -52,9 +55,36 @@ class StudentScoreServiceImplTest {
assertThrows
(
BusinessException
.
class
,
()
->
service
.
detail
(
1
,
"student-1"
));
assertThrows
(
BusinessException
.
class
,
()
->
service
.
detail
(
1
,
"student-1"
));
}
}
@Test
@ParameterizedTest
void
theoryDetailShouldAggregateQuestionCountsAndMergeClassAnalysis
()
{
@ValueSource
(
strings
=
{
"理论"
,
"理论考试"
,
"THEORY"
})
StudentScoreVO
.
Detail
detail
=
detail
(
"理论"
);
void
theoryFilterAliasesShouldNormalizeToCanonicalValue
(
String
inputType
)
{
StudentScoreQueryDTO
query
=
new
StudentScoreQueryDTO
();
query
.
setType
(
inputType
);
when
(
mapper
.
selectPage
(
query
,
"student-1"
)).
thenReturn
(
Collections
.
emptyList
());
service
.
page
(
query
,
"student-1"
);
// Mapper只接收稳定规范值,具体历史别名匹配由SQL统一完成。
assertEquals
(
"理论考试"
,
query
.
getType
());
}
@ParameterizedTest
@ValueSource
(
strings
=
{
"实训"
,
"实训考试"
,
"PRACTICE"
})
void
practiceFilterAliasesShouldNormalizeToCanonicalValue
(
String
inputType
)
{
StudentScoreQueryDTO
query
=
new
StudentScoreQueryDTO
();
query
.
setType
(
inputType
);
when
(
mapper
.
selectPage
(
query
,
"student-1"
)).
thenReturn
(
Collections
.
emptyList
());
service
.
page
(
query
,
"student-1"
);
// 保持与理论筛选一致,避免控制器传入短值时被错误拒绝。
assertEquals
(
"实训考试"
,
query
.
getType
());
}
@ParameterizedTest
@ValueSource
(
strings
=
{
"理论"
,
"理论考试"
,
"THEORY"
})
void
theoryAliasesShouldLoadQuestionsAndAggregateAnalysis
(
String
examType
)
{
StudentScoreVO
.
Detail
detail
=
detail
(
examType
);
when
(
mapper
.
selectDetail
(
1
,
"student-1"
)).
thenReturn
(
detail
);
when
(
mapper
.
selectDetail
(
1
,
"student-1"
)).
thenReturn
(
detail
);
StudentScoreVO
.
TheoryQuestion
right
=
theoryQuestion
(
true
,
false
);
StudentScoreVO
.
TheoryQuestion
right
=
theoryQuestion
(
true
,
false
);
StudentScoreVO
.
TheoryQuestion
partial
=
theoryQuestion
(
false
,
true
);
StudentScoreVO
.
TheoryQuestion
partial
=
theoryQuestion
(
false
,
true
);
...
@@ -81,9 +111,10 @@ class StudentScoreServiceImplTest {
...
@@ -81,9 +111,10 @@ class StudentScoreServiceImplTest {
assertEquals
(
70
D
,
result
.
getTypeAnalysis
().
get
(
0
).
getClassAverageRate
());
assertEquals
(
70
D
,
result
.
getTypeAnalysis
().
get
(
0
).
getClassAverageRate
());
}
}
@Test
@ParameterizedTest
void
practiceDetailShouldUseExistingResultTextWithoutInventingMaxScores
()
{
@ValueSource
(
strings
=
{
"实训"
,
"实训考试"
,
"PRACTICE"
})
StudentScoreVO
.
Detail
detail
=
detail
(
"实训"
);
void
practiceAliasesShouldLoadItemsWithoutInventingMaxScores
(
String
examType
)
{
StudentScoreVO
.
Detail
detail
=
detail
(
examType
);
when
(
mapper
.
selectDetail
(
1
,
"student-1"
)).
thenReturn
(
detail
);
when
(
mapper
.
selectDetail
(
1
,
"student-1"
)).
thenReturn
(
detail
);
StudentScoreVO
.
PracticeItem
pass
=
new
StudentScoreVO
.
PracticeItem
();
StudentScoreVO
.
PracticeItem
pass
=
new
StudentScoreVO
.
PracticeItem
();
pass
.
setResult
(
"通过"
);
pass
.
setResult
(
"通过"
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment