package com.qmth.boot.core.ai.model.llm;

import org.springframework.validation.annotation.Validated;

import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.util.ArrayList;
import java.util.List;

/**
 * 自动判分请求参数
 */
@Validated
public class AutoScoreRequest {

    @NotBlank(message = "科目名称不能为空")
    private String subjectName;

    @NotBlank(message = "试题内容不能为空")
    private String questionBody;

    @NotNull(message = "标答不能为空")
    @Size(min = 1, message = "标答不能为空")
    @Valid
    private List<StandardAnswer> standardAnswer = new ArrayList<>();

    @NotNull(message = "考生回答不能为空")
    private String studentAnswer;

    private double totalScore;

    private double intervalScore = 1;

    public String getSubjectName() {
        return subjectName;
    }

    public void setSubjectName(String subjectName) {
        this.subjectName = subjectName;
    }

    public String getQuestionBody() {
        return questionBody;
    }

    public void setQuestionBody(String questionBody) {
        this.questionBody = questionBody;
    }

    public List<StandardAnswer> getStandardAnswer() {
        return standardAnswer;
    }

    public void setStandardAnswer(List<StandardAnswer> standardAnswer) {
        this.standardAnswer = standardAnswer;
    }

    /**
     * 增加标答内容及分值
     *
     * @param content 文本内容
     * @param score   格式化后的分数字符串
     */
    public void addStandardAnswer(@NotNull String content, @NotNull double score) {
        StandardAnswer answer = new StandardAnswer();
        answer.setContent(content);
        answer.setScore(score);
        this.standardAnswer.add(answer);
    }

    public String getStudentAnswer() {
        return studentAnswer;
    }

    public void setStudentAnswer(String studentAnswer) {
        this.studentAnswer = studentAnswer;
    }

    public double getTotalScore() {
        return totalScore;
    }

    public void setTotalScore(double totalScore) {
        this.totalScore = totalScore;
    }

    public double getIntervalScore() {
        return intervalScore;
    }

    public void setIntervalScore(double intervalScore) {
        this.intervalScore = intervalScore;
    }
}
