sync: return binding between challenge.txt IDs and DB item
This commit is contained in:
parent
4a490b1a33
commit
d97ecde3fb
5 changed files with 20 additions and 10 deletions
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue