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
df776d52
Commit
df776d52
authored
Sep 04, 2026
by
wujipeng
Browse files
优化
parent
0dab2c99
Changes
6
Hide whitespace changes
Inline
Side-by-side
practical-api/practical-business-api/src/main/java/com/platform/business/model/vo/StudentExamCenterVO.java
View file @
df776d52
...
@@ -123,6 +123,7 @@ public final class StudentExamCenterVO {
...
@@ -123,6 +123,7 @@ public final class StudentExamCenterVO {
@Data
@Data
public
static
class
SubmitResult
{
public
static
class
SubmitResult
{
private
Integer
examStudentId
;
private
Integer
examStudentId
;
/** 面向学生端交卷完成弹窗展示的中文状态文案,例如“已交卷”。 */
private
String
status
;
private
String
status
;
private
Integer
totalCount
;
private
Integer
totalCount
;
private
Integer
answeredCount
;
private
Integer
answeredCount
;
...
...
practical-business/src/main/java/com/platform/business/service/impl/StudentExamCenterServiceImpl.java
View file @
df776d52
...
@@ -44,6 +44,11 @@ public class StudentExamCenterServiceImpl implements StudentExamCenterService {
...
@@ -44,6 +44,11 @@ public class StudentExamCenterServiceImpl implements StudentExamCenterService {
private
static
final
int
MAX_KEYWORD_LENGTH
=
40
;
private
static
final
int
MAX_KEYWORD_LENGTH
=
40
;
private
static
final
int
MAX_ANSWER_LENGTH
=
2000
;
private
static
final
int
MAX_ANSWER_LENGTH
=
2000
;
/**
* 交卷结果面向学生端弹窗展示,因此返回中文文案而不是内部流程状态码。
* 列表中的 workflowStatus 仍保留 SUBMITTED,避免影响状态筛选和流程判断。
*/
private
static
final
String
SUBMIT_STATUS_TEXT
=
"已交卷"
;
private
static
final
DateTimeFormatter
ANSWER_TIME_FORMATTER
=
private
static
final
DateTimeFormatter
ANSWER_TIME_FORMATTER
=
DateTimeFormatter
.
ofPattern
(
"yyyy.MM.dd HH:mm:ss"
);
DateTimeFormatter
.
ofPattern
(
"yyyy.MM.dd HH:mm:ss"
);
...
@@ -441,7 +446,7 @@ public class StudentExamCenterServiceImpl implements StudentExamCenterService {
...
@@ -441,7 +446,7 @@ public class StudentExamCenterServiceImpl implements StudentExamCenterService {
String
duration
)
{
String
duration
)
{
StudentExamCenterVO
.
SubmitResult
result
=
new
StudentExamCenterVO
.
SubmitResult
();
StudentExamCenterVO
.
SubmitResult
result
=
new
StudentExamCenterVO
.
SubmitResult
();
result
.
setExamStudentId
(
attempt
.
getId
());
result
.
setExamStudentId
(
attempt
.
getId
());
result
.
setStatus
(
"
SUBMIT
TED"
);
result
.
setStatus
(
SUBMIT
_STATUS_TEXT
);
result
.
setTotalCount
(
check
.
getTotalCount
());
result
.
setTotalCount
(
check
.
getTotalCount
());
result
.
setAnsweredCount
(
check
.
getAnsweredCount
());
result
.
setAnsweredCount
(
check
.
getAnsweredCount
());
result
.
setUnansweredCount
(
check
.
getUnansweredCount
());
result
.
setUnansweredCount
(
check
.
getUnansweredCount
());
...
...
practical-business/src/main/resources/com/platform/business/mapper/ClassSubjectMapper.xml
View file @
df776d52
...
@@ -76,13 +76,22 @@
...
@@ -76,13 +76,22 @@
cs.remark,
cs.remark,
cs.location,
cs.location,
cs.type,
cs.type,
c.name as className
c.name as className,
coalesce(nullif(teacher.nick_name, ''), teacher.username) as teacherName
from
from
class_subject cs
class_subject cs
left join
left join
class c
class c
on
on
cs.class_id = c.id
cs.class_id = c.id
<!--
学员端课程详情弹窗直接复用日历列表中的课程对象,因此列表查询必须同步返回教师姓名。
nick_name 可能为空字符串,统一回退到登录名,避免已正确关联教师时仍展示为空。
-->
left join
user teacher
on
cs.teacher_id = teacher.id
where
where
cs.class_id in
cs.class_id in
<foreach
item=
"item"
index=
"index"
collection=
"classIds"
open=
"("
separator=
","
close=
")"
>
<foreach
item=
"item"
index=
"index"
collection=
"classIds"
open=
"("
separator=
","
close=
")"
>
...
@@ -123,7 +132,7 @@
...
@@ -123,7 +132,7 @@
type as subjectType,
type as subjectType,
cs.id as subjectId,
cs.id as subjectId,
subject_name as subjectName,
subject_name as subjectName,
u.nick_name
as teacherName,
coalesce(nullif(u.nick_name, ''), u.username)
as teacherName,
location,
location,
date as subjectTime
date as subjectTime
from
from
...
@@ -154,7 +163,7 @@
...
@@ -154,7 +163,7 @@
cs.remark,
cs.remark,
cs.location,
cs.location,
cs.type,
cs.type,
u.nick_name
as teacherName,
coalesce(nullif(u.nick_name, ''), u.username)
as teacherName,
c.name as className
c.name as className
from
from
class_subject cs
class_subject cs
...
...
practical-business/src/main/resources/student-exam-center-api.md
View file @
df776d52
...
@@ -29,6 +29,7 @@
...
@@ -29,6 +29,7 @@
-
`PUT /attempts/{examStudentId}/questions/{questionId}/answer`
:请求体
`{ "actualChoice": "A" }`
;
-
`PUT /attempts/{examStudentId}/questions/{questionId}/answer`
:请求体
`{ "actualChoice": "A" }`
;
传
`null`
或空白表示清空本题答案。
传
`null`
或空白表示清空本题答案。
-
`GET /attempts/{examStudentId}/submit-check`
:返回已答/未答数量和禁交状态。
-
`GET /attempts/{examStudentId}/submit-check`
:返回已答/未答数量和禁交状态。
-
`POST /attempts/{examStudentId}/submit`
:确认交卷;重复网络请求幂等返回,响应不包含未发布分数。
-
`POST /attempts/{examStudentId}/submit`
:确认交卷;重复网络请求幂等返回,响应不包含未发布分数;
返回结果中的
`status`
为面向交卷完成弹窗展示的中文文案“已交卷”。
所有应考、试卷和题目查询都同时校验
`examStudentId/questionId + JWT学员ID`
。
所有应考、试卷和题目查询都同时校验
`examStudentId/questionId + JWT学员ID`
。
practical-business/src/test/java/com/platform/business/mapper/TeacherCourseMapperXmlTest.java
View file @
df776d52
...
@@ -58,8 +58,22 @@ class TeacherCourseMapperXmlTest {
...
@@ -58,8 +58,22 @@ class TeacherCourseMapperXmlTest {
"com.platform.business.mapper.ClassSubjectMapper.todayCourse"
)
"com.platform.business.mapper.ClassSubjectMapper.todayCourse"
)
.
getBoundSql
(
todayParameters
).
getSql
());
.
getBoundSql
(
todayParameters
).
getSql
());
assertTrue
(
todaySql
.
contains
(
"cs.date = ?"
));
assertTrue
(
todaySql
.
contains
(
"cs.date = ?"
));
assertTrue
(
todaySql
.
contains
(
"coalesce(nullif(u.nick_name, ''), u.username) as teacherName"
));
assertTrue
(
todaySql
.
contains
(
"order by cs.time_frame asc, cs.id asc"
));
assertTrue
(
todaySql
.
contains
(
"order by cs.time_frame asc, cs.id asc"
));
Map
<
String
,
Object
>
scheduleParameters
=
new
HashMap
<>();
scheduleParameters
.
put
(
"classIds"
,
Collections
.
singletonList
(
10
));
scheduleParameters
.
put
(
"startDate"
,
new
Date
());
scheduleParameters
.
put
(
"endDate"
,
new
Date
());
String
scheduleSql
=
compact
(
configuration
.
getMappedStatement
(
"com.platform.business.mapper.ClassSubjectMapper.queryOneself"
)
.
getBoundSql
(
scheduleParameters
).
getSql
());
// 详情弹窗使用日历列表项作为数据源,回归测试必须保证列表查询已经补齐教师关联和姓名。
assertTrue
(
scheduleSql
.
contains
(
"left join user teacher on cs.teacher_id = teacher.id"
));
assertTrue
(
scheduleSql
.
contains
(
"coalesce(nullif(teacher.nick_name, ''), teacher.username) as teacherName"
));
ClassSubjectDTO
detailQuery
=
new
ClassSubjectDTO
();
ClassSubjectDTO
detailQuery
=
new
ClassSubjectDTO
();
detailQuery
.
setDate
(
"2026-08-19"
);
detailQuery
.
setDate
(
"2026-08-19"
);
detailQuery
.
setClassIds
(
Collections
.
singletonList
(
10
));
detailQuery
.
setClassIds
(
Collections
.
singletonList
(
10
));
...
@@ -68,7 +82,8 @@ class TeacherCourseMapperXmlTest {
...
@@ -68,7 +82,8 @@ class TeacherCourseMapperXmlTest {
.
getBoundSql
(
detailQuery
).
getSql
());
.
getBoundSql
(
detailQuery
).
getSql
());
assertTrue
(
detailSql
.
contains
(
"cs.id"
));
assertTrue
(
detailSql
.
contains
(
"cs.id"
));
assertTrue
(
detailSql
.
contains
(
"cs.date"
));
assertTrue
(
detailSql
.
contains
(
"cs.date"
));
assertTrue
(
detailSql
.
contains
(
"u.nick_name as teacherName"
));
assertTrue
(
detailSql
.
contains
(
"coalesce(nullif(u.nick_name, ''), u.username) as teacherName"
));
assertTrue
(
detailSql
.
contains
(
"cs.class_id in"
));
assertTrue
(
detailSql
.
contains
(
"cs.class_id in"
));
Map
<
String
,
Object
>
attendanceParameters
=
new
HashMap
<>();
Map
<
String
,
Object
>
attendanceParameters
=
new
HashMap
<>();
...
...
practical-business/src/test/java/com/platform/business/service/impl/StudentExamCenterServiceImplTest.java
View file @
df776d52
...
@@ -28,7 +28,6 @@ import java.util.List;
...
@@ -28,7 +28,6 @@ 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
.
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
.
mockito
.
ArgumentMatchers
.
any
;
import
static
org
.
mockito
.
ArgumentMatchers
.
any
;
import
static
org
.
mockito
.
ArgumentMatchers
.
anyCollection
;
import
static
org
.
mockito
.
ArgumentMatchers
.
anyCollection
;
import
static
org
.
mockito
.
ArgumentMatchers
.
eq
;
import
static
org
.
mockito
.
ArgumentMatchers
.
eq
;
...
@@ -177,7 +176,7 @@ class StudentExamCenterServiceImplTest {
...
@@ -177,7 +176,7 @@ class StudentExamCenterServiceImplTest {
StudentExamCenterVO
.
SubmitResult
result
=
service
.
submit
(
1
,
"student-1"
);
StudentExamCenterVO
.
SubmitResult
result
=
service
.
submit
(
1
,
"student-1"
);
assertEquals
(
"
SUBMITTED
"
,
result
.
getStatus
());
assertEquals
(
"
已交卷
"
,
result
.
getStatus
());
assertEquals
(
2
,
result
.
getAnsweredCount
());
assertEquals
(
2
,
result
.
getAnsweredCount
());
verify
(
mapper
).
updateQuestionResult
(
"q-1"
,
true
,
5
D
);
verify
(
mapper
).
updateQuestionResult
(
"q-1"
,
true
,
5
D
);
verify
(
mapper
).
updateQuestionResult
(
"q-2"
,
false
,
0
D
);
verify
(
mapper
).
updateQuestionResult
(
"q-2"
,
false
,
0
D
);
...
@@ -194,10 +193,27 @@ class StudentExamCenterServiceImplTest {
...
@@ -194,10 +193,27 @@ class StudentExamCenterServiceImplTest {
.
thenReturn
(
Collections
.
singletonList
(
question
(
"q-1"
,
"单选题"
,
"A"
,
"A"
,
5
D
)));
.
thenReturn
(
Collections
.
singletonList
(
question
(
"q-1"
,
"单选题"
,
"A"
,
"A"
,
5
D
)));
StudentExamCenterVO
.
SubmitResult
result
=
service
.
submit
(
1
,
"student-1"
);
StudentExamCenterVO
.
SubmitResult
result
=
service
.
submit
(
1
,
"student-1"
);
assert
True
(
"SUBMITTED"
.
equals
(
result
.
getStatus
())
)
;
assert
Equals
(
"已交卷"
,
result
.
getStatus
());
verify
(
mapper
,
never
()).
updateAttemptSubmitted
(
any
(),
any
(),
any
(),
any
());
verify
(
mapper
,
never
()).
updateAttemptSubmitted
(
any
(),
any
(),
any
(),
any
());
}
}
@Test
void
submitResultShouldExposeChineseStatusForCompletionDialog
()
{
StudentExamCenterVO
.
Attempt
attempt
=
attempt
(
true
);
StudentExamCenterVO
.
SubmitCheck
check
=
new
StudentExamCenterVO
.
SubmitCheck
();
check
.
setTotalCount
(
120
);
check
.
setAnsweredCount
(
13
);
check
.
setUnansweredCount
(
107
);
// 普通交卷与重复交卷都调用同一个结果构建方法,隔离验证可覆盖两条响应路径的展示文案。
StudentExamCenterVO
.
SubmitResult
result
=
ReflectionTestUtils
.
invokeMethod
(
service
,
"buildSubmitResult"
,
attempt
,
check
,
"00:03:31"
);
assertEquals
(
"已交卷"
,
result
.
getStatus
());
assertEquals
(
13
,
result
.
getAnsweredCount
());
assertEquals
(
107
,
result
.
getUnansweredCount
());
}
@Test
@Test
void
submitShouldRespectConfiguredForbidMinutes
()
{
void
submitShouldRespectConfiguredForbidMinutes
()
{
StudentExamCenterVO
.
Attempt
attempt
=
attempt
(
false
);
StudentExamCenterVO
.
Attempt
attempt
=
attempt
(
false
);
...
...
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