src/Entity/Capsule.php line 21

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Traits\Timestampable;
  4. use App\Repository\CapsuleRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. // Contenu pédagogique numérique interactif (module Apprentissage) : une suite
  9. // ordonnée de CapsuleBlock consultée par l'élève, avec éventuellement des
  10. // activités auto-corrigées. Rattachée à une Subject (donc à une classe/école/
  11. // année via Subject) et, optionnellement, à un SubjectLesson existant du
  12. // cahier de texte pour "digitaliser" ce point précis du programme — une
  13. // capsule sans subjectLesson est un contenu/exercice libre. Entité neuve et
  14. // isolée : aucun rapport avec Lesson/SubjectLesson/LessonProgress au-delà de
  15. // ce lien optionnel purement additif.
  16. #[ORM\HasLifecycleCallbacks]
  17. #[ORM\Entity(repositoryClassCapsuleRepository::class)]
  18. class Capsule
  19. {
  20.     use Timestampable;
  21.     #[ORM\Id]
  22.     #[ORM\GeneratedValue]
  23.     #[ORM\Column]
  24.     private ?int $id null;
  25.     #[ORM\ManyToOne(inversedBy'capsules')]
  26.     #[ORM\JoinColumn(nullablefalseonDelete'CASCADE')]
  27.     private ?Subject $subject null;
  28.     #[ORM\ManyToOne(inversedBy'capsules')]
  29.     #[ORM\JoinColumn(nullabletrueonDelete'SET NULL')]
  30.     private ?SubjectLesson $subjectLesson null;
  31.     #[ORM\Column(length255)]
  32.     private ?string $title null;
  33.     #[ORM\Column(type'text'nullabletrue)]
  34.     private ?string $description null;
  35.     #[ORM\Column]
  36.     private int $position 0;
  37.     #[ORM\Column]
  38.     private bool $published false;
  39.     #[ORM\Column(type'datetime'nullabletrue)]
  40.     private ?\DateTimeInterface $publishedAt null;
  41.     // Temps limite (en secondes) de consultation de l'ENSEMBLE de la capsule,
  42.     // cumulé sur toutes les sessions de l'élève (voir
  43.     // StudentCapsuleProgress::timeSpentSeconds). Null = pas de limite. Une
  44.     // fois atteint, le mobile verrouille l'écran et soumet automatiquement
  45.     // les tentatives d'activité en cours (voir StudentActivityAttempt::autoSubmitted).
  46.     #[ORM\Column(nullabletrue)]
  47.     private ?int $timeLimitSeconds null;
  48.     // Compétence évaluée par TOUTE la capsule (module Apprentissage,
  49.     // indépendant du système trimestriel — voir LearningCompetency). Niveau
  50.     // le plus large de la chaîne de résolution : une Activity ou une Question
  51.     // peuvent avoir leur propre compétence, plus spécifique, qui prime alors
  52.     // sur celle-ci (voir Question::getEffectiveLearningCompetency()). Choix
  53.     // proposés limités aux compétences de subjectLesson — vide si la capsule
  54.     // n'est pas rattachée à une leçon/TD.
  55.     #[ORM\ManyToOne]
  56.     #[ORM\JoinColumn(nullabletrueonDelete'SET NULL')]
  57.     private ?LearningCompetency $learningCompetency null;
  58.     // Trimestre auquel rattacher la capsule pour permettre à l'élève de
  59.     // filtrer les capsules par trimestre + matière côté mobile. Sans rapport
  60.     // avec le système de notation (Quarter est simplement réutilisé comme
  61.     // référentiel de périodes déjà connu de l'école) — null = visible sur
  62.     // tous les trimestres.
  63.     #[ORM\ManyToOne]
  64.     #[ORM\JoinColumn(nullabletrueonDelete'SET NULL')]
  65.     private ?Quarter $quarter null;
  66.     // Photo de couverture affichée sur la carte de la capsule (web et
  67.     // mobile) — chemin relatif sous le même répertoire média que les blocs
  68.     // (voir CapsuleBlockController::moveMediaFile). Null = visuel par défaut.
  69.     #[ORM\Column(length255nullabletrue)]
  70.     private ?string $coverPath null;
  71.     #[ORM\ManyToOne]
  72.     #[ORM\JoinColumn(nullablefalse)]
  73.     private ?User $author null;
  74.     #[ORM\ManyToOne]
  75.     private ?User $editor null;
  76.     #[ORM\OneToMany(mappedBy'capsule'targetEntityCapsuleBlock::class, cascade: ['persist''remove'], orphanRemovaltrue)]
  77.     #[ORM\OrderBy(['position' => 'ASC'])]
  78.     private Collection $blocks;
  79.     public function __construct()
  80.     {
  81.         $this->blocks = new ArrayCollection();
  82.     }
  83.     public function __toString(): string
  84.     {
  85.         return $this->title ?? '';
  86.     }
  87.     public function getId(): ?int
  88.     {
  89.         return $this->id;
  90.     }
  91.     public function getSubject(): ?Subject
  92.     {
  93.         return $this->subject;
  94.     }
  95.     public function setSubject(?Subject $subject): static
  96.     {
  97.         $this->subject $subject;
  98.         return $this;
  99.     }
  100.     public function getSubjectLesson(): ?SubjectLesson
  101.     {
  102.         return $this->subjectLesson;
  103.     }
  104.     public function setSubjectLesson(?SubjectLesson $subjectLesson): static
  105.     {
  106.         $this->subjectLesson $subjectLesson;
  107.         return $this;
  108.     }
  109.     public function getTitle(): ?string
  110.     {
  111.         return $this->title;
  112.     }
  113.     public function setTitle(string $title): static
  114.     {
  115.         $this->title $title;
  116.         return $this;
  117.     }
  118.     public function getDescription(): ?string
  119.     {
  120.         return $this->description;
  121.     }
  122.     public function setDescription(?string $description): static
  123.     {
  124.         $this->description $description;
  125.         return $this;
  126.     }
  127.     public function getPosition(): int
  128.     {
  129.         return $this->position;
  130.     }
  131.     public function setPosition(int $position): static
  132.     {
  133.         $this->position $position;
  134.         return $this;
  135.     }
  136.     public function isPublished(): bool
  137.     {
  138.         return $this->published;
  139.     }
  140.     public function setPublished(bool $published): static
  141.     {
  142.         $this->published $published;
  143.         return $this;
  144.     }
  145.     public function getPublishedAt(): ?\DateTimeInterface
  146.     {
  147.         return $this->publishedAt;
  148.     }
  149.     public function setPublishedAt(?\DateTimeInterface $publishedAt): static
  150.     {
  151.         $this->publishedAt $publishedAt;
  152.         return $this;
  153.     }
  154.     public function getTimeLimitSeconds(): ?int
  155.     {
  156.         return $this->timeLimitSeconds;
  157.     }
  158.     public function setTimeLimitSeconds(?int $timeLimitSeconds): static
  159.     {
  160.         $this->timeLimitSeconds $timeLimitSeconds;
  161.         return $this;
  162.     }
  163.     public function getLearningCompetency(): ?LearningCompetency
  164.     {
  165.         return $this->learningCompetency;
  166.     }
  167.     public function setLearningCompetency(?LearningCompetency $learningCompetency): static
  168.     {
  169.         $this->learningCompetency $learningCompetency;
  170.         return $this;
  171.     }
  172.     public function getQuarter(): ?Quarter
  173.     {
  174.         return $this->quarter;
  175.     }
  176.     public function setQuarter(?Quarter $quarter): static
  177.     {
  178.         $this->quarter $quarter;
  179.         return $this;
  180.     }
  181.     public function getCoverPath(): ?string
  182.     {
  183.         return $this->coverPath;
  184.     }
  185.     public function setCoverPath(?string $coverPath): static
  186.     {
  187.         $this->coverPath $coverPath;
  188.         return $this;
  189.     }
  190.     public function getAuthor(): ?User
  191.     {
  192.         return $this->author;
  193.     }
  194.     public function setAuthor(?User $author): static
  195.     {
  196.         $this->author $author;
  197.         return $this;
  198.     }
  199.     public function getEditor(): ?User
  200.     {
  201.         return $this->editor;
  202.     }
  203.     public function setEditor(?User $editor): static
  204.     {
  205.         $this->editor $editor;
  206.         return $this;
  207.     }
  208.     /** @return Collection<int, CapsuleBlock> */
  209.     public function getBlocks(): Collection
  210.     {
  211.         return $this->blocks;
  212.     }
  213.     public function addBlock(CapsuleBlock $block): static
  214.     {
  215.         if (!$this->blocks->contains($block)) {
  216.             $this->blocks->add($block);
  217.             $block->setCapsule($this);
  218.         }
  219.         return $this;
  220.     }
  221.     public function removeBlock(CapsuleBlock $block): static
  222.     {
  223.         if ($this->blocks->removeElement($block)) {
  224.             if ($block->getCapsule() === $this) {
  225.                 $block->setCapsule(null);
  226.             }
  227.         }
  228.         return $this;
  229.     }
  230. }