src/Entity/TeamplayUserRecap.php line 53

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Core\Annotation\ApiFilter;
  4. use ApiPlatform\Core\Annotation\ApiResource;
  5. use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\OrderFilter;
  6. use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter;
  7. use ApiPlatform\Core\Serializer\Filter\PropertyFilter;
  8. use App\Repository\TeamplayUserRecapRepository;
  9. use Doctrine\ORM\Mapping as ORM;
  10. use Gedmo\Mapping\Annotation as Gedmo;
  11. use Symfony\Component\Serializer\Annotation\Groups;
  12. use Symfony\Component\Validator\Constraints as Assert;
  13. /**
  14.  * Snapshot des performances d'un utilisateur à la fin d'un Teamplay
  15.  * 
  16.  * @ORM\Entity(repositoryClass=TeamplayUserRecapRepository::class)
  17.  * @ORM\Table(
  18.  *     name="teamplay_user_recap",
  19.  *     uniqueConstraints={
  20.  *         @ORM\UniqueConstraint(name="unique_user_teamplay_recap", columns={"user_id", "teamplay_id"})
  21.  *     },
  22.  *     indexes={
  23.  *         @ORM\Index(name="idx_user_recap", columns={"user_id"}),
  24.  *         @ORM\Index(name="idx_teamplay_recap", columns={"teamplay_id"}),
  25.  *         @ORM\Index(name="idx_team_recap", columns={"team_id"}),
  26.  *         @ORM\Index(name="idx_recap_created", columns={"created_at"})
  27.  *     }
  28.  * )
  29.  * @ApiResource(
  30.  *      normalizationContext={"groups"={"teamplay_recap:read"}},
  31.  *      denormalizationContext={"groups"={"teamplay_recap:write"}},
  32.  *      itemOperations={
  33.  *          "get"={"security"="is_granted('ROLE_ADMIN') or object.getUser() == user"},
  34.  *          "delete"={"security"="is_granted('ROLE_ADMIN')"}
  35.  *      },
  36.  *      collectionOperations={
  37.  *          "get"={"security"="is_granted('ROLE_USER')"},
  38.  *          "post"={"security"="is_granted('ROLE_ADMIN')"}
  39.  *      }
  40.  * )
  41.  * @ApiFilter(SearchFilter::class, properties={
  42.  *   "user": "exact",
  43.  *    "teamplay": "exact", 
  44.  *   "team": "exact",
  45.  *    "company": "exact"
  46.  * })
  47.  * @ApiFilter(OrderFilter::class, properties={"id", "createdAt", "teamplayStartDate", "teamplayEndDate", "totalPoints", "userRank"})
  48.  * @ApiFilter(PropertyFilter::class, arguments={"parameterName"="fields", "overrideDefaultProperties"=true})
  49.  */
  50. class TeamplayUserRecap
  51. {
  52.     /**
  53.      * @ORM\Id
  54.      * @ORM\GeneratedValue
  55.      * @ORM\Column(type="integer")
  56.      * @Groups({"teamplay_recap:read"})
  57.      */
  58.     private $id;
  59.     // ═══════════════════════════════════════════════════════════════
  60.     // RELATIONS
  61.     // ═══════════════════════════════════════════════════════════════
  62.     /**
  63.      * @ORM\ManyToOne(targetEntity=User::class)
  64.      * @ORM\JoinColumn(nullable=false, onDelete="CASCADE")
  65.      * @Assert\NotNull
  66.      * @Groups({"teamplay_recap:read", "teamplay_recap:write"})
  67.      */
  68.     private $user;
  69.     /**
  70.      * @ORM\ManyToOne(targetEntity=Teamplay::class)
  71.      * @ORM\JoinColumn(nullable=false, onDelete="CASCADE")
  72.      * @Assert\NotNull
  73.      * @Groups({"teamplay_recap:read", "teamplay_recap:write"})
  74.      */
  75.     private $teamplay;
  76.     /**
  77.      * @ORM\ManyToOne(targetEntity=Team::class)
  78.      * @ORM\JoinColumn(nullable=true, onDelete="SET NULL")
  79.      * @Groups({"teamplay_recap:read", "teamplay_recap:write"})
  80.      */
  81.     private $team;
  82.     /**
  83.      * @ORM\ManyToOne(targetEntity=Company::class)
  84.      * @ORM\JoinColumn(nullable=true, onDelete="SET NULL")
  85.      * @Groups({"teamplay_recap:read", "teamplay_recap:write"})
  86.      */
  87.     private $company;
  88.     // ═══════════════════════════════════════════════════════════════
  89.     // INFORMATIONS TEAMPLAY (SNAPSHOT)
  90.     // ═══════════════════════════════════════════════════════════════
  91.     /**
  92.      * @ORM\Column(type="string", length=255)
  93.      * @Groups({"teamplay_recap:read", "teamplay_recap:write"})
  94.      */
  95.     private $teamplayName;
  96.     /**
  97.      * @ORM\Column(type="text", nullable=true)
  98.      * @Groups({"teamplay_recap:read", "teamplay_recap:write"})
  99.      */
  100.     private $teamplayDescription;
  101.     /**
  102.      * @ORM\ManyToOne(targetEntity=MediaObject::class)
  103.      * @Groups({"teamplay_recap:read", "teamplay_recap:write"})
  104.      */
  105.     private $teamplayPicture;
  106.     /**
  107.      * @ORM\Column(type="datetime")
  108.      * @Groups({"teamplay_recap:read", "teamplay_recap:write"})
  109.      */
  110.     private $teamplayStartDate;
  111.     /**
  112.      * @ORM\Column(type="datetime")
  113.      * @Groups({"teamplay_recap:read", "teamplay_recap:write"})
  114.      */
  115.     private $teamplayEndDate;
  116.     /**
  117.      * @ORM\Column(type="integer")
  118.      * @Groups({"teamplay_recap:read", "teamplay_recap:write"})
  119.      */
  120.     private $teamplayDuration;
  121.     // ═══════════════════════════════════════════════════════════════
  122.     // PERFORMANCES UTILISATEUR
  123.     // ═══════════════════════════════════════════════════════════════
  124.     /**
  125.      * @ORM\Column(type="integer", options={"default": 0})
  126.      * @Groups({"teamplay_recap:read", "teamplay_recap:write"})
  127.      */
  128.     private $totalPoints = 0;
  129.     /**
  130.      * @ORM\Column(type="integer", nullable=true)
  131.      * @Groups({"teamplay_recap:read", "teamplay_recap:write"})
  132.      */
  133.     private $userRank;
  134.     /**
  135.      * @ORM\Column(type="integer", nullable=true)
  136.      * @Groups({"teamplay_recap:read", "teamplay_recap:write"})
  137.      */
  138.     private $globalRank;
  139.     /**
  140.      * @ORM\Column(type="integer", options={"default": 0})
  141.      * @Groups({"teamplay_recap:read", "teamplay_recap:write"})
  142.      */
  143.     private $totalParticipants = 0;
  144.     // ═══════════════════════════════════════════════════════════════
  145.     // STATISTIQUES ACTIVITÉS UTILISATEUR
  146.     // ═══════════════════════════════════════════════════════════════
  147.     /**
  148.      * @ORM\Column(type="bigint", options={"default": 0})
  149.      * @Groups({"teamplay_recap:read", "teamplay_recap:write"})
  150.      */
  151.     private $totalSteps = 0;
  152.     /**
  153.      * @ORM\Column(type="decimal", precision=12, scale=2, options={"default": 0})
  154.      * @Groups({"teamplay_recap:read", "teamplay_recap:write"})
  155.      */
  156.     private $totalBikeDistance = 0;
  157.     /**
  158.      * @ORM\Column(type="decimal", precision=12, scale=2, options={"default": 0})
  159.      * @Groups({"teamplay_recap:read", "teamplay_recap:write"})
  160.      */
  161.     private $totalRunDistance = 0;
  162.     /**
  163.      * @ORM\Column(type="integer", options={"default": 0})
  164.      * @Groups({"teamplay_recap:read", "teamplay_recap:write"})
  165.      */
  166.     private $totalKinestexReps = 0;
  167.     /**
  168.      * @ORM\Column(type="integer", options={"default": 0})
  169.      * @Groups({"teamplay_recap:read", "teamplay_recap:write"})
  170.      */
  171.     private $totalKinestexDuration = 0;
  172.     /**
  173.      * @ORM\Column(type="integer", options={"default": 0})
  174.      * @Groups({"teamplay_recap:read", "teamplay_recap:write"})
  175.      */
  176.     private $totalKinestexSessions = 0;
  177.     /**
  178.      * @ORM\Column(type="integer", options={"default": 0})
  179.      * @Groups({"teamplay_recap:read", "teamplay_recap:write"})
  180.      */
  181.     private $totalQuizCorrect = 0;
  182.     /**
  183.      * @ORM\Column(type="integer", options={"default": 0})
  184.      * @Groups({"teamplay_recap:read", "teamplay_recap:write"})
  185.      */
  186.     private $totalQuizQuestions = 0;
  187.     /**
  188.      * @ORM\Column(type="integer", options={"default": 0})
  189.      * @Groups({"teamplay_recap:read", "teamplay_recap:write"})
  190.      */
  191.     private $totalVideosWatched = 0;
  192.     // ═══════════════════════════════════════════════════════════════
  193.     // INFORMATIONS ÉQUIPE (SNAPSHOT)
  194.     // ═══════════════════════════════════════════════════════════════
  195.     /**
  196.      * @ORM\Column(type="string", length=255, nullable=true)
  197.      * @Groups({"teamplay_recap:read", "teamplay_recap:write"})
  198.      */
  199.     private $teamName;
  200.     /**
  201.      * @ORM\ManyToOne(targetEntity=MediaObject::class)
  202.      * @Groups({"teamplay_recap:read", "teamplay_recap:write"})
  203.      */
  204.     private $teamPicture;
  205.     /**
  206.      * @ORM\Column(type="integer", options={"default": 0})
  207.      * @Groups({"teamplay_recap:read", "teamplay_recap:write"})
  208.      */
  209.     private $teamPoints = 0;
  210.     /**
  211.      * @ORM\Column(type="integer", nullable=true)
  212.      * @Groups({"teamplay_recap:read", "teamplay_recap:write"})
  213.      */
  214.     private $teamRank;
  215.     /**
  216.      * @ORM\Column(type="integer", options={"default": 0})
  217.      * @Groups({"teamplay_recap:read", "teamplay_recap:write"})
  218.      */
  219.     private $totalTeams = 0;
  220.     /**
  221.      * @ORM\Column(type="integer", options={"default": 0})
  222.      * @Groups({"teamplay_recap:read", "teamplay_recap:write"})
  223.      */
  224.     private $teamMembersCount = 0;
  225.     // ═══════════════════════════════════════════════════════════════
  226.     // STATISTIQUES ÉQUIPE
  227.     // ═══════════════════════════════════════════════════════════════
  228.     /**
  229.      * @ORM\Column(type="bigint", options={"default": 0})
  230.      * @Groups({"teamplay_recap:read", "teamplay_recap:write"})
  231.      */
  232.     private $teamTotalSteps = 0;
  233.     /**
  234.      * @ORM\Column(type="decimal", precision=12, scale=2, options={"default": 0})
  235.      * @Groups({"teamplay_recap:read", "teamplay_recap:write"})
  236.      */
  237.     private $teamTotalBikeDistance = 0;
  238.     /**
  239.      * @ORM\Column(type="decimal", precision=12, scale=2, options={"default": 0})
  240.      * @Groups({"teamplay_recap:read", "teamplay_recap:write"})
  241.      */
  242.     private $teamTotalRunDistance = 0;
  243.     /**
  244.      * @ORM\Column(type="integer", options={"default": 0})
  245.      * @Groups({"teamplay_recap:read", "teamplay_recap:write"})
  246.      */
  247.     private $teamTotalQuizCorrect = 0;
  248.     /**
  249.      * @ORM\Column(type="integer", options={"default": 0})
  250.      * @Groups({"teamplay_recap:read", "teamplay_recap:write"})
  251.      */
  252.     private $teamTotalVideosWatched = 0;
  253.     /**
  254.      * @ORM\Column(type="integer", options={"default": 0})
  255.      * @Groups({"teamplay_recap:read", "teamplay_recap:write"})
  256.      */
  257.     private $teamTotalKinestexSessions = 0;
  258.     // ═══════════════════════════════════════════════════════════════
  259.     // RÉSUMÉ DES TYPES DE CHALLENGES PRÉSENTS (NOUVEAU)
  260.     // ═══════════════════════════════════════════════════════════════
  261.     /**
  262.      * Tableau récapitulatif des types d'activités présents dans le Teamplay
  263.      * (quiz, bike, run, step, kinestex, video, etc.) + détail des exos Kinestex
  264.      * 
  265.      * @ORM\Column(type="json", nullable=true)
  266.      * @Groups({"teamplay_recap:read", "teamplay_recap:write"})
  267.      */
  268.     private $challengeTypesSummary = [];
  269.     // ═══════════════════════════════════════════════════════════════
  270.     // DÉTAILS CHALLENGES COMPLÉTÉS
  271.     // ═══════════════════════════════════════════════════════════════
  272.     /**
  273.      * @ORM\Column(type="json", nullable=true)
  274.      * @Groups({"teamplay_recap:read", "teamplay_recap:write"})
  275.      */
  276.     private $challengesData = [];
  277.     /**
  278.      * @ORM\Column(type="integer", options={"default": 0})
  279.      * @Groups({"teamplay_recap:read", "teamplay_recap:write"})
  280.      */
  281.     private $challengesCompletedCount = 0;
  282.     /**
  283.      * @ORM\Column(type="integer", options={"default": 0})
  284.      * @Groups({"teamplay_recap:read", "teamplay_recap:write"})
  285.      */
  286.     private $challengesTotalCount = 0;
  287.     // ═══════════════════════════════════════════════════════════════
  288.     // MÉTADONNÉES
  289.     // ═══════════════════════════════════════════════════════════════
  290.     /**
  291.      * @ORM\Column(type="datetime", options={"default": "CURRENT_TIMESTAMP"})
  292.      * @Gedmo\Timestampable(on="create")
  293.      * @Groups({"teamplay_recap:read"})
  294.      */
  295.     private $createdAt;
  296.     /**
  297.      * @ORM\Column(type="datetime", nullable=true)
  298.      * @Gedmo\Timestampable(on="update")
  299.      * @Groups({"teamplay_recap:read"})
  300.      */
  301.     private $updatedAt;
  302.     /**
  303.      * @ORM\Column(type="boolean", options={"default": true})
  304.      * @Groups({"teamplay_recap:read", "teamplay_recap:write"})
  305.      */
  306.     private $autoGenerated = true;
  307.     /**
  308.      * @ORM\Column(type="json", nullable=true)
  309.      * @Groups({"teamplay_recap:read", "teamplay_recap:write"})
  310.      */
  311.     private $extraData = [];
  312.     // ═══════════════════════════════════════════════════════════════
  313.     // GETTERS & SETTERS
  314.     // ═══════════════════════════════════════════════════════════════
  315.     public function getId(): ?int
  316.     {
  317.         return $this->id;
  318.     }
  319.     public function getUser(): ?User
  320.     {
  321.         return $this->user;
  322.     }
  323.     public function setUser(?User $user): self
  324.     {
  325.         $this->user = $user;
  326.         return $this;
  327.     }
  328.     public function getTeamplay(): ?Teamplay
  329.     {
  330.         return $this->teamplay;
  331.     }
  332.     public function setTeamplay(?Teamplay $teamplay): self
  333.     {
  334.         $this->teamplay = $teamplay;
  335.         return $this;
  336.     }
  337.     public function getTeam(): ?Team
  338.     {
  339.         return $this->team;
  340.     }
  341.     public function setTeam(?Team $team): self
  342.     {
  343.         $this->team = $team;
  344.         return $this;
  345.     }
  346.     public function getCompany(): ?Company
  347.     {
  348.         return $this->company;
  349.     }
  350.     public function setCompany(?Company $company): self
  351.     {
  352.         $this->company = $company;
  353.         return $this;
  354.     }
  355.     public function getTeamplayName(): ?string
  356.     {
  357.         return $this->teamplayName;
  358.     }
  359.     public function setTeamplayName(string $teamplayName): self
  360.     {
  361.         $this->teamplayName = $teamplayName;
  362.         return $this;
  363.     }
  364.     public function getTeamplayDescription(): ?string
  365.     {
  366.         return $this->teamplayDescription;
  367.     }
  368.     public function setTeamplayDescription(?string $teamplayDescription): self
  369.     {
  370.         $this->teamplayDescription = $teamplayDescription;
  371.         return $this;
  372.     }
  373.     public function getTeamplayPicture(): ?MediaObject
  374.     {
  375.         return $this->teamplayPicture;
  376.     }
  377.     public function setTeamplayPicture(?MediaObject $teamplayPicture): self
  378.     {
  379.         $this->teamplayPicture = $teamplayPicture;
  380.         return $this;
  381.     }
  382.     public function getTeamplayStartDate(): ?\DateTimeInterface
  383.     {
  384.         return $this->teamplayStartDate;
  385.     }
  386.     public function setTeamplayStartDate(\DateTimeInterface $teamplayStartDate): self
  387.     {
  388.         $this->teamplayStartDate = $teamplayStartDate;
  389.         return $this;
  390.     }
  391.     public function getTeamplayEndDate(): ?\DateTimeInterface
  392.     {
  393.         return $this->teamplayEndDate;
  394.     }
  395.     public function setTeamplayEndDate(\DateTimeInterface $teamplayEndDate): self
  396.     {
  397.         $this->teamplayEndDate = $teamplayEndDate;
  398.         return $this;
  399.     }
  400.     public function getTeamplayDuration(): ?int
  401.     {
  402.         return $this->teamplayDuration;
  403.     }
  404.     public function setTeamplayDuration(int $teamplayDuration): self
  405.     {
  406.         $this->teamplayDuration = $teamplayDuration;
  407.         return $this;
  408.     }
  409.     public function getTotalPoints(): int
  410.     {
  411.         return $this->totalPoints;
  412.     }
  413.     public function setTotalPoints(int $totalPoints): self
  414.     {
  415.         $this->totalPoints = $totalPoints;
  416.         return $this;
  417.     }
  418.     public function getUserRank(): ?int
  419.     {
  420.         return $this->userRank;
  421.     }
  422.     public function setUserRank(?int $userRank): self
  423.     {
  424.         $this->userRank = $userRank;
  425.         return $this;
  426.     }
  427.     public function getGlobalRank(): ?int
  428.     {
  429.         return $this->globalRank;
  430.     }
  431.     public function setGlobalRank(?int $globalRank): self
  432.     {
  433.         $this->globalRank = $globalRank;
  434.         return $this;
  435.     }
  436.     public function getTotalParticipants(): int
  437.     {
  438.         return $this->totalParticipants;
  439.     }
  440.     public function setTotalParticipants(int $totalParticipants): self
  441.     {
  442.         $this->totalParticipants = $totalParticipants;
  443.         return $this;
  444.     }
  445.     public function getTotalSteps(): int
  446.     {
  447.         return $this->totalSteps;
  448.     }
  449.     public function setTotalSteps(int $totalSteps): self
  450.     {
  451.         $this->totalSteps = $totalSteps;
  452.         return $this;
  453.     }
  454.     public function getTotalBikeDistance(): float
  455.     {
  456.         return (float) $this->totalBikeDistance;
  457.     }
  458.     public function setTotalBikeDistance(float $totalBikeDistance): self
  459.     {
  460.         $this->totalBikeDistance = $totalBikeDistance;
  461.         return $this;
  462.     }
  463.     /**
  464.      * @Groups({"teamplay_recap:read"})
  465.      */
  466.     public function getTotalBikeDistanceKm(): float
  467.     {
  468.         return round($this->getTotalBikeDistance() / 1000, 2);
  469.     }
  470.     public function getTotalRunDistance(): float
  471.     {
  472.         return (float) $this->totalRunDistance;
  473.     }
  474.     public function setTotalRunDistance(float $totalRunDistance): self
  475.     {
  476.         $this->totalRunDistance = $totalRunDistance;
  477.         return $this;
  478.     }
  479.     /**
  480.      * @Groups({"teamplay_recap:read"})
  481.      */
  482.     public function getTotalRunDistanceKm(): float
  483.     {
  484.         return round($this->getTotalRunDistance() / 1000, 2);
  485.     }
  486.     public function getTotalKinestexReps(): int
  487.     {
  488.         return $this->totalKinestexReps;
  489.     }
  490.     public function setTotalKinestexReps(int $totalKinestexReps): self
  491.     {
  492.         $this->totalKinestexReps = $totalKinestexReps;
  493.         return $this;
  494.     }
  495.     public function getTotalKinestexDuration(): int
  496.     {
  497.         return $this->totalKinestexDuration;
  498.     }
  499.     public function setTotalKinestexDuration(int $totalKinestexDuration): self
  500.     {
  501.         $this->totalKinestexDuration = $totalKinestexDuration;
  502.         return $this;
  503.     }
  504.     public function getTotalKinestexSessions(): int
  505.     {
  506.         return $this->totalKinestexSessions;
  507.     }
  508.     public function setTotalKinestexSessions(int $totalKinestexSessions): self
  509.     {
  510.         $this->totalKinestexSessions = $totalKinestexSessions;
  511.         return $this;
  512.     }
  513.     public function getTotalQuizCorrect(): int
  514.     {
  515.         return $this->totalQuizCorrect;
  516.     }
  517.     public function setTotalQuizCorrect(int $totalQuizCorrect): self
  518.     {
  519.         $this->totalQuizCorrect = $totalQuizCorrect;
  520.         return $this;
  521.     }
  522.     public function getTotalQuizQuestions(): int
  523.     {
  524.         return $this->totalQuizQuestions;
  525.     }
  526.     public function setTotalQuizQuestions(int $totalQuizQuestions): self
  527.     {
  528.         $this->totalQuizQuestions = $totalQuizQuestions;
  529.         return $this;
  530.     }
  531.     public function getTotalVideosWatched(): int
  532.     {
  533.         return $this->totalVideosWatched;
  534.     }
  535.     public function setTotalVideosWatched(int $totalVideosWatched): self
  536.     {
  537.         $this->totalVideosWatched = $totalVideosWatched;
  538.         return $this;
  539.     }
  540.     public function getTeamName(): ?string
  541.     {
  542.         return $this->teamName;
  543.     }
  544.     public function setTeamName(?string $teamName): self
  545.     {
  546.         $this->teamName = $teamName;
  547.         return $this;
  548.     }
  549.     public function getTeamPicture(): ?MediaObject
  550.     {
  551.         return $this->teamPicture;
  552.     }
  553.     public function setTeamPicture(?MediaObject $teamPicture): self
  554.     {
  555.         $this->teamPicture = $teamPicture;
  556.         return $this;
  557.     }
  558.     public function getTeamPoints(): int
  559.     {
  560.         return $this->teamPoints;
  561.     }
  562.     public function setTeamPoints(int $teamPoints): self
  563.     {
  564.         $this->teamPoints = $teamPoints;
  565.         return $this;
  566.     }
  567.     public function getTeamRank(): ?int
  568.     {
  569.         return $this->teamRank;
  570.     }
  571.     public function setTeamRank(?int $teamRank): self
  572.     {
  573.         $this->teamRank = $teamRank;
  574.         return $this;
  575.     }
  576.     public function getTotalTeams(): int
  577.     {
  578.         return $this->totalTeams;
  579.     }
  580.     public function setTotalTeams(int $totalTeams): self
  581.     {
  582.         $this->totalTeams = $totalTeams;
  583.         return $this;
  584.     }
  585.     public function getTeamMembersCount(): int
  586.     {
  587.         return $this->teamMembersCount;
  588.     }
  589.     public function setTeamMembersCount(int $teamMembersCount): self
  590.     {
  591.         $this->teamMembersCount = $teamMembersCount;
  592.         return $this;
  593.     }
  594.     public function getTeamTotalSteps(): int
  595.     {
  596.         return $this->teamTotalSteps;
  597.     }
  598.     public function setTeamTotalSteps(int $teamTotalSteps): self
  599.     {
  600.         $this->teamTotalSteps = $teamTotalSteps;
  601.         return $this;
  602.     }
  603.     public function getTeamTotalBikeDistance(): float
  604.     {
  605.         return (float) $this->teamTotalBikeDistance;
  606.     }
  607.     public function setTeamTotalBikeDistance(float $teamTotalBikeDistance): self
  608.     {
  609.         $this->teamTotalBikeDistance = $teamTotalBikeDistance;
  610.         return $this;
  611.     }
  612.     public function getTeamTotalRunDistance(): float
  613.     {
  614.         return (float) $this->teamTotalRunDistance;
  615.     }
  616.     public function setTeamTotalRunDistance(float $teamTotalRunDistance): self
  617.     {
  618.         $this->teamTotalRunDistance = $teamTotalRunDistance;
  619.         return $this;
  620.     }
  621.     /**
  622.      * Distance vélo de l'équipe en km (stockée en mètres depuis #3369).
  623.      *
  624.      * @Groups({"teamplay_recap:read"})
  625.      */
  626.     public function getTeamTotalBikeDistanceKm(): float
  627.     {
  628.         return round($this->getTeamTotalBikeDistance() / 1000, 2);
  629.     }
  630.     /**
  631.      * Distance course de l'équipe en km (stockée en mètres depuis #3369).
  632.      *
  633.      * @Groups({"teamplay_recap:read"})
  634.      */
  635.     public function getTeamTotalRunDistanceKm(): float
  636.     {
  637.         return round($this->getTeamTotalRunDistance() / 1000, 2);
  638.     }
  639.     public function getTeamTotalQuizCorrect(): int
  640.     {
  641.         return $this->teamTotalQuizCorrect;
  642.     }
  643.     public function setTeamTotalQuizCorrect(int $teamTotalQuizCorrect): self
  644.     {
  645.         $this->teamTotalQuizCorrect = $teamTotalQuizCorrect;
  646.         return $this;
  647.     }
  648.     public function getTeamTotalVideosWatched(): int
  649.     {
  650.         return $this->teamTotalVideosWatched;
  651.     }
  652.     public function setTeamTotalVideosWatched(int $teamTotalVideosWatched): self
  653.     {
  654.         $this->teamTotalVideosWatched = $teamTotalVideosWatched;
  655.         return $this;
  656.     }
  657.     public function getTeamTotalKinestexSessions(): int
  658.     {
  659.         return $this->teamTotalKinestexSessions;
  660.     }
  661.     public function setTeamTotalKinestexSessions(int $teamTotalKinestexSessions): self
  662.     {
  663.         $this->teamTotalKinestexSessions = $teamTotalKinestexSessions;
  664.         return $this;
  665.     }
  666.     public function getChallengeTypesSummary(): ?array
  667.     {
  668.         return $this->challengeTypesSummary;
  669.     }
  670.     public function setChallengeTypesSummary(?array $challengeTypesSummary): self
  671.     {
  672.         $this->challengeTypesSummary = $challengeTypesSummary;
  673.         return $this;
  674.     }
  675.     public function getChallengesData(): ?array
  676.     {
  677.         return $this->challengesData;
  678.     }
  679.     public function setChallengesData(?array $challengesData): self
  680.     {
  681.         $this->challengesData = $challengesData;
  682.         return $this;
  683.     }
  684.     public function getChallengesCompletedCount(): int
  685.     {
  686.         return $this->challengesCompletedCount;
  687.     }
  688.     public function setChallengesCompletedCount(int $challengesCompletedCount): self
  689.     {
  690.         $this->challengesCompletedCount = $challengesCompletedCount;
  691.         return $this;
  692.     }
  693.     public function getChallengesTotalCount(): int
  694.     {
  695.         return $this->challengesTotalCount;
  696.     }
  697.     public function setChallengesTotalCount(int $challengesTotalCount): self
  698.     {
  699.         $this->challengesTotalCount = $challengesTotalCount;
  700.         return $this;
  701.     }
  702.     /**
  703.      * @Groups({"teamplay_recap:read"})
  704.      */
  705.     public function getCompletionRate(): float
  706.     {
  707.         if ($this->challengesTotalCount === 0) {
  708.             return 0;
  709.         }
  710.         return round(($this->challengesCompletedCount / $this->challengesTotalCount) * 100, 2);
  711.     }
  712.     public function getCreatedAt(): ?\DateTimeInterface
  713.     {
  714.         return $this->createdAt;
  715.     }
  716.     public function setCreatedAt(\DateTimeInterface $createdAt): self
  717.     {
  718.         $this->createdAt = $createdAt;
  719.         return $this;
  720.     }
  721.     public function getUpdatedAt(): ?\DateTimeInterface
  722.     {
  723.         return $this->updatedAt;
  724.     }
  725.     public function setUpdatedAt(?\DateTimeInterface $updatedAt): self
  726.     {
  727.         $this->updatedAt = $updatedAt;
  728.         return $this;
  729.     }
  730.     public function isAutoGenerated(): bool
  731.     {
  732.         return $this->autoGenerated;
  733.     }
  734.     public function setAutoGenerated(bool $autoGenerated): self
  735.     {
  736.         $this->autoGenerated = $autoGenerated;
  737.         return $this;
  738.     }
  739.     public function getExtraData(): ?array
  740.     {
  741.         return $this->extraData;
  742.     }
  743.     public function setExtraData(?array $extraData): self
  744.     {
  745.         $this->extraData = $extraData;
  746.         return $this;
  747.     }
  748.     /**
  749.      * URL directe de l'image du teamplay
  750.      * @Groups({"teamplay_recap:read"})
  751.      */
  752.     public function getTeamplayPictureUrl(): ?string
  753.     {
  754.         return $this->teamplayPicture ? $this->teamplayPicture->getContentUrl() : null;
  755.     }
  756.     /**
  757.      * URL directe de l'image de l'équipe
  758.      * @Groups({"teamplay_recap:read"})
  759.      */
  760.     public function getTeamPictureUrl(): ?string
  761.     {
  762.         return $this->teamPicture ? $this->teamPicture->getContentUrl() : null;
  763.     }
  764.     /**
  765.      * URL directe de l'avatar de l'utilisateur
  766.      * @Groups({"teamplay_recap:read"})
  767.      */
  768.     public function getUserPictureUrl(): ?string
  769.     {
  770.         if ($this->user && $this->user->getClient() && $this->user->getClient()->getAvatar()) {
  771.             return $this->user->getClient()->getAvatar()->getContentUrl();
  772.         }
  773.         return null;
  774.     }
  775. }