mirror of
https://github.com/MarijnDoeve/TijdVoorDeTest.git
synced 2026-07-11 12:28:23 +02:00
fix: wrap candidate progress reset in a transaction
Avoids leaving a candidate half-reset (answers deleted but started still set) if the second flush fails. Addresses CodeRabbit review comment on PR #204.
This commit is contained in:
@@ -409,8 +409,10 @@ class QuizController extends AbstractController
|
||||
)]
|
||||
public function resetCandidateProgress(Quiz $quiz, Candidate $candidate): RedirectResponse
|
||||
{
|
||||
$this->givenAnswerRepository->deleteAllForCandidateInQuiz($quiz, $candidate);
|
||||
$this->quizCandidateRepository->resetProgressForCandidate($quiz, $candidate);
|
||||
$this->em->wrapInTransaction(function () use ($quiz, $candidate): void {
|
||||
$this->givenAnswerRepository->deleteAllForCandidateInQuiz($quiz, $candidate);
|
||||
$this->quizCandidateRepository->resetProgressForCandidate($quiz, $candidate);
|
||||
});
|
||||
|
||||
$this->addFlash(FlashType::Success, $this->translator->trans('Candidate progress reset'));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user