backend: save the checksum of each try, to be able to detect duplicates after
This commit is contained in:
parent
44d335bc9f
commit
333bb408e1
3 changed files with 15 additions and 5 deletions
|
@ -205,8 +205,8 @@ func (e Exercice) GetLevel() (int, error) {
|
|||
}
|
||||
|
||||
// NewTry registers a solving attempt for the given Team.
|
||||
func (e Exercice) NewTry(t Team) error {
|
||||
if _, err := DBExec("INSERT INTO exercice_tries (id_exercice, id_team, time) VALUES (?, ?, ?)", e.Id, t.Id, time.Now()); err != nil {
|
||||
func (e Exercice) NewTry(t Team, cksum []byte) error {
|
||||
if _, err := DBExec("INSERT INTO exercice_tries (id_exercice, id_team, time, cksum) VALUES (?, ?, ?, ?)", e.Id, t.Id, time.Now(), cksum); err != nil {
|
||||
return err
|
||||
} else {
|
||||
return nil
|
||||
|
@ -264,8 +264,8 @@ func (e Exercice) TriedCount() int64 {
|
|||
|
||||
// CheckResponse, given both flags and MCQ responses, figures out if thoses are correct (or if they are previously solved).
|
||||
// In the meanwhile, CheckResponse registers good answers given (but it does not mark the challenge as solved at the end).
|
||||
func (e Exercice) CheckResponse(respflags map[string]string, respmcq map[int64]bool, t Team) (bool, error) {
|
||||
if err := e.NewTry(t); err != nil {
|
||||
func (e Exercice) CheckResponse(cksum []byte, respflags map[string]string, respmcq map[int64]bool, t Team) (bool, error) {
|
||||
if err := e.NewTry(t, cksum); err != nil {
|
||||
return false, err
|
||||
} else if flags, err := e.GetFlags(); err != nil {
|
||||
return false, err
|
||||
|
|
Reference in a new issue