src/Entity/Core/StudentDifficulty.php line 13

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