fix(aihr): persist daily drill scores
This commit is contained in:
+1
@@ -262,6 +262,7 @@ public final class AihrPracticeDto {
|
||||
String userAnswer,
|
||||
String feedback,
|
||||
Boolean correct,
|
||||
Integer score,
|
||||
String audioUrl,
|
||||
Long audioOssId
|
||||
) {
|
||||
|
||||
+11
-6
@@ -993,7 +993,7 @@ public class AihrPracticeSeedService {
|
||||
args.add(limit);
|
||||
String sql = """
|
||||
SELECT id, ext_party_id, trainee_name, scenario_id, scenario_name, source, reason, status, create_time,
|
||||
answer_text, answer_audio_url, answer_audio_oss_id, feedback, correct
|
||||
answer_text, answer_audio_url, answer_audio_oss_id, feedback, correct, score
|
||||
FROM aihr_practice_assignment
|
||||
%s
|
||||
ORDER BY create_time DESC, id DESC
|
||||
@@ -1716,7 +1716,7 @@ public class AihrPracticeSeedService {
|
||||
ensureDailyDrills(party);
|
||||
return jdbcTemplate.query("""
|
||||
SELECT id, ext_party_id, trainee_name, scenario_id, scenario_name, source, reason, status, create_time,
|
||||
answer_text, answer_audio_url, answer_audio_oss_id, feedback, correct
|
||||
answer_text, answer_audio_url, answer_audio_oss_id, feedback, correct, score
|
||||
FROM aihr_practice_assignment
|
||||
WHERE tenant_id = ?
|
||||
AND (? = '' OR ext_party_id = ?)
|
||||
@@ -1754,7 +1754,7 @@ public class AihrPracticeSeedService {
|
||||
args.add(normalizeLimit(limit));
|
||||
return jdbcTemplate.query("""
|
||||
SELECT id, ext_party_id, trainee_name, scenario_id, scenario_name, source, reason, status, create_time,
|
||||
answer_text, answer_audio_url, answer_audio_oss_id, feedback, correct
|
||||
answer_text, answer_audio_url, answer_audio_oss_id, feedback, correct, score
|
||||
FROM aihr_practice_assignment
|
||||
WHERE tenant_id = ?
|
||||
AND ext_party_id IN (%s)
|
||||
@@ -1857,13 +1857,13 @@ public class AihrPracticeSeedService {
|
||||
""", tenantId(), extPartyId, traineeName, scenario.id(), firstNonBlank(request == null ? null : request.scenarioName(), scenario.name()), source, reason, createdAt, createdAt);
|
||||
List<PracticeAssignmentResponse> rows = jdbcTemplate.query("""
|
||||
SELECT id, ext_party_id, trainee_name, scenario_id, scenario_name, source, reason, status, create_time,
|
||||
answer_text, answer_audio_url, answer_audio_oss_id, feedback, correct
|
||||
answer_text, answer_audio_url, answer_audio_oss_id, feedback, correct, score
|
||||
FROM aihr_practice_assignment
|
||||
WHERE tenant_id = ? AND ext_party_id = ? AND scenario_id = ? AND source = ? AND reason = ?
|
||||
ORDER BY id DESC
|
||||
LIMIT 1
|
||||
""", this::mapAssignment, tenantId(), extPartyId, scenario.id(), source, reason);
|
||||
return rows.isEmpty() ? new PracticeAssignmentResponse(null, extPartyId, traineeName, scenario.id(), scenario.name(), source, reason, "待训练", now.format(TIME_FORMATTER), null, null, null, null, null, null, null) : rows.get(0);
|
||||
return rows.isEmpty() ? new PracticeAssignmentResponse(null, extPartyId, traineeName, scenario.id(), scenario.name(), source, reason, "待训练", now.format(TIME_FORMATTER), null, null, null, null, null, null, null, null) : rows.get(0);
|
||||
}
|
||||
|
||||
public PracticeAssignmentResponse createAssignment(PracticeAssignmentRequest request, String supervisorExtPartyId) {
|
||||
@@ -1935,6 +1935,7 @@ public class AihrPracticeSeedService {
|
||||
answer_audio_oss_id = ?,
|
||||
feedback = ?,
|
||||
correct = ?,
|
||||
score = ?,
|
||||
finished_time = ?,
|
||||
update_time = ?
|
||||
WHERE tenant_id = ? AND id = ? AND source = 'daily'
|
||||
@@ -1946,6 +1947,7 @@ public class AihrPracticeSeedService {
|
||||
audioOssId,
|
||||
score.feedback(),
|
||||
score.correct() ? 1 : 0,
|
||||
score.score(),
|
||||
Timestamp.valueOf(now),
|
||||
Timestamp.valueOf(now),
|
||||
tenantId(),
|
||||
@@ -2509,6 +2511,7 @@ public class AihrPracticeSeedService {
|
||||
rs.getString("answer_text"),
|
||||
"daily".equals(source) ? stripReferenceAnswer(rs.getString("feedback")) : rs.getString("feedback"),
|
||||
correctValue == null ? null : rs.getBoolean("correct"),
|
||||
rs.getObject("score") == null ? null : rs.getInt("score"),
|
||||
rs.getString("answer_audio_url"),
|
||||
rs.getObject("answer_audio_oss_id") == null ? null : rs.getLong("answer_audio_oss_id")
|
||||
);
|
||||
@@ -3315,6 +3318,7 @@ public class AihrPracticeSeedService {
|
||||
`answer_audio_oss_id` bigint DEFAULT NULL COMMENT '每日三题语音OSS编号',
|
||||
`feedback` varchar(1000) DEFAULT NULL COMMENT '每日三题反馈',
|
||||
`correct` tinyint DEFAULT NULL COMMENT '是否答对',
|
||||
`score` int DEFAULT NULL COMMENT '每日三题得分',
|
||||
`finished_time` datetime DEFAULT NULL COMMENT '完成时间',
|
||||
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
|
||||
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
|
||||
@@ -3328,7 +3332,8 @@ public class AihrPracticeSeedService {
|
||||
ensureColumn("aihr_practice_assignment", "answer_audio_oss_id", "ALTER TABLE aihr_practice_assignment ADD COLUMN `answer_audio_oss_id` bigint DEFAULT NULL COMMENT '每日三题语音OSS编号' AFTER `answer_audio_url`");
|
||||
ensureColumn("aihr_practice_assignment", "feedback", "ALTER TABLE aihr_practice_assignment ADD COLUMN `feedback` varchar(1000) DEFAULT NULL COMMENT '每日三题反馈' AFTER `answer_audio_oss_id`");
|
||||
ensureColumn("aihr_practice_assignment", "correct", "ALTER TABLE aihr_practice_assignment ADD COLUMN `correct` tinyint DEFAULT NULL COMMENT '是否答对' AFTER `feedback`");
|
||||
ensureColumn("aihr_practice_assignment", "finished_time", "ALTER TABLE aihr_practice_assignment ADD COLUMN `finished_time` datetime DEFAULT NULL COMMENT '完成时间' AFTER `correct`");
|
||||
ensureColumn("aihr_practice_assignment", "score", "ALTER TABLE aihr_practice_assignment ADD COLUMN `score` int DEFAULT NULL COMMENT '每日三题得分' AFTER `correct`");
|
||||
ensureColumn("aihr_practice_assignment", "finished_time", "ALTER TABLE aihr_practice_assignment ADD COLUMN `finished_time` datetime DEFAULT NULL COMMENT '完成时间' AFTER `score`");
|
||||
assignmentTableReady = true;
|
||||
}
|
||||
}
|
||||
|
||||
+14
@@ -135,6 +135,20 @@ public class AihrPracticeSeedServiceTest {
|
||||
assertTrue(method.contains("if (updated == 0)"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void dailyDrillScoreSurvivesAssignmentRefresh() throws Exception {
|
||||
String source = Files.readString(Path.of("src/main/java/org/dromara/aihr/service/AihrPracticeSeedService.java"));
|
||||
int answerStart = source.indexOf("public DailyDrillAnswerResponse answerDailyDrill");
|
||||
int answerEnd = source.indexOf("public List<PromptTemplateResponse> promptTemplates", answerStart);
|
||||
assertTrue(answerStart >= 0 && answerEnd > answerStart);
|
||||
String answerMethod = source.substring(answerStart, answerEnd);
|
||||
assertTrue(answerMethod.contains("score = ?"));
|
||||
assertTrue(answerMethod.contains("score.score()"));
|
||||
assertTrue(source.contains("feedback, correct, score"));
|
||||
assertTrue(source.contains("rs.getObject(\"score\")"));
|
||||
assertTrue(source.contains("ADD COLUMN `score` int"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void mobileAssignmentStartValidatesOwnerStatusAndScenario() throws Exception {
|
||||
String source = Files.readString(Path.of("src/main/java/org/dromara/aihr/service/AihrPracticeSeedService.java"));
|
||||
|
||||
Reference in New Issue
Block a user