<?php
namespace App\Entity;
use App\Entity\Traits\Timestampable;
use App\Repository\ExamsRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use JMS\Serializer\Annotation\Groups;
#[ORM\HasLifecycleCallbacks]
#[ORM\Entity(repositoryClass: ExamsRepository::class)]
class Exams
{
use Timestampable;
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
#[Groups(['note','getBulletin','getExamStudent', 'getStatsStudentParentIndex'])]
private ?int $id = null;
#[ORM\Column(length: 255)]
#[Groups(['note','getBulletin','getExamStudent','getLate','getAbsence','getPunish', 'getStatsStudentParentIndex'])]
private ?string $name = null;
#[ORM\Column]
#[Groups(['note'])]
private ?float $coef = null;
#[ORM\OneToMany(mappedBy: 'exams', targetEntity: Note::class)]
private Collection $notes;
#[ORM\Column(nullable: true)]
#[Groups(['note'])]
private ?bool $control = null;
#[ORM\ManyToOne(inversedBy: 'exams', cascade: ["persist"])]
private ?SchoolYear $year = null;
#[ORM\ManyToOne(inversedBy: 'exams', cascade: ["persist"])]
private ?Subject $subject = null;
#[ORM\ManyToOne(inversedBy: 'exams', cascade: ["persist"])]
private ?User $author = null;
#[ORM\ManyToOne(inversedBy: 'examsEdited', cascade: ["persist"])]
private ?User $editor = null;
#[ORM\OneToMany(mappedBy: 'exam', targetEntity: SubSequence::class, orphanRemoval: true)]
private Collection $subSequences;
#[ORM\ManyToOne(inversedBy: 'exams')]
#[ORM\JoinColumn(nullable: false)]
private ?Quarter $quarter = null;
#[ORM\OneToMany(mappedBy: 'exam', targetEntity: Absence::class, orphanRemoval: true)]
private Collection $absences;
#[ORM\OneToMany(mappedBy: 'exam', targetEntity: Late::class, orphanRemoval: true)]
private Collection $lates;
#[ORM\ManyToOne(inversedBy: 'exams')]
#[ORM\JoinColumn(nullable: true)]
private ?GlobalExam $globalExam = null;
#[ORM\OneToMany(mappedBy: 'exam', targetEntity: ParentNote::class)]
private Collection $parentNotes;
#[ORM\OneToMany(mappedBy: 'exam', targetEntity: DisciplineBlame::class)]
private Collection $disciplineBlames;
#[ORM\OneToMany(mappedBy: 'exam', targetEntity: DisciplineWarning::class)]
private Collection $disciplineWarnings;
#[ORM\OneToMany(mappedBy: 'exam', targetEntity: DisciplineRetained::class)]
private Collection $disciplineRetaineds;
#[ORM\Column(length: 255, nullable: true)]
#[Groups(['note','getBulletin','getExamStudent','getLate','getAbsence','getPunish', 'getStatsStudentParentIndex'])]
private ?string $nameEn = null;
#[ORM\Column(nullable: true)]
private ?int $type = null;
#[ORM\Column(nullable: true)]
private ?int $dividend = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $primaryName = null;
#[ORM\OneToMany(mappedBy: 'exam', targetEntity: DisciplinePunish::class)]
private Collection $disciplinePunishes;
#[ORM\OneToMany(mappedBy: 'exam', targetEntity: Retained::class)]
private Collection $retaineds;
#[ORM\Column(length: 255, nullable: true)]
#[Groups(['getExamStudent', 'getStatsStudentParentIndex'])]
private ?string $slug = null;
#[ORM\OneToMany(mappedBy: 'exam', targetEntity: DisciplineConcile::class)]
private Collection $disciplineConciles;
#[ORM\OneToMany(mappedBy: 'exam', targetEntity: DisciplineExclusion::class)]
private Collection $disciplineExclusions;
#[ORM\OneToMany(mappedBy: 'exam', targetEntity: ExamWeek::class)]
private Collection $examWeeks;
#[ORM\OneToMany(mappedBy: 'exam', targetEntity: Competence::class)]
private Collection $competences;
#[ORM\OneToMany(mappedBy: 'exam', targetEntity: ProfSchoolPlanner::class)]
private Collection $profSchoolPlanners;
#[ORM\OneToMany(mappedBy: 'exam', targetEntity: ProfTime::class)]
private Collection $profTimes;
#[ORM\Column(type: Types::DATE_MUTABLE, nullable: true)]
private ?\DateTimeInterface $startAt = null;
#[ORM\Column(type: Types::DATETIME_IMMUTABLE, nullable: true)]
private ?\DateTimeImmutable $endAt = null;
public function __construct()
{
$this->notes = new ArrayCollection();
$this->subSequences = new ArrayCollection();
$this->absences = new ArrayCollection();
$this->lates = new ArrayCollection();
$this->parentNotes = new ArrayCollection();
$this->disciplineBlames = new ArrayCollection();
$this->disciplineWarnings = new ArrayCollection();
$this->disciplineRetaineds = new ArrayCollection();
$this->disciplinePunishes = new ArrayCollection();
$this->retaineds = new ArrayCollection();
$this->disciplineConciles = new ArrayCollection();
$this->disciplineExclusions = new ArrayCollection();
$this->examWeeks = new ArrayCollection();
$this->competences = new ArrayCollection();
$this->profSchoolPlanners = new ArrayCollection();
$this->profTimes = new ArrayCollection();
}
public function __toString(): string
{
return $this->getName();
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): static
{
$this->name = $name;
return $this;
}
public function getCoef(): ?float
{
return $this->coef;
}
public function setCoef(float $coef): static
{
$this->coef = $coef;
return $this;
}
/**
* @return Collection<int, Note>
*/
public function getNotes(): Collection
{
return $this->notes;
}
public function addNote(Note $note): static
{
if (!$this->notes->contains($note)) {
$this->notes->add($note);
$note->setExams($this);
}
return $this;
}
public function removeNote(Note $note): static
{
if ($this->notes->removeElement($note)) {
// set the owning side to null (unless already changed)
if ($note->getExams() === $this) {
$note->setExams(null);
}
}
return $this;
}
public function isControl(): ?bool
{
return $this->control;
}
public function setControl(?bool $control): static
{
$this->control = $control;
return $this;
}
public function getYear(): ?SchoolYear
{
return $this->year;
}
public function setYear(?SchoolYear $year): static
{
$this->year = $year;
return $this;
}
public function getSubject(): ?Subject
{
return $this->subject;
}
public function setSubject(?Subject $subject): static
{
$this->subject = $subject;
return $this;
}
public function getAuthor(): ?User
{
return $this->author;
}
public function setAuthor(?User $author): static
{
$this->author = $author;
return $this;
}
public function getEditor(): ?User
{
return $this->editor;
}
public function setEditor(?User $editor): static
{
$this->editor = $editor;
return $this;
}
/**
* @return Collection<int, SubSequence>
*/
public function getSubSequences(): Collection
{
return $this->subSequences;
}
public function addSubSequence(SubSequence $subSequence): static
{
if (!$this->subSequences->contains($subSequence)) {
$this->subSequences->add($subSequence);
$subSequence->setExam($this);
}
return $this;
}
public function removeSubSequence(SubSequence $subSequence): static
{
if ($this->subSequences->removeElement($subSequence)) {
// set the owning side to null (unless already changed)
if ($subSequence->getExam() === $this) {
$subSequence->setExam(null);
}
}
return $this;
}
public function getQuarter(): ?Quarter
{
return $this->quarter;
}
public function setQuarter(?Quarter $quarter): static
{
$this->quarter = $quarter;
return $this;
}
/**
* @return Collection<int, Absence>
*/
public function getAbsences(): Collection
{
return $this->absences;
}
public function addAbsence(Absence $absence): static
{
if (!$this->absences->contains($absence)) {
$this->absences->add($absence);
$absence->setExam($this);
}
return $this;
}
public function removeAbsence(Absence $absence): static
{
if ($this->absences->removeElement($absence)) {
// set the owning side to null (unless already changed)
if ($absence->getExam() === $this) {
$absence->setExam(null);
}
}
return $this;
}
/**
* @return Collection<int, Late>
*/
public function getLates(): Collection
{
return $this->lates;
}
public function addLate(Late $late): static
{
if (!$this->lates->contains($late)) {
$this->lates->add($late);
$late->setExam($this);
}
return $this;
}
public function removeLate(Late $late): static
{
if ($this->lates->removeElement($late)) {
// set the owning side to null (unless already changed)
if ($late->getExam() === $this) {
$late->setExam(null);
}
}
return $this;
}
public function getGlobalExam(): ?GlobalExam
{
return $this->globalExam;
}
public function setGlobalExam(?GlobalExam $globalExam): static
{
$this->globalExam = $globalExam;
return $this;
}
/**
* @return Collection<int, ParentNote>
*/
public function getParentNotes(): Collection
{
return $this->parentNotes;
}
public function addParentNote(ParentNote $parentNote): static
{
if (!$this->parentNotes->contains($parentNote)) {
$this->parentNotes->add($parentNote);
$parentNote->setExam($this);
}
return $this;
}
public function removeParentNote(ParentNote $parentNote): static
{
if ($this->parentNotes->removeElement($parentNote)) {
// set the owning side to null (unless already changed)
if ($parentNote->getExam() === $this) {
$parentNote->setExam(null);
}
}
return $this;
}
/**
* @return Collection<int, DisciplineBlame>
*/
public function getDisciplineBlames(): Collection
{
return $this->disciplineBlames;
}
public function addDisciplineBlame(DisciplineBlame $disciplineBlame): static
{
if (!$this->disciplineBlames->contains($disciplineBlame)) {
$this->disciplineBlames->add($disciplineBlame);
$disciplineBlame->setExam($this);
}
return $this;
}
public function removeDisciplineBlame(DisciplineBlame $disciplineBlame): static
{
if ($this->disciplineBlames->removeElement($disciplineBlame)) {
// set the owning side to null (unless already changed)
if ($disciplineBlame->getExam() === $this) {
$disciplineBlame->setExam(null);
}
}
return $this;
}
/**
* @return Collection<int, DisciplineWarning>
*/
public function getDisciplineWarnings(): Collection
{
return $this->disciplineWarnings;
}
public function addDisciplineWarning(DisciplineWarning $disciplineWarning): static
{
if (!$this->disciplineWarnings->contains($disciplineWarning)) {
$this->disciplineWarnings->add($disciplineWarning);
$disciplineWarning->setExam($this);
}
return $this;
}
public function removeDisciplineWarning(DisciplineWarning $disciplineWarning): static
{
if ($this->disciplineWarnings->removeElement($disciplineWarning)) {
// set the owning side to null (unless already changed)
if ($disciplineWarning->getExam() === $this) {
$disciplineWarning->setExam(null);
}
}
return $this;
}
/**
* @return Collection<int, DisciplineRetained>
*/
public function getDisciplineRetaineds(): Collection
{
return $this->disciplineRetaineds;
}
public function addDisciplineRetained(DisciplineRetained $disciplineRetained): static
{
if (!$this->disciplineRetaineds->contains($disciplineRetained)) {
$this->disciplineRetaineds->add($disciplineRetained);
$disciplineRetained->setExam($this);
}
return $this;
}
public function removeDisciplineRetained(DisciplineRetained $disciplineRetained): static
{
if ($this->disciplineRetaineds->removeElement($disciplineRetained)) {
// set the owning side to null (unless already changed)
if ($disciplineRetained->getExam() === $this) {
$disciplineRetained->setExam(null);
}
}
return $this;
}
public function getNameEn(): ?string
{
return $this->nameEn;
}
public function setNameEn(?string $nameEn): static
{
$this->nameEn = $nameEn;
return $this;
}
public function getType(): ?int
{
return $this->type;
}
public function setType(?int $type): static
{
$this->type = $type;
return $this;
}
public function getDividend(): ?int
{
return $this->dividend;
}
public function setDividend(?int $dividend): static
{
$this->dividend = $dividend;
return $this;
}
public function getPrimaryName(): ?string
{
return $this->primaryName;
}
public function setPrimaryName(?string $primaryName): static
{
$this->primaryName = $primaryName;
return $this;
}
/**
* @return Collection<int, DisciplinePunish>
*/
public function getDisciplinePunishes(): Collection
{
return $this->disciplinePunishes;
}
public function addDisciplinePunish(DisciplinePunish $disciplinePunish): static
{
if (!$this->disciplinePunishes->contains($disciplinePunish)) {
$this->disciplinePunishes->add($disciplinePunish);
$disciplinePunish->setExam($this);
}
return $this;
}
public function removeDisciplinePunish(DisciplinePunish $disciplinePunish): static
{
if ($this->disciplinePunishes->removeElement($disciplinePunish)) {
// set the owning side to null (unless already changed)
if ($disciplinePunish->getExam() === $this) {
$disciplinePunish->setExam(null);
}
}
return $this;
}
/**
* @return Collection<int, Retained>
*/
public function getRetaineds(): Collection
{
return $this->retaineds;
}
public function addRetained(Retained $retained): static
{
if (!$this->retaineds->contains($retained)) {
$this->retaineds->add($retained);
$retained->setExam($this);
}
return $this;
}
public function removeRetained(Retained $retained): static
{
if ($this->retaineds->removeElement($retained)) {
// set the owning side to null (unless already changed)
if ($retained->getExam() === $this) {
$retained->setExam(null);
}
}
return $this;
}
public function getSlug(): ?string
{
return $this->slug;
}
public function setSlug(?string $slug): static
{
$this->slug = $slug;
return $this;
}
/**
* @return Collection<int, DisciplineConcile>
*/
public function getDisciplineConciles(): Collection
{
return $this->disciplineConciles;
}
public function addDisciplineConcile(DisciplineConcile $disciplineConcile): static
{
if (!$this->disciplineConciles->contains($disciplineConcile)) {
$this->disciplineConciles->add($disciplineConcile);
$disciplineConcile->setExam($this);
}
return $this;
}
public function removeDisciplineConcile(DisciplineConcile $disciplineConcile): static
{
if ($this->disciplineConciles->removeElement($disciplineConcile)) {
// set the owning side to null (unless already changed)
if ($disciplineConcile->getExam() === $this) {
$disciplineConcile->setExam(null);
}
}
return $this;
}
/**
* @return Collection<int, DisciplineExclusion>
*/
public function getDisciplineExclusions(): Collection
{
return $this->disciplineExclusions;
}
public function addDisciplineExclusion(DisciplineExclusion $disciplineExclusion): static
{
if (!$this->disciplineExclusions->contains($disciplineExclusion)) {
$this->disciplineExclusions->add($disciplineExclusion);
$disciplineExclusion->setExam($this);
}
return $this;
}
public function removeDisciplineExclusion(DisciplineExclusion $disciplineExclusion): static
{
if ($this->disciplineExclusions->removeElement($disciplineExclusion)) {
// set the owning side to null (unless already changed)
if ($disciplineExclusion->getExam() === $this) {
$disciplineExclusion->setExam(null);
}
}
return $this;
}
/**
* @return Collection<int, ExamWeek>
*/
public function getExamWeeks(): Collection
{
return $this->examWeeks;
}
public function addExamWeek(ExamWeek $examWeek): static
{
if (!$this->examWeeks->contains($examWeek)) {
$this->examWeeks->add($examWeek);
$examWeek->setExam($this);
}
return $this;
}
public function removeExamWeek(ExamWeek $examWeek): static
{
if ($this->examWeeks->removeElement($examWeek)) {
// set the owning side to null (unless already changed)
if ($examWeek->getExam() === $this) {
$examWeek->setExam(null);
}
}
return $this;
}
/**
* @return Collection<int, Competence>
*/
public function getCompetences(): Collection
{
return $this->competences;
}
public function addCompetence(Competence $competence): static
{
if (!$this->competences->contains($competence)) {
$this->competences->add($competence);
$competence->setExam($this);
}
return $this;
}
public function removeCompetence(Competence $competence): static
{
if ($this->competences->removeElement($competence)) {
// set the owning side to null (unless already changed)
if ($competence->getExam() === $this) {
$competence->setExam(null);
}
}
return $this;
}
/**
* @return Collection<int, ProfSchoolPlanner>
*/
public function getProfSchoolPlanners(): Collection
{
return $this->profSchoolPlanners;
}
public function addProfSchoolPlanner(ProfSchoolPlanner $profSchoolPlanner): static
{
if (!$this->profSchoolPlanners->contains($profSchoolPlanner)) {
$this->profSchoolPlanners->add($profSchoolPlanner);
$profSchoolPlanner->setExam($this);
}
return $this;
}
public function removeProfSchoolPlanner(ProfSchoolPlanner $profSchoolPlanner): static
{
if ($this->profSchoolPlanners->removeElement($profSchoolPlanner)) {
// set the owning side to null (unless already changed)
if ($profSchoolPlanner->getExam() === $this) {
$profSchoolPlanner->setExam(null);
}
}
return $this;
}
/**
* @return Collection<int, ProfTime>
*/
public function getProfTimes(): Collection
{
return $this->profTimes;
}
public function addProfTime(ProfTime $profTime): static
{
if (!$this->profTimes->contains($profTime)) {
$this->profTimes->add($profTime);
$profTime->setExam($this);
}
return $this;
}
public function removeProfTime(ProfTime $profTime): static
{
if ($this->profTimes->removeElement($profTime)) {
// set the owning side to null (unless already changed)
if ($profTime->getExam() === $this) {
$profTime->setExam(null);
}
}
return $this;
}
public function getStartAt(): ?\DateTimeInterface
{
return $this->startAt;
}
public function setStartAt(?\DateTimeInterface $startAt): static
{
$this->startAt = $startAt;
return $this;
}
public function getEndAt(): ?\DateTimeImmutable
{
return $this->endAt;
}
public function setEndAt(?\DateTimeImmutable $endAt): static
{
$this->endAt = $endAt;
return $this;
}
}