src/Entity/Core/SelfStudy/SelfStudyTopicStudentDifficulty.php line 12

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