mirror of
https://github.com/MarijnDoeve/TijdVoorDeTest.git
synced 2026-07-07 16:10:15 +02:00
Rector
This commit is contained in:
@@ -264,7 +264,7 @@ class QuizController extends AbstractController
|
|||||||
'candidate' => $candidate,
|
'candidate' => $candidate,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if (!$quizCandidate) {
|
if (!$quizCandidate instanceof \Tvdt\Entity\QuizCandidate) {
|
||||||
// Create new QuizCandidate if it doesn't exist (inactive by default when first toggling)
|
// Create new QuizCandidate if it doesn't exist (inactive by default when first toggling)
|
||||||
$quizCandidate = new QuizCandidate($quiz, $candidate);
|
$quizCandidate = new QuizCandidate($quiz, $candidate);
|
||||||
$quizCandidate->active = false;
|
$quizCandidate->active = false;
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ use Symfony\Component\Uid\Uuid;
|
|||||||
use Tvdt\Repository\AnswerRepository;
|
use Tvdt\Repository\AnswerRepository;
|
||||||
|
|
||||||
#[ORM\Entity(repositoryClass: AnswerRepository::class)]
|
#[ORM\Entity(repositoryClass: AnswerRepository::class)]
|
||||||
class Answer
|
class Answer implements \Stringable
|
||||||
{
|
{
|
||||||
#[ORM\Column(type: UuidType::NAME)]
|
#[ORM\Column(type: UuidType::NAME)]
|
||||||
#[ORM\CustomIdGenerator(class: 'doctrine.uuid_generator')]
|
#[ORM\CustomIdGenerator(class: 'doctrine.uuid_generator')]
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ use Symfony\Component\Uid\Uuid;
|
|||||||
use Tvdt\Repository\QuestionRepository;
|
use Tvdt\Repository\QuestionRepository;
|
||||||
|
|
||||||
#[ORM\Entity(repositoryClass: QuestionRepository::class)]
|
#[ORM\Entity(repositoryClass: QuestionRepository::class)]
|
||||||
class Question
|
class Question implements \Stringable
|
||||||
{
|
{
|
||||||
#[ORM\Column(type: UuidType::NAME)]
|
#[ORM\Column(type: UuidType::NAME)]
|
||||||
#[ORM\CustomIdGenerator(class: 'doctrine.uuid_generator')]
|
#[ORM\CustomIdGenerator(class: 'doctrine.uuid_generator')]
|
||||||
|
|||||||
+5
-3
@@ -135,6 +135,7 @@ class Quiz
|
|||||||
if (!isset($candidateCounts[$candidateId])) {
|
if (!isset($candidateCounts[$candidateId])) {
|
||||||
$candidateCounts[$candidateId] = ['name' => $candidate->name, 'count' => 0];
|
$candidateCounts[$candidateId] = ['name' => $candidate->name, 'count' => 0];
|
||||||
}
|
}
|
||||||
|
|
||||||
++$candidateCounts[$candidateId]['count'];
|
++$candidateCounts[$candidateId]['count'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -154,9 +155,9 @@ class Quiz
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($missing) || !empty($duplicates)) {
|
if ($missing !== [] || $duplicates !== []) {
|
||||||
$errors = [];
|
$errors = [];
|
||||||
if (!empty($missing)) {
|
if ($missing !== []) {
|
||||||
// If all active candidates are missing, show a special message
|
// If all active candidates are missing, show a special message
|
||||||
if (\count($missing) === \count($activeCandidates)) {
|
if (\count($missing) === \count($activeCandidates)) {
|
||||||
$errors[] = 'No candidates assigned to this question';
|
$errors[] = 'No candidates assigned to this question';
|
||||||
@@ -164,7 +165,8 @@ class Quiz
|
|||||||
$errors[] = 'Missing candidates: '.implode(', ', $missing);
|
$errors[] = 'Missing candidates: '.implode(', ', $missing);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!empty($duplicates)) {
|
|
||||||
|
if ($duplicates !== []) {
|
||||||
$errors[] = 'Duplicate candidates: '.implode(', ', $duplicates);
|
$errors[] = 'Duplicate candidates: '.implode(', ', $duplicates);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user