|
|
@@ -0,0 +1,188 @@
|
|
|
+<?php
|
|
|
+declare(strict_types=1);
|
|
|
+
|
|
|
+namespace App\Entity\Education;
|
|
|
+
|
|
|
+use ApiPlatform\Core\Annotation\ApiResource;
|
|
|
+use App\Annotation\OrganizationDefaultValue;
|
|
|
+use App\Entity\Access\Access;
|
|
|
+use App\Repository\Education\EducationNotationConfigRepository;
|
|
|
+use App\Entity\Organization\Organization;
|
|
|
+use Doctrine\Common\Collections\ArrayCollection;
|
|
|
+use Doctrine\Common\Collections\Collection;
|
|
|
+use Doctrine\ORM\Mapping as ORM;
|
|
|
+use JetBrains\PhpStorm\Pure;
|
|
|
+use Symfony\Component\Validator\Constraints as Assert;
|
|
|
+
|
|
|
+/**
|
|
|
+ * Configuration des grilles d'évaluation
|
|
|
+ */
|
|
|
+#[ApiResource(
|
|
|
+ collectionOperations: [
|
|
|
+ "get" => ["security" => "is_granted('ROLE_PEDAGOGICS_ADMINISTRATION_VIEW')"]
|
|
|
+ ],
|
|
|
+ itemOperations: [
|
|
|
+ "get" => ["security" => "is_granted('ROLE_PEDAGOGICS_ADMINISTRATION_VIEW') and object.getOrganization().getId() == user.getOrganization().getId()"],
|
|
|
+ "put" => ["security" => "object.getOrganization().getId() == user.getOrganization().getId()"],
|
|
|
+ ],
|
|
|
+ attributes: ["security" => "is_granted('ROLE_PEDAGOGICS_ADMINISTRATION')"]
|
|
|
+)]
|
|
|
+#[ORM\Entity(repositoryClass: EducationNotationConfigRepository::class)]
|
|
|
+#[OrganizationDefaultValue(fieldName: "organization")]
|
|
|
+class EducationNotationConfig
|
|
|
+{
|
|
|
+ #[ORM\Id]
|
|
|
+ #[ORM\Column]
|
|
|
+ #[ORM\GeneratedValue]
|
|
|
+ private ?int $id = null;
|
|
|
+
|
|
|
+ #[ORM\ManyToOne(inversedBy: 'educationNotationConfigs')]
|
|
|
+ private Organization $organization;
|
|
|
+
|
|
|
+ #[ORM\Column(length: 255)]
|
|
|
+ private string $label;
|
|
|
+
|
|
|
+ #[ORM\Column(options: ['default' => true])]
|
|
|
+ private bool $isActive = true;
|
|
|
+
|
|
|
+ #[ORM\Column(type: 'text', nullable: true)]
|
|
|
+ private ?string $description;
|
|
|
+
|
|
|
+ #[ORM\Column(options: ['default' => 1])]
|
|
|
+ #[Assert\GreaterThanOrEqual(1, message: 'greaterThanOrEqual1')]
|
|
|
+ #[Assert\LessThanOrEqual(10, message: 'lessThanOrEqual10')]
|
|
|
+ private int $coefficient = 1;
|
|
|
+
|
|
|
+ #[ORM\OneToMany( mappedBy: 'educationNotationConfig', targetEntity: Access::class)]
|
|
|
+ private Collection $teachers;
|
|
|
+
|
|
|
+ #[ORM\OneToMany( mappedBy: 'educationNotationConfig', targetEntity: EducationCurriculum::class)]
|
|
|
+ private Collection $educationCurriculums;
|
|
|
+
|
|
|
+
|
|
|
+ #[Pure] public function __construct() {
|
|
|
+ $this->teachers = new ArrayCollection();
|
|
|
+ $this->educationCurriculums = new ArrayCollection();
|
|
|
+ }
|
|
|
+
|
|
|
+ public function getId(): ?int
|
|
|
+ {
|
|
|
+ return $this->id;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function setOrganization(Organization $organization): self
|
|
|
+ {
|
|
|
+ $this->organization = $organization;
|
|
|
+
|
|
|
+ return $this;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function getOrganization(): Organization
|
|
|
+ {
|
|
|
+ return $this->organization;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function setLabel(string $label): self
|
|
|
+ {
|
|
|
+ $this->label = $label;
|
|
|
+
|
|
|
+ return $this;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function getLabel(): string
|
|
|
+ {
|
|
|
+ return $this->label;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function setIsActive(bool $isActive): self
|
|
|
+ {
|
|
|
+ $this->isActive = $isActive;
|
|
|
+
|
|
|
+ return $this;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function getIsActive(): bool
|
|
|
+ {
|
|
|
+ return $this->isActive;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function setDescription(?string $description): self
|
|
|
+ {
|
|
|
+ $this->description = $description;
|
|
|
+
|
|
|
+ return $this;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function getDescription(): ?string
|
|
|
+ {
|
|
|
+ return $this->description;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function setCoefficient(?int $coefficient): self
|
|
|
+ {
|
|
|
+ if($coefficient === null) $coefficient = 1;
|
|
|
+ $this->coefficient = $coefficient;
|
|
|
+
|
|
|
+ return $this;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function getCoefficient(): int
|
|
|
+ {
|
|
|
+ return $this->coefficient;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public function addTeacher(Access $teacher): self
|
|
|
+ {
|
|
|
+ if (!$this->teachers->contains($teacher)) {
|
|
|
+ $this->teachers[] = $teacher;
|
|
|
+ $teacher->setEducationNotationConfig($this);
|
|
|
+ }
|
|
|
+
|
|
|
+ return $this;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function removeTeacher(Access $teacher): self
|
|
|
+ {
|
|
|
+ if ($this->teachers->removeElement($teacher)) {
|
|
|
+ // set the owning side to null (unless already changed)
|
|
|
+ if ($teacher->getEducationNotationConfig() === $this) {
|
|
|
+ $teacher->setEducationNotationConfig(null);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return $this;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function getTeachers(): Collection
|
|
|
+ {
|
|
|
+ return $this->teachers;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public function addEducationCurriculum(EducationCurriculum $educationCurriculums): self
|
|
|
+ {
|
|
|
+ if (!$this->educationCurriculums->contains($educationCurriculums)) {
|
|
|
+ $this->educationCurriculums[] = $educationCurriculums;
|
|
|
+ $educationCurriculums->setEducationNotationConfig($this);
|
|
|
+ }
|
|
|
+
|
|
|
+ return $this;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function removeEducationCurriculum(EducationCurriculum $educationCurriculums): self
|
|
|
+ {
|
|
|
+ if ($this->educationCurriculums->removeElement($educationCurriculums)) {
|
|
|
+ // set the owning side to null (unless already changed)
|
|
|
+ if ($educationCurriculums->getEducationNotationConfig() === $this) {
|
|
|
+ $educationCurriculums->setEducationNotationConfig(null);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return $this;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function getEducationCurriculums(): Collection
|
|
|
+ {
|
|
|
+ return $this->educationCurriculums;
|
|
|
+ }
|
|
|
+}
|