src/CoreBundle/Entity/ReadingTestSession.php line 15

Open in your IDE?
  1. <?php
  2. namespace CoreBundle\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use UserBundle\Entity\User;
  6. use JsonSerializable;
  7. /**
  8. * @ORM\Table("reading_test_session")
  9. * @ORM\Entity(repositoryClass="CoreBundle\Entity\ReadingTestSessionRepository")
  10. */
  11. class ReadingTestSession implements JsonSerializable
  12. {
  13. /**
  14. * @var int
  15. *
  16. * @ORM\Column(name="id", type="integer")
  17. * @ORM\Id
  18. * @ORM\GeneratedValue(strategy="AUTO")
  19. */
  20. private $id;
  21. /**
  22. * @var ReadingTest
  23. *
  24. * @ORM\ManyToOne(targetEntity="CoreBundle\Entity\ReadingTest")
  25. * @ORM\JoinColumn(name="readingTest", referencedColumnName="id")
  26. */
  27. private $readingTest;
  28. /**
  29. * @var User
  30. *
  31. * @ORM\ManyToOne(targetEntity="UserBundle\Entity\User")
  32. * @ORM\JoinColumn(name="created_by", referencedColumnName="id")
  33. */
  34. private $createdBy;
  35. /**
  36. * @var Classroom
  37. *
  38. * @ORM\ManyToOne(targetEntity="CoreBundle\Entity\Classroom")
  39. */
  40. private $classroom;
  41. /**
  42. * @var string
  43. *
  44. * @ORM\Column(name="name", type="string", length=255, nullable=true)
  45. */
  46. private $name;
  47. /**
  48. * @var \DateTime
  49. *
  50. * @ORM\Column(name="startTime", type="datetime", nullable=true)
  51. */
  52. private $startTime;
  53. /**
  54. * @var \DateTime
  55. * @ORM\Column(name="deadline", type="datetime", nullable=true)
  56. */
  57. private $deadline;
  58. /**
  59. * @var \DateTime
  60. *
  61. * @ORM\Column(name="createdAt", type="datetime", nullable=false)
  62. */
  63. private $createdAt;
  64. /**
  65. * @var ReadingTestUnit[]
  66. *
  67. * @ORM\OneToMany(targetEntity="CoreBundle\Entity\ReadingTestUnit", mappedBy="readingTestSession", cascade={"persist"})
  68. */
  69. private $readingTestUnits;
  70. /**
  71. * @ORM\Column(type="boolean", nullable=true)
  72. */
  73. private ?bool $deleted;
  74. /**
  75. * @var int
  76. *
  77. * @ORM\Column(type="smallint", nullable=true)
  78. */
  79. private $duration;
  80. /**
  81. * ReadingTestSession constructor.
  82. * @throws \Exception
  83. */
  84. public function __construct()
  85. {
  86. $this->createdAt = new \DateTime('now', new \DateTimeZone('Europe/Copenhagen'));
  87. $this->readingTestUnits = new ArrayCollection();
  88. $this->startTime = new \DateTime("now");
  89. $this->deadline = new \DateTime("+1DAY");
  90. }
  91. /**
  92. * @return int
  93. */
  94. public function getId(): int
  95. {
  96. return $this->id;
  97. }
  98. /**
  99. * @param int $id
  100. */
  101. public function setId(int $id): void
  102. {
  103. $this->id = $id;
  104. }
  105. /**
  106. * @return ReadingTest
  107. */
  108. public function getReadingTest()
  109. {
  110. return $this->readingTest;
  111. }
  112. /**
  113. * @param ReadingTest $readingTest
  114. */
  115. public function setReadingTest(ReadingTest $readingTest): void
  116. {
  117. $this->readingTest = $readingTest;
  118. }
  119. /**
  120. * @return User
  121. */
  122. public function getCreatedBy()
  123. {
  124. return $this->createdBy;
  125. }
  126. /**
  127. * @param User $createdBy
  128. */
  129. public function setCreatedBy(User $createdBy): void
  130. {
  131. $this->createdBy = $createdBy;
  132. }
  133. /**
  134. * @return Classroom
  135. */
  136. public function getClassroom()
  137. {
  138. return $this->classroom;
  139. }
  140. /**
  141. * @param Classroom $classroom
  142. */
  143. public function setClassroom(Classroom $classroom): void
  144. {
  145. $this->classroom = $classroom;
  146. }
  147. /**
  148. * @return string
  149. */
  150. public function getName()
  151. {
  152. return $this->name;
  153. }
  154. public function setName(?string $name): void
  155. {
  156. $this->name = $name;
  157. }
  158. /**
  159. * @return \DateTime
  160. */
  161. public function getStartTime()
  162. {
  163. return $this->startTime;
  164. }
  165. /**
  166. * @param \DateTime $startTime
  167. */
  168. public function setStartTime(\DateTime $startTime): void
  169. {
  170. $this->startTime = $startTime;
  171. }
  172. /**
  173. * @return \DateTime
  174. */
  175. public function getDeadline()
  176. {
  177. return $this->deadline;
  178. }
  179. /**
  180. * @param \DateTime $deadline
  181. */
  182. public function setDeadline(\DateTime $deadline): void
  183. {
  184. $this->deadline = $deadline;
  185. }
  186. /**
  187. * @return \DateTime
  188. */
  189. public function getCreatedAt()
  190. {
  191. return $this->createdAt;
  192. }
  193. /**
  194. * @param \DateTime $createdAt
  195. */
  196. public function setCreatedAt(\DateTime $createdAt): void
  197. {
  198. $this->createdAt = $createdAt;
  199. }
  200. /**
  201. * @return ReadingTestUnit[]
  202. */
  203. public function getReadingTestUnits()
  204. {
  205. return $this->readingTestUnits;
  206. }
  207. /**
  208. * @param ReadingTestUnit[] $readingTestUnits
  209. */
  210. public function setReadingTestUnits(array $readingTestUnits): void
  211. {
  212. $this->readingTestUnits = $readingTestUnits;
  213. }
  214. /**
  215. * @return bool|null
  216. */
  217. public function isDeleted(): ?bool
  218. {
  219. return $this->deleted;
  220. }
  221. /**
  222. * @param bool $deleted
  223. * @return void
  224. */
  225. public function setDeleted(bool $deleted): void
  226. {
  227. $this->deleted = $deleted;
  228. }
  229. public function getDuration(): ?int
  230. {
  231. return $this->duration;
  232. }
  233. public function setDuration(?int $duration)
  234. {
  235. $this->duration = $duration;
  236. }
  237. public function jsonSerialize(): mixed
  238. {
  239. return [
  240. "duration" => $this->getDuration(),
  241. "id" => $this->getId(),
  242. "name" => $this->getName(),
  243. "startTime" => $this->getStartTime(),
  244. 'deadline' => $this->getDeadline(),
  245. ];
  246. }
  247. }