src/Entity/Core/Homework/HomeworkResponse.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Core\Homework;
  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('homework_response')]
  9. #[ORM\Entity(repositoryClass: HomeworkResponseRepository::class)]
  10. class HomeworkResponse 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 HomeworkUnit
  21. */
  22. #[ORM\JoinColumn(name: 'homework_unit', referencedColumnName: 'id', onDelete: 'CASCADE')]
  23. #[ORM\ManyToOne(targetEntity: HomeworkUnit::class, inversedBy: 'homeworkResponses')]
  24. private $homeworkUnit;
  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. /**
  48. * @var Answer
  49. */
  50. #[ORM\JoinColumn(name: 'second_answer', referencedColumnName: 'id', onDelete: 'RESTRICT', nullable: true)]
  51. #[ORM\ManyToOne(targetEntity: Answer::class)]
  52. private $secondAnswer;
  53. /**
  54. * @var string|null
  55. */
  56. #[ORM\Column(name: 'answer_text', type: 'text', nullable: true)]
  57. private string|null $answerText = null;
  58. /**
  59. * @var string|null
  60. */
  61. #[ORM\Column(name: 'second_answer_text', type: 'text', nullable: true)]
  62. private string|null $secondAnswerText = null;
  63. /**
  64. * @var int
  65. */
  66. #[ORM\Column(name: 'seconds_delayed', type: 'integer', nullable: false, options: ['default' => 0])]
  67. private $secondsDelayed;
  68. #[ORM\Column(name: 'repetition_flag', type: 'boolean', nullable: true)]
  69. private $repetitionFlag;
  70. /**
  71. * @var bool
  72. */
  73. #[ORM\Column(name: 'is_valid', type: 'boolean', nullable: true, options: ['default' => true])]
  74. private $isValid = true;
  75. /**
  76. * @var DateTime
  77. */
  78. #[ORM\Column(name: 'archived_at', type: 'datetime', nullable: true)]
  79. private $archivedAt;
  80. /**
  81. * Get id.
  82. *
  83. * @return int
  84. */
  85. public function getId()
  86. {
  87. return $this->id;
  88. }
  89. /**
  90. * Set HomeworkUnit.
  91. *
  92. * @param HomeworkUnit $homeworkUnit
  93. *
  94. * @return HomeworkResponse
  95. */
  96. public function setHomeworkUnit($homeworkUnit)
  97. {
  98. $this->homeworkUnit = $homeworkUnit;
  99. return $this;
  100. }
  101. /**
  102. * Get HomeworkUnit.
  103. *
  104. * @return HomeworkUnit
  105. */
  106. public function getHomeworkUnit()
  107. {
  108. return $this->homeworkUnit;
  109. }
  110. /**
  111. * Set mathproblem.
  112. *
  113. * @param Mathproblem $mathproblem
  114. *
  115. * @return HomeworkResponse
  116. */
  117. public function setMathproblem($mathproblem)
  118. {
  119. $this->mathproblem = $mathproblem;
  120. return $this;
  121. }
  122. /**
  123. * Get mathproblem.
  124. *
  125. * @return Mathproblem
  126. */
  127. public function getMathproblem()
  128. {
  129. return $this->mathproblem;
  130. }
  131. /**
  132. * Set answerChosen.
  133. *
  134. * @param Answer $answerChosen
  135. *
  136. * @return HomeworkResponse
  137. */
  138. public function setAnswerChosen($answerChosen)
  139. {
  140. $this->answerChosen = $answerChosen;
  141. return $this;
  142. }
  143. /**
  144. * Get answerChosen.
  145. *
  146. * @return Answer
  147. */
  148. public function getAnswerChosen()
  149. {
  150. return $this->answerChosen;
  151. }
  152. /**
  153. * @param DateTime $endTime
  154. */
  155. public function setEndTime($endTime)
  156. {
  157. $this->endTime = $endTime;
  158. }
  159. /**
  160. * @return DateTime
  161. */
  162. public function getEndTime()
  163. {
  164. return $this->endTime;
  165. }
  166. /**
  167. * @param DateTime $startTime
  168. */
  169. public function setStartTime($startTime)
  170. {
  171. $this->startTime = $startTime;
  172. }
  173. /**
  174. * @return DateTime
  175. */
  176. public function getStartTime()
  177. {
  178. return $this->startTime;
  179. }
  180. /**
  181. * @return Answer
  182. */
  183. public function getSecondAnswer()
  184. {
  185. return $this->secondAnswer;
  186. }
  187. /**
  188. * @param Answer $secondAnswer
  189. */
  190. public function setSecondAnswer($secondAnswer)
  191. {
  192. $this->secondAnswer = $secondAnswer;
  193. }
  194. function getAnswerText(): string|null {
  195. return $this->answerText;
  196. }
  197. /**
  198. * @return $this
  199. */
  200. function setAnswerText(string $answerText):self {
  201. $this->answerText = $answerText;
  202. return $this;
  203. }
  204. function getSecondAnswerText(): string|null {
  205. return $this->secondAnswerText;
  206. }
  207. /**
  208. * @return $this
  209. */
  210. function setSecondAnswerText(string $secondAnswerText):self {
  211. $this->secondAnswerText = $secondAnswerText;
  212. return $this;
  213. }
  214. /**
  215. * @return int
  216. */
  217. public function getSecondsDelayed()
  218. {
  219. return $this->secondsDelayed;
  220. }
  221. /**
  222. * @param int $secondsDelayed
  223. * @return $this
  224. */
  225. public function setSecondsDelayed($secondsDelayed)
  226. {
  227. $this->secondsDelayed = $secondsDelayed;
  228. return $this;
  229. }
  230. /**
  231. * @return mixed
  232. */
  233. public function getRepetitionFlag()
  234. {
  235. return $this->repetitionFlag;
  236. }
  237. /**
  238. * @param mixed $repetitionFlag
  239. */
  240. public function setRepetitionFlag($repetitionFlag)
  241. {
  242. $this->repetitionFlag = $repetitionFlag;
  243. }
  244. public function isValid(): bool
  245. {
  246. return $this->isValid;
  247. }
  248. public function setIsValid(bool $isValid): void
  249. {
  250. $this->isValid = $isValid;
  251. }
  252. /**
  253. * @return DateTime|null
  254. */
  255. public function getArchivedAt(): ?DateTime
  256. {
  257. return $this->archivedAt;
  258. }
  259. /**
  260. * @param DateTime $archivedAt
  261. */
  262. public function setArchivedAt(DateTime $archivedAt): void
  263. {
  264. $this->archivedAt = $archivedAt;
  265. }
  266. public function jsonSerialize(): mixed
  267. {
  268. return [
  269. 'id' => $this->id,
  270. 'answerChosen' => $this->answerChosen,
  271. 'mathproblem' => $this->mathproblem,
  272. 'startTime' => $this->startTime,
  273. 'endTime' => $this->endTime,
  274. 'secondAnswer' => $this->secondAnswer,
  275. 'archivedAt' => $this->archivedAt,
  276. 'homeworkUnit' => $this->homeworkUnit,
  277. 'isValid' => $this->isValid,
  278. 'repetitionFlag' => $this->repetitionFlag,
  279. 'secondsDelayed' => $this->secondsDelayed,
  280. ];
  281. }
  282. }