Skip to content
Snippets Groups Projects
Verified Commit 0b0505a2 authored by Bayu Samudra's avatar Bayu Samudra
Browse files

fix: add safetinees

parent d0a5c0ec
Pipeline #58067 passed with stages
in 3 minutes and 25 seconds
......@@ -41,12 +41,18 @@ func (q *QuizRepositoryImpl) GetQuizDetail(quizId uuid.UUID) (*quiz.Quiz, error)
}
func (q *QuizRepositoryImpl) UpdateScore(email string, quizId uuid.UUID, score int) error {
return q.db.
Model(&quiz.QuizTake{}).
Where("quiz_id = ? AND email = ?", quizId, email).
Updates(quiz.QuizTake{
tx := q.db.Begin()
defer tx.Commit()
tx.Where("quiz_id = ? AND email = ?", quizId, email).Delete(&quiz.QuizTake{})
return tx.
Create(quiz.QuizTake{
Score: score,
IsFinished: true,
QuizId: quizId,
Email: email,
Id: uuid.New(),
}).Error
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment