src/CoreBundle/Entity/Session.php line 14

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 Doctrine\Common\Collections\Collection;
  6. use JsonSerializable;
  7. /**
  8. * @ORM\Table("session")
  9. * @ORM\Entity(repositoryClass="CoreBundle\Entity\SessionRepository")
  10. */
  11. class Session extends SessionType implements SessionInterface, JsonSerializable
  12. {
  13. /**
  14. * @var Classroom
  15. *
  16. * @ORM\ManyToOne(targetEntity="Classroom", inversedBy="sessions")
  17. * @ORM\JoinColumn(name="classroom", referencedColumnName="id", onDelete="CASCADE")
  18. */
  19. private $classroom;
  20. /**
  21. * @var ArrayCollection|Topic[]
  22. *
  23. * @ORM\ManyToMany(targetEntity="Topic", inversedBy="sessions")
  24. * @ORM\JoinTable(name="session_topic",
  25. * joinColumns={@ORM\JoinColumn(name="session", referencedColumnName="id")},
  26. * inverseJoinColumns={@ORM\JoinColumn(name="topic", referencedColumnName="id")})
  27. */
  28. private $topics;
  29. /**
  30. * @var ArrayCollection
  31. *
  32. * @ORM\ManyToMany(targetEntity="TagMathproblem")
  33. * @ORM\JoinTable(name="session_tag",
  34. * joinColumns={@ORM\JoinColumn(name="session", referencedColumnName="id")},
  35. * inverseJoinColumns={@ORM\JoinColumn(name="tag", referencedColumnName="id")})
  36. */
  37. private $tags;
  38. /**
  39. * @var bool
  40. *
  41. * @ORM\Column(name="dormant", type="boolean")
  42. */
  43. private $dormant = false;
  44. /**
  45. * @var Pretest
  46. *
  47. * @ORM\ManyToOne(targetEntity="Pretest")
  48. * @ORM\JoinColumn(name="pretest", referencedColumnName="id", nullable=true, onDelete="CASCADE")
  49. */
  50. private $pretest;
  51. /**
  52. * @ORM\Column(type="integer", nullable=true)
  53. */
  54. private $pretestDuration;
  55. /**
  56. * @ORM\Column(type="integer", nullable=true, options={"default"=1})
  57. */
  58. private $groupSize = 1;
  59. /**
  60. * @ORM\Column(type="boolean", nullable=true)
  61. */
  62. private $usePretest;
  63. /**
  64. * @ORM\OneToMany(targetEntity="TrainingUnit",
  65. * mappedBy="session", cascade={"persist","remove"})
  66. */
  67. private Collection $TrainingUnits;
  68. /**
  69. * @var PretestResponse[]
  70. *
  71. * @ORM\OneToMany(targetEntity="PretestResponse",
  72. * mappedBy="session", cascade={"persist","remove"})
  73. */
  74. private $PretestResponses;
  75. /**
  76. * @var ArrayCollection|SessionStudent[]
  77. *
  78. * @ORM\OneToMany(targetEntity="SessionStudent",
  79. * mappedBy="session", cascade={"persist","remove"})
  80. */
  81. private $students;
  82. /**
  83. * @ORM\Column(type="integer", nullable=true, options={"default"=0})
  84. */
  85. private $status = 0;
  86. /**
  87. * @ORM\Column(type="integer")
  88. */
  89. private $templateCount;
  90. /**
  91. * @ORM\Column(type="integer")
  92. *
  93. * assistance = 1 (both CAS and no CAS)
  94. * assistance = 2 (no CAS)
  95. */
  96. private $assistance;
  97. /**
  98. * @var bool
  99. * @ORM\Column(name="is_self_study", type="boolean", nullable=true, options={"default":false})
  100. */
  101. private $isSelfStudy;
  102. /**
  103. * @ORM\Column(name="has_many_topics", type="integer", nullable=true, options={"default"=0})
  104. *
  105. * hasManyTopics = 0 (count of topics <= 3)
  106. * hasManyTopics = 1 (count of topics > 3)
  107. */
  108. private $hasManyTopics = 0;
  109. /**
  110. * @var SelfStudyTopic
  111. *
  112. * @ORM\ManyToOne(targetEntity="SelfStudyTopic")
  113. * @ORM\JoinColumn(name="self_study_topic", referencedColumnName="id")
  114. */
  115. private $selfStudyTopic = null;
  116. /**
  117. * @ORM\Column(name="start_difficulty", type="integer", nullable=true)
  118. */
  119. private $startDifficulty;
  120. public function __construct()
  121. {
  122. $this->TrainingUnits = new ArrayCollection();
  123. $this->PretestResponses = new ArrayCollection();
  124. $this->topics = new ArrayCollection();
  125. $this->tags = new ArrayCollection();
  126. $this->students = new ArrayCollection();
  127. }
  128. /**
  129. * Set classroom.
  130. *
  131. * @param Classroom $classroom
  132. *
  133. * @return Session
  134. */
  135. public function setClassroom($classroom)
  136. {
  137. $this->classroom = $classroom;
  138. return $this;
  139. }
  140. /**
  141. * Get classroom.
  142. *
  143. * @return Classroom
  144. */
  145. public function getClassroom()
  146. {
  147. return $this->classroom;
  148. }
  149. /**
  150. * @param Topic[] $topics
  151. */
  152. public function setTopics(array $topics)
  153. {
  154. $this->topics = $topics;
  155. }
  156. public function getTopics(): Collection
  157. {
  158. return $this->topics;
  159. }
  160. /**
  161. * @param Topic $topic
  162. *
  163. * @return Session
  164. */
  165. public function addTopic(Topic $topic)
  166. {
  167. $this->topics->add($topic);
  168. return $this;
  169. }
  170. /**
  171. * @param Topic $topic
  172. *
  173. * @return bool
  174. */
  175. public function removeTopic(Topic $topic)
  176. {
  177. return $this->topics->removeElement($topic);
  178. }
  179. /**
  180. * @return Collection
  181. */
  182. public function getTags(): Collection
  183. {
  184. return $this->tags;
  185. }
  186. /**
  187. * @param TagMathproblem $tag
  188. *
  189. * @return Session
  190. */
  191. public function addTag(TagMathproblem $tag)
  192. {
  193. $this->tags->add($tag);
  194. return $this;
  195. }
  196. /**
  197. * @param TagMathproblem[] $tags
  198. */
  199. public function setTags(array $tags)
  200. {
  201. $this->tags = $tags;
  202. }
  203. /**
  204. * @param TagMathproblem $tag
  205. *
  206. * @return bool
  207. */
  208. public function removeTag(TagMathproblem $tag)
  209. {
  210. return $this->tags->removeElement($tag);
  211. }
  212. public function isDormant()
  213. {
  214. return $this->dormant;
  215. }
  216. public function setDormant($dormant)
  217. {
  218. $this->dormant = $dormant;
  219. }
  220. /**
  221. * Set pretest.
  222. *
  223. * @param Pretest $pretest
  224. *
  225. * @return Session
  226. */
  227. public function setPretest($pretest)
  228. {
  229. $this->pretest = $pretest;
  230. return $this;
  231. }
  232. /**
  233. * Get pretest.
  234. *
  235. * @return Pretest
  236. */
  237. public function getPretest()
  238. {
  239. return $this->pretest;
  240. }
  241. /**
  242. * Set Duration.
  243. *
  244. * @param int $duration
  245. *
  246. * @return Session
  247. */
  248. public function setDuration($duration)
  249. {
  250. $this->duration = $duration;
  251. return $this;
  252. }
  253. /**
  254. * Get duration.
  255. *
  256. * @return int
  257. */
  258. public function getDuration()
  259. {
  260. return $this->duration;
  261. }
  262. /**
  263. * Set groupSize.
  264. *
  265. * @param int $groupSize
  266. *
  267. * @return Session
  268. */
  269. public function setGroupSize($groupSize)
  270. {
  271. $this->groupSize = $groupSize;
  272. return $this;
  273. }
  274. /**
  275. * Get groupSize.
  276. *
  277. * @return int
  278. */
  279. public function getGroupSize()
  280. {
  281. return $this->groupSize;
  282. }
  283. /**
  284. * Set pretestDuration.
  285. *
  286. * @param int $pretestDuration
  287. *
  288. * @return Session
  289. */
  290. public function setPretestDuration($pretestDuration)
  291. {
  292. $this->pretestDuration = $pretestDuration;
  293. return $this;
  294. }
  295. /**
  296. * Get pretestDuration
  297. *
  298. * @return int
  299. */
  300. public function getPretestDuration()
  301. {
  302. return $this->pretestDuration;
  303. }
  304. /**
  305. * Set usePretest.
  306. *
  307. * @param int $usePretest
  308. *
  309. * @return Session
  310. */
  311. public function setUsePretest($usePretest)
  312. {
  313. $this->usePretest = $usePretest;
  314. return $this;
  315. }
  316. /**
  317. * Get usePretest.
  318. *
  319. * @return boolean
  320. */
  321. public function getUsePretest()
  322. {
  323. return $this->usePretest;
  324. }
  325. /**
  326. * @return ArrayCollection|TrainingUnit[]
  327. */
  328. public function getTrainingUnits(): Collection
  329. {
  330. return $this->TrainingUnits;
  331. }
  332. /**
  333. * @param TrainingUnit $TrainingUnit
  334. *
  335. * @return Session
  336. */
  337. public function addTrainingUnit(TrainingUnit $TrainingUnit)
  338. {
  339. $TrainingUnit->setSession($this);
  340. $this->TrainingUnits->add($TrainingUnit);
  341. return $this;
  342. }
  343. /**
  344. * @param TrainingUnit $TrainingUnit
  345. *
  346. * @return bool
  347. */
  348. public function removeTrainingUnit(TrainingUnit $TrainingUnit)
  349. {
  350. $TrainingUnit->setSession(null);
  351. return $this->TrainingUnits->removeElement($TrainingUnit);
  352. }
  353. /**
  354. * @return PretestResponse[]
  355. */
  356. public function getPretestResponses()
  357. {
  358. return $this->PretestResponses;
  359. }
  360. /**
  361. * @param PretestResponse $PretestResponse
  362. *
  363. * @return Session
  364. */
  365. public function addPretestResponse(PretestResponse $PretestResponse)
  366. {
  367. $PretestResponse->setSession($this);
  368. $this->PretestResponses->add($PretestResponse);
  369. return $this;
  370. }
  371. /**
  372. * @param PretestResponse $PretestResponse
  373. *
  374. * @return bool
  375. */
  376. public function removePretestResponse(PretestResponse $PretestResponse)
  377. {
  378. $PretestResponse->setSession(null);
  379. return $this->PretestResponses->removeElement($PretestResponse);
  380. }
  381. /**
  382. * @return SessionStudent[]
  383. */
  384. public function getStudents()
  385. {
  386. return $this->students;
  387. }
  388. /**
  389. * @param SessionStudent $student
  390. *
  391. * @return Session
  392. */
  393. public function addStudent(SessionStudent $student)
  394. {
  395. $this->students->add($student);
  396. return $this;
  397. }
  398. /**
  399. * @param SessionStudent $student
  400. *
  401. * @return bool
  402. */
  403. public function removeStudent(SessionStudent $student)
  404. {
  405. $student->setSession(null);
  406. return $this->students->removeElement($student);
  407. }
  408. /**
  409. * @return int|null
  410. */
  411. public function getStatus(): ?int
  412. {
  413. return $this->status;
  414. }
  415. /**
  416. * @param mixed $status
  417. */
  418. public function setStatus($status)
  419. {
  420. $this->status = $status;
  421. }
  422. public function getTemplateCount()
  423. {
  424. return $this->templateCount;
  425. }
  426. public function setTemplateCount($count)
  427. {
  428. $this->templateCount = $count;
  429. }
  430. public function getAssistance()
  431. {
  432. return $this->assistance;
  433. }
  434. /**
  435. * @param mixed $assistance
  436. */
  437. public function setAssistance($assistance)
  438. {
  439. $this->assistance = $assistance;
  440. }
  441. /**
  442. * @return bool | null
  443. */
  444. public function isSelfStudy()
  445. {
  446. return $this->isSelfStudy;
  447. }
  448. /**
  449. * @param bool $isSelfStudy
  450. */
  451. public function setIsSelfStudy(bool $isSelfStudy)
  452. {
  453. $this->isSelfStudy = $isSelfStudy;
  454. }
  455. /**
  456. * @return int
  457. */
  458. public function hasManyTopics(): int
  459. {
  460. return $this->hasManyTopics;
  461. }
  462. /**
  463. * @param int $hasManyTopics
  464. */
  465. public function setHasManyTopics(int $hasManyTopics): void
  466. {
  467. $this->hasManyTopics = $hasManyTopics;
  468. }
  469. /**
  470. * @return mixed
  471. */
  472. public function getStartDifficulty()
  473. {
  474. return $this->startDifficulty;
  475. }
  476. /**
  477. * @param mixed $startDifficulty
  478. */
  479. public function setStartDifficulty($startDifficulty): void
  480. {
  481. $this->startDifficulty = $startDifficulty;
  482. }
  483. public function getSelfStudyTopic(): ?SelfStudyTopic
  484. {
  485. return $this->selfStudyTopic;
  486. }
  487. public function setSelfStudyTopic(?SelfStudyTopic $selfStudyTopic): void
  488. {
  489. $this->selfStudyTopic = $selfStudyTopic;
  490. }
  491. public function jsonSerialize(): mixed
  492. {
  493. return [
  494. "id" => $this->getId(),
  495. "duration" => $this->getDuration(),
  496. "tags" => $this->getTags()->toArray(),
  497. "status" => $this->getStatus(),
  498. "name" => $this->getName(),
  499. "deadline" => $this->getDeadline(),
  500. "classroom" => $this->getClassroom(),
  501. "startTime" => $this->getStartTime(),
  502. "assistance" => $this->getAssistance(),
  503. "groupSize" => $this->getGroupSize(),
  504. "pretest" => $this->getPretest(),
  505. "pretestDuration" => $this->getPretestDuration(),
  506. "startDifficulty" => $this->getStartDifficulty(),
  507. "students" => $this->getStudents()->toArray(),
  508. // "pretestResponses" => $this->getPretestResponses()->toArray(),
  509. "templateCount" => $this->getTemplateCount(),
  510. "topics" => $this->getTopics()->toArray(),
  511. "trainingUnits" => $this->getTrainingUnits()->toArray(),
  512. "usePretest" => $this->getUsePretest(),
  513. ];
  514. }
  515. }