admin/sync: handle exercice gain from toml file: defines.txt
This commit is contained in:
parent
e7d3e34c0b
commit
332aa90931
20
admin/sync/exercice_defines.go
Normal file
20
admin/sync/exercice_defines.go
Normal file
@ -0,0 +1,20 @@
|
||||
package sync
|
||||
|
||||
import (
|
||||
"path"
|
||||
|
||||
"github.com/BurntSushi/toml"
|
||||
)
|
||||
|
||||
type ExerciceParams struct {
|
||||
Gain int64
|
||||
}
|
||||
|
||||
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
|
||||
}
|
@ -78,8 +78,16 @@ func SyncExercices(i Importer, theme fic.Theme) []string {
|
||||
continue
|
||||
}
|
||||
|
||||
// TODO: calculate gain
|
||||
var gain int64 = 42
|
||||
// Handle score gain
|
||||
var gain int64
|
||||
if p, err := parseExerciceParams(i, path.Join(theme.Name, edir)); err != nil {
|
||||
errs = append(errs, fmt.Sprintf("%q: defines.txt: %s", edir, err))
|
||||
continue
|
||||
} else if p.Gain == 0 {
|
||||
errs = append(errs, fmt.Sprintf("%q: defines.txt: Undefined gain for challenge", edir))
|
||||
} else {
|
||||
gain = p.Gain
|
||||
}
|
||||
|
||||
// Handle video
|
||||
videoURI, err := findResolutionMovie(i, path.Join(theme.Name, edir))
|
||||
|
Loading…
Reference in New Issue
Block a user