package top.tqx.demo_1.dto;

import com.fasterxml.jackson.annotation.JsonAlias;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

@Data
public class ExamGradeRequest implements Serializable {

    private static final long serialVersionUID = 1L;

    @JsonProperty("request_id")
    @JsonAlias("requestId")
    private String requestId;

    @JsonProperty("paper_id")
    @JsonAlias("paperId")
    private String paperId;

    @JsonProperty("session_id")
    @JsonAlias("sessionId")
    private String sessionId;

    @JsonProperty("record_id")
    @JsonAlias("recordId")
    private String recordId;

    @JsonProperty("answer_type")
    @JsonAlias("answerType")
    private String answerType;

    @JsonProperty("answers")
    private List<AnswerItem> answers;

    @Data
    public static class AnswerItem implements Serializable {
        private static final long serialVersionUID = 1L;

        @JsonProperty("question_id")
        @JsonAlias("questionId")
        private String questionId;

        @JsonProperty("question_type")
        @JsonAlias("questionType")
        private String questionType;

        @JsonProperty("question_content")
        @JsonAlias("questionContent")
        private QuestionContent questionContent;

        @JsonProperty("student_answer")
        @JsonAlias("studentAnswer")
        private Object studentAnswer;

        @JsonProperty("max_score")
        @JsonAlias("maxScore")
        private BigDecimal maxScore;
    }

    @Data
    @JsonIgnoreProperties(ignoreUnknown = true)
    public static class QuestionContent implements Serializable {
        private static final long serialVersionUID = 1L;

        @JsonProperty("stem")
        private String stem;

        @JsonProperty("data")
        private Map<String, Object> data;

        @JsonProperty("answer")
        private Object answer;

        @JsonProperty("explanation")
        private String explanation;
    }

    public enum QuestionType {
        SINGLE_CHOICE("single_choice"),
        MULTIPLE_CHOICE("multiple_choice"),
        TRUE_FALSE("true_false"),
        FILL_BLANK("fill_blank"),
        SUBJECTIVE("subjective");

        private final String value;

        QuestionType(String value) {
            this.value = value;
        }

        public String getValue() {
            return value;
        }
    }
}