src/Entity/Evaluation.php line 21

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Course;
  4. use App\Entity\SchoolYear;
  5. use App\Entity\Attribution;
  6. use Doctrine\DBAL\Types\Types;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use App\Entity\Traits\TimeStampable;
  9. use Doctrine\Persistence\ObjectManager;
  10. use App\Repository\EvaluationRepository;
  11. use Doctrine\ORM\EntityManagerInterface;
  12. use Doctrine\Common\Collections\Collection;
  13. use Doctrine\Persistence\Mapping\ClassMetadata;
  14. use Doctrine\Common\Collections\ArrayCollection;
  15. /**
  16.  * @ORM\Entity(repositoryClass=EvaluationRepository::class)
  17.  */
  18. class Evaluation 
  19. {
  20.     use TimeStampable;
  21.     public const NUM_ITEMS_PER_PAGE 20;
  22.     /**
  23.      * @ORM\Id
  24.      * @ORM\GeneratedValue
  25.      * @ORM\Column(type="integer")
  26.      */
  27.     private $id;
  28.     /**
  29.      * @ORM\ManyToOne(targetEntity=Sequence::class, inversedBy="evaluations")
  30.      * @ORM\JoinColumn(nullable=false)
  31.      */
  32.     private $sequence;
  33.     /**
  34.      * @ORM\Column(type="float")
  35.      */
  36.     private $moyenne;
  37.     /**
  38.      * @ORM\Column(type="text", nullable=true)
  39.      */
  40.     private $competence;
  41.     /**
  42.      * @ORM\Column(type="integer", options={"default":0})
  43.      */
  44.     private $abscent;
  45.     /**
  46.      * @ORM\Column(type="integer" , options={"default":0})
  47.      */
  48.     private $successH;
  49.     /**
  50.      * @ORM\Column(type="integer", options={"default":0})
  51.      */
  52.     private $successF;
  53.     /**
  54.      * @ORM\Column(type="integer", options={"default":0})
  55.      */
  56.     private $failluresH;
  57.     /**
  58.      * @ORM\Column(type="integer", options={"default":0})
  59.      */
  60.     private $failluresF;
  61.     /**
  62.      * @ORM\ManyToOne(targetEntity=Course::class, inversedBy="evaluations")
  63.      * @ORM\JoinColumn(nullable=false)
  64.      */
  65.     private $course;
  66.     /**
  67.      * @ORM\ManyToOne(targetEntity=ClassRoom::class)
  68.      * @ORM\JoinColumn(nullable=false)
  69.      */
  70.     private $classRoom;
  71.     
  72.     /**
  73.      * @ORM\ManyToOne(targetEntity=User::class)
  74.      * @ORM\JoinColumn(nullable=true)
  75.      */
  76.     private $author;
  77.     /**
  78.      * @ORM\OneToMany(targetEntity=Mark::class, mappedBy="evaluation", orphanRemoval=true)
  79.      */
  80.     private $marks;
  81.     public function __construct()
  82.     {
  83.         $this->marks = new ArrayCollection();
  84.         $this->setFailluresF(0);
  85.         $this->setFailluresH(0);
  86.         $this->setSuccessF(0);
  87.         $this->setSuccessH(0);
  88.         $this->setAbscent(0);
  89.         $this->createdAt= new \DateTime();
  90.         $this->updatedAt= new \DateTime();
  91.        
  92.     }
  93.     public function injectObjectManager(
  94.         ObjectManager $objectManager,
  95.         ClassMetadata $classMetadata
  96.     ) {
  97.         $this->em $objectManager;
  98.     }
  99.     
  100.     public function getTeacher() {
  101.        
  102.         $year  $this->em->getRepository(SchoolYear::class)->findOneBy(array("activated" => true));
  103.         $attribution  $this->em->getRepository(Attribution::class)->findOneBy(array("schoolYear" => $year"course" => $this->getCourse()));
  104.         return $attribution->getTeacher();
  105.     }
  106.  
  107.     public function getId(): ?int
  108.     {
  109.         return $this->id;
  110.     }
  111.     public function getSequence(): ?Sequence
  112.     {
  113.         return $this->sequence;
  114.     }
  115.     public function setSequence(?Sequence $sequence): self
  116.     {
  117.         $this->sequence $sequence;
  118.         return $this;
  119.     }
  120.     public function getMoyenne(): ?float
  121.     {
  122.         return $this->moyenne;
  123.     }
  124.     
  125.     public function setMoyenne(float $moyenne): self
  126.     {
  127.         $this->moyenne $moyenne;
  128.         return $this;
  129.     }
  130.     public function getCompetence(): ?string
  131.     {
  132.         return $this->competence;
  133.     }
  134.     public function setCompetence(?string $competence): self
  135.     {
  136.         $this->competence $competence;
  137.         return $this;
  138.     }
  139.     public function getAbscent(): ?int
  140.     {
  141.         return $this->abscent;
  142.     }
  143.     public function setAbscent(int $abscent): self
  144.     {
  145.         $this->abscent $abscent;
  146.         return $this;
  147.     }
  148.     public function getSuccessH(): ?int
  149.     {
  150.         return $this->successH;
  151.     }
  152.     public function setSuccessH(int $successH): self
  153.     {
  154.         $this->successH $successH;
  155.         return $this;
  156.     }
  157.     public function getSuccessF(): ?int
  158.     {
  159.         return $this->successF;
  160.     }
  161.     public function setSuccessF(int $successF): self
  162.     {
  163.         $this->successF $successF;
  164.         return $this;
  165.     }
  166.     public function getFailluresH(): ?int
  167.     {
  168.         return $this->failluresH;
  169.     }
  170.     public function setFailluresH(int $failluresH): self
  171.     {
  172.         $this->failluresH $failluresH;
  173.         return $this;
  174.     }
  175.     public function getFailluresF(): ?int
  176.     {
  177.         return $this->failluresF;
  178.     }
  179.     public function setFailluresF(int $failluresF): self
  180.     {
  181.         $this->failluresF $failluresF;
  182.         return $this;
  183.     }
  184.         /**
  185.     * Set successF
  186.     *
  187.     *
  188.     * @return Evaluation
  189.     */
  190.     public function addSuccessF()
  191.     {
  192.         $this->successF++;
  193.         return $this;
  194.     }
  195.   
  196.        /**
  197.     * Set successF
  198.     *
  199.     *
  200.     * @return Evaluation
  201.     */
  202.     public function addSuccessH()
  203.     {
  204.         $this->successH++;
  205.         return $this;
  206.     }
  207.     /**
  208.     * Add failluresF
  209.     *
  210.     *
  211.     * @return Evaluation
  212.     */
  213.     public function addFailluresH()
  214.     {
  215.         $this->failluresH++;
  216.         return $this;
  217.     }
  218.   
  219.      /**
  220.     * Add Abscent
  221.     *
  222.     *
  223.     * @return Evaluation
  224.     */
  225.     public function addAbscent()
  226.     {
  227.         $this->abscent++;
  228.         return $this;
  229.     }
  230.       /**
  231.      * Set failluresF
  232.      *
  233.      * @param integer $failluresF
  234.      *
  235.      * @return Evaluation
  236.      */
  237.     public function addFailluresF()
  238.     {
  239.         $this->failluresF++;
  240.         return $this;
  241.     }
  242.     
  243.     public function getCourse(): ?Course
  244.     {
  245.         return $this->course;
  246.     }
  247.     public function setCourse(?Course $course): self
  248.     {
  249.         $this->course $course;
  250.         return $this;
  251.     }
  252.     public function getClassRoom(): ?ClassRoom
  253.     {
  254.         return $this->classRoom;
  255.     }
  256.     public function setClassRoom(?ClassRoom $classRoom): self
  257.     {
  258.         $this->classRoom $classRoom;
  259.         return $this;
  260.     }
  261.     /**
  262.      * @return Collection|Mark[]
  263.      */
  264.     public function getMarks(): Collection
  265.     {
  266.         return $this->marks;
  267.     }
  268.     public function addMark(Mark $mark): self
  269.     {
  270.         if (!$this->marks->contains($mark)) {
  271.             $this->marks[] = $mark;
  272.             $mark->setEvaluation($this);
  273.         }
  274.         return $this;
  275.     }
  276.     public function removeMark(Mark $mark): self
  277.     {
  278.         if ($this->marks->removeElement($mark)) {
  279.             // set the owning side to null (unless already changed)
  280.             if ($mark->getEvaluation() === $this) {
  281.                 $mark->setEvaluation(null);
  282.             }
  283.         }
  284.         return $this;
  285.     }
  286.     public function getAuthor(): ?User
  287.     {
  288.         return $this->author;
  289.     }
  290.     public function setAuthor(?User $author): static
  291.     {
  292.         $this->author $author;
  293.         return $this;
  294.     }
  295. }