Coefficients transit and display on UI
This commit is contained in:
parent
5a37158f45
commit
cec3600a38
7 changed files with 64 additions and 20 deletions
|
|
@ -129,17 +129,23 @@ func (t Team) OpenHint(h EHint) (error) {
|
|||
return err
|
||||
}
|
||||
|
||||
func (t Team) CountTries(e Exercice) (int64, time.Time) {
|
||||
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 {
|
||||
return 0, time.Unix(0, 0)
|
||||
} else if nb == nil {
|
||||
return 0, *tm
|
||||
} else {
|
||||
return *nb, *tm
|
||||
}
|
||||
}
|
||||
|
||||
func (t Team) HasSolved(e Exercice) (bool, time.Time, int64) {
|
||||
var nb *int64
|
||||
var tm *time.Time
|
||||
if DBQueryRow("SELECT MIN(time) FROM exercice_solved WHERE id_team = ? AND id_exercice = ?", t.Id, e.Id).Scan(&tm); tm == nil {
|
||||
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 false, time.Unix(0, 0), 0
|
||||
} else if nb == nil {
|
||||
return false, *tm, 0
|
||||
} else {
|
||||
return false, *tm, *nb
|
||||
}
|
||||
return false, time.Unix(0, 0), 0
|
||||
} else if DBQueryRow("SELECT COUNT(id_exercice) FROM exercice_solved WHERE id_exercice = ? AND time < ?", e.Id, tm).Scan(&nb); nb == nil {
|
||||
return true, *tm, 0
|
||||
} else {
|
||||
|
|
|
|||
Reference in a new issue