Refactor flags

Both QCM and Key are Flag
This commit is contained in:
nemunaire 2019-01-02 21:51:09 +01:00
commit a66d6885e7
13 changed files with 315 additions and 246 deletions

View file

@ -14,12 +14,12 @@ type FlagLabel struct {
}
// IsMCQJustification tells you if this key represent a justification from a MCQ.
func (k Flag) IsMCQJustification() (bool) {
func (k FlagKey) IsMCQJustification() (bool) {
return len(k.Label) > 0 && k.Label[0] == '%'
}
// GetMCQJustification returns the structure corresponding to the given flag.
func (k Flag) GetMCQJustification() (fl FlagLabel, err error) {
func (k FlagKey) GetMCQJustification() (fl FlagLabel, err error) {
spl := strings.Split(k.Label, "%")
if len(spl) >= 3 && len(spl[0]) == 0 {
fl.IdChoice, err = strconv.ParseInt(spl[1], 10, 64)