src/CoreBundle/Entity/ReadingTest.php line 14

Open in your IDE?
  1. <?php
  2. namespace CoreBundle\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. /**
  7. * @ORM\Table("reading_test")
  8. * @ORM\Entity(repositoryClass="CoreBundle\Entity\ReadingTestRepository")
  9. */
  10. class ReadingTest
  11. {
  12. /**
  13. * @var int
  14. *
  15. * @ORM\Column(name="id", type="integer")
  16. * @ORM\Id
  17. * @ORM\GeneratedValue(strategy="AUTO")
  18. */
  19. private $id;
  20. /**
  21. * @var string
  22. *
  23. * @ORM\Column(name="title", type="string", length=255, nullable=true)
  24. */
  25. private $title;
  26. /**
  27. * @var string
  28. *
  29. * @ORM\Column(name="text", type="text", length=65000, nullable=false)
  30. */
  31. private $text;
  32. /**
  33. * @var ClassroomType
  34. *
  35. * @ORM\ManyToOne(targetEntity="CoreBundle\Entity\ClassroomType")
  36. * @ORM\JoinColumn(name="classroom_type", referencedColumnName="id")
  37. */
  38. private $classroomType;
  39. /**
  40. * @ORM\ManyToMany(targetEntity="Mathproblem")
  41. * @ORM\JoinTable(name="reading_test_mathproblem",
  42. * joinColumns={@ORM\JoinColumn(name="reading_test_id")},
  43. * inverseJoinColumns={@ORM\JoinColumn(name="mathproblem_id")})
  44. */
  45. private Collection $mathproblems;
  46. /**
  47. * @var array
  48. *
  49. * @ORM\Column(name="problem_order", type="simple_array", nullable=true)
  50. */
  51. private $problemOrder;
  52. /**
  53. * @var array
  54. *
  55. * @ORM\Column(name="color_wrong_count_threshold", type="simple_array", nullable=true)
  56. */
  57. private $colorWrongCountThreshold;
  58. /**
  59. * @var array
  60. *
  61. * @ORM\Column(name="color_wrong_word_per_minute_threshold", type="simple_array", nullable=true)
  62. */
  63. private $colorWrongWordPerMinuteThreshold;
  64. public function __construct()
  65. {
  66. $this->mathproblems = new ArrayCollection();
  67. }
  68. /**
  69. * @return int
  70. */
  71. public function getId(): int
  72. {
  73. return $this->id;
  74. }
  75. /**
  76. * @param int $id
  77. */
  78. public function setId(int $id): void
  79. {
  80. $this->id = $id;
  81. }
  82. /**
  83. * @return string
  84. */
  85. public function getTitle(): string
  86. {
  87. return $this->title;
  88. }
  89. /**
  90. * @param string $title
  91. */
  92. public function setTitle(string $title): void
  93. {
  94. $this->title = $title;
  95. }
  96. /**
  97. * @return string
  98. */
  99. public function getText(): string
  100. {
  101. return $this->text;
  102. }
  103. /**
  104. * @param string $text
  105. */
  106. public function setText(string $text): void
  107. {
  108. $this->text = $text;
  109. }
  110. /**
  111. * @return ClassroomType
  112. */
  113. public function getClassroomType()
  114. {
  115. return $this->classroomType;
  116. }
  117. /**
  118. * @param ClassroomType $classroomType
  119. */
  120. public function setClassroomType(ClassroomType $classroomType): void
  121. {
  122. $this->classroomType = $classroomType;
  123. }
  124. /**
  125. * @return ArrayCollection|Mathproblem[]
  126. */
  127. public function getMathproblems(): Collection
  128. {
  129. return $this->mathproblems;
  130. }
  131. /**
  132. * @param Mathproblem[]
  133. * @return ReadingTest
  134. */
  135. public function setMathproblems(array $mathproblems): self
  136. {
  137. $this->mathproblems = new ArrayCollection($mathproblems);
  138. return $this;
  139. }
  140. /**
  141. * @return array|null
  142. */
  143. public function getProblemOrder(): ?array
  144. {
  145. return $this->problemOrder;
  146. }
  147. /**
  148. * @param array $problemOrder
  149. */
  150. public function setProblemOrder(array $problemOrder)
  151. {
  152. $this->problemOrder = $problemOrder;
  153. }
  154. /**
  155. * @return array|null
  156. */
  157. public function getColorWrongCountThreshold(): ?array
  158. {
  159. return $this->colorWrongCountThreshold;
  160. }
  161. /**
  162. * @param array|null $colorWrongCountThreshold
  163. * @return $this
  164. */
  165. public function setColorWrongCountThreshold(?array $colorWrongCountThreshold): self
  166. {
  167. $this->colorWrongCountThreshold = $colorWrongCountThreshold;
  168. return $this;
  169. }
  170. /**
  171. * @return array|null
  172. */
  173. public function getColorWrongWordPerMinuteThreshold(): ?array
  174. {
  175. return $this->colorWrongWordPerMinuteThreshold;
  176. }
  177. /**
  178. * @param array|null $colorWrongWordPerMinuteThreshold
  179. * @return $this
  180. */
  181. public function setColorWrongWordPerMinuteThreshold(?array $colorWrongWordPerMinuteThreshold): self
  182. {
  183. $this->colorWrongWordPerMinuteThreshold = $colorWrongWordPerMinuteThreshold;
  184. return $this;
  185. }
  186. /**
  187. * @return array
  188. */
  189. public function getSortedMathproblems()
  190. {
  191. $problemOrder = $this->problemOrder;
  192. $mathproblems = $this->mathproblems;
  193. if ($problemOrder && count($problemOrder) == count($mathproblems)) {
  194. $newmathproblems = [];
  195. foreach ($mathproblems as $mp) {
  196. $newkey = array_search($mp->getId(), $problemOrder);
  197. $newmathproblems[$newkey] = $mp;
  198. }
  199. ksort($newmathproblems);
  200. return $newmathproblems;
  201. } else {
  202. return $this->mathproblems->toArray();
  203. }
  204. }
  205. }