src/Entity/ElTaskAttempt.php line 56

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use App\Filter\ElTaskAttemptFilter;
  5. use ApiPlatform\Core\Annotation\ApiFilter;
  6. use App\Repository\ElTaskAttemptRepository;
  7. use ApiPlatform\Core\Annotation\ApiResource;
  8. use App\Entity\Interfaces\ContainerMappedInterface;
  9. use Symfony\Component\Serializer\Annotation\Groups;
  10. use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\DateFilter;
  11. use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\OrderFilter;
  12. use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter;
  13. /**
  14.  * @ApiResource(
  15.  *      collectionOperations={
  16.  *          "get"={
  17.  *              "security"="is_granted('IS_AUTHENTICATED_FULLY')",
  18.  *              "normalization_context"={"groups"={"ElTaskAttempt:Read"}, "skip_null_values"=false}
  19.  *          },
  20.  *          "post_start_task"={
  21.  *              "route_name"="api_el_task_attempts_start_task",
  22.  *              "method"="POST",
  23.  *              "security"="is_granted('IS_AUTHENTICATED_FULLY')",
  24.  *              "denormalization_context"={"groups"={"ElTaskAttempt:Start-Task"}}
  25.  *          }
  26.  *      },
  27.  *      itemOperations={
  28.  *          "get"={
  29.  *              "security"="is_granted('IS_CO_ANY_SPE', object)",
  30.  *              "normalization_context"={"groups"={"ElTaskAttempt:Read"}, "skip_null_values"=false}
  31.  *          },
  32.  *          "patch_end_task"={
  33.  *              "route_name"="api_el_task_attempts_end_task",
  34.  *              "method"="PATCH",
  35.  *              "security"="is_granted('IS_CO_ANY_SPE', object)",
  36.  *              "denormalization_context"={"groups"={"ElTaskAttempt:End-Task"}}
  37.  *          },
  38.  *          "patch_update_time"={
  39.  *              "path"="/el_task_attempts/{id}/update-time",
  40.  *              "method"="PATCH",
  41.  *              "security"="is_granted('IS_CO_ANY_SPE', object)",
  42.  *              "denormalization_context"={"groups"={"ElTaskAttempt:Update-Time"}}
  43.  *          },
  44.  *          "delete"={"security"="is_granted('IS_CO_ANY_SPE', object)"}
  45.  *     }
  46.  * )
  47.  * @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"})
  48.  * @ApiFilter(DateFilter::class, properties={"start", "end"})
  49.  * @ApiFilter(ElTaskAttemptFilter::class, properties={"search": "partial"})
  50.  * @ApiFilter(OrderFilter::class, properties={"id", "start", "end", "status"})
  51.  * @ORM\Entity(repositoryClass=ElTaskAttemptRepository::class)
  52.  */
  53. class ElTaskAttempt implements ContainerMappedInterface
  54. {
  55.     /**
  56.      * @ORM\Id
  57.      * @ORM\GeneratedValue
  58.      * @ORM\Column(type="integer")
  59.      * @Groups({"ElTaskAttempt:Read", "User:Me"})
  60.      */
  61.     private $id;
  62.     /**
  63.      * @ORM\Column(type="datetime", nullable=true)
  64.      * @Groups({"ElTaskAttempt:Read", "User:Me"})
  65.      */
  66.     private $start;
  67.     /**
  68.      * @ORM\Column(type="datetime", nullable=true)
  69.      * @Groups({"ElTaskAttempt:Read", "User:Me"})
  70.      */
  71.     private $end;
  72.     /**
  73.      * @ORM\Column(type="string", length=16)
  74.      * @Groups({"ElTaskAttempt:Read", "User:Me"})
  75.      */
  76.     private $status;
  77.     public const STATUSTASKATTEMPT_STARTED "STARTED";
  78.     public const STATUSTASKATTEMPT_COMPLETED "COMPLETED";
  79.     public const STATUSTASKATTEMPT_EXPIRED "EXPIRED";
  80.     /**
  81.      * @ORM\ManyToOne(targetEntity=User::class, inversedBy="elTaskAttempts")
  82.      * @ORM\JoinColumn(nullable=false, onDelete="CASCADE")
  83.      * @Groups({"ElTaskAttempt:Read"})
  84.      */
  85.     private $user;
  86.     /**
  87.      * @ORM\ManyToOne(targetEntity=ElTask::class, inversedBy="elTaskAttempts")
  88.      * @ORM\JoinColumn(nullable=false, onDelete="CASCADE")
  89.      * @Groups({"ElTaskAttempt:Read", "ElTaskAttempt:Start-Task", "User:Me"})
  90.      */
  91.     private $elTask;
  92.     /**
  93.      * @ORM\ManyToOne(targetEntity=Container::class)
  94.      * @ORM\JoinColumn(nullable=false, onDelete="CASCADE")
  95.      * @Groups({"ElTaskAttempt:Start-Task"})
  96.      */
  97.     private $container;
  98.     /**
  99.      * @ORM\Column(type="integer", nullable=true)
  100.      * @Groups({"ElTaskAttempt:Read", "User:Me"})
  101.      */
  102.     private $progress;
  103.     /**
  104.      * @ORM\Column(type="integer", nullable=true)
  105.      * @Groups({"ElTaskAttempt:Read", "User:Me", "ElTaskAttempt:Update-Time"})
  106.      */
  107.     private $videoProgress;
  108.     /**
  109.      * @ORM\Column(type="boolean", nullable=true)
  110.      * @Groups({"ElTaskAttempt:Read", "User:Me", "ElTaskAttempt:Update-Time"})
  111.      */
  112.     private $isVideoCompleted;
  113.     public function getId(): ?int
  114.     {
  115.         return $this->id;
  116.     }
  117.     public function getStart(): ?\DateTimeInterface
  118.     {
  119.         return $this->start;
  120.     }
  121.     public function setStart(?\DateTimeInterface $start): self
  122.     {
  123.         $this->start $start;
  124.         return $this;
  125.     }
  126.     public function getEnd(): ?\DateTimeInterface
  127.     {
  128.         return $this->end;
  129.     }
  130.     public function setEnd(?\DateTimeInterface $end): self
  131.     {
  132.         $this->end $end;
  133.         return $this;
  134.     }
  135.     public function getStatus(): ?string
  136.     {
  137.         return $this->status;
  138.     }
  139.     public function setStatus(string $status): self
  140.     {
  141.         $this->status $status;
  142.         return $this;
  143.     }
  144.     public function getUser(): ?User
  145.     {
  146.         return $this->user;
  147.     }
  148.     public function setUser(?User $user): self
  149.     {
  150.         $this->user $user;
  151.         return $this;
  152.     }
  153.     public function getElTask(): ?ElTask
  154.     {
  155.         return $this->elTask;
  156.     }
  157.     public function setElTask(?ElTask $elTask): self
  158.     {
  159.         $this->elTask $elTask;
  160.         return $this;
  161.     }
  162.     public function getContainer(): ?Container
  163.     {
  164.         return $this->container;
  165.     }
  166.     public function setContainer(?Container $container): self
  167.     {
  168.         $this->container $container;
  169.         return $this;
  170.     }
  171.     public function getProgress(): ?int
  172.     {
  173.         return $this->progress;
  174.     }
  175.     public function setProgress(?int $progress): self
  176.     {
  177.         $this->progress $progress;
  178.         return $this;
  179.     }
  180.     public function getVideoProgress(): ?int
  181.     {
  182.         return $this->videoProgress;
  183.     }
  184.     public function setVideoProgress(?int $videoProgress): self
  185.     {
  186.         $this->videoProgress $videoProgress;
  187.         return $this;
  188.     }
  189.     public function getIsVideoCompleted(): ?bool
  190.     {
  191.         return $this->isVideoCompleted;
  192.     }
  193.     public function setIsVideoCompleted(?bool $isVideoCompleted): self
  194.     {
  195.         $this->isVideoCompleted $isVideoCompleted;
  196.         return $this;
  197.     }
  198. }