src/Entity/ChannelUserData/Cursus/AbstractCursus.php line 72

Open in your IDE?
  1. <?php
  2. namespace App\Entity\ChannelUserData\Cursus;
  3. use App\Entity\Account\User;
  4. use App\Entity\Channel\ChannelLicencesResourceInterface;
  5. use App\Entity\Channel\ChannelUserCursusPermission;
  6. use App\Entity\Channel\Organization;
  7. use App\Entity\Channel\Place;
  8. use App\Entity\Channel\Training;
  9. use App\Entity\ChannelUserData\Activity\ActivityFeed;
  10. use App\Entity\ChannelUserData\ChannelUserData;
  11. use App\Entity\Common\ImportableData\ImportableDataInterface;
  12. use App\Entity\Common\ImportableData\ImportableDataTrait;
  13. use App\Entity\Sync\SyncableInterface;
  14. use App\Enum\ChannelUserData\Activity\CursusActivityTagEnum;
  15. use App\Enum\ChannelUserData\CursusFoundingStatusEnum;
  16. use App\Enum\ChannelUserData\CursusInternshipStatus;
  17. use App\Enum\ChannelUserData\CursusStoppedStatusEnum;
  18. use App\Enum\ChannelUserData\ExamStatusEnum;
  19. use App\Repository\ChannelUserData\Cursus\AbstractCursusRepository;
  20. use App\Validator\Constraints as AppAssert;
  21. use App\Validator\Constraints\AbstractCursusConstraint;
  22. use App\Validator\Constraints\ChannelLicensesConstraint;
  23. use DateTimeInterface;
  24. use Doctrine\Common\Collections\ArrayCollection;
  25. use Doctrine\Common\Collections\Collection;
  26. use Doctrine\ORM\Mapping as ORM;
  27. use Drosalys\Bundle\ApiBundle\Serializer\Attributes\IdGroups;
  28. use Nellapp\Bundle\SDKBundle\Auth\Entity\UserInterface;
  29. use Nellapp\Bundle\SDKBundle\Channel\Entity\ChannelInterface;
  30. use Nellapp\Bundle\SDKBundle\Channel\Entity\Cursus\AbstractCursusInterface;
  31. use Nellapp\Bundle\SDKBundle\Channel\Entity\Cursus\AbstractCursusMethodTrait;
  32. use Nellapp\Bundle\SDKBundle\Enum\ChannelUserData\CursusCourseEnum;
  33. use Nellapp\Bundle\SDKBundle\Enum\ChannelUserData\CursusModalityEnum;
  34. use Nellapp\Bundle\SDKBundle\Enum\ChannelUserData\CursusSuspensionReasonEnum;
  35. use Nellapp\Bundle\SDKBundle\Permission\Entity\ChannelResourceInterface;
  36. use Nellapp\Bundle\SDKBundle\Permission\UserOwner\UserOwnerResourceInterface;
  37. use Nellapp\Bundle\SDKBundle\Permission\UsersResource\UsersResourceInterface;
  38. use Nellapp\Bundle\SDKBundle\Sync\EntityKeys;
  39. use Nellapp\Bundle\SDKBundle\TrackData\Attribute\TrackEntity;
  40. use Nellapp\Bundle\SDKBundle\TrackData\Attribute\TrackField;
  41. use Nellapp\Bundle\SDKBundle\Utils\NellappFormatService;
  42. use Symfony\Component\Serializer\Annotation as Serial;
  43. use Symfony\Component\Validator\Constraints as Assert;
  44. #[
  45. ORM\Entity(repositoryClass: AbstractCursusRepository::class),
  46. ORM\Table(name: 'channel_user_data_cursus'),
  47. ORM\InheritanceType('JOINED'),
  48. ORM\DiscriminatorColumn(name: 'type', type: 'string'),
  49. ORM\DiscriminatorMap(['session-type' => SessionCursus::class, 'training-type' => TrainingCursus::class]),
  50. AbstractCursusConstraint(message: 'abstract_cursus.abstract_cursus_constraint.message'),
  51. TrackEntity(
  52. fieldGroups: [
  53. 'progress' => [
  54. 'tags' => [CursusActivityTagEnum::PROGRESSION],
  55. ],
  56. 'internship' => [
  57. 'tags' => [CursusActivityTagEnum::INTERNSHIP],
  58. ],
  59. 'founding' => [
  60. 'tags' => [CursusActivityTagEnum::FOUNDING]
  61. ],
  62. 'exam' => [
  63. 'tags' => [CursusActivityTagEnum::EXAM],
  64. ]
  65. ]
  66. ),
  67. ChannelLicensesConstraint
  68. ]
  69. abstract class AbstractCursus implements AbstractCursusInterface, SyncableInterface, ChannelLicencesResourceInterface, ChannelResourceInterface, ImportableDataInterface, UserOwnerResourceInterface, UsersResourceInterface
  70. {
  71. use AbstractCursusMethodTrait;
  72. use ImportableDataTrait;
  73. #[ORM\Id, ORM\GeneratedValue, ORM\Column(type: 'integer')]
  74. #[Serial\Groups(['Sync', 'GlobalJSVariable'])]
  75. private ?int $id = null;
  76. #[ORM\ManyToOne(targetEntity: ChannelUserData::class, cascade: ['persist'], inversedBy: 'cursuses')]
  77. #[ORM\JoinColumn(nullable: false, onDelete: 'CASCADE')]
  78. #[IdGroups(['Sync'])]
  79. #[Assert\NotBlank]
  80. private ?ChannelUserData $channelUserData = null;
  81. #[
  82. ORM\ManyToOne(targetEntity: Training::class),
  83. ORM\JoinColumn(nullable: true, onDelete: 'SET NULL')
  84. ]
  85. #[IdGroups(['Sync'])]
  86. private ?Training $training = null;
  87. #[ORM\Column(type: 'datetime')]
  88. #[Serial\Groups(['Sync'])]
  89. #[Assert\NotBlank(groups: ['CursusProgress'])]
  90. #[TrackField(name: 'cursus.entity.startAt.label', fieldKey: 'progress', callable: 'format', callableParams: ['d/m/Y'])]
  91. private ?DateTimeInterface $startAt = null;
  92. #[ORM\Column(type: 'datetime')]
  93. #[Serial\Groups(['Sync'])]
  94. #[
  95. Assert\GreaterThanOrEqual(propertyPath: 'startAt', message: 'abstract_cursus.endAt.GreaterThan', groups: ['CursusProgress', 'Default']),
  96. AppAssert\DateWithinIntervalOf(reference: 'startAt', maxInterval: 'P5Y', message: 'abstract_cursus.endAt.MaxDate', groups: ['CursusProgress', 'Default']),
  97. Assert\NotBlank(groups: ['CursusProgress'])
  98. ]
  99. #[TrackField(name: 'cursus.entity.endAt.label', fieldKey: 'progress', callable: 'format', callableParams: ['d/m/Y'])]
  100. private ?DateTimeInterface $endAt = null;
  101. #[ORM\Column(type: 'integer', nullable: true)]
  102. #[
  103. Assert\Type(type: 'integer', groups: ['CursusProgress']),
  104. Assert\GreaterThanOrEqual(value: 1),
  105. Assert\LessThanOrEqual(value: 24)
  106. ]
  107. #[TrackField(name: 'cursus.entity.monthDuration.label', fieldKey: 'progress')]
  108. private ?int $monthDuration = null;
  109. #[ORM\OneToOne(inversedBy: 'cursus', targetEntity: AbstractCursusProgression::class, cascade: ['persist', 'remove'], orphanRemoval: true)]
  110. #[ORM\JoinColumn(nullable: true, onDelete: 'SET NULL')]
  111. private ?AbstractCursusProgression $cursusProgression = null;
  112. #[ORM\Column(type: 'integer', nullable: true)]
  113. #[TrackField(name: 'cursus.entity.physicalDuration.label', fieldKey: 'progress', callable: 'formatDuration', callableClass: NellappFormatService::class)]
  114. #[
  115. Assert\Type(type: 'integer'),
  116. Assert\GreaterThanOrEqual(value: 0)
  117. ]
  118. private ?int $physicalDuration = null;
  119. #[ORM\Column(type: 'integer', nullable: true)]
  120. #[TrackField(name: 'cursus.entity.distanceSyncDuration.label', fieldKey: 'progress', callable: 'formatDuration', callableClass: NellappFormatService::class)]
  121. #[
  122. Assert\Type(type: 'integer'),
  123. Assert\GreaterThanOrEqual(value: 0)
  124. ]
  125. private ?int $distanceSyncDuration = null;
  126. #[ORM\Column(type: 'integer', nullable: true)]
  127. #[TrackField(name: 'cursus.entity.distanceAsyncDuration.label', fieldKey: 'progress', callable: 'formatDuration', callableClass: NellappFormatService::class)]
  128. #[
  129. Assert\Type(type: 'integer'),
  130. Assert\GreaterThanOrEqual(value: 0)
  131. ]
  132. private ?int $distanceAsyncDuration = null;
  133. #[ORM\Column(type: 'integer', nullable: true)]
  134. #[TrackField(name: 'cursus.entity.examDuration.label', fieldKey: 'progress', callable: 'formatDuration', callableClass: NellappFormatService::class)]
  135. #[
  136. Assert\Type(type: 'integer'),
  137. Assert\GreaterThanOrEqual(value: 0)
  138. ]
  139. private ?int $examDuration = null;
  140. #[ORM\Column(type: 'integer', nullable: true)]
  141. #[TrackField(name: 'cursus.entity.internshipDuration.label', fieldKey: 'progress', callable: 'formatDuration', callableClass: NellappFormatService::class)]
  142. #[
  143. Assert\Type(type: 'integer'),
  144. Assert\GreaterThanOrEqual(value: 0)
  145. ]
  146. private ?int $internshipDuration = null;
  147. #[ORM\Column(type: 'integer', nullable: true)]
  148. #[TrackField(name: 'cursus.entity.cursusModality.label', fieldKey: 'progress', callable: 'getStatusKey', callableClass: CursusModalityEnum::class)]
  149. #[Assert\NotBlank(groups: ['CursusProgress'])]
  150. #[Serial\Groups(['Sync'])]
  151. private ?int $cursusModality = null;
  152. #[ORM\Column(type: 'integer', nullable: true)]
  153. #[TrackField(name: 'cursus.entity.cursusCourse.label', fieldKey: 'progress', callable: 'getStatusKey', callableClass: CursusCourseEnum::class)]
  154. #[Assert\NotBlank(groups: ['CursusProgress'])]
  155. #[Serial\Groups(['Sync'])]
  156. private ?int $cursusCourse = null;
  157. #[ORM\Column(type: 'integer', nullable: true)]
  158. #[TrackField(name: 'cursus.entity.foundingStatus.label', fieldKey: 'founding', callable: 'getStatusKey', callableClass: CursusFoundingStatusEnum::class)]
  159. #[Assert\Choice(
  160. callback: [CursusFoundingStatusEnum::class, 'getChoices'],
  161. groups: ['CursusFounding']
  162. )]
  163. /**
  164. * Historical naming: employment status, distinct from funding completeness.
  165. */
  166. private ?int $foundingStatus = null;
  167. #[ORM\ManyToOne(targetEntity: Organization::class)]
  168. #[ORM\JoinColumn(nullable: true, onDelete: "SET NULL")]
  169. private ?Organization $organization = null;
  170. #[ORM\OneToMany(mappedBy: 'cursus', targetEntity: Founder::class, cascade: ['remove'], orphanRemoval: true)]
  171. private Collection $founders;
  172. #[ORM\Column(type: 'integer', nullable: true)]
  173. #[
  174. Assert\NotBlank(groups: ['CursusInternship']),
  175. Assert\Type(type: 'integer', groups: ['CursusInternship'])
  176. ]
  177. #[TrackField(name: 'cursus.entity.internshipStatus.label', fieldKey: 'internship', callable: 'getStatusKey', callableClass: CursusInternshipStatus::class)]
  178. private ?int $internshipStatus = 0;
  179. #[ORM\OneToMany(mappedBy: 'cursus', targetEntity: Internship::class, cascade: ['remove', 'persist'], orphanRemoval: true)]
  180. private Collection $internships;
  181. #[ORM\Column(type: 'integer', nullable: true)]
  182. #[Serial\Groups(['Sync'])]
  183. #[TrackField(name: 'cursus.entity.stoppedStatus.label', fieldKey: 'progress', callable: 'getStatusKey', callableClass: CursusStoppedStatusEnum::class)]
  184. private ?int $stoppedStatus = null;
  185. #[ORM\Column(type: 'integer', nullable: true)]
  186. #[Assert\NotBlank(groups: ['CursusStatus'])]
  187. #[TrackField(name: 'cursus.entity.stoppedDetails.label', fieldKey: 'progress', callable: 'getStatusKey', callableClass: CursusStoppedStatusEnum::class)]
  188. private ?int $stoppedDetails = null;
  189. #[ORM\Column(type: 'datetime', nullable: true)]
  190. #[Serial\Groups(['Sync'])]
  191. #[
  192. Assert\NotBlank(message: 'abstract_cursus.stoppedAt.NotBlank', groups: ['CursusStatus']),
  193. Assert\GreaterThanOrEqual('-45 days', message: 'abstract_cursus.stoppedAt.GreaterThanOrEqual', groups: ['CursusStatus']),
  194. ]
  195. #[TrackField(name: 'cursus.entity.stoppedAt.label', fieldKey: 'progress', callable: 'format', callableParams: ['d/m/Y'])]
  196. private ?\DateTimeInterface $stoppedAt = null;
  197. #[ORM\Column(type: 'text', nullable: true)]
  198. #[
  199. Assert\Length(max: 500, groups: ['CursusStatus'])
  200. ]
  201. private ?string $stoppedInfos = null;
  202. #[ORM\Column(type: 'datetime', nullable: true)]
  203. #[Serial\Groups(['Sync'])]
  204. #[TrackField(name: 'cursus.entity.suspendedAt.label', fieldKey: 'progress', callable: 'format', callableParams: ['d/m/Y'])]
  205. private ?\DateTimeInterface $suspendedAt = null;
  206. #[ORM\Column(type: 'integer', nullable: true)]
  207. #[Serial\Groups(['Sync'])]
  208. #[TrackField(name: 'cursus.entity.suspendedFor.label', fieldKey: 'progress', callable: 'getStatusKey', callableClass: CursusSuspensionReasonEnum::class)]
  209. private ?int $suspendedFor = null;
  210. #[ORM\ManyToOne(targetEntity: Place::class)]
  211. #[ORM\JoinColumn(nullable: true, onDelete: 'SET NULL')]
  212. #[TrackField(name: 'cursus.entity.examPlace.label', fieldKey: 'exam')]
  213. private ?Place $examPlace = null;
  214. #[ORM\Column(type: 'datetime', nullable: true)]
  215. #[TrackField(
  216. name: 'cursus.entity.examSession.label',
  217. fieldKey: 'exam',
  218. callable: 'format',
  219. callableParams: ['m/Y'])
  220. ]
  221. #[Assert\NotBlank(groups: ['CursusExam'])]
  222. private ?DateTimeInterface $examSession = null;
  223. #[ORM\Column(type: 'string', nullable: true)]
  224. #[TrackField(name: 'cursus.entity.examCeres.label', fieldKey: 'exam')]
  225. #[
  226. Assert\Length(max: 255, groups: ['CursusExam'])
  227. ]
  228. private ?string $examCeres = null;
  229. #[ORM\Column(type: 'integer', nullable: true)]
  230. #[TrackField(name: 'cursus.entity.examStatus.label', fieldKey: 'exam', callable: 'getStatusKey', callableClass: ExamStatusEnum::class)]
  231. #[Assert\Choice(
  232. callback: [ExamStatusEnum::class, 'getChoices'],
  233. groups: ['CursusExam']
  234. )]
  235. private ?int $examStatus = null;
  236. #[ORM\Column(type: 'string', nullable: true)]
  237. #[TrackField(name: 'cursus.entity.examCCP.label', fieldKey: 'exam')]
  238. #[
  239. Assert\Length(max: 255, groups: ['CursusExam'])
  240. ]
  241. private ?string $examCCP = null;
  242. #[ORM\OneToMany(mappedBy: 'cursus', targetEntity: Exam::class, cascade: ['remove'], orphanRemoval: true)]
  243. private Collection $exams;
  244. #[ORM\ManyToOne(targetEntity: Place::class)]
  245. #[ORM\JoinColumn(nullable: true, onDelete: 'SET NULL')]
  246. #[TrackField(name: 'cursus.entity.place.label', fieldKey: 'progress')]
  247. #[IdGroups(['Sync'])]
  248. private ?Place $place = null;
  249. #[ORM\OneToMany(mappedBy: 'cursus', targetEntity: ReportDetails::class, cascade: ['remove'], fetch: 'EXTRA_LAZY', orphanRemoval: true)]
  250. private Collection $reportDetailsList;
  251. #[ORM\OneToOne(targetEntity: ActivityFeed::class, cascade: ['remove', 'persist'], orphanRemoval: true)]
  252. #[ORM\JoinColumn(nullable: false)]
  253. private ?ActivityFeed $activityFeed = null;
  254. public function __construct()
  255. {
  256. $this->founders = new ArrayCollection();
  257. $this->internships = new ArrayCollection();
  258. $this->exams = new ArrayCollection();
  259. $this->reportDetailsList = new ArrayCollection();
  260. }
  261. public static function getSyncKey(): string
  262. {
  263. return EntityKeys::ABSTRACT_CURSUS;
  264. }
  265. public function getSyncDisplayLabel(): string
  266. {
  267. return $this->getLabel() ?? 'unknown';
  268. }
  269. abstract public function getLabelType(): string;
  270. public static function getPermissionResourceClass(): ?string
  271. {
  272. return ChannelUserCursusPermission::class;
  273. }
  274. public function getUserOwners(): array
  275. {
  276. $learner = $this->getChannelUserData()?->getUser();
  277. return $learner ? [$learner] : [];
  278. }
  279. #[Serial\Groups(['GlobalJSVariable'])]
  280. public function getLearnerName(): ?string
  281. {
  282. return $this->getChannelUserData()?->getUser();
  283. }
  284. public function __toString(): string
  285. {
  286. return 'cursus ' . $this->getLabel() . ' pour ' . $this->getChannelUserData()?->getUser();
  287. }
  288. public function isTrainingType(): bool
  289. {
  290. return $this instanceof TrainingCursus;
  291. }
  292. public function isSessionType(): bool
  293. {
  294. return $this instanceof SessionCursus;
  295. }
  296. public function getChannel(): ?ChannelInterface
  297. {
  298. return $this->getChannelUserData()?->getChannel();
  299. }
  300. public function getOwnerChannel(): ?ChannelInterface
  301. {
  302. return $this->getChannel();
  303. }
  304. public function hasOneOralExam(): bool
  305. {
  306. if (!$this->getExams()->isEmpty()) {
  307. /** @var Exam $exam */
  308. foreach ($this->getExams() as $exam) {
  309. if ($exam->getType() === $exam::ORAL_TYPE) {
  310. return true;
  311. }
  312. }
  313. }
  314. return false;
  315. }
  316. public function hasUser(?UserInterface $user, array $tags = []): bool
  317. {
  318. if (!in_array('internship_tutor', $tags)) {
  319. return false;
  320. }
  321. if (!$user instanceof User) {
  322. return false;
  323. }
  324. return $this->getInternships()->exists(function ($k, Internship $internship) use ($user): bool {
  325. return $internship->getTutor()?->getUser() === $user && $internship->isActiveWithDelays();
  326. });
  327. }
  328. public function getLabel(): ?string
  329. {
  330. return $this->training?->getName();
  331. }
  332. public function getTotalDuration(): ?int
  333. {
  334. return $this->getPhysicalDurationDisplayed()
  335. + $this->getDistanceAsyncDurationDisplayed()
  336. + $this->getDistanceSyncDurationDisplayed()
  337. + $this->getInternshipDurationDisplayed()
  338. + $this->getExamDurationDisplayed();
  339. }
  340. public function getPhysicalDuration(): ?int
  341. {
  342. return $this->physicalDuration;
  343. }
  344. public function setPhysicalDuration(?int $physicalDuration): self
  345. {
  346. $this->physicalDuration = $physicalDuration;
  347. return $this;
  348. }
  349. public function getDistanceSyncDuration(): ?int
  350. {
  351. return $this->distanceSyncDuration;
  352. }
  353. public function setDistanceSyncDuration(?int $distanceSyncDuration): self
  354. {
  355. $this->distanceSyncDuration = $distanceSyncDuration;
  356. return $this;
  357. }
  358. public function getDistanceAsyncDuration(): ?int
  359. {
  360. return $this->distanceAsyncDuration;
  361. }
  362. public function setDistanceAsyncDuration(?int $distanceAsyncDuration): self
  363. {
  364. $this->distanceAsyncDuration = $distanceAsyncDuration;
  365. return $this;
  366. }
  367. public function getExamDuration(): ?int
  368. {
  369. return $this->examDuration;
  370. }
  371. public function setExamDuration(?int $examDuration): AbstractCursus
  372. {
  373. $this->examDuration = $examDuration;
  374. return $this;
  375. }
  376. public function getInternshipDuration(): ?int
  377. {
  378. return $this->internshipDuration;
  379. }
  380. public function setInternshipDuration(?int $internshipDuration): AbstractCursus
  381. {
  382. $this->internshipDuration = $internshipDuration;
  383. return $this;
  384. }
  385. public function getFoundingStatus(): ?int
  386. {
  387. return $this->foundingStatus;
  388. }
  389. public function setFoundingStatus(?int $foundingStatus): AbstractCursus
  390. {
  391. $this->foundingStatus = $foundingStatus;
  392. return $this;
  393. }
  394. public function getFounders(): Collection
  395. {
  396. return $this->founders;
  397. }
  398. public function addFounder(Founder $founder): static
  399. {
  400. if (!$this->founders->contains($founder)) {
  401. $this->founders->add($founder);
  402. }
  403. return $this;
  404. }
  405. public function setFounders(Collection $founders): AbstractCursus
  406. {
  407. $this->founders = $founders;
  408. return $this;
  409. }
  410. /**
  411. * @return Collection<Internship>
  412. */
  413. public function getInternships(): Collection
  414. {
  415. return $this->internships;
  416. }
  417. public function addInternship(Internship $internship): static
  418. {
  419. if (!$this->internships->contains($internship)) {
  420. $this->internships->add($internship);
  421. }
  422. return $this;
  423. }
  424. public function setInternships(Collection $internships): AbstractCursus
  425. {
  426. $this->internships = $internships;
  427. return $this;
  428. }
  429. public function getInternshipStatus(): ?int
  430. {
  431. return $this->internshipStatus;
  432. }
  433. public function setInternshipStatus(?int $internshipStatus): AbstractCursus
  434. {
  435. $this->internshipStatus = $internshipStatus;
  436. return $this;
  437. }
  438. public function getMonthDuration(): ?int
  439. {
  440. return $this->monthDuration;
  441. }
  442. public function setMonthDuration(?int $monthDuration): AbstractCursus
  443. {
  444. $this->monthDuration = $monthDuration;
  445. return $this;
  446. }
  447. public function getCursusProgression(): ?AbstractCursusProgression
  448. {
  449. return $this->cursusProgression;
  450. }
  451. public function setCursusProgression(?AbstractCursusProgression $cursusProgression): AbstractCursus
  452. {
  453. $this->cursusProgression = $cursusProgression;
  454. return $this;
  455. }
  456. public function getExamPlace(): ?Place
  457. {
  458. return $this->examPlace;
  459. }
  460. public function setExamPlace(?Place $examPlace): AbstractCursus
  461. {
  462. $this->examPlace = $examPlace;
  463. return $this;
  464. }
  465. public function getExamSession(): ?DateTimeInterface
  466. {
  467. return $this->examSession;
  468. }
  469. public function setExamSession(?DateTimeInterface $examSession): AbstractCursus
  470. {
  471. $this->examSession = $examSession;
  472. return $this;
  473. }
  474. public function getExamCeres(): ?string
  475. {
  476. return $this->examCeres;
  477. }
  478. public function setExamCeres(?string $examCeres): AbstractCursus
  479. {
  480. $this->examCeres = $examCeres;
  481. return $this;
  482. }
  483. public function getExamStatus(): ?int
  484. {
  485. return $this->examStatus;
  486. }
  487. public function setExamStatus(?int $examStatus): AbstractCursus
  488. {
  489. $this->examStatus = $examStatus;
  490. return $this;
  491. }
  492. public function getExamCCP(): ?string
  493. {
  494. return $this->examCCP;
  495. }
  496. public function setExamCCP(?string $examCCP): AbstractCursus
  497. {
  498. $this->examCCP = $examCCP;
  499. return $this;
  500. }
  501. public function getExams(): Collection
  502. {
  503. return $this->exams;
  504. }
  505. public function addExam(Exam $exam): AbstractCursus
  506. {
  507. if (!$this->getExams()->contains($exam)) {
  508. $this->getExams()->add($exam);
  509. }
  510. return $this;
  511. }
  512. public function setExams(Collection $exams): AbstractCursus
  513. {
  514. $this->exams = $exams;
  515. return $this;
  516. }
  517. public function getStoppedInfos(): ?string
  518. {
  519. return $this->stoppedInfos;
  520. }
  521. public function setStoppedInfos(?string $stoppedInfos): AbstractCursus
  522. {
  523. $this->stoppedInfos = $stoppedInfos;
  524. return $this;
  525. }
  526. public function getStoppedDetails(): ?int
  527. {
  528. return $this->stoppedDetails;
  529. }
  530. public function setStoppedDetails(?int $stoppedDetails): AbstractCursus
  531. {
  532. $this->stoppedDetails = $stoppedDetails;
  533. return $this;
  534. }
  535. public function getPlace(): ?Place
  536. {
  537. return $this->place;
  538. }
  539. public function setPlace(?Place $place): static
  540. {
  541. $this->place = $place;
  542. return $this;
  543. }
  544. public function getPhysicalDurationDisplayed(): ?int
  545. {
  546. if ($this->getPhysicalDuration() !== null && $this->getPhysicalDuration() !== 0) {
  547. return $this->getPhysicalDuration();
  548. }
  549. if ($this instanceof SessionCursus) {
  550. return $this->getSession()?->getDurationInCenter();
  551. }
  552. return null;
  553. }
  554. public function getDistanceAsyncDurationDisplayed(): ?int
  555. {
  556. if ($this->getDistanceAsyncDuration() !== null && $this->getDistanceAsyncDuration() !== 0) {
  557. return $this->getDistanceAsyncDuration();
  558. }
  559. if ($this instanceof SessionCursus) {
  560. return $this->getSession()?->getDurationInELearning();
  561. }
  562. return null;
  563. }
  564. public function getDistanceSyncDurationDisplayed(): ?int
  565. {
  566. if ($this->getDistanceSyncDuration() !== null && $this->getDistanceSyncDuration() !== 0) {
  567. return $this->getDistanceSyncDuration();
  568. }
  569. if ($this instanceof SessionCursus) {
  570. return $this->getSession()?->getDurationInVisio();
  571. }
  572. return null;
  573. }
  574. public function getInternshipDurationDisplayed(): ?int
  575. {
  576. if ($this->getInternshipDuration() !== null && $this->getInternshipDuration() !== 0) {
  577. return $this->getInternshipDuration();
  578. }
  579. if ($this instanceof SessionCursus) {
  580. return $this->getSession()?->getDurationInCompany();
  581. }
  582. if (!$this->getInternships()->isEmpty()) {
  583. $internshipDuration = 0;
  584. /** @var Internship $internship */
  585. foreach ($this->getInternships() as $internship) {
  586. if ($internship->getDuration() !== null) {
  587. $internshipDuration += $internship->getDuration();
  588. }
  589. }
  590. return $internshipDuration;
  591. }
  592. return null;
  593. }
  594. public function getInternshipDurationForProgress(): ?int
  595. {
  596. if ($this->getInternshipDuration() !== null && $this->getInternshipDuration() !== 0) {
  597. return $this->getInternshipDuration();
  598. }
  599. if (!$this->getInternships()->isEmpty()) {
  600. $internshipDuration = 0;
  601. /** @var Internship $internship */
  602. foreach ($this->getInternships() as $internship) {
  603. if ($internship->getDuration() !== null) {
  604. $internshipDuration += $internship->getDuration();
  605. }
  606. }
  607. return $internshipDuration;
  608. }
  609. return null;
  610. }
  611. public function getExamDurationDisplayed(): ?int
  612. {
  613. if ($this->getExamDuration() !== null && $this->getExamDuration() !== 0) {
  614. return $this->getExamDuration();
  615. }
  616. if ($this instanceof SessionCursus) {
  617. return $this->getSession()?->getDurationInExam();
  618. }
  619. return null;
  620. }
  621. public function getOrganization(): ?Organization
  622. {
  623. return $this->organization;
  624. }
  625. public function setOrganization(?Organization $organization): AbstractCursus
  626. {
  627. $this->organization = $organization;
  628. return $this;
  629. }
  630. public function getReportDetailsList(): Collection
  631. {
  632. return $this->reportDetailsList ?? $this->reportDetailsList = new ArrayCollection();
  633. }
  634. public function setReportDetailsList(Collection $reportDetailsList): AbstractCursus
  635. {
  636. $this->reportDetailsList = $reportDetailsList;
  637. return $this;
  638. }
  639. public function getActivityFeed(): ?ActivityFeed
  640. {
  641. return $this->activityFeed;
  642. }
  643. public function setActivityFeed(?ActivityFeed $activityFeed): AbstractCursus
  644. {
  645. $this->activityFeed = $activityFeed;
  646. return $this;
  647. }
  648. }