Commit df776d52 authored by wujipeng's avatar wujipeng
Browse files

优化

parent 0dab2c99
......@@ -123,6 +123,7 @@ public final class StudentExamCenterVO {
@Data
public static class SubmitResult {
private Integer examStudentId;
/** 面向学生端交卷完成弹窗展示的中文状态文案,例如“已交卷”。 */
private String status;
private Integer totalCount;
private Integer answeredCount;
......
......@@ -44,6 +44,11 @@ public class StudentExamCenterServiceImpl implements StudentExamCenterService {
private static final int MAX_KEYWORD_LENGTH = 40;
private static final int MAX_ANSWER_LENGTH = 2000;
/**
* 交卷结果面向学生端弹窗展示,因此返回中文文案而不是内部流程状态码。
* 列表中的 workflowStatus 仍保留 SUBMITTED,避免影响状态筛选和流程判断。
*/
private static final String SUBMIT_STATUS_TEXT = "已交卷";
private static final DateTimeFormatter ANSWER_TIME_FORMATTER =
DateTimeFormatter.ofPattern("yyyy.MM.dd HH:mm:ss");
......@@ -441,7 +446,7 @@ public class StudentExamCenterServiceImpl implements StudentExamCenterService {
String duration) {
StudentExamCenterVO.SubmitResult result = new StudentExamCenterVO.SubmitResult();
result.setExamStudentId(attempt.getId());
result.setStatus("SUBMITTED");
result.setStatus(SUBMIT_STATUS_TEXT);
result.setTotalCount(check.getTotalCount());
result.setAnsweredCount(check.getAnsweredCount());
result.setUnansweredCount(check.getUnansweredCount());
......
......@@ -76,13 +76,22 @@
cs.remark,
cs.location,
cs.type,
c.name as className
c.name as className,
coalesce(nullif(teacher.nick_name, ''), teacher.username) as teacherName
from
class_subject cs
left join
class c
on
cs.class_id = c.id
<!--
学员端课程详情弹窗直接复用日历列表中的课程对象,因此列表查询必须同步返回教师姓名。
nick_name 可能为空字符串,统一回退到登录名,避免已正确关联教师时仍展示为空。
-->
left join
user teacher
on
cs.teacher_id = teacher.id
where
cs.class_id in
<foreach item="item" index="index" collection="classIds" open="(" separator="," close=")">
......@@ -123,7 +132,7 @@
type as subjectType,
cs.id as subjectId,
subject_name as subjectName,
u.nick_name as teacherName,
coalesce(nullif(u.nick_name, ''), u.username) as teacherName,
location,
date as subjectTime
from
......@@ -154,7 +163,7 @@
cs.remark,
cs.location,
cs.type,
u.nick_name as teacherName,
coalesce(nullif(u.nick_name, ''), u.username) as teacherName,
c.name as className
from
class_subject cs
......
......@@ -29,6 +29,7 @@
- `PUT /attempts/{examStudentId}/questions/{questionId}/answer`:请求体 `{ "actualChoice": "A" }`;
传 `null` 或空白表示清空本题答案。
- `GET /attempts/{examStudentId}/submit-check`:返回已答/未答数量和禁交状态。
- `POST /attempts/{examStudentId}/submit`:确认交卷;重复网络请求幂等返回,响应不包含未发布分数。
- `POST /attempts/{examStudentId}/submit`:确认交卷;重复网络请求幂等返回,响应不包含未发布分数;
返回结果中的 `status` 为面向交卷完成弹窗展示的中文文案“已交卷”。
所有应考、试卷和题目查询都同时校验 `examStudentId/questionId + JWT学员ID`。
......@@ -58,8 +58,22 @@ class TeacherCourseMapperXmlTest {
"com.platform.business.mapper.ClassSubjectMapper.todayCourse")
.getBoundSql(todayParameters).getSql());
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"));
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();
detailQuery.setDate("2026-08-19");
detailQuery.setClassIds(Collections.singletonList(10));
......@@ -68,7 +82,8 @@ class TeacherCourseMapperXmlTest {
.getBoundSql(detailQuery).getSql());
assertTrue(detailSql.contains("cs.id"));
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"));
Map<String, Object> attendanceParameters = new HashMap<>();
......
......@@ -28,7 +28,6 @@ import java.util.List;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
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.anyCollection;
import static org.mockito.ArgumentMatchers.eq;
......@@ -177,7 +176,7 @@ class StudentExamCenterServiceImplTest {
StudentExamCenterVO.SubmitResult result = service.submit(1, "student-1");
assertEquals("SUBMITTED", result.getStatus());
assertEquals("已交卷", result.getStatus());
assertEquals(2, result.getAnsweredCount());
verify(mapper).updateQuestionResult("q-1", true, 5D);
verify(mapper).updateQuestionResult("q-2", false, 0D);
......@@ -194,10 +193,27 @@ class StudentExamCenterServiceImplTest {
.thenReturn(Collections.singletonList(question("q-1", "单选题", "A", "A", 5D)));
StudentExamCenterVO.SubmitResult result = service.submit(1, "student-1");
assertTrue("SUBMITTED".equals(result.getStatus()));
assertEquals("已交卷", result.getStatus());
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
void submitShouldRespectConfiguredForbidMinutes() {
StudentExamCenterVO.Attempt attempt = attempt(false);
......
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