Handle choices in UCQ (db, sync done)
This commit is contained in:
parent
333bb408e1
commit
488a032eba
7 changed files with 202 additions and 1 deletions
|
@ -188,6 +188,26 @@ func flagHandler(f func(fic.Flag, fic.Exercice, []byte) (interface{}, error)) fu
|
|||
}
|
||||
}
|
||||
|
||||
func choiceHandler(f func(fic.FlagChoice, fic.Exercice, []byte) (interface{}, error)) func(httprouter.Params, []byte) (interface{}, error) {
|
||||
return func(ps httprouter.Params, body []byte) (interface{}, error) {
|
||||
var exercice fic.Exercice
|
||||
var flag fic.Flag
|
||||
flagHandler(func(fl fic.Flag, ex fic.Exercice, _ []byte) (interface{}, error) {
|
||||
exercice = ex
|
||||
flag = fl
|
||||
return nil, nil
|
||||
})(ps, body)
|
||||
|
||||
if cid, err := strconv.Atoi(string(ps.ByName("cid"))); err != nil {
|
||||
return nil, err
|
||||
} else if choice, err := flag.GetChoice(cid); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return f(choice, exercice, body)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func quizHandler(f func(fic.MCQ, fic.Exercice, []byte) (interface{}, error)) func(httprouter.Params, []byte) (interface{}, error) {
|
||||
return func(ps httprouter.Params, body []byte) (interface{}, error) {
|
||||
var exercice fic.Exercice
|
||||
|
|
Reference in a new issue