| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436 |
- <?php
- namespace AppBundle\Entity\Education;
- use AppBundle\Entity\Core\Tagg;
- use AppBundle\Enum\Education\TypeCriteriaEnum;
- use Doctrine\Common\Collections\ArrayCollection;
- use Doctrine\ORM\Mapping as ORM;
- use Dunglas\ApiBundle\Annotation\Iri;
- use Symfony\Component\Serializer\Annotation\Groups;
- use Symfony\Component\Validator\Constraints as Assert;
- use AppBundle\Entity\Traits\TimestampableEntity;
- use AppBundle\Entity\Traits\CreatorUpdaterEntity;
- /**
- * Notes d'un élève pour un enseignement suivi EducationStudent
- *
- * @Iri("http://schema.org/EducationNotation")
- */
- #[ORM\Entity(repositoryClass: 'AppBundle\Entity\Education\Repository\EducationNotationRepository')]
- class EducationNotation
- {
- use TimestampableEntity;
- use CreatorUpdaterEntity;
- /**
- * @var int
- */
- #[ORM\Column(type: 'integer')]
- #[ORM\Id]
- #[ORM\GeneratedValue(strategy: 'AUTO')]
- #[Groups(['educationnotation', 'report_card_educationstudent', 'educationnotation_list', 'educationstudent_notation', 'education_input_list'])]
- private $id;
- /**
- * @var EducationStudent
- */
- #[ORM\ManyToOne(targetEntity: 'EducationStudent', inversedBy: 'educationNotations')]
- #[ORM\JoinColumn(nullable: false)]
- #[Assert\NotNull]
- #[Groups(['educationnotation', 'educationnotation_list'])]
- private $educationStudent;
- /**
- * @var CriteriaNotation
- */
- #[ORM\ManyToOne(targetEntity: 'AppBundle\Entity\Education\CriteriaNotation', inversedBy: 'educationNotations')]
- #[ORM\JoinColumn(referencedColumnName: 'id', nullable: true, onDelete: 'SET NULL')]
- #[Groups(['educationnotation', 'report_card_educationstudent', 'educationnotation_list', 'educationstudent_notation_educationnotations', 'education_input_list_educationnotations'])]
- private $criteriaNotation;
- /**
- * @var EducationNotationCriteriaConfig
- */
- #[ORM\ManyToOne(targetEntity: 'AppBundle\Entity\Education\EducationNotationCriteriaConfig', inversedBy: 'educationNotations')]
- #[ORM\JoinColumn(referencedColumnName: 'id', nullable: true, onDelete: 'SET NULL')]
- #[Groups(['educationnotation', 'report_card_educationstudent', 'educationnotation_list', 'educationstudent_notation_educationnotations', 'education_input_list_educationnotations'])]
- private $criteriaNotationConfig;
- /**
- * @var string
- */
- #[ORM\Column(type: 'text', nullable: true)]
- #[Assert\Type(type: 'string')]
- #[Groups(['educationnotation', 'report_card_educationstudent', 'educationstudent_notation_educationnotations', 'educationnotation_list'])]
- private $freeCriterion;
- /**
- * @var string
- */
- #[ORM\Column(type: 'string', nullable: true)]
- #[Assert\Choice(callback: ['\AppBundle\Enum\Education\PeriodEnum', 'toArray'], multiple: false)]
- #[Groups(['educationnotation', 'report_card_educationstudent', 'educationnotation_list', 'educationstudent_notation_educationnotations', 'education_input_list_educationnotations'])]
- private $period;
- /**
- * @var \DateTime
- */
- #[ORM\Column(type: 'date', nullable: true)]
- #[Assert\Date]
- #[Groups(['educationnotation', 'educationstudent_notation_educationnotations', 'educationnotation_list'])]
- private $date;
- /**
- * @var float
- */
- #[ORM\Column(type: 'decimal', nullable: true, precision: 10, scale: 2)]
- #[Assert\GreaterThanOrEqual(value: 0)]
- #[Assert\LessThanOrEqual(value: 100, message: 'lessThanOrEqual20')]
- #[Groups(['educationnotation', 'report_card_educationstudent', 'educationnotation_list', 'educationstudent_notation_educationnotations', 'education_input_list_educationnotations'])]
- private $note;
- /**
- * @var string
- */
- #[ORM\Column(type: 'string', nullable: true)]
- #[Groups(['educationnotation', 'report_card_educationstudent', 'educationnotation_list', 'educationstudent_notation_educationnotations', 'education_input_list_educationnotations'])]
- private $mention;
- /**
- * @var string
- */
- #[ORM\Column(type: 'text', nullable: true)]
- #[Assert\Type(type: 'string')]
- #[Groups(['educationnotation', 'report_card_educationstudent', 'educationstudent_notation_educationnotations', 'educationnotation_list'])]
- private $appreciation;
- /**
- * @var bool
- */
- #[ORM\Column(type: 'boolean', options: ['default' => false])]
- #[Assert\Type(type: 'boolean')]
- #[Assert\NotNull]
- #[Groups(['educationnotation', 'report_card_educationstudent', 'educationstudent_notation_educationnotations', 'educationnotation_list'])]
- private $isValid = false;
- /**
- * @var string
- */
- #[Groups(['educationnotation', 'educationstudent_notation_educationnotations', 'educationnotation_list'])]
- private $noteTemplate;
- /**
- * @var string
- */
- #[Groups(['educationnotation', 'educationstudent_notation_educationnotations', 'educationnotation_list'])]
- private $noteOriTemplate;
- /**
- * @var ArrayCollection<Tagg>
- */
- #[ORM\ManyToMany(targetEntity: 'AppBundle\Entity\Core\Tagg', cascade: ['persist'], inversedBy: 'educationNotations')]
- #[Assert\Valid]
- #[ORM\JoinTable(name: 'tag_educationNotation', joinColumns: [], inverseJoinColumns: [])]
- #[ORM\JoinColumn(name: 'educationNotation_id', referencedColumnName: 'id')]
- #[ORM\JoinColumn(name: 'tag_id', referencedColumnName: 'id')]
- #[Groups(['eductionnotation_tags', 'educationstudent_notation_educationnotations', 'manage_tags'])]
- private $tags;
- public function __construct() {
- $this->tags = new ArrayCollection();
- }
- /**
- * Sets id.
- *
- * @param int $id
- *
- * @return $this
- */
- public function setId($id)
- {
- $this->id = $id;
- return $this;
- }
- /**
- * Gets id.
- *
- * @return int
- */
- public function getId()
- {
- return $this->id;
- }
- /**
- * Sets criteriaNotation.
- *
- * @param CriteriaNotation $criteriaNotation
- *
- * @return $this
- */
- public function setCriteriaNotation($criteriaNotation)
- {
- $this->criteriaNotation = $criteriaNotation;
- return $this;
- }
- /**
- * Gets criteriaNotation.
- *
- * @return CriteriaNotation
- */
- public function getCriteriaNotation()
- {
- return $this->criteriaNotation;
- }
- /**
- * Sets freeCriterion.
- *
- * @param string $freeCriterion
- *
- * @return $this
- */
- public function setFreeCriterion($freeCriterion)
- {
- $this->freeCriterion = $freeCriterion;
- return $this;
- }
- /**
- * Gets freeCriterion.
- *
- * @return string
- */
- public function getFreeCriterion()
- {
- return $this->freeCriterion;
- }
- /**
- * Sets period.
- *
- * @param string $period
- *
- * @return $this
- */
- public function setPeriod($period)
- {
- if(empty($period) || $period=='')
- $period = null;
- $this->period = $period;
- return $this;
- }
- /**
- * Gets period.
- *
- * @return string
- */
- public function getPeriod()
- {
- return $this->period;
- }
- /**
- * Sets date.
- *
- * @param \DateTime $date
- *
- * @return $this
- */
- public function setDate(\DateTime $date = null)
- {
- $this->date = $date;
- return $this;
- }
- /**
- * Gets date.
- *
- * @return \DateTime
- */
- public function getDate()
- {
- return $this->date ? $this->date->format('Y-m-d') : $this->date;
- }
- /**
- * Sets note.
- *
- * @param float $note
- *
- * @return $this
- */
- public function setNote($note)
- {
- $this->note = (!is_null($note)) ? floatval($note) : $note;
- return $this;
- }
- /**
- * Gets note.
- *
- * @return float
- */
- public function getNote()
- {
- if(is_null($this->note)) return $this->note;
- return round ( $this->note , 2 );
- }
- /**
- * Sets mention.
- *
- * @param string $mention
- *
- * @return $this
- */
- public function setMention($mention)
- {
- $this->mention = $mention;
- return $this;
- }
- /**
- * Gets mention.
- *
- * @return string
- */
- public function getMention()
- {
- return $this->mention;
- }
- /**
- * Sets appreciation.
- *
- * @param string $appreciation
- *
- * @return $this
- */
- public function setAppreciation($appreciation)
- {
- $this->appreciation = $appreciation;
- return $this;
- }
- /**
- * Gets appreciation.
- *
- * @return string
- */
- public function getAppreciation()
- {
- return $this->appreciation;
- }
- /**
- * Set isValid
- *
- * @param boolean $isValid
- *
- * @return EducationNotation
- */
- public function setIsValid($isValid)
- {
- $this->isValid = $isValid;
- return $this;
- }
- /**
- * Get isValid
- *
- * @return boolean
- */
- public function getIsValid()
- {
- return $this->isValid;
- }
- /**
- * Set educationStudent
- *
- * @param \AppBundle\Entity\Education\EducationStudent $educationStudent
- *
- * @return EducationNotation
- */
- public function setEducationStudent(\AppBundle\Entity\Education\EducationStudent $educationStudent)
- {
- $this->educationStudent = $educationStudent;
- return $this;
- }
- /**
- * Get educationStudent
- *
- * @return \AppBundle\Entity\Education\EducationStudent
- */
- public function getEducationStudent()
- {
- return $this->educationStudent;
- }
- /**
- * Add tag
- *
- * @param \AppBundle\Entity\Core\Tagg $tag
- *
- * @return EducationNotation
- */
- public function addTag(\AppBundle\Entity\Core\Tagg $tag)
- {
- $this->tags[] = $tag;
- return $this;
- }
- /**
- * Remove tag
- *
- * @param \AppBundle\Entity\Core\Tagg $tag
- */
- public function removeTag(\AppBundle\Entity\Core\Tagg $tag)
- {
- $this->tags->removeElement($tag);
- }
- /**
- * Get tags
- *
- * @return \Doctrine\Common\Collections\Collection
- */
- public function getTags()
- {
- return $this->tags;
- }
- public function getNoteTemplate($withNoteMax = true)
- {
- if(is_null($this->getNote())) return null;
- if(!$this->getCriteriaNotation()) return null;
- if($this->getCriteriaNotation()->getType() !== TypeCriteriaEnum::WITH_NOTATION) return null;
- $noteMax = $this->getEducationStudent()->getAccess()->getOrganization()->getParameters()->getAverage();
- $note = (!is_null($this->getNote())) ? floatval(($this->getNote() * $noteMax) / 100) : $this->getNote();
- $note = round ( $note , 2 );
- return $withNoteMax ? $note . '/'. $noteMax : $note;
- }
- public function getNoteOriTemplate($withNoteMax = true)
- {
- if(is_null($this->getNote())) return null;
- if(!$this->getCriteriaNotation()) return null;
- if($this->getCriteriaNotation()->getType() !== TypeCriteriaEnum::WITH_NOTATION) return null;
- $noteMax = $this->getCriteriaNotation()->getNoteMax();
- $note = (!is_null($this->getNote())) ? floatval(($this->getNote() * $noteMax) / 100) : $this->getNote();
- $note = round ( $note , 2 );
- return $withNoteMax ? $note . '/'. $noteMax : $note;
- }
- /**
- * Sets criteriaNotationConfig.
- *
- * @param EducationNotationCriteriaConfig $criteriaNotationConfig
- *
- * @return $this
- */
- public function setCriteriaNotationConfig($criteriaNotationConfig)
- {
- $this->criteriaNotationConfig = $criteriaNotationConfig;
- return $this;
- }
- /**
- * Gets criteriaNotationConfig.
- *
- * @return EducationNotationCriteriaConfig
- */
- public function getCriteriaNotationConfig()
- {
- return $this->criteriaNotationConfig;
- }
- /**
- * Pour elasticsearch...
- */
- public function noteOrigine(){
- return null;
- }
- public function noteRecalcul(){
- return null;
- }
- }
|