src/Entity/QuizQuestion.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\QuizQuestionRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use JMS\Serializer\Annotation as Serializer;
  8. /**
  9. * @ORM\Entity(repositoryClass=QuizQuestionRepository::class)
  10. * @Serializer\ExclusionPolicy("ALL")
  11. */
  12. class QuizQuestion extends BaseEntity
  13. {
  14. /**
  15. * @ORM\Id
  16. * @ORM\GeneratedValue
  17. * @ORM\Column(type="integer")
  18. * @Serializer\Expose
  19. */
  20. private $id;
  21. /**
  22. * @ORM\Column(type="string", length=255)
  23. * @Serializer\Expose
  24. */
  25. private $question;
  26. /**
  27. * @ORM\Column(type="string", length=255)
  28. * @Serializer\Expose
  29. */
  30. private $questionType;
  31. /**
  32. * @ORM\Column(type="boolean")
  33. * @Serializer\Expose
  34. */
  35. private $isRequired;
  36. /**
  37. * @ORM\OneToOne(targetEntity=ImageManager::class, cascade={"persist", "remove"})
  38. */
  39. private $image;
  40. /**
  41. * @ORM\Column(type="integer", nullable=true)
  42. */
  43. private $points;
  44. /**
  45. * @ORM\ManyToOne(targetEntity=Quiz::class, inversedBy="quizQuestions")
  46. */
  47. private $quiz;
  48. /**
  49. * @ORM\Column(type="time", nullable=true)
  50. * @Serializer\Expose
  51. */
  52. private $time;
  53. /**
  54. * @ORM\OneToMany(targetEntity=QuizAnswer::class, mappedBy="question", cascade={"persist", "remove"}, fetch="EXTRA_LAZY")
  55. * @Serializer\Expose
  56. */
  57. private $quizAnswers;
  58. /**
  59. * @ORM\OneToMany(targetEntity=UserQuizQuestion::class, mappedBy="quizQuestion", fetch="EXTRA_LAZY")
  60. */
  61. private $userQuizQuestions;
  62. /**
  63. * @ORM\Column(type="boolean", nullable=true)
  64. * @Serializer\Expose
  65. */
  66. private $isTrueOrFalse;
  67. /**
  68. * @ORM\Column(type="boolean", nullable=true)
  69. * @Serializer\Expose
  70. */
  71. private $isMultipleChoice;
  72. /**
  73. * @ORM\Column(type="string", length=255, nullable=true)
  74. * @Serializer\Expose
  75. */
  76. private $helpText;
  77. public function __construct()
  78. {
  79. $this->quizAnswers = new ArrayCollection();
  80. $this->userQuizQuestions = new ArrayCollection();
  81. }
  82. public function getId(): ?int
  83. {
  84. return $this->id;
  85. }
  86. public function getQuestion(): ?string
  87. {
  88. return $this->question;
  89. }
  90. public function setQuestion(string $question): self
  91. {
  92. $this->question = $question;
  93. return $this;
  94. }
  95. public function getQuestionType(): ?string
  96. {
  97. return $this->questionType;
  98. }
  99. public function setQuestionType(string $questionType): self
  100. {
  101. $this->questionType = $questionType;
  102. return $this;
  103. }
  104. public function isIsRequired(): ?bool
  105. {
  106. return $this->isRequired;
  107. }
  108. public function setIsRequired(bool $isRequired): self
  109. {
  110. $this->isRequired = $isRequired;
  111. return $this;
  112. }
  113. public function getImage(): ?ImageManager
  114. {
  115. return $this->image;
  116. }
  117. public function setImage(?ImageManager $image): self
  118. {
  119. $this->image = $image;
  120. return $this;
  121. }
  122. public function getPoints(): ?int
  123. {
  124. return $this->points;
  125. }
  126. public function setPoints(?int $points): self
  127. {
  128. $this->points = $points;
  129. return $this;
  130. }
  131. public function getQuiz(): ?Quiz
  132. {
  133. return $this->quiz;
  134. }
  135. public function setQuiz(?Quiz $quiz): self
  136. {
  137. $this->quiz = $quiz;
  138. return $this;
  139. }
  140. public function getTime(): ?\DateTimeInterface
  141. {
  142. return $this->time;
  143. }
  144. public function setTime(?\DateTimeInterface $time): self
  145. {
  146. $this->time = $time;
  147. return $this;
  148. }
  149. /**
  150. * @return Collection<int, QuizAnswer>
  151. */
  152. public function getQuizAnswers(): Collection
  153. {
  154. return $this->quizAnswers;
  155. }
  156. public function addQuizAnswer(QuizAnswer $quizAnswer): self
  157. {
  158. if (!$this->quizAnswers->contains($quizAnswer)) {
  159. $this->quizAnswers[] = $quizAnswer;
  160. $quizAnswer->setQuestion($this);
  161. }
  162. return $this;
  163. }
  164. public function removeQuizAnswer(QuizAnswer $quizAnswer): self
  165. {
  166. if ($this->quizAnswers->removeElement($quizAnswer)) {
  167. // set the owning side to null (unless already changed)
  168. if ($quizAnswer->getQuestion() === $this) {
  169. $quizAnswer->setQuestion(null);
  170. }
  171. }
  172. return $this;
  173. }
  174. /**
  175. * @return Collection<int, UserQuizQuestion>
  176. */
  177. public function getUserQuizQuestions(): Collection
  178. {
  179. return $this->userQuizQuestions;
  180. }
  181. public function addUserQuizQuestion(UserQuizQuestion $userQuizQuestion): self
  182. {
  183. if (!$this->userQuizQuestions->contains($userQuizQuestion)) {
  184. $this->userQuizQuestions[] = $userQuizQuestion;
  185. $userQuizQuestion->setQuizQuestion($this);
  186. }
  187. return $this;
  188. }
  189. public function removeUserQuizQuestion(UserQuizQuestion $userQuizQuestion): self
  190. {
  191. if ($this->userQuizQuestions->removeElement($userQuizQuestion)) {
  192. // set the owning side to null (unless already changed)
  193. if ($userQuizQuestion->getQuizQuestion() === $this) {
  194. $userQuizQuestion->setQuizQuestion(null);
  195. }
  196. }
  197. return $this;
  198. }
  199. public function isIsTrueOrFalse(): ?bool
  200. {
  201. return $this->isTrueOrFalse;
  202. }
  203. public function setIsTrueOrFalse(?bool $isTrueOrFalse): self
  204. {
  205. $this->isTrueOrFalse = $isTrueOrFalse;
  206. return $this;
  207. }
  208. public function isIsMultipleChoice(): ?bool
  209. {
  210. return $this->isMultipleChoice;
  211. }
  212. public function setIsMultipleChoice(?bool $isMultipleChoice): self
  213. {
  214. $this->isMultipleChoice = $isMultipleChoice;
  215. return $this;
  216. }
  217. public function getHelpText(): ?string
  218. {
  219. return $this->helpText;
  220. }
  221. public function setHelpText(?string $helpText): self
  222. {
  223. $this->helpText = $helpText;
  224. return $this;
  225. }
  226. }