src/CoreBundle/Entity/DictateUnit.php line 12

Open in your IDE?
  1. <?php
  2. namespace CoreBundle\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use UserBundle\Entity\User;
  5. /**
  6. * @ORM\Table("dictate_unit")
  7. * @ORM\Entity(repositoryClass="CoreBundle\Entity\DictateUnitRepository")
  8. */
  9. class DictateUnit
  10. {
  11. /**
  12. * @var int
  13. *
  14. * @ORM\Column(name="id", type="integer")
  15. * @ORM\Id
  16. * @ORM\GeneratedValue(strategy="AUTO")
  17. */
  18. private $id;
  19. /**
  20. * @var DictateSession
  21. *
  22. * @ORM\ManyToOne(targetEntity="CoreBundle\Entity\DictateSession", inversedBy="dictateUnits")
  23. * @ORM\JoinColumn(name="dictate_session", referencedColumnName="id", onDelete="CASCADE")
  24. */
  25. private $dictateSession;
  26. /**
  27. * @var User
  28. *
  29. * @ORM\ManyToOne(targetEntity="UserBundle\Entity\User")
  30. * @ORM\JoinColumn(name="student", referencedColumnName="id")
  31. */
  32. private $student;
  33. /**
  34. * @var \DateTime
  35. * @ORM\Column(name="deadline", type="datetime", nullable=true)
  36. */
  37. private $deadline;
  38. /**
  39. * @var bool
  40. * @ORM\Column(name="finished", type="boolean", options={"default" : false})
  41. */
  42. private $finished;
  43. /**
  44. * @var DictateResponse[]
  45. *
  46. * @ORM\OneToMany(targetEntity="CoreBundle\Entity\DictateResponse", mappedBy="dictateUnit", cascade={"persist"})
  47. */
  48. private $dictateResponses;
  49. /**
  50. * @var \DateTime
  51. *
  52. * @ORM\Column(name="extended_deadline", type="datetime", nullable=true)
  53. */
  54. private $extendedDeadline;
  55. /**
  56. * @return int
  57. */
  58. public function getId(): int
  59. {
  60. return $this->id;
  61. }
  62. /**
  63. * @param int $id
  64. */
  65. public function setId(int $id): void
  66. {
  67. $this->id = $id;
  68. }
  69. /**
  70. * @return DictateSession
  71. */
  72. public function getDictateSession(): DictateSession
  73. {
  74. return $this->dictateSession;
  75. }
  76. /**
  77. * @param DictateSession $dictateSession
  78. */
  79. public function setDictateSession(DictateSession $dictateSession): void
  80. {
  81. $this->dictateSession = $dictateSession;
  82. }
  83. /**
  84. * @return User
  85. */
  86. public function getStudent(): User
  87. {
  88. return $this->student;
  89. }
  90. /**
  91. * @param User $student
  92. */
  93. public function setStudent(User $student): void
  94. {
  95. $this->student = $student;
  96. }
  97. /**
  98. * @return \DateTime
  99. */
  100. public function getDeadline(): ?\DateTime
  101. {
  102. return $this->deadline;
  103. }
  104. /**
  105. * @param \DateTime $deadline
  106. */
  107. public function setDeadline(?\DateTime $deadline): void
  108. {
  109. $this->deadline = $deadline;
  110. }
  111. /**
  112. * @return bool
  113. */
  114. public function isFinished(): bool
  115. {
  116. return $this->finished;
  117. }
  118. /**
  119. * @param bool $finished
  120. */
  121. public function setFinished(bool $finished): void
  122. {
  123. $this->finished = $finished;
  124. }
  125. /**
  126. * @return array
  127. */
  128. public function getValidDictateResponses()
  129. {
  130. $quizResponses = [];
  131. foreach ($this->dictateResponses as $response) {
  132. $quizResponses[] = $response;
  133. }
  134. // sort by position
  135. // usort($quizResponses, function (QuizResponse $first, QuizResponse $second) {
  136. // return $first->getPosition() > $second->getPosition();
  137. // });
  138. return $quizResponses;
  139. }
  140. public function getExtendedDeadline(): ?\DateTime
  141. {
  142. return $this->extendedDeadline;
  143. }
  144. public function setExtendedDeadline(\DateTime $extendedDeadline): void
  145. {
  146. $this->extendedDeadline = $extendedDeadline;
  147. }
  148. }