<?php
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass="App\Repository\QuizQuestionOptionRepository")
*/
class QuizQuestionOption
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="bigint")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $title;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\QuizQuestion", inversedBy="quizQuestionOptions")
* @ORM\JoinColumn(name="question_id", referencedColumnName="id", onDelete="SET NULL")
*/
private $quizQuestion;
/**
* @ORM\OneToMany(targetEntity="App\Entity\QuizAnswer", mappedBy="quizQuestionOption", orphanRemoval=true, cascade={"persist", "remove"}, fetch="EAGER")
*/
private $quizAnswers;
/**
* @ORM\Column(type="integer")
*/
private $sort;
/**
* @ORM\Column(type="integer")
*/
private $answer_weight;
public function __construct ()
{
$this->title = "";
$this->sort = 0;
$this->answer_weight = 0;
$this->quizAnswers = new ArrayCollection();
}
public function getId()
{
return $this->id;
}
public function getTitle(): ?string
{
return $this->title;
}
public function setTitle (string $title = null): ?self
{
$this->title = $title ? $title : "";
return $this;
}
public function getQuiz(): ?Quiz
{
return $this->quiz;
}
public function setQuiz(?Quiz $quiz = null): self
{
$this->quiz = $quiz;
return $this;
}
public function getQuizQuestion(): ?QuizQuestion
{
return $this->quizQuestion;
}
public function setQuizQuestion(?QuizQuestion $quizQuestion = null): self
{
$this->quizQuestion = $quizQuestion;
return $this;
}
/**
* @return Collection|QuizAnswer[]
*/
public function getQuizAnswers(): Collection
{
return $this->quizAnswers;
}
public function addQuizAnswer(QuizAnswer $quizAnswer): self
{
if (!$this->quizAnswers->contains($quizAnswer)) {
$this->quizAnswers[] = $quizAnswer;
$quizAnswer->setQuizQuestionOption($this);
}
return $this;
}
public function removeQuizAnswer(QuizAnswer $quizAnswer): self
{
if ($this->quizAnswers->contains($quizAnswer)) {
$this->quizAnswers->removeElement($quizAnswer);
// set the owning side to null (unless already changed)
if ($quizAnswer->getQuizQuestionOption() === $this) {
$quizAnswer->setQuizQuestionOption(null);
}
}
return $this;
}
public function getSort(): int
{
return $this->sort;
}
public function setSort(int $sort): self
{
$this->sort = $sort;
return $this;
}
public function getAnswerWeight(): int
{
return $this->answer_weight;
}
public function setAnswerWeight(int $answer_weight): self
{
$this->answer_weight = $answer_weight;
return $this;
}
public function __toString ()
{
return $this->getTitle();
}
}