Implement radio flag type
This commit is contained in:
parent
41565729fd
commit
49664c3dfe
2 changed files with 64 additions and 44 deletions
|
|
@ -145,7 +145,7 @@ func buildKeyFlag(exercice fic.Exercice, flag ExerciceFlag, flagline int, defaul
|
|||
})
|
||||
f = &fl
|
||||
|
||||
if len(flag.Choice) > 0 || flag.Type == "ucq" {
|
||||
if len(flag.Choice) > 0 || (flag.Type == "ucq" || flag.Type == "radio") {
|
||||
// Import choices
|
||||
hasOne := false
|
||||
|
||||
|
|
@ -241,10 +241,12 @@ func buildExerciceFlag(i Importer, exercice fic.Exercice, flag ExerciceFlag, nli
|
|||
flag.Type = "vector"
|
||||
case "ucq":
|
||||
flag.Type = "ucq"
|
||||
case "radio":
|
||||
flag.Type = "radio"
|
||||
case "mcq":
|
||||
flag.Type = "mcq"
|
||||
default:
|
||||
errs = append(errs, fmt.Sprintf("%q: flag #%d: invalid type of flag: should be 'key', 'number', 'text', 'mcq', 'ucq' or 'vector'.", path.Base(exercice.Path), nline+1))
|
||||
errs = append(errs, fmt.Sprintf("%q: flag #%d: invalid type of flag: should be 'key', 'number', 'text', 'mcq', 'ucq', 'radio' or 'vector'.", path.Base(exercice.Path), nline+1))
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -258,7 +260,7 @@ func buildExerciceFlag(i Importer, exercice fic.Exercice, flag ExerciceFlag, nli
|
|||
}
|
||||
}
|
||||
|
||||
if flag.Type == "key" || strings.HasPrefix(flag.Type, "number") || flag.Type == "text" || flag.Type == "ucq" || flag.Type == "vector" {
|
||||
if flag.Type == "key" || strings.HasPrefix(flag.Type, "number") || flag.Type == "text" || flag.Type == "ucq" || flag.Type == "radio" || flag.Type == "vector" {
|
||||
addedFlag, choices, berrs := buildKeyFlag(exercice, flag, nline+1, "Flag")
|
||||
if len(berrs) > 0 {
|
||||
errs = append(errs, berrs...)
|
||||
|
|
|
|||
Reference in a new issue