Example #1
0
 private function getPointForObjectives(Activity $activity)
 {
     $points = 0;
     $round = $activity->getRound();
     $objectiveDoneCount = count($activity->getObjectivesDone());
     $objectivesDoableCount = count($round->getObjectives());
     $points += round(300 / $objectivesDoableCount) * $objectiveDoneCount;
     if ($objectiveDoneCount === $objectivesDoableCount) {
         $timePoints = floor(1 / $activity->getDuration() * 3000);
         $activity->setTimePoints($timePoints);
         $this->em->persist($activity);
         $this->em->flush();
         $points += $timePoints;
     }
     return $points;
 }
 public function canAccessScores(Activity $activity)
 {
     $currentUserActivity = $this->getActivity($activity->getRound());
     $gameAuthor = $activity->getRound()->getGame()->getAuthor();
     return $this->currentUser === $gameAuthor || $currentUserActivity->getEndDate() ? true : false;
 }