<?php
namespace App\Entity;
use App\Repository\ActivityConfigurationRepository;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: ActivityConfigurationRepository::class)]
class ActivityConfiguration
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\ManyToOne(inversedBy: 'activityConfigurations')]
#[ORM\JoinColumn(nullable: false)]
private ?Activity $activity = null;
#[ORM\ManyToOne(inversedBy: 'activityConfigurations')]
#[ORM\JoinColumn(nullable: false)]
private ?Season $season = null;
#[ORM\Column(type: Types::JSON, nullable: true)]
private ?array $pointsConfig = null;
#[ORM\Column(type: Types::JSON, nullable: true)]
private ?array $validationConfig = null;
#[ORM\Column(type: Types::JSON, nullable: true)]
private ?array $evidenceConfig = null;
#[ORM\Column]
private ?bool $isEnabled = true;
#[ORM\Column(length: 50)]
private ?string $validationMethod = 'automatic';
public function getId(): ?int
{
return $this->id;
}
public function getActivity(): ?Activity
{
return $this->activity;
}
public function setActivity(?Activity $activity): static
{
$this->activity = $activity;
return $this;
}
public function getSeason(): ?Season
{
return $this->season;
}
public function setSeason(?Season $season): static
{
$this->season = $season;
return $this;
}
public function getPointsConfig(): ?array
{
return $this->pointsConfig;
}
public function setPointsConfig(?array $pointsConfig): static
{
$this->pointsConfig = $pointsConfig;
return $this;
}
public function getValidationConfig(): ?array
{
return $this->validationConfig;
}
public function setValidationConfig(?array $validationConfig): static
{
$this->validationConfig = $validationConfig;
return $this;
}
public function getEvidenceConfig(): ?array
{
return $this->evidenceConfig;
}
public function setEvidenceConfig(?array $evidenceConfig): static
{
$this->evidenceConfig = $evidenceConfig;
return $this;
}
public function isIsEnabled(): ?bool
{
return $this->isEnabled;
}
public function setIsEnabled(bool $isEnabled): static
{
$this->isEnabled = $isEnabled;
return $this;
}
public function getValidationMethod(): ?string
{
return $this->validationMethod;
}
public function setValidationMethod(string $validationMethod): static
{
$this->validationMethod = $validationMethod;
return $this;
}
/**
* Get the points for this activity in this season
*/
public function getPoints(): ?int
{
if ($this->pointsConfig && isset($this->pointsConfig['basePoints'])) {
return $this->pointsConfig['basePoints'];
}
return $this->activity ? $this->activity->getPoints() : 0;
}
/**
* Check if this activity is enabled for this season
*/
public function isEnabled(): bool
{
return $this->isEnabled;
}
/**
* Get the maximum submissions per period for this activity in this season
*/
public function getMaxPerPeriod(): ?int
{
if ($this->pointsConfig && isset($this->pointsConfig['maxPerPeriod'])) {
return $this->pointsConfig['maxPerPeriod'];
}
return $this->activity ? $this->activity->getMaxPerPeriod() : 0;
}
/**
* Check if evidence is required for this activity in this season
*/
public function isEvidenceRequired(): bool
{
if ($this->evidenceConfig && isset($this->evidenceConfig['required'])) {
return $this->evidenceConfig['required'];
}
return $this->activity ? $this->activity->isEvidenceRequired() : false;
}
}