mirror of
https://github.com/MarijnDoeve/TijdVoorDeTest.git
synced 2026-03-06 12:44:20 +01:00
Refactor elimination feature and improve backoffice usability
This commit introduces a refactored EliminationFactory for better modularity, updates the elimination preparation process, and adds functionality to view eliminations. Backoffice templates and forms have been reorganized, minor translations were corrected, and additional assets like styles and flashes were included for enhanced user experience.
This commit is contained in:
@@ -7,27 +7,37 @@ namespace App\Entity;
|
||||
use App\Repository\EliminationRepository;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Safe\DateTimeImmutable;
|
||||
use Symfony\Bridge\Doctrine\IdGenerator\UuidGenerator;
|
||||
use Symfony\Bridge\Doctrine\Types\UuidType;
|
||||
use Symfony\Component\Uid\Uuid;
|
||||
|
||||
#[ORM\Entity(repositoryClass: EliminationRepository::class)]
|
||||
#[ORM\HasLifecycleCallbacks]
|
||||
class Elimination
|
||||
{
|
||||
public const string SCREEN_GREEN = 'green';
|
||||
public const string SCREEN_RED = 'red';
|
||||
|
||||
#[ORM\Id]
|
||||
#[ORM\Column(type: UuidType::NAME, unique: true)]
|
||||
#[ORM\GeneratedValue(strategy: 'CUSTOM')]
|
||||
#[ORM\CustomIdGenerator(class: UuidGenerator::class)]
|
||||
private Uuid $id;
|
||||
|
||||
#[ORM\ManyToOne(inversedBy: 'eliminations')]
|
||||
#[ORM\JoinColumn(nullable: false)]
|
||||
private Quiz $quiz;
|
||||
|
||||
/** @var array<string, mixed> */
|
||||
#[ORM\Column(type: Types::JSON)]
|
||||
private array $data = [];
|
||||
|
||||
#[ORM\Column(type: Types::DATETIME_IMMUTABLE, nullable: false)]
|
||||
private \DateTimeImmutable $created;
|
||||
|
||||
public function __construct(
|
||||
#[ORM\ManyToOne(inversedBy: 'eliminations')]
|
||||
#[ORM\JoinColumn(nullable: false)]
|
||||
private Quiz $quiz,
|
||||
) {}
|
||||
|
||||
public function getId(): Uuid
|
||||
{
|
||||
return $this->id;
|
||||
@@ -40,22 +50,26 @@ class Elimination
|
||||
}
|
||||
|
||||
/** @param array<string, mixed> $data */
|
||||
public function setData(array $data): static
|
||||
public function setData(array $data): self
|
||||
{
|
||||
$this->data = $data;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setQuiz(Quiz $quiz): self
|
||||
{
|
||||
$this->quiz = $quiz;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getQuiz(): Quiz
|
||||
{
|
||||
return $this->quiz;
|
||||
}
|
||||
|
||||
#[ORM\PrePersist]
|
||||
public function setCreatedAtValue(): void
|
||||
{
|
||||
$this->created = new DateTimeImmutable();
|
||||
}
|
||||
|
||||
public function getCreated(): \DateTimeInterface
|
||||
{
|
||||
return $this->created;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,11 +38,12 @@ class Quiz
|
||||
#[ORM\OneToMany(targetEntity: Correction::class, mappedBy: 'quiz', orphanRemoval: true)]
|
||||
private Collection $corrections;
|
||||
|
||||
#[ORM\Column(nullable: true)]
|
||||
private ?int $dropouts = null;
|
||||
#[ORM\Column(nullable: false, options: ['default' => 1])]
|
||||
private int $dropouts = 1;
|
||||
|
||||
/** @var Collection<int, Elimination> */
|
||||
#[ORM\OneToMany(targetEntity: Elimination::class, mappedBy: 'quiz', cascade: ['persist'], orphanRemoval: true)]
|
||||
#[ORM\OrderBy(['created' => 'DESC'])]
|
||||
private Collection $eliminations;
|
||||
|
||||
public function __construct()
|
||||
@@ -113,12 +114,12 @@ class Quiz
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDropouts(): ?int
|
||||
public function getDropouts(): int
|
||||
{
|
||||
return $this->dropouts;
|
||||
}
|
||||
|
||||
public function setDropouts(?int $dropouts): static
|
||||
public function setDropouts(int $dropouts): static
|
||||
{
|
||||
$this->dropouts = $dropouts;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user