ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilContSkillCollector.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2020 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
11 {
15  protected $tab_skills = array();
16 
20  protected $pres_skills = array();
21 
25  protected $container_skills;
26 
31 
36 
40  protected $skmg_settings;
41 
48  public function __construct(
49  ilContainerSkills $a_cont_skills,
50  ilContainerGlobalProfiles $a_cont_glb_profiles,
51  ilContainerLocalProfiles $a_cont_lcl_profiles
52  ) {
53  $this->container_skills = $a_cont_skills;
54  $this->container_global_profiles = $a_cont_glb_profiles;
55  $this->container_local_profiles = $a_cont_lcl_profiles;
56  $this->skmg_settings = new ilSkillManagementSettings();
57  }
58 
62  public function getSkillsForTableGUI() : array
63  {
64  // Get single and profile skills WITHOUT array keys so as not to remove multiple occurrences when merging
65 
66  $s_skills = array_values($this->getSingleSkills());
67  $p_skills = $this->getProfileSkills();
68 
69  $this->tab_skills = array_merge($s_skills, $p_skills);
70 
71  // order skills per virtual skill tree
72  $vtree = new ilVirtualSkillTree();
73  $this->tab_skills = $vtree->getOrderedNodeset($this->tab_skills, "base_skill_id", "tref_id");
74 
75  return $this->tab_skills;
76  }
77 
83  public function getSkillsForPresentationGUI() : array
84  {
85  // Get single and profile skills WITH array keys so as to remove multiple occurrences when merging
86 
87  $s_skills = $this->getSingleSkills();
88  $p_skills = array();
89 
90  foreach ($this->getProfileSkills() as $ps) {
91  $p_skills[$ps["base_skill_id"] . "-" . $ps["tref_id"]] = array(
92  "base_skill_id" => $ps["base_skill_id"],
93  "tref_id" => $ps["tref_id"],
94  "title" => $ps["title"],
95  "profile" => $ps["profile"]
96  );
97  }
98 
99  $this->pres_skills = array_merge($s_skills, $p_skills);
100 
101  return $this->pres_skills;
102  }
103 
109  protected function getSingleSkills() : array
110  {
111  $s_skills = array_map(function ($v) {
112  return array(
113  "base_skill_id" => $v["skill_id"],
114  "tref_id" => $v["tref_id"],
115  "title" => ilBasicSkill::_lookupTitle($v["skill_id"], $v["tref_id"])
116  );
117  }, $this->container_skills->getSkills());
118 
119  return $s_skills;
120  }
121 
127  protected function getProfileSkills() : array
128  {
129  $p_skills = array();
130  // Global skills
131  if ($this->skmg_settings->getLocalAssignmentOfProfiles()) {
132  foreach ($this->container_global_profiles->getProfiles() as $gp) {
133  $profile = new ilSkillProfile($gp["profile_id"]);
134  $sklvs = $profile->getSkillLevels();
135  foreach ($sklvs as $s) {
136  $p_skills[] = array(
137  "base_skill_id" => $s["base_skill_id"],
138  "tref_id" => $s["tref_id"],
139  "title" => ilBasicSkill::_lookupTitle($s["base_skill_id"], $s["tref_id"]),
140  "profile" => $profile->getTitle()
141  );
142  }
143  }
144  }
145 
146  // Local skills
147  if ($this->skmg_settings->getAllowLocalProfiles()) {
148  foreach ($this->container_local_profiles->getProfiles() as $lp) {
149  $profile = new ilSkillProfile($lp["profile_id"]);
150  $sklvs = $profile->getSkillLevels();
151  foreach ($sklvs as $s) {
152  $p_skills[] = array(
153  "base_skill_id" => $s["base_skill_id"],
154  "tref_id" => $s["tref_id"],
155  "title" => ilBasicSkill::_lookupTitle($s["base_skill_id"], $s["tref_id"]),
156  "profile" => $profile->getTitle()
157  );
158  }
159  }
160  }
161 
162  return $p_skills;
163  }
164 }
getSingleSkills()
Get single skills of container.
Skills of a container.
Global competence profiles of a container.
getSkillsForPresentationGUI()
Get all skills for presentation gui.
getProfileSkills()
Get profile skills of container.
static _lookupTitle($a_obj_id, $a_tref_id=0)
Lookup Title.
Local competence profiles of a container.
Collector of skills for a container.
__construct(ilContainerSkills $a_cont_skills, ilContainerGlobalProfiles $a_cont_glb_profiles, ilContainerLocalProfiles $a_cont_lcl_profiles)
Constructor.