maatma: new function to update unlocked challenge
This commit is contained in:
parent
de1492e1db
commit
0af3355576
@ -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
|
||||
|
Reference in New Issue
Block a user