server/admin/sync/exercice_defines.go

31 lines
683 B
Go

package sync
import (
"path"
"github.com/BurntSushi/toml"
)
// ExerciceHintParams holds EHint definition infomation.
type ExerciceHintParams struct {
Filename string
Cost int64
Title string
}
// ExerciceParams contains values parsed from defines.txt.
type ExerciceParams struct {
Gain int64
Hints []ExerciceHintParams `toml:"hint"`
}
// parseExerciceParams reads challenge definitions from defines.txt and extract usefull data to set up the challenge.
func parseExerciceParams(i Importer, exPath string) (p ExerciceParams, err error) {
var defs string
defs, err = getFileContent(i, path.Join(exPath, "challenge.txt"))
_, err = toml.Decode(defs, &p)
return
}