New settings to only count bad submissions
This commit is contained in:
parent
b887288c78
commit
cd73622cae
9 changed files with 61 additions and 18 deletions
|
|
@ -247,9 +247,21 @@ func (t Team) DisplayChoices(k FlagKey) error {
|
|||
|
||||
// CountTries gets the amount of attempts made by the Team and retrieves the time of the latest attempt.
|
||||
func (t Team) CountTries(e Exercice) (int64, time.Time) {
|
||||
table := "exercice_tries"
|
||||
if CountOnlyNotGoodTries {
|
||||
table += "_notgood"
|
||||
}
|
||||
|
||||
var nb *int64
|
||||
var tm *time.Time
|
||||
if DBQueryRow("SELECT COUNT(id_exercice), MAX(time) FROM exercice_tries WHERE id_team = ? AND id_exercice = ?", t.Id, e.Id).Scan(&nb, &tm); tm == nil {
|
||||
if DBQueryRow("SELECT COUNT(id_exercice), MAX(time) FROM "+table+" WHERE id_team = ? AND id_exercice = ?", t.Id, e.Id).Scan(&nb, &tm); tm == nil {
|
||||
if CountOnlyNotGoodTries {
|
||||
if DBQueryRow("SELECT COUNT(id_exercice), MAX(time) FROM exercice_tries WHERE id_team = ? AND id_exercice = ?", t.Id, e.Id).Scan(&nb, &tm); tm == nil {
|
||||
return 0, time.Unix(0, 0)
|
||||
} else {
|
||||
return 0, *tm
|
||||
}
|
||||
}
|
||||
return 0, time.Unix(0, 0)
|
||||
} else if nb == nil {
|
||||
return 0, *tm
|
||||
|
|
|
|||
Reference in a new issue