src/Entity/Evaluation.php line 98

  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Metadata\ApiResource;
  4. use App\Repository\EvaluationRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use ApiPlatform\Metadata\Get;
  8. use ApiPlatform\Metadata\GetCollection;
  9. use ApiPlatform\Metadata\Post;
  10. use App\Controller\Api\Controller\Evaluation\EvaluationsEleve;
  11. use App\Controller\Api\Controller\Evaluation\InscriptionController;
  12. use App\Controller\Api\Controller\Evaluation\ListController;
  13. use App\Controller\Api\Controller\Evaluation\PostCorrectionController;
  14. use App\Controller\Api\Controller\Evaluation\QuestionnaireController;
  15. use App\Controller\Api\Controller\Evaluation\ResultatController;
  16. use Doctrine\DBAL\Types\Types;
  17. use Doctrine\ORM\Mapping as ORM;
  18. use Symfony\Component\Serializer\Annotation\Groups;
  19. #[ORM\Entity(repositoryClassEvaluationRepository::class)]
  20. #[ApiResource(
  21.     operations: [
  22.         new GetCollection(
  23.             uriTemplate'/evaluations/{id}/list',
  24.             controllerListController::class,
  25.             openapiContext: [
  26.                 'security' => [['bearerAuth' => []]],
  27.                 'description' => 'ID = Id de eleve'
  28.             ],
  29.             normalizationContext: [
  30.                 'groups' => ['read:evaluation:collection']
  31.             ],
  32.             readfalse
  33.         ),
  34.         new GetCollection(
  35.             uriTemplate'/evaluations/student/{id}',
  36.             controllerEvaluationsEleve::class,
  37.             openapiContext: [
  38.                 'security' => [['bearerAuth' => []]],
  39.                 'description' => "Permet de recuperer la liste des Ã©valuations d'un Ã©lève"
  40.             ],
  41.             normalizationContext: [
  42.                 'groups' => ['read:evaluation:collection']
  43.             ],
  44.             readfalse
  45.         ),
  46.         new Post(
  47.             uriTemplate'/evaluations/{id}/inscription',
  48.             controllerInscriptionController::class,
  49.             openapiContext: [
  50.                 'security' => [['bearerAuth' => []]],
  51.                 'description' => 'id = evaluation_id'
  52.             ],
  53.             writefalse
  54.         ),
  55.         new Get(
  56.             uriTemplate'/evaluations/{id}/questionnaire',
  57.             controllerQuestionnaireController::class,
  58.             openapiContext: [
  59.                 'security' => [['bearerAuth' => []]],
  60.                 'description' => 'id = evaluation_id'
  61.             ],
  62.             normalizationContext: [
  63.                 'groups' => ['read:evaluation:question''read:evaluation:item']
  64.             ],
  65.             readfalse
  66.         ),
  67.         new Post(
  68.             uriTemplate'/evaluations/{id}/corrige',
  69.             controllerPostCorrectionController::class,
  70.             openapiContext: [
  71.                 'security' => [['bearerAuth' => []]],
  72.                 'description' => 'id = evaluation_id'
  73.             ],
  74.             normalizationContext: [
  75.                 'groups' => ['read:evaluation:question'],
  76.                 'description' => 'id = evaluation_id'
  77.             ],
  78.             writefalse
  79.         ),
  80.         new Get(
  81.             uriTemplate'/evaluations/{id}/resultat',
  82.             controllerResultatController::class,
  83.             openapiContext: [
  84.                 'security' => [['bearerAuth' => []]],
  85.                 'description' => "Cette route permet de récupérer la correction d'une Ã©valuation. id = evaluation_id"
  86.             ],
  87.             normalizationContext: [
  88.                 'groups' => ['read:evaluation:item']
  89.             ],
  90.             readfalse
  91.         )
  92.     ]
  93. )]
  94. class Evaluation
  95. {
  96.     #[ORM\Id]
  97.     #[ORM\GeneratedValue]
  98.     #[ORM\Column]
  99.     #[Groups(['read:evaluation:collection'])]
  100.     private ?int $id null;
  101.     #[ORM\Column(length255)]
  102.     #[Groups(['read:evaluation:collection'])]
  103.     private ?string $titre null;
  104.     #[ORM\Column(typeTypes::TEXT)]
  105.     private ?string $description null;
  106.     #[ORM\ManyToOne(inversedBy'evaluations')]
  107.     #[ORM\JoinColumn(nullablefalse)]
  108.     #[Groups(['read:evaluation:collection'])]
  109.     private ?Categorie $matiere null;
  110.     #[ORM\ManyToMany(targetEntityClasse::class, inversedBy'evaluations')]
  111.     #[Groups(['read:evaluation:collection'])]
  112.     private Collection $classes;
  113.     #[ORM\Column(nullable:true)]
  114.     #[Groups(['read:evaluation:collection'])]
  115.     private ?\DateTime $startAt null;
  116.     #[ORM\Column(nullable:true)]
  117.     #[Groups(['read:evaluation:collection'])]
  118.     private ?\DateTime $endAt null;
  119.     #[ORM\Column(typeTypes::SMALLINT)]
  120.     #[Groups(['read:evaluation:collection'])]
  121.     private ?int $duree null;
  122.     #[ORM\Column]
  123.     #[Groups(['read:evaluation:collection'])]
  124.     private ?bool $isGeneratedRandomQuestions null;
  125.     #[ORM\OneToMany(mappedBy'evaluation'targetEntityEvaluationQuestion::class, orphanRemovaltrue)]
  126.     #[Groups(['read:evaluation:item'])]
  127.     private Collection $evaluationQuestions;
  128.     #[ORM\Column(length255)]
  129.     #[Groups(['read:evaluation:collection'])]
  130.     private ?string $slug null;
  131.     #[ORM\Column]
  132.     #[Groups(['read:evaluation:collection'])]
  133.     private ?bool $isPassed false;
  134.     #[ORM\ManyToMany(targetEntityEleve::class, inversedBy'evaluations')]
  135.     private Collection $Eleves;
  136.     #[ORM\OneToMany(mappedBy'evaluation'targetEntityEvaluationResultat::class, orphanRemovaltrue)]
  137.     private Collection $results;
  138.     #[ORM\ManyToOne(inversedBy'evaluations')]
  139.     private ?Enseignant $enseignant null;
  140.     #[ORM\Column(nullabletrue)]
  141.     private ?bool $isPublished null;
  142.     public function __construct()
  143.     {
  144.         $this->classes = new ArrayCollection();
  145.         $this->evaluationQuestions = new ArrayCollection();
  146.         $this->Eleves = new ArrayCollection();
  147.         $this->results = new ArrayCollection();
  148.     }
  149.     public function getId(): ?int
  150.     {
  151.         return $this->id;
  152.     }
  153.     public function getTitre(): ?string
  154.     {
  155.         return $this->titre;
  156.     }
  157.     public function setTitre(string $titre): self
  158.     {
  159.         $this->titre $titre;
  160.         return $this;
  161.     }
  162.     public function getDescription(): ?string
  163.     {
  164.         return $this->description;
  165.     }
  166.     public function setDescription(string $description): self
  167.     {
  168.         $this->description $description;
  169.         return $this;
  170.     }
  171.     public function getMatiere(): ?Categorie
  172.     {
  173.         return $this->matiere;
  174.     }
  175.     public function setMatiere(?Categorie $matiere): self
  176.     {
  177.         $this->matiere $matiere;
  178.         return $this;
  179.     }
  180.     /**
  181.      * @return Collection<int, Classe>
  182.      */
  183.     public function getClasses(): Collection
  184.     {
  185.         return $this->classes;
  186.     }
  187.     public function addClass(Classe $class): self
  188.     {
  189.         if (!$this->classes->contains($class)) {
  190.             $this->classes->add($class);
  191.         }
  192.         return $this;
  193.     }
  194.     public function removeClass(Classe $class): self
  195.     {
  196.         $this->classes->removeElement($class);
  197.         return $this;
  198.     }
  199.     public function getStartAt(): ?\DateTime
  200.     {
  201.         return $this->startAt;
  202.     }
  203.     public function setStartAt(\DateTime $startAt): self
  204.     {
  205.         $this->startAt $startAt;
  206.         return $this;
  207.     }
  208.     public function getEndAt(): ?\DateTime
  209.     {
  210.         return $this->endAt;
  211.     }
  212.     public function setEndAt(\DateTime $endAt): self
  213.     {
  214.         $this->endAt $endAt;
  215.         return $this;
  216.     }
  217.     public function getDuree(): ?int
  218.     {
  219.         return $this->duree;
  220.     }
  221.     public function setDuree(int $duree): self
  222.     {
  223.         $this->duree $duree;
  224.         return $this;
  225.     }
  226.     public function isIsGeneratedRandomQuestions(): ?bool
  227.     {
  228.         return $this->isGeneratedRandomQuestions;
  229.     }
  230.     public function setIsGeneratedRandomQuestions(bool $isGeneratedRandomQuestions): self
  231.     {
  232.         $this->isGeneratedRandomQuestions $isGeneratedRandomQuestions;
  233.         return $this;
  234.     }
  235.     /**
  236.      * @return Collection<int, EvaluationQuestion>
  237.      */
  238.     public function getEvaluationQuestions(): Collection
  239.     {
  240.         return $this->evaluationQuestions;
  241.     }
  242.     public function addEvaluationQuestion(EvaluationQuestion $evaluationQuestion): self
  243.     {
  244.         if (!$this->evaluationQuestions->contains($evaluationQuestion)) {
  245.             $this->evaluationQuestions->add($evaluationQuestion);
  246.             $evaluationQuestion->setEvaluation($this);
  247.         }
  248.         return $this;
  249.     }
  250.     public function removeEvaluationQuestion(EvaluationQuestion $evaluationQuestion): self
  251.     {
  252.         if ($this->evaluationQuestions->removeElement($evaluationQuestion)) {
  253.             // set the owning side to null (unless already changed)
  254.             if ($evaluationQuestion->getEvaluation() === $this) {
  255.                 $evaluationQuestion->setEvaluation(null);
  256.             }
  257.         }
  258.         return $this;
  259.     }
  260.     public function getSlug(): ?string
  261.     {
  262.         return $this->slug;
  263.     }
  264.     public function setSlug(string $slug): self
  265.     {
  266.         $this->slug $slug;
  267.         return $this;
  268.     }
  269.     public function isIsPassed(): ?bool
  270.     {
  271.         return $this->isPassed;
  272.     }
  273.     public function setIsPassed(bool $isPassed): self
  274.     {
  275.         $this->isPassed $isPassed;
  276.         return $this;
  277.     }
  278.     /**
  279.      * @return Collection<int, Eleve>
  280.      */
  281.     public function getEleves(): Collection
  282.     {
  283.         return $this->Eleves;
  284.     }
  285.     public function addEleve(Eleve $eleve): self
  286.     {
  287.         if (!$this->Eleves->contains($eleve)) {
  288.             $this->Eleves->add($eleve);
  289.         }
  290.         return $this;
  291.     }
  292.     public function removeEleve(Eleve $eleve): self
  293.     {
  294.         $this->Eleves->removeElement($eleve);
  295.         return $this;
  296.     }
  297.     /**
  298.      * @return Collection<int, EvaluationResultat>
  299.      */
  300.     public function getResults(): Collection
  301.     {
  302.         return $this->results;
  303.     }
  304.     public function addResult(EvaluationResultat $result): self
  305.     {
  306.         if (!$this->results->contains($result)) {
  307.             $this->results->add($result);
  308.             $result->setEvaluation($this);
  309.         }
  310.         return $this;
  311.     }
  312.     public function removeResult(EvaluationResultat $result): self
  313.     {
  314.         if ($this->results->removeElement($result)) {
  315.             // set the owning side to null (unless already changed)
  316.             if ($result->getEvaluation() === $this) {
  317.                 $result->setEvaluation(null);
  318.             }
  319.         }
  320.         return $this;
  321.     }
  322.    /**
  323.      * @return ?Enseignant
  324.      * @Groups({"read:evaluation:collection", "read:evaluation:item"})
  325.      */
  326.     public function getEnseignant(): ?Enseignant
  327.     {
  328.         return $this->enseignant;
  329.     }
  330.     public function setEnseignant(?Enseignant $enseignant): static
  331.     {
  332.         $this->enseignant $enseignant;
  333.         return $this;
  334.     }
  335.     public function isIsPublished(): ?bool
  336.     {
  337.         return $this->isPublished;
  338.     }
  339.     public function setIsPublished(?bool $isPublished): static
  340.     {
  341.         $this->isPublished $isPublished;
  342.         return $this;
  343.     }
  344. }