<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use App\Filter\ElTaskAttemptFilter;
use ApiPlatform\Core\Annotation\ApiFilter;
use App\Repository\ElTaskAttemptRepository;
use ApiPlatform\Core\Annotation\ApiResource;
use App\Entity\Interfaces\ContainerMappedInterface;
use Symfony\Component\Serializer\Annotation\Groups;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\DateFilter;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\OrderFilter;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter;
/**
* @ApiResource(
* collectionOperations={
* "get"={
* "security"="is_granted('IS_AUTHENTICATED_FULLY')",
* "normalization_context"={"groups"={"ElTaskAttempt:Read"}, "skip_null_values"=false}
* },
* "post_start_task"={
* "route_name"="api_el_task_attempts_start_task",
* "method"="POST",
* "security"="is_granted('IS_AUTHENTICATED_FULLY')",
* "denormalization_context"={"groups"={"ElTaskAttempt:Start-Task"}}
* }
* },
* itemOperations={
* "get"={
* "security"="is_granted('IS_CO_ANY_SPE', object)",
* "normalization_context"={"groups"={"ElTaskAttempt:Read"}, "skip_null_values"=false}
* },
* "patch_end_task"={
* "route_name"="api_el_task_attempts_end_task",
* "method"="PATCH",
* "security"="is_granted('IS_CO_ANY_SPE', object)",
* "denormalization_context"={"groups"={"ElTaskAttempt:End-Task"}}
* },
* "patch_update_time"={
* "path"="/el_task_attempts/{id}/update-time",
* "method"="PATCH",
* "security"="is_granted('IS_CO_ANY_SPE', object)",
* "denormalization_context"={"groups"={"ElTaskAttempt:Update-Time"}}
* },
* "delete"={"security"="is_granted('IS_CO_ANY_SPE', object)"}
* }
* )
* @ApiFilter(SearchFilter::class, properties={"id": "exact", "container.id": "exact", "elTask.id": "exact", "elTask.elCourse.id": "exact", "elTask.elLession.id": "exact", "elTask.elLessionTopic.id": "exact", "user.id": "exact", "status": "exact"})
* @ApiFilter(DateFilter::class, properties={"start", "end"})
* @ApiFilter(ElTaskAttemptFilter::class, properties={"search": "partial"})
* @ApiFilter(OrderFilter::class, properties={"id", "start", "end", "status"})
* @ORM\Entity(repositoryClass=ElTaskAttemptRepository::class)
*/
class ElTaskAttempt implements ContainerMappedInterface
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
* @Groups({"ElTaskAttempt:Read", "User:Me"})
*/
private $id;
/**
* @ORM\Column(type="datetime", nullable=true)
* @Groups({"ElTaskAttempt:Read", "User:Me"})
*/
private $start;
/**
* @ORM\Column(type="datetime", nullable=true)
* @Groups({"ElTaskAttempt:Read", "User:Me"})
*/
private $end;
/**
* @ORM\Column(type="string", length=16)
* @Groups({"ElTaskAttempt:Read", "User:Me"})
*/
private $status;
public const STATUSTASKATTEMPT_STARTED = "STARTED";
public const STATUSTASKATTEMPT_COMPLETED = "COMPLETED";
public const STATUSTASKATTEMPT_EXPIRED = "EXPIRED";
/**
* @ORM\ManyToOne(targetEntity=User::class, inversedBy="elTaskAttempts")
* @ORM\JoinColumn(nullable=false, onDelete="CASCADE")
* @Groups({"ElTaskAttempt:Read"})
*/
private $user;
/**
* @ORM\ManyToOne(targetEntity=ElTask::class, inversedBy="elTaskAttempts")
* @ORM\JoinColumn(nullable=false, onDelete="CASCADE")
* @Groups({"ElTaskAttempt:Read", "ElTaskAttempt:Start-Task", "User:Me"})
*/
private $elTask;
/**
* @ORM\ManyToOne(targetEntity=Container::class)
* @ORM\JoinColumn(nullable=false, onDelete="CASCADE")
* @Groups({"ElTaskAttempt:Start-Task"})
*/
private $container;
/**
* @ORM\Column(type="integer", nullable=true)
* @Groups({"ElTaskAttempt:Read", "User:Me"})
*/
private $progress;
/**
* @ORM\Column(type="integer", nullable=true)
* @Groups({"ElTaskAttempt:Read", "User:Me", "ElTaskAttempt:Update-Time"})
*/
private $videoProgress;
/**
* @ORM\Column(type="boolean", nullable=true)
* @Groups({"ElTaskAttempt:Read", "User:Me", "ElTaskAttempt:Update-Time"})
*/
private $isVideoCompleted;
public function getId(): ?int
{
return $this->id;
}
public function getStart(): ?\DateTimeInterface
{
return $this->start;
}
public function setStart(?\DateTimeInterface $start): self
{
$this->start = $start;
return $this;
}
public function getEnd(): ?\DateTimeInterface
{
return $this->end;
}
public function setEnd(?\DateTimeInterface $end): self
{
$this->end = $end;
return $this;
}
public function getStatus(): ?string
{
return $this->status;
}
public function setStatus(string $status): self
{
$this->status = $status;
return $this;
}
public function getUser(): ?User
{
return $this->user;
}
public function setUser(?User $user): self
{
$this->user = $user;
return $this;
}
public function getElTask(): ?ElTask
{
return $this->elTask;
}
public function setElTask(?ElTask $elTask): self
{
$this->elTask = $elTask;
return $this;
}
public function getContainer(): ?Container
{
return $this->container;
}
public function setContainer(?Container $container): self
{
$this->container = $container;
return $this;
}
public function getProgress(): ?int
{
return $this->progress;
}
public function setProgress(?int $progress): self
{
$this->progress = $progress;
return $this;
}
public function getVideoProgress(): ?int
{
return $this->videoProgress;
}
public function setVideoProgress(?int $videoProgress): self
{
$this->videoProgress = $videoProgress;
return $this;
}
public function getIsVideoCompleted(): ?bool
{
return $this->isVideoCompleted;
}
public function setIsVideoCompleted(?bool $isVideoCompleted): self
{
$this->isVideoCompleted = $isVideoCompleted;
return $this;
}
}