fix(aihr): bind assignment completion to session

This commit is contained in:
2026-07-14 11:27:42 +08:00
parent 516bfabee3
commit 23cc4bc7bc
3 changed files with 9 additions and 1 deletions
@@ -656,7 +656,7 @@ public class AihrPracticeSeedService {
String extPartyId = activeSession == null ? trainee : activeSession.extPartyId();
RecordResponse record = new RecordResponse(null, sessionId, formatNow(), trainee, scenario.name(), result.total(), "待复盘", result.summary(), extPartyId);
savePracticeRecord(sessionId, activeSession, scenario, record, result);
markAssignmentCompleted(request == null ? null : request.assignmentId(), activeSession);
markAssignmentCompleted(activeSession == null ? null : activeSession.assignmentId(), activeSession);
return new FinishResponse(
result.total(),
result.scores(),
@@ -149,6 +149,13 @@ public class AihrPracticeSeedServiceTest {
assertTrue(method.contains("训练任务场景与请求不一致"));
}
@Test
public void finishUsesAssignmentBoundToActiveSession() throws Exception {
String source = Files.readString(Path.of("src/main/java/org/dromara/aihr/service/AihrPracticeSeedService.java"));
assertTrue(source.contains("markAssignmentCompleted(activeSession == null ? null : activeSession.assignmentId(), activeSession)"));
assertFalse(source.contains("markAssignmentCompleted(request == null ? null : request.assignmentId(), activeSession)"));
}
@Test
public void mobilePracticeSessionRejectsForeignAndUnknownOwner() {
JdbcTemplate jdbcTemplate = mock(JdbcTemplate.class);