Save MCQ diff

This commit is contained in:
nemunaire 2017-12-17 02:48:02 +01:00
commit 830dacd6f5
5 changed files with 28 additions and 2 deletions

View file

@ -168,6 +168,14 @@ func (e Exercice) NewTry(t Team) error {
}
}
func (e Exercice) UpdateTry(t Team, nbdiff int) error {
if _, err := DBExec("UPDATE exercice_tries SET nbdiff = ?, time = ? WHERE id_exercice = ? AND id_team = ? ORDER BY time DESC LIMIT 1", nbdiff, time.Now(), e.Id, t.Id); err != nil {
return err
} else {
return nil
}
}
func (e Exercice) Solved(t Team) error {
if _, err := DBExec("INSERT INTO exercice_solved (id_exercice, id_team, time, coefficient) VALUES (?, ?, ?, ?)", e.Id, t.Id, time.Now(), e.Coefficient); err != nil {
return err