Esempio n. 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;
     }
 }
Esempio n. 2
0
 /**
  * Add coursesFinished
  *
  * @param \Calculus\BaranekBundle\Entity\Course $coursesFinished
  *
  * @return $this
  */
 public function addCoursesFinished(\Calculus\BaranekBundle\Entity\Course $coursesFinished)
 {
     $this->courses_finished[] = $coursesFinished;
     $coursesFinished->addProfilesFinished($this);
     return $this;
 }
Esempio n. 3
0
 /**
  * Checks if step with given ID is the last one in course
  * 
  * @param int $step_id
  * @param Calculus\BaranekBundle\Entity\Course $course
  * @return boolean
  */
 public function isLast(int $step_id, \Calculus\BaranekBundle\Entity\Course $course) : bool
 {
     $steps = $course->getSteps();
     $last = $steps->last();
     return $last->getId() === $step_id;
 }