예제 #1
0
 /**
  * Displays the scale levels of a given competency framework for selection.
  *
  * @EXT\Route("/framework/{id}/levels", name="hevinci_pick_level")
  * @EXT\Template
  *
  * @param Competency $framework
  * @return array
  * @throws \LogicException if the competency is not a framework root
  */
 public function levelsAction(Competency $framework)
 {
     if ($framework->getRoot() !== $framework->getId()) {
         throw new \LogicException('Scales are only linked to root competencies');
     }
     return ['scale' => $framework->getScale()];
 }
 /**
  * Returns the association between a competency and an ability.
  *
  * @param Competency $parent
  * @param Ability    $ability
  *
  * @return null|object
  *
  * @throws \Exception if the ability is not linked to the competency
  */
 public function findOneByTerms(Competency $parent, Ability $ability)
 {
     $link = $this->findOneBy(['competency' => $parent, 'ability' => $ability]);
     if (!$link) {
         throw new \RuntimeException("Competency {$parent->getId()} is not linked to ability {$ability->getId()}");
     }
     return $link;
 }
 /**
  * Displays the competency creation form.
  *
  * @EXT\Route("/{id}/sub", name="hevinci_new_competency")
  * @EXT\Template("HeVinciCompetencyBundle:Competency:competencyForm.html.twig")
  *
  * @param Competency $parent
  * @return array
  */
 public function newSubCompetencyAction(Competency $parent)
 {
     return ['form' => $this->formHandler->getView('hevinci_form_competency', null, ['parent_competency' => $parent]), 'parentId' => $parent->getId()];
 }
예제 #4
0
 private function loadCompetency(Competency $competency)
 {
     return ['id' => $competency->getId(), 'name' => $competency->getName(), 'type' => 'competency_', 'paths' => [['level' => '-', 'steps' => array_map(function ($step) {
         return $step->getName();
     }, $this->competencyRepo->getPath($competency))]]];
 }
예제 #5
0
 /**
  * Creates a link between a competency and an existing ability.
  *
  * @param Competency $parent
  * @param Ability $ability
  * @param Level $level
  * @return Ability
  * @throws \LogicException if a link already exists
  */
 public function linkAbilityToCompetency(Competency $parent, Ability $ability, Level $level)
 {
     $link = $this->competencyAbilityRepo->findOneBy(['competency' => $parent, 'ability' => $ability]);
     if ($link) {
         throw new \LogicException("Ability {$ability->getId()} is already linked to competency {$parent->getId()}");
     }
     $link = new CompetencyAbility();
     $link->setCompetency($parent);
     $link->setAbility($ability);
     $link->setLevel($level);
     $this->om->persist($link);
     $this->om->flush();
     return $ability;
 }
예제 #6
0
 private function getCompetencyProgress(Competency $competency, User $user)
 {
     if (!isset($this->cachedCompetencyProgresses[$competency->getId()])) {
         $progress = $this->competencyProgressRepo->findOneBy(['competency' => $competency, 'user' => $user]);
         if (!$progress) {
             $progress = new CompetencyProgress();
             $progress->setCompetency($competency);
             $progress->setUser($user);
             $this->om->persist($progress);
         } else {
             $this->om->persist($progress->makeLog());
         }
         $this->cachedCompetencyProgresses[$competency->getId()] = $progress;
     }
     return $this->cachedCompetencyProgresses[$competency->getId()];
 }