src/Entity/Core/CrammingActivity/CrammingActivityResponse.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Core\CrammingActivity;
  3. use App\Entity\Core\Answer;
  4. use App\Entity\Core\Mathproblem;
  5. use App\Entity\Core\TemplateSet;
  6. use DateTime;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use JsonSerializable;
  9. #[ORM\Table('cramming_activity_response')]
  10. #[ORM\Entity(repositoryClass: CrammingActivityResponseRepository::class)]
  11. class CrammingActivityResponse implements JsonSerializable
  12. {
  13. /**
  14. * @var int
  15. */
  16. #[ORM\Column(name: 'id', type: 'integer')]
  17. #[ORM\Id]
  18. #[ORM\GeneratedValue(strategy: 'AUTO')]
  19. private $id;
  20. /**
  21. * @var CrammingActivityUnit
  22. */
  23. #[ORM\JoinColumn(name: 'cramming_activity_unit', referencedColumnName: 'id', onDelete: 'CASCADE')]
  24. #[ORM\ManyToOne(targetEntity: CrammingActivityUnit::class, inversedBy: 'crammingActivityResponses')]
  25. private $crammingActivityUnit;
  26. /**
  27. * @var Mathproblem
  28. */
  29. #[ORM\JoinColumn(name: 'mathproblem', referencedColumnName: 'id', onDelete: 'CASCADE')]
  30. #[ORM\ManyToOne(targetEntity: Mathproblem::class)]
  31. private $mathproblem;
  32. /**
  33. * @var Answer
  34. */
  35. #[ORM\JoinColumn(name: 'answer', referencedColumnName: 'id', onDelete: 'RESTRICT')]
  36. #[ORM\ManyToOne(targetEntity: Answer::class)]
  37. private $answerChosen;
  38. /**
  39. * @var Answer
  40. */
  41. #[ORM\JoinColumn(name: 'second_answer', referencedColumnName: 'id', onDelete: 'RESTRICT')]
  42. #[ORM\ManyToOne(targetEntity: Answer::class)]
  43. private $secondAnswer;
  44. #[ORM\Column(name: 'answer_text', type: 'text', nullable: true)]
  45. private $answerText;
  46. #[ORM\Column(name: 'second_answer_text', type: 'text', nullable: true)]
  47. private $secondAnswerText;
  48. /**
  49. * @var DateTime
  50. */
  51. #[ORM\Column(name: 'start_time', type: 'datetime')]
  52. private $startTime;
  53. /**
  54. * @var DateTime
  55. */
  56. #[ORM\Column(name: 'end_time', type: 'datetime', nullable: true)]
  57. private $endTime = null;
  58. /**
  59. * @var int
  60. */
  61. #[ORM\Column(name: 'seconds_delayed', type: 'integer', nullable: true, options: ['default' => 0])]
  62. private $secondsDelayed = 0;
  63. /**
  64. * @var bool
  65. */
  66. #[ORM\Column(name: 'is_valid', type: 'boolean', nullable: true, options: ['default' => true])]
  67. private $isValid = true;
  68. /**
  69. * @var DateTime
  70. */
  71. #[ORM\Column(name: 'archived_at', type: 'datetime', nullable: true)]
  72. private $archivedAt;
  73. /**
  74. * @var TemplateSet
  75. */
  76. #[ORM\JoinColumn(name: 'template_set', referencedColumnName: 'id', onDelete: 'CASCADE')]
  77. #[ORM\ManyToOne(targetEntity: TemplateSet::class)]
  78. private $templateSet;
  79. public function getId(): int
  80. {
  81. return $this->id;
  82. }
  83. public function setId(int $id): void
  84. {
  85. $this->id = $id;
  86. }
  87. public function getCrammingActivityUnit(): CrammingActivityUnit
  88. {
  89. return $this->crammingActivityUnit;
  90. }
  91. public function setCrammingActivityUnit(CrammingActivityUnit $crammingActivityUnit): void
  92. {
  93. $this->crammingActivityUnit = $crammingActivityUnit;
  94. }
  95. public function getMathproblem(): Mathproblem
  96. {
  97. return $this->mathproblem;
  98. }
  99. public function setMathproblem(Mathproblem $mathproblem): void
  100. {
  101. $this->mathproblem = $mathproblem;
  102. }
  103. /**
  104. * @return Answer
  105. */
  106. public function getAnswerChosen(): ?Answer
  107. {
  108. return $this->answerChosen;
  109. }
  110. /**
  111. * @param Answer $answerChosen
  112. */
  113. public function setAnswerChosen(?Answer $answerChosen): void
  114. {
  115. $this->answerChosen = $answerChosen;
  116. }
  117. /**
  118. * @return DateTime
  119. */
  120. public function getEndTime(): ?DateTime
  121. {
  122. return $this->endTime;
  123. }
  124. /**
  125. * @param DateTime $endTime
  126. */
  127. public function setEndTime(?DateTime $endTime): void
  128. {
  129. $this->endTime = $endTime;
  130. }
  131. /**
  132. * @return DateTime
  133. */
  134. public function getStartTime(): DateTime
  135. {
  136. return $this->startTime;
  137. }
  138. /**
  139. * @param DateTime $startTime
  140. */
  141. public function setStartTime(DateTime $startTime): void
  142. {
  143. $this->startTime = $startTime;
  144. }
  145. public function getTemplateSet(): TemplateSet
  146. {
  147. return $this->templateSet;
  148. }
  149. public function setTemplateSet(TemplateSet $templateSet): void
  150. {
  151. $this->templateSet = $templateSet;
  152. }
  153. /**
  154. * @return int
  155. */
  156. public function getSecondsDelayed(): ?int
  157. {
  158. return $this->secondsDelayed;
  159. }
  160. /**
  161. * @param int $secondsDelayed
  162. */
  163. public function setSecondsDelayed(?int $secondsDelayed): void
  164. {
  165. $this->secondsDelayed = $secondsDelayed;
  166. }
  167. /**
  168. * @return Answer
  169. */
  170. public function getSecondAnswer(): ?Answer
  171. {
  172. return $this->secondAnswer;
  173. }
  174. public function setSecondAnswer(Answer $secondAnswer): void
  175. {
  176. $this->secondAnswer = $secondAnswer;
  177. }
  178. function getAnswerText() : string | null{
  179. return $this->answerText;
  180. }
  181. /**
  182. * @return $this
  183. */
  184. function setAnswerText(string $answerText) : self{
  185. $this->answerText = $answerText;
  186. return $this;
  187. }
  188. function getSecondAnswerText() : string | null{
  189. return $this->secondAnswerText;
  190. }
  191. /**
  192. * @return $this
  193. */
  194. function setSecondAnswerText(string $secondAnswerText) : self{
  195. $this->secondAnswerText = $secondAnswerText;
  196. return $this;
  197. }
  198. public function isValid(): bool
  199. {
  200. return $this->isValid;
  201. }
  202. public function setIsValid(bool $isValid): void
  203. {
  204. $this->isValid = $isValid;
  205. }
  206. /**
  207. * @return DateTime|null
  208. */
  209. public function getArchivedAt(): ?DateTime
  210. {
  211. return $this->archivedAt;
  212. }
  213. /**
  214. * @param DateTime $archivedAt
  215. */
  216. public function setArchivedAt(DateTime $archivedAt): void
  217. {
  218. $this->archivedAt = $archivedAt;
  219. }
  220. public function jsonSerialize(): array
  221. {
  222. return [
  223. 'id' => $this->id,
  224. 'answerChosen' => $this->answerChosen,
  225. 'secondAnswer' => $this->secondAnswer,
  226. 'isValid' => $this->isValid,
  227. ];
  228. }
  229. }