package cn.com.qmth.examcloud.core.questions.base.question.enums;

public enum QuesStructType {

    /**
     * 单选
     */
    SINGLE_ANSWER_QUESTION(1L, "单选", true, false),
    /**
     * 多选
     */
    MULTIPLE_ANSWER_QUESTION(2L, "多选", true, false),
    /**
     * 判断
     */
    BOOL_ANSWER_QUESTION(3L, "判断", true, false),
    /**
     * 填空
     */
    FILL_BLANK_QUESTION(4L, "填空", false, false),
    /**
     * 问答
     */
    TEXT_ANSWER_QUESTION(5L, "问答", false, false),
    /**
     * 套题
     */
    NESTED_ANSWER_QUESTION(6L, "套题", false, true);

    private Long id;
    private String name;
    private boolean objective;//是否是客观题
    private boolean combline;//是否是组合题

    QuesStructType(Long id, String name, boolean objective, boolean combline) {
        this.id = id;
        this.name = name;
        this.objective = objective;
        this.combline = combline;
    }

    /**
     * 通过ID获取试题类型
     *
     * @param id
     * @return
     */
    public static QuesStructType getQuesStructTypeById(Long id) {
        for (QuesStructType type : QuesStructType.values()) {
            if (id.equals(type.getId())) {
                return type;
            }
        }
        return null;
    }

    public Long getId() {
        return id;
    }

    public String getName() {
        return name;
    }

    public boolean isObjective() {
        return objective;
    }

    public boolean isCombline() {
        return combline;
    }

    public String toString() {
        return getName();
    }

}
