package com.seer.teach.common.enums;

/**
 * <p>
 * 例题题型枚举
 * </p>
 *
 * @author ZS
 * @since 2025-10-24
 */
public enum ExampleQuestionTypesEnum {
    /**
     * 选择题
     */
    CHOICE(1, "选择题"),

    /**
     * 多选选择题
     */
    MULTIPLE_CHOICE_QUESTIONS(2, "多选选择题"),

    /**
     * 问答题
     */
    SHORT_ANSWER (3,"问答题"),

    /**
     * 判断题
     */
    BOOLEAN_QUESTIONS(4, "判断题"),

    /**
     * 计算题
     */
    CALCULATION(5, "计算题"),

    /**
     * 填空题
     */
    FILL_BLANK(6, "填空题");

    private final Integer code;
    private final String message;

    ExampleQuestionTypesEnum(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public Integer getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }

    /**
     * 根据code获取枚举实例
     *
     * @param code 题型code
     * @return 枚举实例
     */
    public static ExampleQuestionTypesEnum fromCode(Integer code) {
        for (ExampleQuestionTypesEnum type : ExampleQuestionTypesEnum.values()) {
            if (type.getCode().equals(code)) {
                return type;
            }
        }
        return null;
    }

    public static ExampleQuestionTypesEnum fromMessage(String desc) {
        for (ExampleQuestionTypesEnum type : ExampleQuestionTypesEnum.values()) {
            if (type.getMessage().equals(desc)) {
                return type;
            }
        }
        return null;
    }
}