maatma: new function to update unlocked challenge

This commit is contained in:
nemunaire 2019-03-25 22:46:35 +01:00
parent de1492e1db
commit 0af3355576

View File

@ -225,6 +225,14 @@ func (s Student) UnlockNewChallenge(challenge int, value string) (UnlockedChalle
}
}
func (s Student) UpdateUnlockedChallenge(challenge int, value string) (UnlockedChallenge, error) {
if _, err := DBExec("UPDATE student_challenges SET time = ?, value = ? WHERE id_student = ? AND challenge = ?", time.Now(), value, s.Id, challenge); err != nil {
return UnlockedChallenge{}, err
} else {
return UnlockedChallenge{0, s.Id, challenge, time.Now()}, err
}
}
func (s Student) registerAccess(ip, mac string) error {
if res, err := DBExec("INSERT INTO student_login (id_student, ip, mac, time) VALUES (?, ?, ?, ?)", s.Id, ip, mac, time.Now()); err != nil {
return err