src/Entity/Core/Training/TrainingResponse.php line 14

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