src/Entity/StudentCapsuleProgress.php line 16

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Traits\Timestampable;
  4. use App\Repository\StudentCapsuleProgressRepository;
  5. use Doctrine\ORM\Mapping as ORM;
  6. // Progression d'un élève sur une Capsule (consultation, pas seulement les
  7. // activités) — un élève peut avoir lu une capsule sans avoir encore répondu à
  8. // ses activités. `classe`/`year` sont dénormalisés (comme Absences.yearId...)
  9. // pour permettre le reporting enseignant par classe sans jointure via Student.
  10. #[ORM\HasLifecycleCallbacks]
  11. #[ORM\Entity(repositoryClassStudentCapsuleProgressRepository::class)]
  12. #[ORM\UniqueConstraint(name'uniq_student_capsule_year'columns: ['student_id''capsule_id''year_id'])]
  13. class StudentCapsuleProgress
  14. {
  15.     use Timestampable;
  16.     public const STATUS_NOT_STARTED 'not_started';
  17.     public const STATUS_IN_PROGRESS 'in_progress';
  18.     public const STATUS_DONE 'done';
  19.     #[ORM\Id]
  20.     #[ORM\GeneratedValue]
  21.     #[ORM\Column]
  22.     private ?int $id null;
  23.     #[ORM\ManyToOne]
  24.     #[ORM\JoinColumn(nullablefalseonDelete'CASCADE')]
  25.     private ?Student $student null;
  26.     #[ORM\ManyToOne]
  27.     #[ORM\JoinColumn(nullablefalseonDelete'CASCADE')]
  28.     private ?Capsule $capsule null;
  29.     #[ORM\ManyToOne]
  30.     #[ORM\JoinColumn(nullablefalse)]
  31.     private ?TheClass $classe null;
  32.     #[ORM\ManyToOne]
  33.     #[ORM\JoinColumn(nullablefalse)]
  34.     private ?SchoolYear $year null;
  35.     #[ORM\Column(length20options: ['default' => self::STATUS_NOT_STARTED])]
  36.     private string $status self::STATUS_NOT_STARTED;
  37.     #[ORM\Column]
  38.     private int $progressPercent 0;
  39.     // Temps cumulé (en secondes) passé par l'élève sur cette capsule, toutes
  40.     // sessions confondues — le mobile envoie des mises à jour périodiques
  41.     // (heartbeat) pendant la lecture. Comparé à Capsule::timeLimitSeconds
  42.     // pour déclencher le verrouillage de l'écran élève.
  43.     #[ORM\Column]
  44.     private int $timeSpentSeconds 0;
  45.     #[ORM\Column(type'datetime'nullabletrue)]
  46.     private ?\DateTimeInterface $startedAt null;
  47.     #[ORM\Column(type'datetime'nullabletrue)]
  48.     private ?\DateTimeInterface $completedAt null;
  49.     public function getId(): ?int
  50.     {
  51.         return $this->id;
  52.     }
  53.     public function getStudent(): ?Student
  54.     {
  55.         return $this->student;
  56.     }
  57.     public function setStudent(?Student $student): static
  58.     {
  59.         $this->student $student;
  60.         return $this;
  61.     }
  62.     public function getCapsule(): ?Capsule
  63.     {
  64.         return $this->capsule;
  65.     }
  66.     public function setCapsule(?Capsule $capsule): static
  67.     {
  68.         $this->capsule $capsule;
  69.         return $this;
  70.     }
  71.     public function getClasse(): ?TheClass
  72.     {
  73.         return $this->classe;
  74.     }
  75.     public function setClasse(?TheClass $classe): static
  76.     {
  77.         $this->classe $classe;
  78.         return $this;
  79.     }
  80.     public function getYear(): ?SchoolYear
  81.     {
  82.         return $this->year;
  83.     }
  84.     public function setYear(?SchoolYear $year): static
  85.     {
  86.         $this->year $year;
  87.         return $this;
  88.     }
  89.     public function getStatus(): string
  90.     {
  91.         return $this->status;
  92.     }
  93.     public function setStatus(string $status): static
  94.     {
  95.         $this->status $status;
  96.         return $this;
  97.     }
  98.     public function getProgressPercent(): int
  99.     {
  100.         return $this->progressPercent;
  101.     }
  102.     public function setProgressPercent(int $progressPercent): static
  103.     {
  104.         $this->progressPercent $progressPercent;
  105.         return $this;
  106.     }
  107.     public function getTimeSpentSeconds(): int
  108.     {
  109.         return $this->timeSpentSeconds;
  110.     }
  111.     public function setTimeSpentSeconds(int $timeSpentSeconds): static
  112.     {
  113.         $this->timeSpentSeconds $timeSpentSeconds;
  114.         return $this;
  115.     }
  116.     public function getStartedAt(): ?\DateTimeInterface
  117.     {
  118.         return $this->startedAt;
  119.     }
  120.     public function setStartedAt(?\DateTimeInterface $startedAt): static
  121.     {
  122.         $this->startedAt $startedAt;
  123.         return $this;
  124.     }
  125.     public function getCompletedAt(): ?\DateTimeInterface
  126.     {
  127.         return $this->completedAt;
  128.     }
  129.     public function setCompletedAt(?\DateTimeInterface $completedAt): static
  130.     {
  131.         $this->completedAt $completedAt;
  132.         return $this;
  133.     }
  134. }