subject.go 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. package entity
  2. import (
  3. "errors"
  4. "time"
  5. )
  6. const (
  7. SINGEL_CHOICE = iota
  8. Completion
  9. MULTIPLE_CHOICE
  10. Judgement
  11. )
  12. // Subject 试题
  13. type Subject struct {
  14. Id int `json:"id,omitempty" db:"id,omitempty"`
  15. CreateAt time.Time `json:"create_at,omitempty" db:"create_at,omitempty"`
  16. UpdateAt time.Time `json:"update_at,omitempty" db:"update_at,omitempty"`
  17. DeleteAt *time.Time `json:"-" db:"delete_at,omitempty"`
  18. // 0 禁用 1使用
  19. Status *int `json:"status,omitempty" db:"status,omitempty"`
  20. // 问题
  21. Question string `json:"question,omitempty" db:"question"`
  22. // 0 单选题 1填空题 2多选题 3判断题
  23. Type *int `json:"type,omitempty" db:"type,omitempty"`
  24. OptA string `json:"opt_a,omitempty" db:"opt_a,omitempty"`
  25. OptB string `json:"opt_b,omitempty" db:"opt_b,omitempty"`
  26. OptC string `json:"opt_c,omitempty" db:"opt_c,omitempty"`
  27. OptD string `json:"opt_d,omitempty" db:"opt_d,omitempty"`
  28. // 回答 (ABCD), 单选、填空 多选 判断
  29. Answer string `json:"answer,omitempty" db:"answer,omitempty"`
  30. // 解析
  31. Analysis string `json:"analysis,omitempty" db:"analysis,omitempty"`
  32. // 题库id
  33. QbId int `json:"qb_id,omitempty" db:"qb_id,omitempty"`
  34. }
  35. func GetSubjectTypeName(tp int) (string, error) {
  36. switch tp {
  37. case SINGEL_CHOICE:
  38. return "单选题", nil
  39. case Completion:
  40. return "填空题", nil
  41. case MULTIPLE_CHOICE:
  42. return "判断题", nil
  43. case Judgement:
  44. return "多选题", nil
  45. default:
  46. return "", errors.New("excel格式错误")
  47. }
  48. }