ExamenConvocation.php 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432
  1. <?php
  2. namespace AppBundle\Entity\Booking;
  3. use AppBundle\Annotation\ExportSplitFields;
  4. use AppBundle\Entity\AccessAndFunction\Access;
  5. use AppBundle\Entity\Product\Equipment;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Dunglas\ApiBundle\Annotation\Iri;
  9. use Symfony\Component\Serializer\Annotation\Groups;
  10. use Symfony\Component\Validator\Constraints as Assert;
  11. use AppBundle\Entity\Traits\TimestampableEntity;
  12. use AppBundle\Entity\Traits\CreatorUpdaterEntity;
  13. use AppBundle\Entity\Person\Person;
  14. /**
  15. *
  16. * Convocation d'un Access (élève) à un Examen
  17. *
  18. * @Iri("http://schema.org/ExamenConvocation")
  19. */
  20. #[ORM\Entity]
  21. class ExamenConvocation
  22. {
  23. use TimestampableEntity;
  24. use CreatorUpdaterEntity;
  25. /**
  26. * @var int
  27. */
  28. #[ORM\Column(type: 'integer')]
  29. #[ORM\Id]
  30. #[ORM\GeneratedValue(strategy: 'AUTO')]
  31. #[Groups(['examenconvocation', 'examenconvocation_list', 'report_card', 'presence_attendance', 'examen_details', 'planning_detail', 'examen_informations_edit'])]
  32. private $id;
  33. /**
  34. * @var Examen
  35. */
  36. #[ORM\ManyToOne(targetEntity: 'Examen', inversedBy: 'convocation')]
  37. #[Groups(['examenconvocation', 'examenconvocation_list', 'report_card_examenconvocations'])]
  38. private $examen;
  39. /**
  40. * @var Access
  41. */
  42. #[ORM\ManyToOne(targetEntity: 'AppBundle\Entity\AccessAndFunction\Access', inversedBy: 'examenConvocations')]
  43. #[ORM\JoinColumn(nullable: false)]
  44. #[Assert\NotNull]
  45. #[Groups(['examenconvocation', 'examenconvocation_list', 'presence_attendance_convocation', 'examen_details_convocation', 'planning_detail_convocation', 'examenconvocation_list', 'examen_informations_edit_convocation', 'examenconvocation_list'])]
  46. private $student;
  47. /**
  48. * @var ArrayCollection<Equipment>
  49. */
  50. #[ORM\ManyToMany(targetEntity: 'AppBundle\Entity\Product\Equipment')]
  51. #[ORM\JoinTable(joinColumns: [], inverseJoinColumns: [])]
  52. #[ORM\JoinColumn(name: 'examenconvocation_id', referencedColumnName: 'id')]
  53. #[ORM\JoinColumn(name: 'equipment_id', referencedColumnName: 'id')]
  54. #[Groups(['examenconvocation_equipment', 'examenconvocation_list', 'examen_informations_edit_convocation'])]
  55. private $equipments;
  56. /**
  57. * @var string
  58. */
  59. #[ORM\Column(type: 'text', nullable: true)]
  60. #[Assert\Type(type: 'string')]
  61. #[Groups(['examenconvocation', 'examenconvocation_list', 'examen_informations_edit_convocation'])]
  62. private $info;
  63. /**
  64. * @var string
  65. */
  66. #[ORM\Column(type: 'string', length: 255, nullable: true)]
  67. #[Assert\Type(type: 'string')]
  68. #[Groups(['examenconvocation', 'examenconvocation_list', 'examen_informations_edit_convocation'])]
  69. private $level;
  70. /**
  71. * @var \DateTime
  72. */
  73. #[ORM\Column(type: 'time', nullable: true)]
  74. #[Assert\Time]
  75. #[Groups(['examenconvocation', 'examenconvocation_list', 'examen_details_convocation', 'examen_informations_edit_convocation'])]
  76. private $time;
  77. /**
  78. * @var float
  79. */
  80. #[ORM\Column(type: 'float', nullable: true)]
  81. #[Assert\Type(type: 'float')]
  82. #[Assert\GreaterThanOrEqual(value: 0)]
  83. #[Assert\LessThanOrEqual(value: 100, message: 'lessThanOrEqual20')]
  84. #[Groups(['examenconvocation', 'examenconvocation_list', 'report_card_examenconvocations', 'examen_informations_edit_convocation'])]
  85. private $note;
  86. /**
  87. * @var string
  88. */
  89. #[Groups(['examenconvocation', 'examenconvocation_list'])]
  90. private $noteTemplate;
  91. /**
  92. * @var string
  93. */
  94. #[ORM\Column(type: 'string', length: 255, nullable: true)]
  95. #[Assert\Type(type: 'string')]
  96. #[Groups(['examenconvocation', 'examenconvocation_list', 'report_card_examenconvocations', 'examen_informations_edit_convocation'])]
  97. private $mention;
  98. /**
  99. * @var string
  100. */
  101. #[ORM\Column(type: 'text', nullable: true)]
  102. #[Assert\Type(type: 'string')]
  103. #[Groups(['examenconvocation', 'examenconvocation_list', 'report_card_examenconvocations', 'examen_informations_edit_convocation'])]
  104. private $appreciation;
  105. /**
  106. * @var string
  107. */
  108. #[ORM\Column(type: 'string', length: 255)]
  109. #[Assert\Type(type: 'string')]
  110. #[Assert\NotNull]
  111. #[Assert\Choice(callback: ['\AppBundle\Enum\Booking\ExamenConvocationStatusEnum', 'toArray'])]
  112. #[Groups(['examenconvocation', 'examenconvocation_list', 'examen_informations_edit_convocation'])]
  113. private $status;
  114. /**
  115. * @var bool
  116. */
  117. #[ORM\Column(type: 'boolean', options: ['default' => false])]
  118. #[Assert\Type(type: 'boolean')]
  119. #[Assert\NotNull]
  120. #[Groups(['examenconvocation', 'examenconvocation_list', 'examen_informations_edit_convocation'])]
  121. private $isConvocated = false;
  122. /**
  123. * @var string
  124. */
  125. #[Groups(['examenconvocation_list', 'report_card_examenconvocations'])]
  126. private $cycleYearLevelStudentTemplate;
  127. public function __construct()
  128. {
  129. $this->equipments = new ArrayCollection();
  130. }
  131. /**
  132. * Sets id.
  133. *
  134. * @param int $id
  135. *
  136. * @return $this
  137. */
  138. public function setId($id)
  139. {
  140. $this->id = $id;
  141. return $this;
  142. }
  143. /**
  144. * Gets id.
  145. *
  146. * @return int
  147. */
  148. public function getId()
  149. {
  150. return $this->id;
  151. }
  152. /**
  153. * Sets examen.
  154. *
  155. * @param Examen $examen
  156. *
  157. * @return $this
  158. */
  159. public function setExamen(Examen $examen)
  160. {
  161. $this->examen = $examen;
  162. return $this;
  163. }
  164. /**
  165. * Gets examen.
  166. *
  167. * @return Examen
  168. */
  169. public function getExamen()
  170. {
  171. return $this->examen;
  172. }
  173. /**
  174. * Sets student.
  175. *
  176. * @param Access $student
  177. *
  178. * @return $this
  179. */
  180. public function setStudent(Access $student)
  181. {
  182. $this->student = $student;
  183. return $this;
  184. }
  185. /**
  186. * Gets student.
  187. *
  188. * @return Access
  189. */
  190. public function getStudent()
  191. {
  192. return $this->student;
  193. }
  194. /**
  195. * Sets info.
  196. *
  197. * @param string $info
  198. *
  199. * @return $this
  200. */
  201. public function setInfo($info)
  202. {
  203. $this->info = $info;
  204. return $this;
  205. }
  206. /**
  207. * Gets info.
  208. *
  209. * @return string
  210. */
  211. public function getInfo()
  212. {
  213. return $this->info;
  214. }
  215. /**
  216. * Sets level.
  217. *
  218. * @param string $level
  219. *
  220. * @return $this
  221. */
  222. public function setLevel($level)
  223. {
  224. $this->level = $level;
  225. return $this;
  226. }
  227. /**
  228. * Gets level.
  229. *
  230. * @return string
  231. */
  232. public function getLevel()
  233. {
  234. return $this->level;
  235. }
  236. /**
  237. * Sets time.
  238. *
  239. * @param \DateTime $time
  240. *
  241. * @return $this
  242. */
  243. public function setTime(\DateTime $time = null)
  244. {
  245. $this->time = $time;
  246. return $this;
  247. }
  248. /**
  249. * Gets time.
  250. *
  251. * @return \DateTime
  252. */
  253. public function getTime()
  254. {
  255. return $this->time ? $this->time->format('H:i') : $this->time;
  256. }
  257. /**
  258. * Sets note.
  259. *
  260. * @param float $note
  261. *
  262. * @return $this
  263. */
  264. public function setNote($note)
  265. {
  266. $this->note = (!is_null($note)) ? floatval($note) : $note;
  267. return $this;
  268. }
  269. /**
  270. * Gets note.
  271. *
  272. * @return float
  273. */
  274. public function getNote()
  275. {
  276. return $this->note;
  277. }
  278. /**
  279. * Sets mention.
  280. *
  281. * @param string $mention
  282. *
  283. * @return $this
  284. */
  285. public function setMention($mention)
  286. {
  287. $this->mention = $mention;
  288. return $this;
  289. }
  290. /**
  291. * Gets mention.
  292. *
  293. * @return string
  294. */
  295. public function getMention()
  296. {
  297. return $this->mention;
  298. }
  299. /**
  300. * Sets appreciation.
  301. *
  302. * @param string $appreciation
  303. *
  304. * @return $this
  305. */
  306. public function setAppreciation($appreciation)
  307. {
  308. $this->appreciation = $appreciation;
  309. return $this;
  310. }
  311. /**
  312. * Gets appreciation.
  313. *
  314. * @return string
  315. */
  316. public function getAppreciation()
  317. {
  318. return $this->appreciation;
  319. }
  320. /**
  321. * Sets status.
  322. *
  323. * @param string $status
  324. *
  325. * @return $this
  326. */
  327. public function setStatus($status)
  328. {
  329. $this->status = $status;
  330. return $this;
  331. }
  332. /**
  333. * Gets status.
  334. *
  335. * @return string
  336. */
  337. public function getStatus()
  338. {
  339. return $this->status;
  340. }
  341. /**
  342. * Add equipment
  343. *
  344. * @param \AppBundle\Entity\Product\Equipment $equipment
  345. *
  346. * @return ExamenConvocation
  347. */
  348. public function addEquipment(\AppBundle\Entity\Product\Equipment $equipment)
  349. {
  350. $this->equipments[] = $equipment;
  351. return $this;
  352. }
  353. /**
  354. * Remove equipment
  355. *
  356. * @param \AppBundle\Entity\Product\Equipment $equipment
  357. */
  358. public function removeEquipment(\AppBundle\Entity\Product\Equipment $equipment)
  359. {
  360. $this->equipments->removeElement($equipment);
  361. }
  362. /**
  363. * Get equipments
  364. *
  365. * @return \Doctrine\Common\Collections\Collection
  366. */
  367. public function getEquipments()
  368. {
  369. return $this->equipments;
  370. }
  371. /**
  372. * Sets isConvocated.
  373. *
  374. * @param bool $isConvocated
  375. *
  376. * @return $this
  377. */
  378. public function setIsConvocated($isConvocated)
  379. {
  380. $this->isConvocated = $isConvocated;
  381. return $this;
  382. }
  383. /**
  384. * Gets isConvocated.
  385. *
  386. * @return bool
  387. */
  388. public function getIsConvocated()
  389. {
  390. return $this->isConvocated;
  391. }
  392. /**
  393. * @return float
  394. */
  395. public function getNoteTemplate()
  396. {
  397. return (!is_null($this->getNote())) ? floatval($this->getNote() / 5) : $this->getNote();
  398. }
  399. /**
  400. * Gets full label.
  401. *
  402. * @return array
  403. */
  404. public function getCycleYearLevelStudentTemplate()
  405. {
  406. $cycleYearLevelStudent = '';
  407. foreach($this->getExamen()->getEducationCurriculum() as $educationCurriculum){
  408. foreach($this->getStudent()->getEducationStudent() as $educationStudent){
  409. if(!is_null($educationCurriculum) && !is_null($educationStudent->getEducationCurriculum()) && $educationCurriculum->getId() === $educationStudent->getEducationCurriculum()->getId()){
  410. $cycleYearLevelStudent = $educationCurriculum->getCycleYearLevelTemplate();
  411. break;
  412. }
  413. }
  414. }
  415. return $cycleYearLevelStudent;
  416. }
  417. }