package com.qmth.teachcloud.common.enums;

import java.util.Objects;

/**
 * @Description: 题目类型（主观题、客观题）
 * @Author: CaoZixuan
 * @Date: 2022-05-30
 */
public enum QuestionType {
    OBJECTIVE("客观题"),
    SUBJECTIVE("主观题"),
    ;
    private final String desc;

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

    public String getDesc() {
        return desc;
    }

    public static QuestionType convertToEnum(String desc) {
        QuestionType result = null;
        for (QuestionType e : QuestionType.values()) {
            if (Objects.equals(desc, e.getDesc())) {
                result = e;
            }
        }
        if (result == null){
            throw ExceptionResultEnum.ERROR.exception("枚举类型不存在");
        }
        return result;
    }
}
