first commit
This commit is contained in:
186
src/Entity/ContribIa.php
Normal file
186
src/Entity/ContribIa.php
Normal file
@@ -0,0 +1,186 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use App\Repository\ContribIaRepository;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
|
||||
#[ORM\Entity(repositoryClass: ContribIaRepository::class)]
|
||||
#[ORM\Table(name: 'contrib_ia')]
|
||||
#[ORM\CheckConstraints([
|
||||
new ORM\CheckConstraint(
|
||||
name: 'check_evaluation_pertinence',
|
||||
expression: 'evaluation_pertinence >= 1 AND evaluation_pertinence <= 5'
|
||||
),
|
||||
new ORM\CheckConstraint(
|
||||
name: 'check_evaluation_temps',
|
||||
expression: 'evaluation_temps >= 1 AND evaluation_temps <= 5'
|
||||
),
|
||||
])]
|
||||
class ContribIa
|
||||
{
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column(type: 'integer')]
|
||||
private ?int $id = null;
|
||||
|
||||
#[ORM\ManyToOne(targetEntity: AssistantIa::class, inversedBy: 'contribIas')]
|
||||
#[ORM\JoinColumn(nullable: false)]
|
||||
#[Assert\NotNull(message: 'L\'assistant IA est obligatoire.')]
|
||||
private ?AssistantIa $assistantIa = null;
|
||||
|
||||
#[ORM\ManyToOne(targetEntity: Contribution::class, inversedBy: 'contribIas')]
|
||||
#[ORM\JoinColumn(nullable: false)]
|
||||
#[Assert\NotNull(message: 'La contribution est obligatoire.')]
|
||||
private ?Contribution $contribution = null;
|
||||
|
||||
#[ORM\Column(type: 'integer', nullable: true)]
|
||||
#[Assert\Range(
|
||||
min: 1,
|
||||
max: 5,
|
||||
notInRangeMessage: 'L\'évaluation de pertinence doit être comprise entre {{ min }} et {{ max }}.'
|
||||
)]
|
||||
private ?int $evaluationPertinence = null;
|
||||
|
||||
#[ORM\Column(type: 'integer', nullable: true)]
|
||||
#[Assert\Range(
|
||||
min: 1,
|
||||
max: 5,
|
||||
notInRangeMessage: 'L\'évaluation de temps doit être comprise entre {{ min }} et {{ max }}.'
|
||||
)]
|
||||
private ?int $evaluationTemps = null;
|
||||
|
||||
#[ORM\Column(type: Types::TEXT, nullable: true)]
|
||||
private ?string $commentaire = null;
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getAssistantIa(): ?AssistantIa
|
||||
{
|
||||
return $this->assistantIa;
|
||||
}
|
||||
|
||||
public function setAssistantIa(?AssistantIa $assistantIa): static
|
||||
{
|
||||
$this->assistantIa = $assistantIa;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getContribution(): ?Contribution
|
||||
{
|
||||
return $this->contribution;
|
||||
}
|
||||
|
||||
public function setContribution(?Contribution $contribution): static
|
||||
{
|
||||
$this->contribution = $contribution;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getEvaluationPertinence(): ?int
|
||||
{
|
||||
return $this->evaluationPertinence;
|
||||
}
|
||||
|
||||
public function setEvaluationPertinence(?int $evaluationPertinence): static
|
||||
{
|
||||
$this->evaluationPertinence = $evaluationPertinence;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getEvaluationTemps(): ?int
|
||||
{
|
||||
return $this->evaluationTemps;
|
||||
}
|
||||
|
||||
public function setEvaluationTemps(?int $evaluationTemps): static
|
||||
{
|
||||
$this->evaluationTemps = $evaluationTemps;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCommentaire(): ?string
|
||||
{
|
||||
return $this->commentaire;
|
||||
}
|
||||
|
||||
public function setCommentaire(?string $commentaire): static
|
||||
{
|
||||
$this->commentaire = $commentaire;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retourne la moyenne des deux évaluations
|
||||
*/
|
||||
public function getMoyenneEvaluation(): ?float
|
||||
{
|
||||
if ($this->evaluationPertinence === null && $this->evaluationTemps === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$count = 0;
|
||||
$total = 0;
|
||||
|
||||
if ($this->evaluationPertinence !== null) {
|
||||
$total += $this->evaluationPertinence;
|
||||
$count++;
|
||||
}
|
||||
|
||||
if ($this->evaluationTemps !== null) {
|
||||
$total += $this->evaluationTemps;
|
||||
$count++;
|
||||
}
|
||||
|
||||
return round($total / $count, 2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retourne un libellé pour l'évaluation de pertinence
|
||||
*/
|
||||
public function getLibellePertinence(): string
|
||||
{
|
||||
return match ($this->evaluationPertinence) {
|
||||
1 => 'Très faible',
|
||||
2 => 'Faible',
|
||||
3 => 'Moyen',
|
||||
4 => 'Bon',
|
||||
5 => 'Excellent',
|
||||
default => 'Non évalué',
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Retourne un libellé pour l'évaluation de temps
|
||||
*/
|
||||
public function getLibelleTemps(): string
|
||||
{
|
||||
return match ($this->evaluationTemps) {
|
||||
1 => 'Très lent',
|
||||
2 => 'Lent',
|
||||
3 => 'Moyen',
|
||||
4 => 'Rapide',
|
||||
5 => 'Très rapide',
|
||||
default => 'Non évalué',
|
||||
};
|
||||
}
|
||||
|
||||
public function __toString(): string
|
||||
{
|
||||
return sprintf(
|
||||
'IA: %s - Contribution: %s',
|
||||
$this->assistantIa ? $this->assistantIa->getNom() : '',
|
||||
$this->contribution ? $this->contribution->__toString() : ''
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user