src/Entity/QuizAnswer.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\QuizAnswerRepository;
  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=QuizAnswerRepository::class)
  10. * @Serializer\ExclusionPolicy("ALL")
  11. */
  12. class QuizAnswer
  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="text")
  23. * @Serializer\Expose
  24. */
  25. private $response;
  26. /**
  27. * @ORM\ManyToOne(targetEntity=QuizQuestion::class, inversedBy="quizAnswers")
  28. */
  29. private $question;
  30. /**
  31. * @ORM\Column(type="boolean", nullable=true)
  32. * @Serializer\Expose
  33. */
  34. private $isCorrect;
  35. /**
  36. * @ORM\ManyToMany(targetEntity=UserQuizQuestion::class, mappedBy="quizAnswers")
  37. */
  38. private $userQuizQuestions;
  39. /**
  40. * @ORM\Column(type="text", nullable=true)
  41. * @Serializer\Expose
  42. */
  43. private $correctResponse;
  44. /**
  45. * @ORM\Column(type="integer", nullable=true)
  46. * @Serializer\Expose
  47. */
  48. private $responseOrder;
  49. public function __construct()
  50. {
  51. $this->userQuizQuestions = new ArrayCollection();
  52. }
  53. public function getId(): ?int
  54. {
  55. return $this->id;
  56. }
  57. public function getResponse(): ?string
  58. {
  59. return $this->response;
  60. }
  61. public function setResponse(string $response): self
  62. {
  63. $this->response = $response;
  64. return $this;
  65. }
  66. public function getQuestion(): ?QuizQuestion
  67. {
  68. return $this->question;
  69. }
  70. public function setQuestion(?QuizQuestion $question): self
  71. {
  72. $this->question = $question;
  73. return $this;
  74. }
  75. public function isIsCorrect(): ?bool
  76. {
  77. return $this->isCorrect;
  78. }
  79. public function setIsCorrect(?bool $isCorrect): self
  80. {
  81. $this->isCorrect = $isCorrect;
  82. return $this;
  83. }
  84. /**
  85. * @return Collection<int, UserQuizQuestion>
  86. */
  87. public function getUserQuizQuestions(): Collection
  88. {
  89. return $this->userQuizQuestions;
  90. }
  91. public function addUserQuizQuestion(UserQuizQuestion $userQuizQuestion): self
  92. {
  93. if (!$this->userQuizQuestions->contains($userQuizQuestion)) {
  94. $this->userQuizQuestions[] = $userQuizQuestion;
  95. $userQuizQuestion->addQuizAnswer($this);
  96. }
  97. return $this;
  98. }
  99. public function removeUserQuizQuestion(UserQuizQuestion $userQuizQuestion): self
  100. {
  101. if ($this->userQuizQuestions->removeElement($userQuizQuestion)) {
  102. $userQuizQuestion->removeQuizAnswer($this);
  103. }
  104. return $this;
  105. }
  106. public function getCorrectResponse(): ?string
  107. {
  108. return $this->correctResponse;
  109. }
  110. public function setCorrectResponse(?string $correctResponse): self
  111. {
  112. $this->correctResponse = $correctResponse;
  113. return $this;
  114. }
  115. public function getResponseOrder(): ?int
  116. {
  117. return $this->responseOrder;
  118. }
  119. public function setResponseOrder(?int $responseOrder): self
  120. {
  121. $this->responseOrder = $responseOrder;
  122. return $this;
  123. }
  124. }