src/Entity/QuizQuestionOption.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. /**
  7.  * @ORM\Entity(repositoryClass="App\Repository\QuizQuestionOptionRepository")
  8.  */
  9. class QuizQuestionOption
  10. {
  11.     /**
  12.      * @ORM\Id()
  13.      * @ORM\GeneratedValue()
  14.      * @ORM\Column(type="bigint")
  15.      */
  16.     private $id;
  17.     
  18.     /**
  19.      * @ORM\Column(type="string", length=255)
  20.      */
  21.     private $title;
  22.     
  23.     /**
  24.      * @ORM\ManyToOne(targetEntity="App\Entity\QuizQuestion", inversedBy="quizQuestionOptions")
  25.      * @ORM\JoinColumn(name="question_id", referencedColumnName="id", onDelete="SET NULL")
  26.      */
  27.     private $quizQuestion;
  28.     /**
  29.      * @ORM\OneToMany(targetEntity="App\Entity\QuizAnswer", mappedBy="quizQuestionOption", orphanRemoval=true, cascade={"persist", "remove"}, fetch="EAGER")
  30.      */
  31.     private $quizAnswers;
  32.     /**
  33.      * @ORM\Column(type="integer")
  34.      */
  35.     private $sort;
  36.     
  37.     /**
  38.      * @ORM\Column(type="integer")
  39.      */
  40.     private $answer_weight;
  41.     
  42.     
  43.     public function __construct ()
  44.     {
  45.         $this->title "";
  46.         $this->sort 0;
  47.         $this->answer_weight 0;
  48.         $this->quizAnswers = new ArrayCollection();
  49.     }
  50.     public function getId()
  51.     {
  52.         return $this->id;
  53.     }
  54.     
  55.     public function getTitle(): ?string
  56.     {
  57.         return $this->title;
  58.     }
  59.     
  60.     public function setTitle (string $title null): ?self
  61.     {
  62.         $this->title $title $title "";
  63.         return $this;
  64.     }
  65.     
  66.     public function getQuiz(): ?Quiz
  67.     {
  68.         return $this->quiz;
  69.     }
  70.     
  71.     public function setQuiz(?Quiz $quiz null): self
  72.     {
  73.         $this->quiz $quiz;
  74.         return $this;
  75.     }
  76.     
  77.     public function getQuizQuestion(): ?QuizQuestion
  78.     {
  79.         return $this->quizQuestion;
  80.     }
  81.     
  82.     public function setQuizQuestion(?QuizQuestion $quizQuestion null): self
  83.     {
  84.         $this->quizQuestion $quizQuestion;
  85.         return $this;
  86.     }
  87.     /**
  88.      * @return Collection|QuizAnswer[]
  89.      */
  90.     public function getQuizAnswers(): Collection
  91.     {
  92.         return $this->quizAnswers;
  93.     }
  94.     
  95.     public function addQuizAnswer(QuizAnswer $quizAnswer): self
  96.     {
  97.         if (!$this->quizAnswers->contains($quizAnswer)) {
  98.             $this->quizAnswers[] = $quizAnswer;
  99.             $quizAnswer->setQuizQuestionOption($this);
  100.         }
  101.         
  102.         return $this;
  103.     }
  104.     
  105.     public function removeQuizAnswer(QuizAnswer $quizAnswer): self
  106.     {
  107.         if ($this->quizAnswers->contains($quizAnswer)) {
  108.             $this->quizAnswers->removeElement($quizAnswer);
  109.             // set the owning side to null (unless already changed)
  110.             if ($quizAnswer->getQuizQuestionOption() === $this) {
  111.                 $quizAnswer->setQuizQuestionOption(null);
  112.             }
  113.         }
  114.         
  115.         return $this;
  116.     }
  117.     public function getSort(): int
  118.     {
  119.         return $this->sort;
  120.     }
  121.     
  122.     public function setSort(int $sort): self
  123.     {
  124.         $this->sort $sort;
  125.         return $this;
  126.     }
  127.     public function getAnswerWeight(): int
  128.     {
  129.         return $this->answer_weight;
  130.     }
  131.     
  132.     public function setAnswerWeight(int $answer_weight): self
  133.     {
  134.         $this->answer_weight $answer_weight;
  135.         return $this;
  136.     }
  137.     
  138.     public function __toString ()
  139.     {
  140.         return $this->getTitle();
  141.     }
  142.     
  143. }