fic: Add Order, Help and Type values in struct
This commit is contained in:
parent
867e9bb345
commit
74e8c3801a
16 changed files with 134 additions and 110 deletions
|
|
@ -2,17 +2,17 @@ package fic
|
|||
|
||||
import (
|
||||
"errors"
|
||||
"strings"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type FlagLabel struct {
|
||||
Label string
|
||||
IdChoice int64
|
||||
IdChoice int
|
||||
}
|
||||
|
||||
// IsMCQJustification tells you if this key represent a justification from a MCQ.
|
||||
func (k FlagKey) IsMCQJustification() (bool) {
|
||||
func (k FlagKey) IsMCQJustification() bool {
|
||||
return len(k.Label) > 0 && k.Label[0] == '%'
|
||||
}
|
||||
|
||||
|
|
@ -20,7 +20,9 @@ func (k FlagKey) IsMCQJustification() (bool) {
|
|||
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)
|
||||
var idChoice int64
|
||||
idChoice, err = strconv.ParseInt(spl[1], 10, 32)
|
||||
fl.IdChoice = int(idChoice)
|
||||
fl.Label = strings.Join(spl[2:], "%")
|
||||
} else {
|
||||
err = errors.New("This is not a MCQ justification")
|
||||
|
|
|
|||
Reference in a new issue