Fix gain estimation error due to variable overwrite

This commit is contained in:
nemunaire 2023-04-02 17:24:25 +02:00
parent 3772af4965
commit 5fac0d4b30
2 changed files with 4 additions and 3 deletions

View file

@ -300,7 +300,7 @@ func (t *Team) LastTryDist(e *Exercice) int64 {
// HasSolved checks if the Team already has validated the given challenge. // HasSolved checks if the Team already has validated the given challenge.
// Note that the function also returns the effective validation timestamp. // Note that the function also returns the effective validation timestamp.
func (t *Team) HasSolved(e *Exercice) (tm *time.Time) { func (t *Team) HasSolved(e *Exercice) (tm *time.Time) {
DBQueryRow("SELECT MIN(time) FROM exercice_solved WHERE id_team = ? AND id_exercice = ?", t.Id, e.Id).Scan(&tm) DBQueryRow("SELECT time FROM exercice_solved WHERE id_team = ? AND id_exercice = ? ORDER BY time ASC LIMIT 1", t.Id, e.Id).Scan(&tm)
return return
} }

View file

@ -148,8 +148,9 @@ func MyJSONTeam(t *Team, started bool) (interface{}, error) {
exercice.Finished = e.Finished exercice.Finished = e.Finished
exercice.Tries, _ = t.CountTries(e) exercice.Tries, _ = t.CountTries(e)
} else { } else {
exercice.Tries, stime = t.CountTries(e) var ttime *time.Time
exercice.SolvedTime = stime exercice.Tries, ttime = t.CountTries(e)
exercice.SolvedTime = ttime
if DisplayMCQBadCount && exercice.Tries > 0 { if DisplayMCQBadCount && exercice.Tries > 0 {
exercice.SolveDist = t.LastTryDist(e) exercice.SolveDist = t.LastTryDist(e)
} }