ILIAS  release_8 Revision v8.23
class.ilContSkillCollector.php
Go to the documentation of this file.
1 <?php
2 
22 
29 {
30  protected array $tab_skills = [];
31  protected array $pres_skills = [];
38 
39  public function __construct(
40  ilContainerSkills $a_cont_skills,
41  ilContainerGlobalProfiles $a_cont_glb_profiles,
42  ilContainerLocalProfiles $a_cont_lcl_profiles
43  ) {
44  global $DIC;
45 
46  $this->container_skills = $a_cont_skills;
47  $this->container_global_profiles = $a_cont_glb_profiles;
48  $this->container_local_profiles = $a_cont_lcl_profiles;
49  $this->skmg_settings = new ilSkillManagementSettings();
50  $this->tree_service = $DIC->skills()->tree();
51  $this->profile_service = $DIC->skills()->profile();
52  }
53 
54  public function getSkillsForTableGUI(): array
55  {
56  // Get single and profile skills WITHOUT array keys so as not to remove multiple occurrences when merging
57 
58  $s_skills = array_values($this->getSingleSkills());
59  $p_skills = $this->getProfileSkills();
60 
61  $this->tab_skills = array_merge($s_skills, $p_skills);
62 
63  // order skills per virtual skill tree
64  $vtree = $this->tree_service->getGlobalVirtualSkillTree();
65  $this->tab_skills = $vtree->getOrderedNodeset($this->tab_skills, "base_skill_id", "tref_id");
66 
67  return $this->tab_skills;
68  }
69 
70  public function getSkillsForPresentationGUI(): array
71  {
72  // Get single and profile skills WITH array keys so as to remove multiple occurrences when merging
73 
74  $s_skills = $this->getSingleSkills();
75  $p_skills = [];
76 
77  foreach ($this->getProfileSkills() as $ps) {
78  $p_skills[$ps["base_skill_id"] . "-" . $ps["tref_id"]] = [
79  "base_skill_id" => $ps["base_skill_id"],
80  "tref_id" => $ps["tref_id"],
81  "title" => $ps["title"],
82  "profile" => $ps["profile"]
83  ];
84  }
85 
86  $this->pres_skills = array_merge($s_skills, $p_skills);
87 
88  return $this->pres_skills;
89  }
90 
91  protected function getSingleSkills(): array
92  {
93  $s_skills = array_map(static function (array $v): array {
94  return [
95  "base_skill_id" => $v["skill_id"],
96  "tref_id" => $v["tref_id"],
97  "title" => ilBasicSkill::_lookupTitle($v["skill_id"], $v["tref_id"])
98  ];
99  }, $this->container_skills->getSkills());
100 
101  return $s_skills;
102  }
103 
104  protected function getProfileSkills(): array
105  {
106  $p_skills = [];
107  // Global skills
108  if ($this->skmg_settings->getLocalAssignmentOfProfiles()) {
109  foreach ($this->container_global_profiles->getProfiles() as $gp) {
110  $profile = $this->profile_service->getById($gp["profile_id"]);
111  $sklvs = $profile->getSkillLevels();
112  foreach ($sklvs as $s) {
113  $p_skills[] = [
114  "base_skill_id" => $s["base_skill_id"],
115  "tref_id" => $s["tref_id"],
116  "title" => ilBasicSkill::_lookupTitle($s["base_skill_id"], $s["tref_id"]),
117  "profile" => $profile->getTitle()
118  ];
119  }
120  }
121  }
122 
123  // Local skills
124  if ($this->skmg_settings->getAllowLocalProfiles()) {
125  foreach ($this->container_local_profiles->getProfiles() as $lp) {
126  $profile = $this->profile_service->getById($lp["profile_id"]);
127  $sklvs = $profile->getSkillLevels();
128  foreach ($sklvs as $s) {
129  $p_skills[] = [
130  "base_skill_id" => $s["base_skill_id"],
131  "tref_id" => $s["tref_id"],
132  "title" => ilBasicSkill::_lookupTitle($s["base_skill_id"], $s["tref_id"]),
133  "profile" => $profile->getTitle()
134  ];
135  }
136  }
137  }
138 
139  return $p_skills;
140  }
141 }
ilContainerLocalProfiles $container_local_profiles
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _lookupTitle(int $a_obj_id, int $a_tref_id=0)
Skills of a container.
SkillProfileService $profile_service
ilSkillManagementSettings $skmg_settings
global $DIC
Definition: feed.php:28
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Collector of skills for a container.
__construct(ilContainerSkills $a_cont_skills, ilContainerGlobalProfiles $a_cont_glb_profiles, ilContainerLocalProfiles $a_cont_lcl_profiles)
ilContainerGlobalProfiles $container_global_profiles