package exam

import (
	"zhenyihuibao/conf"
	"errors"
)

const (
	SELECT_SINGLE = 1;
	SELECT_MULTI  = 2;
	SELECT_BLANK  = 3;
)


//试卷题目表
type QuesTitle struct {
	Id        			int   		`xorm:"not null pk autoincr INT(10)" json:"id"`
	Title 				string 		`xorm:"not null comment('标题') index VARCHAR(255)" json:"title"`
	Desc 				string 		`xorm:"not null comment('描述') index VARCHAR(600)" json:"desc"`
	Score   			int 		`xorm:"not null comment('分值') INT(11)" json:"score"`
	Type	   			int 		`xorm:"not null comment('类型') INT(11)" json:"type"`
	Option 				string 		`xorm:"not null comment('选项') index VARCHAR(600)" json:"option"`
	Answer 				string 		`xorm:"not null comment('答案') index VARCHAR(600)" json:"answer"`
	Explain_txt 		string 		`xorm:"not null comment('解答') index VARCHAR(600)" json:"explain_txt"`
}

//获取题目类型
func (this *QuesTitle) GetTypeMap() map[int]string{
	return map[int]string{
		SELECT_SINGLE 	: "单选题",
		SELECT_MULTI 	: "多选题",
		SELECT_BLANK	: "填空题",
	}
}

func (this *QuesTitle) GetRowById(itemId int) (itemRow *QuesTitle, err error) {
	rowModel := &QuesTitle{Id:itemId}
	has, err := conf.SqlServer.Get(rowModel)
	if err != nil || has == false {
		err =  errors.New("获取不到QuesBankTitle信息!")
		return
	}
	itemRow = rowModel
	return
}

