Add HasAccess function

This commit is contained in:
nemunaire 2016-01-18 18:24:46 +01:00
parent 5a2a950b1f
commit 1bd8374703
1 changed files with 10 additions and 0 deletions

View File

@ -68,6 +68,16 @@ func (t Team) Delete() (int64, error) {
}
}
func (t Team) HasAccess(e Exercice) bool {
if e.Depend == nil {
return true
} else {
ed := Exercice{}
ed.Id = *e.Depend
return t.HasSolved(ed)
}
}
func (t Team) HasSolved(e Exercice) bool {
var nb int
if err := DBQueryRow("SELECT COUNT(id_exercice) FROM exercice_solved WHERE id_team = ? AND id_exercice = ?", t.Id, e.Id).Scan(&nb); err != nil {