src/Entity/Core/PretestResponse.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Core;
  3. use App\Entity\Core\Session\Session;
  4. use App\Entity\User\User;
  5. use DateTime;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use JsonSerializable;
  8. #[ORM\Table('pretest_response')]
  9. #[ORM\Entity(repositoryClass: PretestResponseRepository::class)]
  10. class PretestResponse 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 User
  21. */
  22. #[ORM\JoinColumn(name: 'user_id', referencedColumnName: 'id')]
  23. #[ORM\ManyToOne(targetEntity: User::class)]
  24. private $student;
  25. /**
  26. * @var Session
  27. */
  28. #[ORM\JoinColumn(name: 'session', referencedColumnName: 'id', onDelete: 'CASCADE')]
  29. #[ORM\ManyToOne(targetEntity: Session::class, inversedBy: 'PretestResponses')]
  30. private $session;
  31. /**
  32. * @var Mathproblem
  33. */
  34. #[ORM\JoinColumn(name: 'mathproblem', referencedColumnName: 'id')]
  35. #[ORM\ManyToOne(targetEntity: Mathproblem::class, fetch: 'EAGER')]
  36. private $mathproblem;
  37. /**
  38. * @var Answer
  39. */
  40. #[ORM\JoinColumn(name: 'answer', referencedColumnName: 'id', nullable: true, onDelete: 'RESTRICT')]
  41. #[ORM\ManyToOne(targetEntity: Answer::class, fetch: 'EAGER')]
  42. private $answer;
  43. /**
  44. * @var string
  45. */
  46. #[ORM\Column(name: 'answerTxt', type: 'string', nullable: true)]
  47. private $answerTxt;
  48. /**
  49. * @var DateTime
  50. */
  51. #[ORM\Column(name: 'endTime', type: 'datetime', nullable: true)]
  52. private $endTime = null;
  53. /**
  54. * @var DateTime
  55. */
  56. #[ORM\Column(name: 'startTime', type: 'datetime')]
  57. private $startTime;
  58. #[ORM\Column(name: 'elo', type: 'decimal', precision: 9, scale: 5, unique: false, nullable: true)]
  59. private $currentElo;
  60. #[ORM\Column(name: 'elo_mp', type: 'decimal', precision: 9, scale: 5, unique: false, nullable: true)]
  61. private $currentEloMP;
  62. /**
  63. * Get id.
  64. *
  65. * @return int
  66. */
  67. public function getId()
  68. {
  69. return $this->id;
  70. }
  71. /**
  72. * Set student.
  73. *
  74. * @param User $student
  75. *
  76. * @return PretestResponse
  77. */
  78. public function setStudent($student)
  79. {
  80. $this->student = $student;
  81. return $this;
  82. }
  83. /**
  84. * Get student.
  85. *
  86. * @return User
  87. */
  88. public function getStudent()
  89. {
  90. return $this->student;
  91. }
  92. /**
  93. * Set Session.
  94. *
  95. * @param Session $session
  96. *
  97. * @return PretestResponse
  98. */
  99. public function setSession($session)
  100. {
  101. $this->session = $session;
  102. return $this;
  103. }
  104. /**
  105. * Get Session.
  106. *
  107. * @return Session
  108. */
  109. public function getSession()
  110. {
  111. return $this->session;
  112. }
  113. /**
  114. * Set mathproblem.
  115. *
  116. * @param Mathproblem $mathproblem
  117. *
  118. * @return PretestResponse
  119. */
  120. public function setMathproblem($mathproblem)
  121. {
  122. $this->mathproblem = $mathproblem;
  123. return $this;
  124. }
  125. /**
  126. * Get Mathproblem.
  127. *
  128. * @return Mathproblem
  129. */
  130. public function getMathproblem()
  131. {
  132. return $this->mathproblem;
  133. }
  134. /**
  135. * Set answer.
  136. *
  137. * @param Answer $answer
  138. *
  139. * @return PretestResponse
  140. */
  141. public function setAnswer($answer)
  142. {
  143. $this->answer = $answer;
  144. return $this;
  145. }
  146. /**
  147. * @return Answer
  148. */
  149. public function getAnswerChosen()
  150. {
  151. return $this->answer;
  152. }
  153. /**
  154. * Set answer.
  155. *
  156. * @param string
  157. *
  158. * @return PretestResponse
  159. */
  160. public function setAnswerTxt($answer)
  161. {
  162. $this->answerTxt = $answer;
  163. return $this;
  164. }
  165. /**
  166. * Get answerTxt.
  167. *
  168. * @return string
  169. */
  170. public function getAnswerTxt()
  171. {
  172. return $this->answerTxt;
  173. }
  174. /**
  175. * Get answer.
  176. *
  177. * @return Answer
  178. */
  179. public function getAnswer()
  180. {
  181. return $this->answer;
  182. }
  183. /**
  184. * @param DateTime $endTime
  185. */
  186. public function setEndTime($endTime)
  187. {
  188. $this->endTime = $endTime;
  189. }
  190. /**
  191. * @return DateTime
  192. */
  193. public function getEndTime()
  194. {
  195. return $this->endTime;
  196. }
  197. /**
  198. * @param DateTime $startTime
  199. */
  200. public function setStartTime($startTime)
  201. {
  202. $this->startTime = $startTime;
  203. }
  204. /**
  205. * @return DateTime
  206. */
  207. public function getStartTime()
  208. {
  209. return $this->startTime;
  210. }
  211. public function getCurrentElo()
  212. {
  213. return $this->currentElo;
  214. }
  215. public function setCurrentElo($elo)
  216. {
  217. $this->currentElo = $elo;
  218. }
  219. public function getCurrentEloMP()
  220. {
  221. return $this->currentEloMP;
  222. }
  223. public function setCurrentEloMP($elo)
  224. {
  225. $this->currentEloMP = $elo;
  226. }
  227. public function jsonSerialize(): mixed
  228. {
  229. return [
  230. "id" => $this->getId(),
  231. "startTime" => $this->getStartTime(),
  232. "session" => $this->getSession(),
  233. "answerChosen" => $this->getAnswerChosen(),
  234. "mathproblem" => $this->getMathproblem(),
  235. "answer" => $this->getAnswer(),
  236. "student" => $this->getStudent(),
  237. "endTime" => $this->getEndTime(),
  238. "answerTxt" => $this->getAnswerTxt(),
  239. "currentElo" => $this->getCurrentElo(),
  240. "currentEloMP" => $this->getCurrentEloMP(),
  241. ];
  242. }
  243. }