Fix submission replay possibility
This commit is contained in:
parent
a8031452f7
commit
e9f2b166a6
|
@ -53,8 +53,10 @@ func treatSubmission(pathname string, team_id string, exercice_id string) {
|
|||
log.Println(id, "[ERR]", err)
|
||||
} else if theme, err := exercice.GetTheme(); err != nil {
|
||||
log.Println(id, "[ERR]", err)
|
||||
} else if s, tm, _ := team.HasSolved(exercice); s {
|
||||
log.Printf("$s [WRN] Team %d ALREADY solved exercice %d ($s : $s)\n", id, team.Id, exercice.Id, theme.Name, exercice.Title)
|
||||
} else {
|
||||
if solved, firstTry, err := exercice.CheckResponse(keys, team); err != nil {
|
||||
if solved, err := exercice.CheckResponse(keys, team); err != nil {
|
||||
log.Println(id, "[ERR]", err)
|
||||
} else if solved {
|
||||
exercice.Solved(team)
|
||||
|
@ -75,8 +77,8 @@ func treatSubmission(pathname string, team_id string, exercice_id string) {
|
|||
log.Println(id, "[ERR]", err)
|
||||
}
|
||||
|
||||
// Write event
|
||||
if firstTry {
|
||||
// Write event (only on first try)
|
||||
if tm.Unix() == 0 {
|
||||
if lvl, err := exercice.GetLevel(); err != nil {
|
||||
log.Println(id, "[ERR]", err)
|
||||
} else if _, err := fic.NewEvent(fmt.Sprintf("L'équipe %s tente le <strong>%d<sup>e</sup></strong> challenge %s !", team.Name, lvl, theme.Name), "alert-warning"); err != nil {
|
||||
|
|
|
@ -190,19 +190,14 @@ func (e Exercice) TriedCount() int64 {
|
|||
}
|
||||
}
|
||||
|
||||
func (e Exercice) CheckResponse(resps map[string]string, t Team) (bool, bool, error) {
|
||||
s, tm, _ := t.HasSolved(e)
|
||||
if s {
|
||||
return true, false, nil
|
||||
}
|
||||
|
||||
func (e Exercice) CheckResponse(resps map[string]string, t Team) (bool, error) {
|
||||
if err := e.NewTry(t); err != nil {
|
||||
return false, false, err
|
||||
return false, err
|
||||
} else if keys, err := e.GetKeys(); err != nil {
|
||||
return false, false, err
|
||||
return false, err
|
||||
} else {
|
||||
if len(keys) < 1 {
|
||||
return true, false, errors.New("Exercice with no key registered")
|
||||
return true, errors.New("Exercice with no key registered")
|
||||
}
|
||||
|
||||
valid := true
|
||||
|
@ -217,6 +212,6 @@ func (e Exercice) CheckResponse(resps map[string]string, t Team) (bool, bool, er
|
|||
}
|
||||
}
|
||||
|
||||
return valid, tm.Unix() == 0, nil
|
||||
return valid, nil
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user