This repository has been archived on 2025-06-10. You can view files and clone it, but you cannot make any changes to its state, such as pushing and creating new issues, pull requests or comments.
server/admin/sync/exercice_defines.go
2018-05-11 15:03:09 +02:00

30 lines
681 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, "defines.txt"))
_, err = toml.Decode(defs, &p)
return
}