Example #1
0
 /**
  * Adds course's rewards to given profile.
  * 
  * @param \Calculus\UserBundle\Entity\Profile $profile
  * @param \Calculus\BaranekBundle\Entity\Course $course
  */
 private function addRewards(\Calculus\UserBundle\Entity\Profile $profile, \Calculus\BaranekBundle\Entity\Course $course)
 {
     $title = $course->getTitle();
     $achievement = $course->getAchievement();
     if ($title !== null && !$this->hasTitle($title, $profile)) {
         $profile->addTitle($title);
         $this->response["adds"]["title"] = ['id' => $title->getId(), 'name' => $title->getName()];
     }
     if ($achievement !== null && !$this->hasAchievement($achievement, $profile)) {
         $profile->addAchievement($achievement);
         $properties = array('id' => $achievement->getId(), 'name' => $achievement->getName(), 'badge' => $achievement->getBadge());
         $this->response["adds"]["achievement"] = $properties;
     }
     if (!$this->isFinished($course, $profile)) {
         $profile->addCoursesFinished($course);
         $profile->addPoints(50);
         //$course->getPoints() );
         $this->response["adds"]["points"] = 50;
         //$course->getPoints();
     } else {
         $profile->addPoints(5);
         $this->response["adds"]["points"] = 5;
     }
 }