<?php
namespace App\Entity;
use App\Repository\QuizRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
#[ORM\Entity(repositoryClass: QuizRepository::class)]
class Quiz
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 255)]
private ?string $nom = null;
#[ORM\OneToMany(mappedBy: 'quiz', targetEntity: QuizQuestion::class, cascade: ['persist', 'remove'])]
private Collection $quizQuestions;
#[ORM\Column(length: 10000)]
private ?string $components = null;
#[ORM\OneToMany(mappedBy: 'quiz', targetEntity: PourcentageQuiz::class)]
private Collection $pourcentageQuizzes;
#[ORM\ManyToMany(targetEntity: Module::class, inversedBy: 'quizzes')]
private Collection $module;
#[ORM\Column]
private ?bool $validated = false;
#[ORM\OneToMany(mappedBy: 'quiz', targetEntity: QuizResultat::class, orphanRemoval: true)]
private Collection $quizResultats;
public function __construct()
{
$this->quizQuestions = new ArrayCollection();
$this->pourcentageQuizzes = new ArrayCollection();
$this->module = new ArrayCollection();
$this->quizResultats = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getNom(): ?string
{
return $this->nom;
}
public function setNom(string $nom): self
{
$this->nom = $nom;
return $this;
}
/**
* @return Collection<int, QuizQuestion>
*/
public function getQuizQuestions(): Collection
{
return $this->quizQuestions;
}
public function addQuizQuestion(QuizQuestion $quizQuestion): self
{
if (!$this->quizQuestions->contains($quizQuestion)) {
$this->quizQuestions->add($quizQuestion);
$quizQuestion->setQuiz($this);
}
return $this;
}
public function removeQuizQuestion(QuizQuestion $quizQuestion): self
{
if ($this->quizQuestions->removeElement($quizQuestion)) {
// set the owning side to null (unless already changed)
if ($quizQuestion->getQuiz() === $this) {
$quizQuestion->setQuiz(null);
}
}
return $this;
}
public function getComponents(): ?string
{
return $this->components;
}
public function setComponents(string $components): self
{
$this->components = $components;
return $this;
}
public function __toString()
{
return $this->nom;
}
/**
* @return Collection<int, PourcentageQuiz>
*/
public function getPourcentageQuizzes(): Collection
{
return $this->pourcentageQuizzes;
}
public function addPourcentageQuiz(PourcentageQuiz $pourcentageQuiz): self
{
if (!$this->pourcentageQuizzes->contains($pourcentageQuiz)) {
$this->pourcentageQuizzes->add($pourcentageQuiz);
$pourcentageQuiz->setQuiz($this);
}
return $this;
}
public function removePourcentageQuiz(PourcentageQuiz $pourcentageQuiz): self
{
if ($this->pourcentageQuizzes->removeElement($pourcentageQuiz)) {
// set the owning side to null (unless already changed)
if ($pourcentageQuiz->getQuiz() === $this) {
$pourcentageQuiz->setQuiz(null);
}
}
return $this;
}
/**
* @return Collection<int, Module>
*/
public function getModule(): Collection
{
return $this->module;
}
public function addModule(Module $module): self
{
if (!$this->module->contains($module)) {
$this->module->add($module);
}
return $this;
}
public function removeModule(Module $module): self
{
$this->module->removeElement($module);
return $this;
}
public function isValidated(): ?bool
{
return $this->validated;
}
public function setValidated(bool $validated): self
{
$this->validated = $validated;
return $this;
}
/**
* @return Collection<int, QuizResultat>
*/
public function getQuizResultats(): Collection
{
return $this->quizResultats;
}
public function addQuizResultat(QuizResultat $quizResultat): self
{
if (!$this->quizResultats->contains($quizResultat)) {
$this->quizResultats->add($quizResultat);
$quizResultat->setQuiz($this);
}
return $this;
}
public function removeQuizResultat(QuizResultat $quizResultat): self
{
if ($this->quizResultats->removeElement($quizResultat)) {
// set the owning side to null (unless already changed)
if ($quizResultat->getQuiz() === $this) {
$quizResultat->setQuiz(null);
}
}
return $this;
}
}