package com.seer.teach.common.enums;

/**
 * @Author: Captain
 * @Description:
 * @Date: 2025-05-15 19:53
 */
public enum QuestionTypesEnums {
    OTHER_QUESTIONS(0, "其他题型"),
    SINGLE_CHOICE_QUESTIONS(1, "单选选择题"),
    MULTIPLE_CHOICE_QUESTIONS(2, "多选选择题"),
    SHORT_ANSWER(3, "问答题"),
    BOOLEAN_QUESTIONS(4, "判断题"),

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

    private Integer code;
    private String msg;

    QuestionTypesEnums(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public static QuestionTypesEnums getByCode(Integer type) {
        for (QuestionTypesEnums value : QuestionTypesEnums.values()) {
            if (value.getCode().equals(type)) {
                return value;
            }
        }
        return null;
    }

    public static boolean isChoiceQuestion(Integer type) {
        if (type == null) {
            return false;
        }
        return type.intValue() == SINGLE_CHOICE_QUESTIONS.getCode() || type.intValue() == MULTIPLE_CHOICE_QUESTIONS.getCode();
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }
}
