<?php namespace App\Entity; use App\Repository\QuestionRepository; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; /** * @ORM\Entity(repositoryClass=QuestionRepository::class) */ class Question { const TYPE_RADIO = 'radio'; const TYPE_CHECKBOX = 'checkbox'; /** * @ORM\Id * @ORM\GeneratedValue * @ORM\Column(type="integer") */ private $id; /** * @ORM\Column(type="string", length=255) */ private $text; /** * @ORM\Column(type="string", length=255, nullable=true) */ private $image; /** * @ORM\Column(type="string", length=255, options={"default":self::TYPE_RADIO}) */ private $type = self::TYPE_RADIO; /** * @ORM\Column(type="integer", nullable=true) */ private $timeLimit; /** * @ORM\Column(type="integer", nullable=true) */ private $orderIndex; /** * @ORM\OneToMany(targetEntity=Answer::class, mappedBy="question") */ private $answers; /** * @ORM\ManyToOne(targetEntity=Quizz::class, inversedBy="questions") */ private $quizz; /** * @var string * * @ORM\Column(type="text") */ protected $explanation; public function __construct() { $this->answers = new ArrayCollection(); } public function getId(): ?int { return $this->id; } public function getText(): ?string { return $this->text; } public function setText( string $text ): self { $this->text = $text; return $this; } public function getImage(): ?string { return $this->image; } public function setImage( ?string $image ): self { $this->image = $image; return $this; } public function getType(): ?string { return $this->type; } public function setType( string $type ): self { $this->type = $type; return $this; } public function getTimeLimit(): ?int { return $this->timeLimit; } public function setTimeLimit( ?int $timeLimit ): self { $this->timeLimit = $timeLimit; return $this; } public function getOrderIndex(): ?int { return $this->orderIndex; } public function setOrderIndex( ?int $orderIndex ): self { $this->orderIndex = $orderIndex; return $this; } /** * @return Collection|Answer[] */ public function getAnswers(): Collection { return $this->answers; } public function addAnswer( Answer $answer ): self { if ( !$this->answers->contains( $answer ) ) { $this->answers[] = $answer; $answer->setQuestion( $this ); } return $this; } public function removeAnswer( Answer $answer ): self { if ( $this->answers->removeElement( $answer ) ) { // set the owning side to null (unless already changed) if ( $answer->getQuestion() === $this ) { $answer->setQuestion( NULL ); } } return $this; } public function getQuizz(): ?Quizz { return $this->quizz; } public function setQuizz( ?Quizz $quizz ): self { $this->quizz = $quizz; return $this; } /** * @return string */ public function getExplanation(): string { return $this->explanation; } /** * @param string $explanation * @return Question */ public function setExplanation(string $explanation): Question { $this->explanation = $explanation; return $this; } }