sync: return binding between challenge.txt IDs and DB item

This commit is contained in:
nemunaire 2019-11-25 14:57:21 +01:00
parent 4a490b1a33
commit d97ecde3fb
5 changed files with 20 additions and 10 deletions

View file

@ -92,7 +92,7 @@ func CheckExerciceHints(i Importer, exercice fic.Exercice) ([]fic.EHint, []strin
}
// SyncExerciceHints reads the content of hints/ directories and import it as EHint for the given challenge.
func SyncExerciceHints(i Importer, exercice fic.Exercice) (errs []string) {
func SyncExerciceHints(i Importer, exercice fic.Exercice) (hintsBindings map[int]fic.EHint, errs []string) {
if _, err := exercice.WipeHints(); err != nil {
errs = append(errs, err.Error())
} else {
@ -101,8 +101,10 @@ func SyncExerciceHints(i Importer, exercice fic.Exercice) (errs []string) {
for n, hint := range hints {
// Import hint
if _, err := exercice.AddHint(hint.Title, hint.Content, hint.Cost); err != nil {
if h, err := exercice.AddHint(hint.Title, hint.Content, hint.Cost); err != nil {
errs = append(errs, fmt.Sprintf("%q: hint #%d %s: %s", path.Base(exercice.Path), n+1, hint.Title, err))
} else {
hintsBindings[n+1] = h
}
}
}