feat: persist AI training evaluations
parent
e21fec9c75
commit
0c2a9a2184
@ -0,0 +1,28 @@
|
|||||||
|
# Task 1: AI Training Evaluation Persistence Report
|
||||||
|
|
||||||
|
## Delivered
|
||||||
|
|
||||||
|
- Added `docs/sql/2026-07-16-ai-training-evaluation.sql`.
|
||||||
|
- Creates `ai_training_evaluation` with a unique `(student_user_id, teaching_class_id, task_id)` key.
|
||||||
|
- Persists independent help and assessment statuses, task/answer snapshots, reports, raw model responses, model names, completion times, errors, and assessment score.
|
||||||
|
- Adds nullable `student_training_answer.ai_assessment_score`.
|
||||||
|
- Added `AiTrainingEvaluation`, `AiTrainingEvaluationMapper`, and its MyBatis XML mapping.
|
||||||
|
- `findByStudentClassAndTask` retrieves the sole evaluation record for a student, teaching class, and task.
|
||||||
|
- `insertIgnore` safely creates the record under concurrent requests.
|
||||||
|
- `claimHelp` and `claimAssessment` transition only `NOT_STARTED` or `FAILED` rows to `PROCESSING`.
|
||||||
|
- Completion and failure operations update only rows currently in `PROCESSING`.
|
||||||
|
- Added `aiAssessmentScore` to `StudentTrainingAnswer`, its XML result/column/dynamic insert/dynamic update mappings, and `updateAiAssessmentScore` for a targeted score write-back.
|
||||||
|
- Added the assessment score column to the fresh `student_training_answer` table DDL in `StudentTrainingAnswerServiceImpl`.
|
||||||
|
|
||||||
|
## Test-first evidence
|
||||||
|
|
||||||
|
1. Added `AiTrainingEvaluationServiceImplTest` before implementation.
|
||||||
|
2. Ran `mvn -Dtest=AiTrainingEvaluationServiceImplTest test` before production changes.
|
||||||
|
- Expected RED result: test compilation failed because `AiTrainingEvaluation` and `AiTrainingEvaluationMapper` did not exist.
|
||||||
|
3. Implemented the persistence files and re-ran the same targeted Maven test.
|
||||||
|
- GREEN result: 3 tests run; 0 failures; 0 errors; 0 skipped.
|
||||||
|
|
||||||
|
## Verification notes
|
||||||
|
|
||||||
|
- `git diff --check` completed without whitespace errors.
|
||||||
|
- Maven emitted existing project-model warnings about local Aspose `systemPath` dependencies and the relocated MySQL connector artifact. They do not originate from this task and did not prevent compilation or the targeted test from succeeding.
|
||||||
@ -0,0 +1,31 @@
|
|||||||
|
CREATE TABLE IF NOT EXISTS ai_training_evaluation (
|
||||||
|
id varchar(64) NOT NULL,
|
||||||
|
student_user_id varchar(64) NOT NULL,
|
||||||
|
teaching_class_id varchar(64) NOT NULL,
|
||||||
|
task_id varchar(64) NOT NULL,
|
||||||
|
task_key varchar(128) NOT NULL,
|
||||||
|
help_status varchar(16) NOT NULL DEFAULT 'NOT_STARTED',
|
||||||
|
help_task_snapshot longtext NULL,
|
||||||
|
help_answer_snapshot longtext NULL,
|
||||||
|
help_report_json longtext NULL,
|
||||||
|
help_raw_response longtext NULL,
|
||||||
|
help_model varchar(128) NULL,
|
||||||
|
help_completed_at datetime NULL,
|
||||||
|
help_error_message varchar(1000) NULL,
|
||||||
|
assessment_status varchar(16) NOT NULL DEFAULT 'NOT_STARTED',
|
||||||
|
assessment_task_snapshot longtext NULL,
|
||||||
|
assessment_answer_snapshot longtext NULL,
|
||||||
|
assessment_score int NULL,
|
||||||
|
assessment_report_json longtext NULL,
|
||||||
|
assessment_raw_response longtext NULL,
|
||||||
|
assessment_model varchar(128) NULL,
|
||||||
|
assessment_completed_at datetime NULL,
|
||||||
|
assessment_error_message varchar(1000) NULL,
|
||||||
|
create_time datetime NOT NULL,
|
||||||
|
update_time datetime NOT NULL,
|
||||||
|
PRIMARY KEY (id),
|
||||||
|
UNIQUE KEY uk_ai_training_evaluation (student_user_id, teaching_class_id, task_id)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||||
|
|
||||||
|
ALTER TABLE student_training_answer
|
||||||
|
ADD COLUMN IF NOT EXISTS ai_assessment_score int NULL;
|
||||||
@ -0,0 +1,83 @@
|
|||||||
|
package com.sztzjy.linkCommerce.entity;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
public class AiTrainingEvaluation {
|
||||||
|
private String id;
|
||||||
|
private String studentUserId;
|
||||||
|
private String teachingClassId;
|
||||||
|
private String taskId;
|
||||||
|
private String taskKey;
|
||||||
|
private String helpStatus;
|
||||||
|
private String helpTaskSnapshot;
|
||||||
|
private String helpAnswerSnapshot;
|
||||||
|
private String helpReportJson;
|
||||||
|
private String helpRawResponse;
|
||||||
|
private String helpModel;
|
||||||
|
private Date helpCompletedAt;
|
||||||
|
private String helpErrorMessage;
|
||||||
|
private String assessmentStatus;
|
||||||
|
private String assessmentTaskSnapshot;
|
||||||
|
private String assessmentAnswerSnapshot;
|
||||||
|
private Integer assessmentScore;
|
||||||
|
private String assessmentReportJson;
|
||||||
|
private String assessmentRawResponse;
|
||||||
|
private String assessmentModel;
|
||||||
|
private Date assessmentCompletedAt;
|
||||||
|
private String assessmentErrorMessage;
|
||||||
|
private Date createTime;
|
||||||
|
private Date updateTime;
|
||||||
|
|
||||||
|
public String getId() { return id; }
|
||||||
|
public void setId(String id) { this.id = trim(id); }
|
||||||
|
public String getStudentUserId() { return studentUserId; }
|
||||||
|
public void setStudentUserId(String studentUserId) { this.studentUserId = trim(studentUserId); }
|
||||||
|
public String getTeachingClassId() { return teachingClassId; }
|
||||||
|
public void setTeachingClassId(String teachingClassId) { this.teachingClassId = trim(teachingClassId); }
|
||||||
|
public String getTaskId() { return taskId; }
|
||||||
|
public void setTaskId(String taskId) { this.taskId = trim(taskId); }
|
||||||
|
public String getTaskKey() { return taskKey; }
|
||||||
|
public void setTaskKey(String taskKey) { this.taskKey = trim(taskKey); }
|
||||||
|
public String getHelpStatus() { return helpStatus; }
|
||||||
|
public void setHelpStatus(String helpStatus) { this.helpStatus = trim(helpStatus); }
|
||||||
|
public String getHelpTaskSnapshot() { return helpTaskSnapshot; }
|
||||||
|
public void setHelpTaskSnapshot(String helpTaskSnapshot) { this.helpTaskSnapshot = trim(helpTaskSnapshot); }
|
||||||
|
public String getHelpAnswerSnapshot() { return helpAnswerSnapshot; }
|
||||||
|
public void setHelpAnswerSnapshot(String helpAnswerSnapshot) { this.helpAnswerSnapshot = trim(helpAnswerSnapshot); }
|
||||||
|
public String getHelpReportJson() { return helpReportJson; }
|
||||||
|
public void setHelpReportJson(String helpReportJson) { this.helpReportJson = trim(helpReportJson); }
|
||||||
|
public String getHelpRawResponse() { return helpRawResponse; }
|
||||||
|
public void setHelpRawResponse(String helpRawResponse) { this.helpRawResponse = trim(helpRawResponse); }
|
||||||
|
public String getHelpModel() { return helpModel; }
|
||||||
|
public void setHelpModel(String helpModel) { this.helpModel = trim(helpModel); }
|
||||||
|
public Date getHelpCompletedAt() { return helpCompletedAt; }
|
||||||
|
public void setHelpCompletedAt(Date helpCompletedAt) { this.helpCompletedAt = helpCompletedAt; }
|
||||||
|
public String getHelpErrorMessage() { return helpErrorMessage; }
|
||||||
|
public void setHelpErrorMessage(String helpErrorMessage) { this.helpErrorMessage = trim(helpErrorMessage); }
|
||||||
|
public String getAssessmentStatus() { return assessmentStatus; }
|
||||||
|
public void setAssessmentStatus(String assessmentStatus) { this.assessmentStatus = trim(assessmentStatus); }
|
||||||
|
public String getAssessmentTaskSnapshot() { return assessmentTaskSnapshot; }
|
||||||
|
public void setAssessmentTaskSnapshot(String assessmentTaskSnapshot) { this.assessmentTaskSnapshot = trim(assessmentTaskSnapshot); }
|
||||||
|
public String getAssessmentAnswerSnapshot() { return assessmentAnswerSnapshot; }
|
||||||
|
public void setAssessmentAnswerSnapshot(String assessmentAnswerSnapshot) { this.assessmentAnswerSnapshot = trim(assessmentAnswerSnapshot); }
|
||||||
|
public Integer getAssessmentScore() { return assessmentScore; }
|
||||||
|
public void setAssessmentScore(Integer assessmentScore) { this.assessmentScore = assessmentScore; }
|
||||||
|
public String getAssessmentReportJson() { return assessmentReportJson; }
|
||||||
|
public void setAssessmentReportJson(String assessmentReportJson) { this.assessmentReportJson = trim(assessmentReportJson); }
|
||||||
|
public String getAssessmentRawResponse() { return assessmentRawResponse; }
|
||||||
|
public void setAssessmentRawResponse(String assessmentRawResponse) { this.assessmentRawResponse = trim(assessmentRawResponse); }
|
||||||
|
public String getAssessmentModel() { return assessmentModel; }
|
||||||
|
public void setAssessmentModel(String assessmentModel) { this.assessmentModel = trim(assessmentModel); }
|
||||||
|
public Date getAssessmentCompletedAt() { return assessmentCompletedAt; }
|
||||||
|
public void setAssessmentCompletedAt(Date assessmentCompletedAt) { this.assessmentCompletedAt = assessmentCompletedAt; }
|
||||||
|
public String getAssessmentErrorMessage() { return assessmentErrorMessage; }
|
||||||
|
public void setAssessmentErrorMessage(String assessmentErrorMessage) { this.assessmentErrorMessage = trim(assessmentErrorMessage); }
|
||||||
|
public Date getCreateTime() { return createTime; }
|
||||||
|
public void setCreateTime(Date createTime) { this.createTime = createTime; }
|
||||||
|
public Date getUpdateTime() { return updateTime; }
|
||||||
|
public void setUpdateTime(Date updateTime) { this.updateTime = updateTime; }
|
||||||
|
|
||||||
|
private String trim(String value) {
|
||||||
|
return value == null ? null : value.trim();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,30 @@
|
|||||||
|
package com.sztzjy.linkCommerce.mapper;
|
||||||
|
|
||||||
|
import com.sztzjy.linkCommerce.entity.AiTrainingEvaluation;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface AiTrainingEvaluationMapper {
|
||||||
|
AiTrainingEvaluation findByStudentClassAndTask(@Param("studentUserId") String studentUserId,
|
||||||
|
@Param("teachingClassId") String teachingClassId,
|
||||||
|
@Param("taskId") String taskId);
|
||||||
|
|
||||||
|
int insertIgnore(AiTrainingEvaluation record);
|
||||||
|
|
||||||
|
int claimHelp(@Param("id") String id, @Param("updateTime") Date updateTime);
|
||||||
|
|
||||||
|
int claimAssessment(@Param("id") String id, @Param("updateTime") Date updateTime);
|
||||||
|
|
||||||
|
int completeHelp(AiTrainingEvaluation record);
|
||||||
|
|
||||||
|
int completeAssessment(AiTrainingEvaluation record);
|
||||||
|
|
||||||
|
int failHelp(@Param("id") String id, @Param("errorMessage") String errorMessage,
|
||||||
|
@Param("updateTime") Date updateTime);
|
||||||
|
|
||||||
|
int failAssessment(@Param("id") String id, @Param("errorMessage") String errorMessage,
|
||||||
|
@Param("updateTime") Date updateTime);
|
||||||
|
}
|
||||||
@ -0,0 +1,116 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.sztzjy.linkCommerce.mapper.AiTrainingEvaluationMapper">
|
||||||
|
<resultMap id="BaseResultMap" type="com.sztzjy.linkCommerce.entity.AiTrainingEvaluation">
|
||||||
|
<id column="id" jdbcType="VARCHAR" property="id"/>
|
||||||
|
<result column="student_user_id" jdbcType="VARCHAR" property="studentUserId"/>
|
||||||
|
<result column="teaching_class_id" jdbcType="VARCHAR" property="teachingClassId"/>
|
||||||
|
<result column="task_id" jdbcType="VARCHAR" property="taskId"/>
|
||||||
|
<result column="task_key" jdbcType="VARCHAR" property="taskKey"/>
|
||||||
|
<result column="help_status" jdbcType="VARCHAR" property="helpStatus"/>
|
||||||
|
<result column="help_task_snapshot" jdbcType="LONGVARCHAR" property="helpTaskSnapshot"/>
|
||||||
|
<result column="help_answer_snapshot" jdbcType="LONGVARCHAR" property="helpAnswerSnapshot"/>
|
||||||
|
<result column="help_report_json" jdbcType="LONGVARCHAR" property="helpReportJson"/>
|
||||||
|
<result column="help_raw_response" jdbcType="LONGVARCHAR" property="helpRawResponse"/>
|
||||||
|
<result column="help_model" jdbcType="VARCHAR" property="helpModel"/>
|
||||||
|
<result column="help_completed_at" jdbcType="TIMESTAMP" property="helpCompletedAt"/>
|
||||||
|
<result column="help_error_message" jdbcType="VARCHAR" property="helpErrorMessage"/>
|
||||||
|
<result column="assessment_status" jdbcType="VARCHAR" property="assessmentStatus"/>
|
||||||
|
<result column="assessment_task_snapshot" jdbcType="LONGVARCHAR" property="assessmentTaskSnapshot"/>
|
||||||
|
<result column="assessment_answer_snapshot" jdbcType="LONGVARCHAR" property="assessmentAnswerSnapshot"/>
|
||||||
|
<result column="assessment_score" jdbcType="INTEGER" property="assessmentScore"/>
|
||||||
|
<result column="assessment_report_json" jdbcType="LONGVARCHAR" property="assessmentReportJson"/>
|
||||||
|
<result column="assessment_raw_response" jdbcType="LONGVARCHAR" property="assessmentRawResponse"/>
|
||||||
|
<result column="assessment_model" jdbcType="VARCHAR" property="assessmentModel"/>
|
||||||
|
<result column="assessment_completed_at" jdbcType="TIMESTAMP" property="assessmentCompletedAt"/>
|
||||||
|
<result column="assessment_error_message" jdbcType="VARCHAR" property="assessmentErrorMessage"/>
|
||||||
|
<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
|
||||||
|
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<sql id="Base_Column_List">
|
||||||
|
id, student_user_id, teaching_class_id, task_id, task_key,
|
||||||
|
help_status, help_task_snapshot, help_answer_snapshot, help_report_json, help_raw_response,
|
||||||
|
help_model, help_completed_at, help_error_message,
|
||||||
|
assessment_status, assessment_task_snapshot, assessment_answer_snapshot, assessment_score,
|
||||||
|
assessment_report_json, assessment_raw_response, assessment_model, assessment_completed_at,
|
||||||
|
assessment_error_message, create_time, update_time
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
<select id="findByStudentClassAndTask" resultMap="BaseResultMap">
|
||||||
|
SELECT <include refid="Base_Column_List"/>
|
||||||
|
FROM ai_training_evaluation
|
||||||
|
WHERE student_user_id = #{studentUserId,jdbcType=VARCHAR}
|
||||||
|
AND teaching_class_id = #{teachingClassId,jdbcType=VARCHAR}
|
||||||
|
AND task_id = #{taskId,jdbcType=VARCHAR}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<insert id="insertIgnore" parameterType="com.sztzjy.linkCommerce.entity.AiTrainingEvaluation">
|
||||||
|
INSERT IGNORE INTO ai_training_evaluation (
|
||||||
|
id, student_user_id, teaching_class_id, task_id, task_key,
|
||||||
|
help_status, assessment_status, create_time, update_time
|
||||||
|
) VALUES (
|
||||||
|
#{id,jdbcType=VARCHAR}, #{studentUserId,jdbcType=VARCHAR}, #{teachingClassId,jdbcType=VARCHAR},
|
||||||
|
#{taskId,jdbcType=VARCHAR}, #{taskKey,jdbcType=VARCHAR},
|
||||||
|
#{helpStatus,jdbcType=VARCHAR}, #{assessmentStatus,jdbcType=VARCHAR},
|
||||||
|
#{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}
|
||||||
|
)
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<update id="claimHelp">
|
||||||
|
UPDATE ai_training_evaluation
|
||||||
|
SET help_status = 'PROCESSING', help_error_message = NULL, update_time = #{updateTime,jdbcType=TIMESTAMP}
|
||||||
|
WHERE id = #{id,jdbcType=VARCHAR}
|
||||||
|
AND help_status IN ('NOT_STARTED', 'FAILED')
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<update id="claimAssessment">
|
||||||
|
UPDATE ai_training_evaluation
|
||||||
|
SET assessment_status = 'PROCESSING', assessment_error_message = NULL, update_time = #{updateTime,jdbcType=TIMESTAMP}
|
||||||
|
WHERE id = #{id,jdbcType=VARCHAR}
|
||||||
|
AND assessment_status IN ('NOT_STARTED', 'FAILED')
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<update id="completeHelp" parameterType="com.sztzjy.linkCommerce.entity.AiTrainingEvaluation">
|
||||||
|
UPDATE ai_training_evaluation
|
||||||
|
SET help_status = 'SUCCEEDED',
|
||||||
|
help_task_snapshot = #{helpTaskSnapshot},
|
||||||
|
help_answer_snapshot = #{helpAnswerSnapshot},
|
||||||
|
help_report_json = #{helpReportJson},
|
||||||
|
help_raw_response = #{helpRawResponse},
|
||||||
|
help_model = #{helpModel,jdbcType=VARCHAR},
|
||||||
|
help_completed_at = #{helpCompletedAt,jdbcType=TIMESTAMP},
|
||||||
|
help_error_message = NULL,
|
||||||
|
update_time = #{updateTime,jdbcType=TIMESTAMP}
|
||||||
|
WHERE id = #{id,jdbcType=VARCHAR} AND help_status = 'PROCESSING'
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<update id="completeAssessment" parameterType="com.sztzjy.linkCommerce.entity.AiTrainingEvaluation">
|
||||||
|
UPDATE ai_training_evaluation
|
||||||
|
SET assessment_status = 'SUCCEEDED',
|
||||||
|
assessment_task_snapshot = #{assessmentTaskSnapshot},
|
||||||
|
assessment_answer_snapshot = #{assessmentAnswerSnapshot},
|
||||||
|
assessment_score = #{assessmentScore,jdbcType=INTEGER},
|
||||||
|
assessment_report_json = #{assessmentReportJson},
|
||||||
|
assessment_raw_response = #{assessmentRawResponse},
|
||||||
|
assessment_model = #{assessmentModel,jdbcType=VARCHAR},
|
||||||
|
assessment_completed_at = #{assessmentCompletedAt,jdbcType=TIMESTAMP},
|
||||||
|
assessment_error_message = NULL,
|
||||||
|
update_time = #{updateTime,jdbcType=TIMESTAMP}
|
||||||
|
WHERE id = #{id,jdbcType=VARCHAR} AND assessment_status = 'PROCESSING'
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<update id="failHelp">
|
||||||
|
UPDATE ai_training_evaluation
|
||||||
|
SET help_status = 'FAILED', help_error_message = #{errorMessage,jdbcType=VARCHAR},
|
||||||
|
update_time = #{updateTime,jdbcType=TIMESTAMP}
|
||||||
|
WHERE id = #{id,jdbcType=VARCHAR} AND help_status = 'PROCESSING'
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<update id="failAssessment">
|
||||||
|
UPDATE ai_training_evaluation
|
||||||
|
SET assessment_status = 'FAILED', assessment_error_message = #{errorMessage,jdbcType=VARCHAR},
|
||||||
|
update_time = #{updateTime,jdbcType=TIMESTAMP}
|
||||||
|
WHERE id = #{id,jdbcType=VARCHAR} AND assessment_status = 'PROCESSING'
|
||||||
|
</update>
|
||||||
|
</mapper>
|
||||||
@ -0,0 +1,83 @@
|
|||||||
|
package com.sztzjy.linkCommerce.service.impl;
|
||||||
|
|
||||||
|
import com.sztzjy.linkCommerce.entity.AiTrainingEvaluation;
|
||||||
|
import com.sztzjy.linkCommerce.entity.StudentTrainingAnswer;
|
||||||
|
import com.sztzjy.linkCommerce.mapper.AiTrainingEvaluationMapper;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Paths;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
|
class AiTrainingEvaluationServiceImplTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void persistsIndependentHelpAndAssessmentFieldsAndAnswerScore() {
|
||||||
|
AiTrainingEvaluation evaluation = new AiTrainingEvaluation();
|
||||||
|
Date completedAt = new Date();
|
||||||
|
evaluation.setHelpStatus("SUCCEEDED");
|
||||||
|
evaluation.setHelpTaskSnapshot("{\"task\":\"snapshot\"}");
|
||||||
|
evaluation.setHelpAnswerSnapshot("{\"step1\":\"answer\"}");
|
||||||
|
evaluation.setHelpReportJson("{\"overallDiagnosis\":\"ok\"}");
|
||||||
|
evaluation.setHelpRawResponse("raw-help");
|
||||||
|
evaluation.setHelpModel("qwen-test");
|
||||||
|
evaluation.setHelpCompletedAt(completedAt);
|
||||||
|
evaluation.setHelpErrorMessage("help-error");
|
||||||
|
evaluation.setAssessmentStatus("SUCCEEDED");
|
||||||
|
evaluation.setAssessmentTaskSnapshot("{\"task\":\"snapshot\"}");
|
||||||
|
evaluation.setAssessmentAnswerSnapshot("{\"step1\":\"answer\"}");
|
||||||
|
evaluation.setAssessmentScore(86);
|
||||||
|
evaluation.setAssessmentReportJson("{\"score\":86}");
|
||||||
|
evaluation.setAssessmentRawResponse("raw-assessment");
|
||||||
|
evaluation.setAssessmentModel("qwen-test");
|
||||||
|
evaluation.setAssessmentCompletedAt(completedAt);
|
||||||
|
evaluation.setAssessmentErrorMessage("assessment-error");
|
||||||
|
|
||||||
|
StudentTrainingAnswer answer = new StudentTrainingAnswer();
|
||||||
|
answer.setAiAssessmentScore(86);
|
||||||
|
|
||||||
|
assertEquals("SUCCEEDED", evaluation.getHelpStatus());
|
||||||
|
assertEquals("{\"overallDiagnosis\":\"ok\"}", evaluation.getHelpReportJson());
|
||||||
|
assertEquals(86, evaluation.getAssessmentScore());
|
||||||
|
assertEquals("{\"score\":86}", evaluation.getAssessmentReportJson());
|
||||||
|
assertEquals(completedAt, evaluation.getAssessmentCompletedAt());
|
||||||
|
assertEquals(86, answer.getAiAssessmentScore());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void mapperProvidesAtomicClaimsAndCompletionOperations() throws Exception {
|
||||||
|
assertNotNull(AiTrainingEvaluationMapper.class.getDeclaredMethod("findByStudentClassAndTask",
|
||||||
|
String.class, String.class, String.class));
|
||||||
|
assertNotNull(AiTrainingEvaluationMapper.class.getDeclaredMethod("insertIgnore", AiTrainingEvaluation.class));
|
||||||
|
assertNotNull(AiTrainingEvaluationMapper.class.getDeclaredMethod("claimHelp", String.class, Date.class));
|
||||||
|
assertNotNull(AiTrainingEvaluationMapper.class.getDeclaredMethod("claimAssessment", String.class, Date.class));
|
||||||
|
assertNotNull(AiTrainingEvaluationMapper.class.getDeclaredMethod("completeHelp", AiTrainingEvaluation.class));
|
||||||
|
assertNotNull(AiTrainingEvaluationMapper.class.getDeclaredMethod("completeAssessment", AiTrainingEvaluation.class));
|
||||||
|
assertNotNull(AiTrainingEvaluationMapper.class.getDeclaredMethod("failHelp", String.class, String.class, Date.class));
|
||||||
|
assertNotNull(AiTrainingEvaluationMapper.class.getDeclaredMethod("failAssessment", String.class, String.class, Date.class));
|
||||||
|
|
||||||
|
String xml = readResource("src/main/resources/mappers/AiTrainingEvaluationMapper.xml");
|
||||||
|
assertTrue(xml.contains("INSERT IGNORE INTO ai_training_evaluation"));
|
||||||
|
assertTrue(xml.contains("help_status IN ('NOT_STARTED', 'FAILED')"));
|
||||||
|
assertTrue(xml.contains("assessment_status IN ('NOT_STARTED', 'FAILED')"));
|
||||||
|
assertTrue(xml.contains("help_status = 'SUCCEEDED'"));
|
||||||
|
assertTrue(xml.contains("assessment_status = 'SUCCEEDED'"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void answerMapperIncludesAssessmentScoreAndTargetedScoreUpdate() throws Exception {
|
||||||
|
String xml = readResource("src/main/resources/mappers/StudentTrainingAnswerMapper.xml");
|
||||||
|
assertTrue(xml.contains("ai_assessment_score"));
|
||||||
|
assertTrue(xml.contains("<update id=\"updateAiAssessmentScore\""));
|
||||||
|
}
|
||||||
|
|
||||||
|
private String readResource(String path) throws IOException {
|
||||||
|
return new String(Files.readAllBytes(Paths.get(path)), StandardCharsets.UTF_8);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue