src/Entity/QuestionOption.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Traits\Timestampable;
  4. use App\Repository\QuestionOptionRepository;
  5. use Doctrine\ORM\Mapping as ORM;
  6. // Option de réponse pré-définie par l'enseignant pour une Question (qcm,
  7. // true_false, matching, ordering). `isCorrect` sert à la correction
  8. // automatique des qcm/true_false. Pour `ordering`, `position` EST l'ordre
  9. // correct attendu (comparé à l'ordre proposé par l'élève dans StudentAnswer).
  10. // Pour `matching`, `side` ('left'|'right') + `pairKey` regroupent les deux
  11. // éléments d'une paire à relier.
  12. #[ORM\HasLifecycleCallbacks]
  13. #[ORM\Entity(repositoryClassQuestionOptionRepository::class)]
  14. class QuestionOption
  15. {
  16.     use Timestampable;
  17.     public const SIDE_LEFT 'left';
  18.     public const SIDE_RIGHT 'right';
  19.     #[ORM\Id]
  20.     #[ORM\GeneratedValue]
  21.     #[ORM\Column]
  22.     private ?int $id null;
  23.     #[ORM\ManyToOne(inversedBy'options')]
  24.     #[ORM\JoinColumn(nullablefalseonDelete'CASCADE')]
  25.     private ?Question $question null;
  26.     #[ORM\Column(length500)]
  27.     private ?string $text null;
  28.     #[ORM\Column]
  29.     private bool $isCorrect false;
  30.     #[ORM\Column]
  31.     private int $position 0;
  32.     #[ORM\Column(length10nullabletrue)]
  33.     private ?string $side null;
  34.     #[ORM\Column(length50nullabletrue)]
  35.     private ?string $pairKey null;
  36.     public function getId(): ?int
  37.     {
  38.         return $this->id;
  39.     }
  40.     public function getQuestion(): ?Question
  41.     {
  42.         return $this->question;
  43.     }
  44.     public function setQuestion(?Question $question): static
  45.     {
  46.         $this->question $question;
  47.         return $this;
  48.     }
  49.     public function getText(): ?string
  50.     {
  51.         return $this->text;
  52.     }
  53.     public function setText(string $text): static
  54.     {
  55.         $this->text $text;
  56.         return $this;
  57.     }
  58.     public function isCorrect(): bool
  59.     {
  60.         return $this->isCorrect;
  61.     }
  62.     public function setIsCorrect(bool $isCorrect): static
  63.     {
  64.         $this->isCorrect $isCorrect;
  65.         return $this;
  66.     }
  67.     public function getPosition(): int
  68.     {
  69.         return $this->position;
  70.     }
  71.     public function setPosition(int $position): static
  72.     {
  73.         $this->position $position;
  74.         return $this;
  75.     }
  76.     public function getSide(): ?string
  77.     {
  78.         return $this->side;
  79.     }
  80.     public function setSide(?string $side): static
  81.     {
  82.         $this->side $side;
  83.         return $this;
  84.     }
  85.     public function getPairKey(): ?string
  86.     {
  87.         return $this->pairKey;
  88.     }
  89.     public function setPairKey(?string $pairKey): static
  90.     {
  91.         $this->pairKey $pairKey;
  92.         return $this;
  93.     }
  94. }