src/CoreBundle/Entity/StudentDifficulty.php line 13

Open in your IDE?
  1. <?php
  2. namespace CoreBundle\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use FOS\UserBundle\Model\UserInterface;
  5. use UserBundle\Entity\User;
  6. /**
  7. * @ORM\Table("student_difficulty")
  8. * @ORM\Entity(repositoryClass="StudentDifficultyRepository")
  9. */
  10. class StudentDifficulty
  11. {
  12. const DEFAULT_DIFFICULTY = 1;
  13. /**
  14. * @ORM\Column(name="id", type="integer")
  15. * @ORM\Id
  16. * @ORM\GeneratedValue(strategy="AUTO")
  17. */
  18. private $id;
  19. /**
  20. * @ORM\ManyToOne(targetEntity="UserBundle\Entity\User")
  21. * @ORM\JoinColumn(name="user_id", referencedColumnName="id")
  22. */
  23. private $user;
  24. /**
  25. * @ORM\ManyToOne(targetEntity="Topic")
  26. * @ORM\JoinColumn(name="topic_id", referencedColumnName="id")
  27. */
  28. private $topic;
  29. /**
  30. * @ORM\Column(name="resp_array", type="array", nullable=true)
  31. */
  32. private $respArray = [0, 0, 0, 0];
  33. /**
  34. * @ORM\Column(name="difficulty", type="integer")
  35. */
  36. private $difficulty = self::DEFAULT_DIFFICULTY;
  37. /**
  38. * @ORM\Column(name="repetition_flag", type="boolean", nullable=true)
  39. */
  40. private $repetitionFlag;
  41. public function __construct(User $user, Topic $topic)
  42. {
  43. $this->user = $user;
  44. $this->topic = $topic;
  45. }
  46. public function getId()
  47. {
  48. return $this->id;
  49. }
  50. public function setUser(UserInterface $user)
  51. {
  52. $this->user = $user;
  53. }
  54. public function getUser()
  55. {
  56. return $this->user;
  57. }
  58. public function setTopic(Topic $topic)
  59. {
  60. $this->topic = $topic;
  61. return $this;
  62. }
  63. public function getTopic()
  64. {
  65. return $this->topic;
  66. }
  67. /**
  68. * @param int $difficulty
  69. * @return $this
  70. */
  71. public function setDifficulty(int $difficulty)
  72. {
  73. $this->difficulty = $difficulty;
  74. return $this;
  75. }
  76. public function getDifficulty()
  77. {
  78. return $this->difficulty;
  79. }
  80. /**
  81. * @return mixed
  82. */
  83. public function getRespArray()
  84. {
  85. return $this->respArray;
  86. }
  87. /**
  88. * @param $value
  89. * @return $this
  90. */
  91. public function addResponse(int $value)
  92. {
  93. $responseArray = $this->getRespArray();
  94. array_unshift($responseArray, $value);
  95. $this->respArray = array_slice($responseArray, 0, 4);
  96. return $this;
  97. }
  98. /**
  99. * @param mixed $respArray
  100. * @return $this
  101. */
  102. public function setRespArray(array $respArray)
  103. {
  104. $this->respArray = array_slice($respArray, 0, 4);
  105. return $this;
  106. }
  107. /**
  108. * @return bool|null
  109. */
  110. public function getRepetitionFlag(): ?bool
  111. {
  112. return $this->repetitionFlag;
  113. }
  114. /**
  115. * @param mixed $repetitionFlag
  116. */
  117. public function setRepetitionFlag($repetitionFlag)
  118. {
  119. $this->repetitionFlag = $repetitionFlag;
  120. }
  121. }