src/Entity/Quiz.php line 16

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\QuizRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Gedmo\Mapping\Annotation as Gedmo;
  8. use JMS\Serializer\Annotation as Serializer;
  9. /**
  10. * @ORM\Entity(repositoryClass=QuizRepository::class)
  11. * @Serializer\ExclusionPolicy("ALL")
  12. */
  13. class Quiz extends BaseEntity
  14. {
  15. /**
  16. * @ORM\Id
  17. * @ORM\GeneratedValue
  18. * @ORM\Column(type="integer")
  19. * @Serializer\Expose
  20. */
  21. private $id;
  22. /**
  23. * @ORM\Column(type="string", length=255)
  24. * @Serializer\Expose
  25. */
  26. private $title;
  27. /**
  28. * @ORM\Column(type="text", nullable=true)
  29. * @Serializer\Expose
  30. */
  31. private $description;
  32. /**
  33. * @ORM\OneToOne(targetEntity=ImageManager::class, cascade={"persist", "remove"})
  34. * @Serializer\Expose
  35. */
  36. private $background;
  37. /**
  38. * @ORM\Column(type="string", length=255, nullable=true)
  39. */
  40. private $timeLimit = 'aucun';
  41. /**
  42. * @ORM\Column(type="datetime", nullable=true)
  43. * @Serializer\Expose
  44. */
  45. private $startAt;
  46. /**
  47. * @ORM\Column(type="datetime", nullable=true)
  48. * @Serializer\Expose
  49. */
  50. private $endAt;
  51. /**
  52. * @ORM\Column(type="boolean")
  53. * @Serializer\Expose
  54. */
  55. private $isDisplayCorrectAnswerAutomatically = false;
  56. /**
  57. * @ORM\Column(type="boolean")
  58. * @Serializer\Expose
  59. */
  60. private $isQuestionRandomDisplay = false;
  61. /**
  62. * @ORM\Column(type="boolean")
  63. * @Serializer\Expose
  64. */
  65. private $isNotifyParticipant = false;
  66. /**
  67. * @ORM\Column(type="boolean")
  68. * @Serializer\Expose
  69. */
  70. private $isReplayPossible = false;
  71. /**
  72. * @ORM\Column(type="string", length=255)
  73. */
  74. private $status = 'draft';
  75. /**
  76. * @ORM\OneToMany(targetEntity=QuizQuestion::class, mappedBy="quiz", cascade={"persist", "remove"}, fetch="EXTRA_LAZY")
  77. * @Serializer\Expose
  78. */
  79. private $quizQuestions;
  80. /**
  81. * @ORM\Column(type="time", nullable=true)
  82. * @Serializer\Expose
  83. */
  84. private $time;
  85. /**
  86. * @ORM\OneToMany(targetEntity=ModuleItem::class, mappedBy="quiz", cascade={"persist", "remove"}, fetch="EXTRA_LAZY")
  87. */
  88. private $moduleItems;
  89. /**
  90. * @ORM\OneToMany(targetEntity=ModuleParticipation::class, mappedBy="quiz", cascade={"persist", "remove"}, fetch="EXTRA_LAZY")
  91. */
  92. private $moduleParticipations;
  93. /**
  94. * @Gedmo\Slug(fields={"title"})
  95. * @ORM\Column(length=191)
  96. */
  97. private $slug;
  98. /**
  99. * @ORM\Column(type="decimal", precision=10, scale=0, nullable=true)
  100. */
  101. private $minValidationScore;
  102. /**
  103. * @ORM\OneToMany(targetEntity=QuizCertificate::class, mappedBy="quiz", cascade={"persist", "remove"}, fetch="EXTRA_LAZY")
  104. */
  105. private $certificates;
  106. /**
  107. * @ORM\Column(type="boolean", nullable=true)
  108. */
  109. private $isPublished = false;
  110. /**
  111. * @ORM\Column(type="text", nullable=true)
  112. */
  113. private $rejectReason;
  114. /**
  115. * @ORM\Column(type="string", length=255, nullable=true)
  116. */
  117. private $currentPlace;
  118. /**
  119. * @ORM\ManyToMany(targetEntity=Module::class, inversedBy="quiz")
  120. */
  121. private $modules;
  122. /**
  123. * @ORM\OneToMany(targetEntity=QuizView::class, mappedBy="quiz", orphanRemoval=true, fetch="EXTRA_LAZY")
  124. */
  125. private $quizViews;
  126. /**
  127. * @ORM\Column(type="string", length=1000000, nullable=true)
  128. */
  129. private $reviewReason;
  130. /**
  131. * @ORM\Column(type="boolean", nullable=true)
  132. */
  133. private $startingNotificationSent = false;
  134. /**
  135. * @ORM\Column(type="boolean", nullable=true)
  136. */
  137. private $endingNotificationSent;
  138. public function __construct()
  139. {
  140. $this->quizQuestions = new ArrayCollection();
  141. $this->moduleItems = new ArrayCollection();
  142. $this->moduleParticipations = new ArrayCollection();
  143. $this->certificates = new ArrayCollection();
  144. $this->modules = new ArrayCollection();
  145. $this->quizViews = new ArrayCollection();
  146. }
  147. public function getId(): ?int
  148. {
  149. return $this->id;
  150. }
  151. public function getTitle(): ?string
  152. {
  153. return $this->title;
  154. }
  155. public function setTitle(string $title): self
  156. {
  157. $this->title = $title;
  158. return $this;
  159. }
  160. public function getDescription(): ?string
  161. {
  162. return $this->description;
  163. }
  164. public function setDescription(?string $description): self
  165. {
  166. $this->description = $description;
  167. return $this;
  168. }
  169. public function getBackground(): ?ImageManager
  170. {
  171. return $this->background;
  172. }
  173. public function setBackground(?ImageManager $background): self
  174. {
  175. $this->background = $background;
  176. return $this;
  177. }
  178. public function getTimeLimit(): ?string
  179. {
  180. return $this->timeLimit;
  181. }
  182. public function setTimeLimit(?string $timeLimit): self
  183. {
  184. $this->timeLimit = $timeLimit;
  185. return $this;
  186. }
  187. public function getStartAt(): ?\DateTimeInterface
  188. {
  189. return $this->startAt;
  190. }
  191. public function setStartAt(?\DateTimeInterface $startAt): self
  192. {
  193. $this->startAt = $startAt;
  194. return $this;
  195. }
  196. public function getEndAt(): ?\DateTimeInterface
  197. {
  198. return $this->endAt;
  199. }
  200. public function setEndAt(?\DateTimeInterface $endAt): self
  201. {
  202. $this->endAt = $endAt;
  203. return $this;
  204. }
  205. public function isIsDisplayCorrectAnswerAutomatically(): ?bool
  206. {
  207. return $this->isDisplayCorrectAnswerAutomatically;
  208. }
  209. public function setIsDisplayCorrectAnswerAutomatically(bool $isDisplayCorrectAnswerAutomatically): self
  210. {
  211. $this->isDisplayCorrectAnswerAutomatically = $isDisplayCorrectAnswerAutomatically;
  212. return $this;
  213. }
  214. public function isIsQuestionRandomDisplay(): ?bool
  215. {
  216. return $this->isQuestionRandomDisplay;
  217. }
  218. public function setIsQuestionRandomDisplay(bool $isQuestionRandomDisplay): self
  219. {
  220. $this->isQuestionRandomDisplay = $isQuestionRandomDisplay;
  221. return $this;
  222. }
  223. public function isIsNotifyParticipant(): ?bool
  224. {
  225. return $this->isNotifyParticipant;
  226. }
  227. public function setIsNotifyParticipant(bool $isNotifyParticipant): self
  228. {
  229. $this->isNotifyParticipant = $isNotifyParticipant;
  230. return $this;
  231. }
  232. public function isIsReplayPossible(): ?bool
  233. {
  234. return $this->isReplayPossible;
  235. }
  236. public function setIsReplayPossible(bool $isReplayPossible): self
  237. {
  238. $this->isReplayPossible = $isReplayPossible;
  239. return $this;
  240. }
  241. public function getStatus(): ?string
  242. {
  243. return $this->status;
  244. }
  245. public function setStatus(string $status): self
  246. {
  247. $this->status = $status;
  248. return $this;
  249. }
  250. /**
  251. * @return Collection<int, QuizQuestion>
  252. */
  253. public function getQuizQuestions(): Collection
  254. {
  255. return $this->quizQuestions;
  256. }
  257. public function addQuizQuestion(QuizQuestion $quizQuestion): self
  258. {
  259. if (!$this->quizQuestions->contains($quizQuestion)) {
  260. $this->quizQuestions[] = $quizQuestion;
  261. $quizQuestion->setQuiz($this);
  262. }
  263. return $this;
  264. }
  265. public function removeQuizQuestion(QuizQuestion $quizQuestion): self
  266. {
  267. if ($this->quizQuestions->removeElement($quizQuestion)) {
  268. // set the owning side to null (unless already changed)
  269. if ($quizQuestion->getQuiz() === $this) {
  270. $quizQuestion->setQuiz(null);
  271. }
  272. }
  273. return $this;
  274. }
  275. public function getTime(): ?\DateTimeInterface
  276. {
  277. return $this->time;
  278. }
  279. public function setTime(?\DateTimeInterface $time): self
  280. {
  281. $this->time = $time;
  282. return $this;
  283. }
  284. /**
  285. * @return Collection<int, ModuleItem>
  286. */
  287. public function getModuleItems(): Collection
  288. {
  289. return $this->moduleItems;
  290. }
  291. public function addModuleItem(ModuleItem $moduleItem): self
  292. {
  293. if (!$this->moduleItems->contains($moduleItem)) {
  294. $this->moduleItems[] = $moduleItem;
  295. $moduleItem->setQuiz($this);
  296. }
  297. return $this;
  298. }
  299. public function removeModuleItem(ModuleItem $moduleItem): self
  300. {
  301. if ($this->moduleItems->removeElement($moduleItem)) {
  302. // set the owning side to null (unless already changed)
  303. if ($moduleItem->getQuiz() === $this) {
  304. $moduleItem->setQuiz(null);
  305. }
  306. }
  307. return $this;
  308. }
  309. /**
  310. * @return Collection<int, ModuleParticipation>
  311. */
  312. public function getModuleParticipations(): Collection
  313. {
  314. return $this->moduleParticipations;
  315. }
  316. public function addModuleParticipation(ModuleParticipation $moduleParticipation): self
  317. {
  318. if (!$this->moduleParticipations->contains($moduleParticipation)) {
  319. $this->moduleParticipations[] = $moduleParticipation;
  320. $moduleParticipation->setQuiz($this);
  321. }
  322. return $this;
  323. }
  324. public function removeModuleParticipation(ModuleParticipation $moduleParticipation): self
  325. {
  326. if ($this->moduleParticipations->removeElement($moduleParticipation)) {
  327. // set the owning side to null (unless already changed)
  328. if ($moduleParticipation->getQuiz() === $this) {
  329. $moduleParticipation->setQuiz(null);
  330. }
  331. }
  332. return $this;
  333. }
  334. /**
  335. * Get the value of slug
  336. */
  337. public function getSlug()
  338. {
  339. return $this->slug;
  340. }
  341. /**
  342. * Set the value of slug
  343. *
  344. * @return self
  345. */
  346. public function setSlug($slug)
  347. {
  348. $this->slug = $slug;
  349. return $this;
  350. }
  351. public function getMinValidationScore(): ?string
  352. {
  353. return $this->minValidationScore;
  354. }
  355. public function setMinValidationScore(?string $minValidationScore): self
  356. {
  357. $this->minValidationScore = $minValidationScore;
  358. return $this;
  359. }
  360. /**
  361. * @return Collection<int, QuizCertificate>
  362. */
  363. public function getCertificates(): Collection
  364. {
  365. return $this->certificates;
  366. }
  367. public function addCertificate(QuizCertificate $certificate): self
  368. {
  369. if (!$this->certificates->contains($certificate)) {
  370. $this->certificates[] = $certificate;
  371. $certificate->setQuiz($this);
  372. }
  373. return $this;
  374. }
  375. public function removeCertificate(QuizCertificate $certificate): self
  376. {
  377. if ($this->certificates->removeElement($certificate)) {
  378. // set the owning side to null (unless already changed)
  379. if ($certificate->getQuiz() === $this) {
  380. $certificate->setQuiz(null);
  381. }
  382. }
  383. return $this;
  384. }
  385. public function isIsPublished(): ?bool
  386. {
  387. return $this->isPublished;
  388. }
  389. public function setIsPublished(?bool $isPublished): self
  390. {
  391. $this->isPublished = $isPublished;
  392. return $this;
  393. }
  394. public function getRejectReason(): ?string
  395. {
  396. return $this->rejectReason;
  397. }
  398. public function setRejectReason(?string $rejectReason): self
  399. {
  400. $this->rejectReason = $rejectReason;
  401. return $this;
  402. }
  403. public function getCurrentPlace(): ?string
  404. {
  405. return $this->currentPlace;
  406. }
  407. public function setCurrentPlace(?string $currentPlace): self
  408. {
  409. $this->currentPlace = $currentPlace;
  410. return $this;
  411. }
  412. /**
  413. * @return Collection<int, Module>
  414. */
  415. public function getModules(): Collection
  416. {
  417. return $this->modules;
  418. }
  419. public function addModule(Module $module): self
  420. {
  421. if (!$this->modules->contains($module)) {
  422. $this->modules[] = $module;
  423. }
  424. return $this;
  425. }
  426. public function removeModule(Module $module): self
  427. {
  428. $this->modules->removeElement($module);
  429. return $this;
  430. }
  431. /**
  432. * @return Collection<int, QuizView>
  433. */
  434. public function getQuizViews(): Collection
  435. {
  436. return $this->quizViews;
  437. }
  438. public function addQuizView(QuizView $quizView): self
  439. {
  440. if (!$this->quizViews->contains($quizView)) {
  441. $this->quizViews[] = $quizView;
  442. $quizView->setQuiz($this);
  443. }
  444. return $this;
  445. }
  446. public function removeQuizView(QuizView $quizView): self
  447. {
  448. if ($this->quizViews->removeElement($quizView)) {
  449. // set the owning side to null (unless already changed)
  450. if ($quizView->getQuiz() === $this) {
  451. $quizView->setQuiz(null);
  452. }
  453. }
  454. return $this;
  455. }
  456. public function getReviewReason(): ?string
  457. {
  458. return $this->reviewReason;
  459. }
  460. public function setReviewReason(?string $reviewReason): self
  461. {
  462. $this->reviewReason = $reviewReason;
  463. return $this;
  464. }
  465. public function isStartingNotificationSent(): ?bool
  466. {
  467. return $this->startingNotificationSent;
  468. }
  469. public function setStartingNotificationSent(?bool $startingNotificationSent): self
  470. {
  471. $this->startingNotificationSent = $startingNotificationSent;
  472. return $this;
  473. }
  474. public function isEndingNotificationSent(): ?bool
  475. {
  476. return $this->endingNotificationSent;
  477. }
  478. public function setEndingNotificationSent(?bool $endingNotificationSent): self
  479. {
  480. $this->endingNotificationSent = $endingNotificationSent;
  481. return $this;
  482. }
  483. }