Passed
Push — main ( 0795ea...57a23e )
by Yume
02:19 queued 01:06
created

domain/mcq.go   A

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 14
dl 0
loc 28
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A domain.*Mcq.ExtractAnswers 0 3 1
A domain.*Mcq.TableName 0 2 1
A domain.*Mcq.IsLinked 0 2 1
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