mirror of
https://github.com/MarijnDoeve/TijdVoorDeTest.git
synced 2026-03-05 20:44:19 +01:00
Add AbstractController, implement flash message handling, and refactor repositories
This commit is contained in:
@@ -36,4 +36,13 @@ class CandidateRepository extends ServiceEntityRepository
|
||||
->setParameter('name', $name)
|
||||
->getQuery()->getOneOrNullResult();
|
||||
}
|
||||
|
||||
public function save(Candidate $candidate, bool $flush = true): void
|
||||
{
|
||||
$this->getEntityManager()->persist($candidate);
|
||||
|
||||
if (true === $flush) {
|
||||
$this->getEntityManager()->flush();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,4 +17,13 @@ class GivenAnswerRepository extends ServiceEntityRepository
|
||||
{
|
||||
parent::__construct($registry, GivenAnswer::class);
|
||||
}
|
||||
|
||||
public function save(GivenAnswer $givenAnswer, bool $flush = true): void
|
||||
{
|
||||
$this->getEntityManager()->persist($givenAnswer);
|
||||
|
||||
if (true === $flush) {
|
||||
$this->getEntityManager()->flush();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,13 +20,13 @@ class QuestionRepository extends ServiceEntityRepository
|
||||
parent::__construct($registry, Question::class);
|
||||
}
|
||||
|
||||
public function findNextQuestionForCandidate(Candidate $candidate): Question
|
||||
public function findNextQuestionForCandidate(Candidate $candidate): ?Question
|
||||
{
|
||||
$qb = $this->createQueryBuilder('q');
|
||||
|
||||
return $qb->join('q.quiz', 'qz')
|
||||
->andWhere($qb->expr()->notIn('q.id', $this->getEntityManager()->createQueryBuilder()
|
||||
->select('ga.id')
|
||||
->select('q1')
|
||||
->from(GivenAnswer::class, 'ga')
|
||||
->join('ga.answer', 'a')
|
||||
->join('a.question', 'q1')
|
||||
@@ -38,6 +38,6 @@ class QuestionRepository extends ServiceEntityRepository
|
||||
->setMaxResults(1)
|
||||
->setParameter('candidate', $candidate)
|
||||
->setParameter('quiz', $candidate->getSeason()->getActiveQuiz())
|
||||
->getQuery()->getSingleResult();
|
||||
->getQuery()->getOneOrNullResult();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user