| Total Lines | 28 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | package domain |
||
| 2 | |||
| 3 | import ( |
||
| 4 | "strings" |
||
| 5 | |||
| 6 | "gorm.io/gorm" |
||
| 7 | ) |
||
| 8 | |||
| 9 | // Mcq is the domain model for a mcq |
||
| 10 | type Mcq struct { |
||
| 11 | gorm.Model `swaggerignore:"true"` |
||
| 12 | Answers string `json:"answers"` |
||
| 13 | Linked bool `json:"linked"` |
||
| 14 | } |
||
| 15 | |||
| 16 | // TableName returns the table name for the mcq model |
||
| 17 | func (m *Mcq) TableName() string { |
||
| 18 | return "mcqs" |
||
| 19 | } |
||
| 20 | |||
| 21 | // IsLinked returns true if the mcq is linked. |
||
| 22 | func (m *Mcq) IsLinked() bool { |
||
| 23 | return m.Linked |
||
| 24 | } |
||
| 25 | |||
| 26 | func (m *Mcq) ExtractAnswers() []string { |
||
| 27 | // separate the answers by the semicolon |
||
| 28 | return strings.Split(m.Answers, ";") |
||
| 29 | } |
||
| 30 |