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.      * @ORM\OneToMany(targetEntity=Mark::class, mappedBy="evaluation", orphanRemoval=true)
  73.      */
  74.     private $marks;
  75.     public function __construct()
  76.     {
  77.         $this->marks = new ArrayCollection();
  78.         $this->setFailluresF(0);
  79.         $this->setFailluresH(0);
  80.         $this->setSuccessF(0);
  81.         $this->setSuccessH(0);
  82.         $this->setAbscent(0);
  83.         $this->createdAt= new \DateTime();
  84.         $this->updatedAt= new \DateTime();
  85.        
  86.     }
  87.     public function injectObjectManager(
  88.         ObjectManager $objectManager,
  89.         ClassMetadata $classMetadata
  90.     ) {
  91.         $this->em $objectManager;
  92.     }
  93.     
  94.     public function getTeacher() {
  95.        
  96.         $year  $this->em->getRepository(SchoolYear::class)->findOneBy(array("activated" => true));
  97.         $attribution  $this->em->getRepository(Attribution::class)->findOneBy(array("schoolYear" => $year"course" => $this->getCourse()));
  98.         return $attribution->getTeacher();
  99.     }
  100.  
  101.     public function getId(): ?int
  102.     {
  103.         return $this->id;
  104.     }
  105.     public function getSequence(): ?Sequence
  106.     {
  107.         return $this->sequence;
  108.     }
  109.     public function setSequence(?Sequence $sequence): self
  110.     {
  111.         $this->sequence $sequence;
  112.         return $this;
  113.     }
  114.     public function getMoyenne(): ?float
  115.     {
  116.         return $this->moyenne;
  117.     }
  118.     
  119.     public function setMoyenne(float $moyenne): self
  120.     {
  121.         $this->moyenne $moyenne;
  122.         return $this;
  123.     }
  124.     public function getCompetence(): ?string
  125.     {
  126.         return $this->competence;
  127.     }
  128.     public function setCompetence(?string $competence): self
  129.     {
  130.         $this->competence $competence;
  131.         return $this;
  132.     }
  133.     public function getAbscent(): ?int
  134.     {
  135.         return $this->abscent;
  136.     }
  137.     public function setAbscent(int $abscent): self
  138.     {
  139.         $this->abscent $abscent;
  140.         return $this;
  141.     }
  142.     public function getSuccessH(): ?int
  143.     {
  144.         return $this->successH;
  145.     }
  146.     public function setSuccessH(int $successH): self
  147.     {
  148.         $this->successH $successH;
  149.         return $this;
  150.     }
  151.     public function getSuccessF(): ?int
  152.     {
  153.         return $this->successF;
  154.     }
  155.     public function setSuccessF(int $successF): self
  156.     {
  157.         $this->successF $successF;
  158.         return $this;
  159.     }
  160.     public function getFailluresH(): ?int
  161.     {
  162.         return $this->failluresH;
  163.     }
  164.     public function setFailluresH(int $failluresH): self
  165.     {
  166.         $this->failluresH $failluresH;
  167.         return $this;
  168.     }
  169.     public function getFailluresF(): ?int
  170.     {
  171.         return $this->failluresF;
  172.     }
  173.     public function setFailluresF(int $failluresF): self
  174.     {
  175.         $this->failluresF $failluresF;
  176.         return $this;
  177.     }
  178.         /**
  179.     * Set successF
  180.     *
  181.     *
  182.     * @return Evaluation
  183.     */
  184.     public function addSuccessF()
  185.     {
  186.         $this->successF++;
  187.         return $this;
  188.     }
  189.   
  190.        /**
  191.     * Set successF
  192.     *
  193.     *
  194.     * @return Evaluation
  195.     */
  196.     public function addSuccessH()
  197.     {
  198.         $this->successH++;
  199.         return $this;
  200.     }
  201.     /**
  202.     * Add failluresF
  203.     *
  204.     *
  205.     * @return Evaluation
  206.     */
  207.     public function addFailluresH()
  208.     {
  209.         $this->failluresH++;
  210.         return $this;
  211.     }
  212.   
  213.      /**
  214.     * Add Abscent
  215.     *
  216.     *
  217.     * @return Evaluation
  218.     */
  219.     public function addAbscent()
  220.     {
  221.         $this->abscent++;
  222.         return $this;
  223.     }
  224.       /**
  225.      * Set failluresF
  226.      *
  227.      * @param integer $failluresF
  228.      *
  229.      * @return Evaluation
  230.      */
  231.     public function addFailluresF()
  232.     {
  233.         $this->failluresF++;
  234.         return $this;
  235.     }
  236.     
  237.     public function getCourse(): ?Course
  238.     {
  239.         return $this->course;
  240.     }
  241.     public function setCourse(?Course $course): self
  242.     {
  243.         $this->course $course;
  244.         return $this;
  245.     }
  246.     public function getClassRoom(): ?ClassRoom
  247.     {
  248.         return $this->classRoom;
  249.     }
  250.     public function setClassRoom(?ClassRoom $classRoom): self
  251.     {
  252.         $this->classRoom $classRoom;
  253.         return $this;
  254.     }
  255.     /**
  256.      * @return Collection|Mark[]
  257.      */
  258.     public function getMarks(): Collection
  259.     {
  260.         return $this->marks;
  261.     }
  262.     public function addMark(Mark $mark): self
  263.     {
  264.         if (!$this->marks->contains($mark)) {
  265.             $this->marks[] = $mark;
  266.             $mark->setEvaluation($this);
  267.         }
  268.         return $this;
  269.     }
  270.     public function removeMark(Mark $mark): self
  271.     {
  272.         if ($this->marks->removeElement($mark)) {
  273.             // set the owning side to null (unless already changed)
  274.             if ($mark->getEvaluation() === $this) {
  275.                 $mark->setEvaluation(null);
  276.             }
  277.         }
  278.         return $this;
  279.     }
  280. }