package com.qmth.teachcloud.common.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;

/**
 * 题型
 */
public enum QuestionType {
    SINGLE("单选题", 1, true),
    MULTIPLE("多选题", 2, true),
    TRUE_OR_FALSE("判断题", 3, true),
    COMPLETION("填空题", 4, false),
    QUESTION_ANSWER("解答题", 5, false);

    private String name;

    @EnumValue
    private int value;
    private Boolean isObjective;

    private QuestionType(String name, int value, Boolean isObjective) {
        this.name = name;
        this.value = value;
        this.isObjective = isObjective;
    }

    public String getName() {
        return name;
    }

    public int getValue() {
        return value;
    }

    public Boolean getObjective() {
        return isObjective;
    }

    public static QuestionType findByValue(int value) {
        for (QuestionType c : QuestionType.values()) {
            if (c.getValue() == value) {
                return c;
            }
        }
        return null;
    }
}
