Multiple hints
This commit is contained in:
parent
22e8937879
commit
25bf34e82c
9 changed files with 217 additions and 35 deletions
|
@ -115,3 +115,22 @@ func createExerciceKey(theme fic.Theme, exercice fic.Exercice, args map[string]s
|
|||
|
||||
return exercice.AddRawKey(uk.Name, uk.Key)
|
||||
}
|
||||
|
||||
type uploadedHint struct {
|
||||
Title string
|
||||
Content string
|
||||
Cost int64
|
||||
}
|
||||
|
||||
func createExerciceHint(theme fic.Theme, exercice fic.Exercice, args map[string]string, body []byte) (interface{}, error) {
|
||||
var uh uploadedHint
|
||||
if err := json.Unmarshal(body, &uh); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(uh.Content) == 0 {
|
||||
return nil, errors.New("Hint's content not filled")
|
||||
}
|
||||
|
||||
return exercice.AddHint(uh.Title, uh.Content, uh.Cost)
|
||||
}
|
||||
|
|
Reference in a new issue