コード例 #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()];
 }
コード例 #2
0
 /**
  * Returns an array representation of all the abilities linked
  * to a given competency tree. Result includes information
  * about ability level as well.
  *
  * @param Competency $competency
  *
  * @return array
  */
 public function findByCompetency(Competency $competency)
 {
     return $this->createQueryBuilder('a')->select('a.id', 'a.name', 'a.activityCount', 'a.minActivityCount', 'c.id AS competencyId', 'l.name AS levelName', 'l.value AS levelValue')->join('a.competencyAbilities', 'ca')->join('ca.competency', 'c')->join('ca.level', 'l')->where('c.root = :root')->andWhere('c.lft >= :lft')->andWhere('c.rgt <= :rgt')->orderBy('l.value, a.id')->setParameters([':root' => $competency->getRoot(), ':lft' => $competency->getLeft(), ':rgt' => $competency->getRight()])->getQuery()->getArrayResult();
 }
コード例 #3
0
 /**
  * Ensures a competency is the root of the framework.
  *
  * @param Competency $competency
  * @throws \LogicException
  */
 public function ensureIsRoot(Competency $competency)
 {
     if ($competency->getRoot() !== $competency->getId()) {
         throw new \LogicException('Framework edition must be done on the root competency');
     }
 }
コード例 #4
0
 /**
  * Returns the builder needed to find the levels associated
  * to a competency (or its ancestor).
  *
  * Note: this method is used in the ability form type.
  *
  * @param Competency $competency
  * @return \Doctrine\ORM\QueryBuilder
  */
 public function getFindByCompetencyBuilder(Competency $competency)
 {
     return $this->createQueryBuilder('l')->join('l.scale', 's')->join('s.competencies', 'c')->where('c.root = :compRoot')->setParameter(':compRoot', $competency->getRoot());
 }
コード例 #5
0
 /**
  * Creates an association between an objective and a competency,
  * with an expected level. Returns a full array representation of
  * the newly associated competency if the link doesn't already exist.
  * Otherwise, returns false.
  *
  * @param Objective  $objective
  * @param Competency $competency
  * @param Level      $level
  *
  * @return mixed array|bool
  *
  * @throws \LogicException if the level doesn't belong to the root competency scale
  */
 public function linkCompetency(Objective $objective, Competency $competency, Level $level)
 {
     $link = $this->objectiveCompetencyRepo->findOneBy(['competency' => $competency, 'objective' => $objective]);
     if ($link) {
         return false;
     }
     $framework = $this->competencyRepo->findOneBy(['root' => $competency->getRoot()]);
     if ($level->getScale() !== $framework->getScale()) {
         throw new \LogicException('Objective level must belong to the root competency scale');
     }
     $link = new ObjectiveCompetency();
     $link->setObjective($objective);
     $link->setCompetency($competency);
     $link->setLevel($level);
     $link->setFramework($framework);
     $this->om->persist($link);
     $this->om->flush();
     $this->progressManager->recomputeObjectiveProgress($objective);
     $competency = $this->competencyManager->loadCompetency($competency);
     $competency['id'] = $link->getId();
     // link is treated as the competency itself on client-side
     $competency['framework'] = $framework->getName();
     $competency['level'] = $level->getName();
     return $competency;
 }