sync: Allow justified as flag type
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
nemunaire 2024-05-18 00:28:59 +02:00
parent 651d428223
commit eeced21be8

View File

@ -355,8 +355,10 @@ func buildExerciceFlag(i Importer, exercice *fic.Exercice, flag ExerciceFlag, nl
flag.Type = "radio"
case "mcq":
flag.Type = "mcq"
case "justified":
flag.Type = "justified"
default:
errs = multierr.Append(errs, NewFlagError(exercice, &flag, nline+1, fmt.Errorf("invalid type of flag: should be 'key', 'number', 'text', 'mcq', 'ucq', 'radio' or 'vector'")))
errs = multierr.Append(errs, NewFlagError(exercice, &flag, nline+1, fmt.Errorf("invalid type of flag: should be 'key', 'number', 'text', 'mcq', 'justified', 'ucq', 'radio' or 'vector'")))
return
}
@ -404,7 +406,7 @@ func buildExerciceFlag(i Importer, exercice *fic.Exercice, flag ExerciceFlag, nl
Choices: choices,
})
}
} else if flag.Type == "mcq" {
} else if flag.Type == "mcq" || flag.Type == "justified" {
addedFlag := fic.MCQ{
IdExercice: exercice.Id,
Order: int8(nline + 1),
@ -413,7 +415,7 @@ func buildExerciceFlag(i Importer, exercice *fic.Exercice, flag ExerciceFlag, nl
}
hasOne := false
isJustified := false
isJustified := flag.Type == "justified"
if len(flag.Variant) != 0 {
errs = multierr.Append(errs, NewFlagError(exercice, &flag, nline+1, fmt.Errorf("variant is not defined for this kind of flag")))