ILIAS  trunk Revision v11.0_alpha-1689-g66c127b4ae8
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
class.AssignedMaterialManager.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
21 namespace ILIAS\Skill\Personal;
22 
24 
29 {
32 
33  public function __construct(
34  ?AssignedMaterialDBRepository $ass_mat_repo = null,
35  ?PersonalSkillDBRepository $personal_repo = null
36  ) {
37  global $DIC;
38 
39  $this->ass_mat_repo = ($ass_mat_repo) ?: $DIC->skills()->internal()->repo()->getAssignedMaterialRepo();
40  $this->personal_repo = ($personal_repo) ?: $DIC->skills()->internal()->repo()->getPersonalSkillRepo();
41  }
42 
53  public function assignMaterial(
54  int $user_id,
55  int $top_skill_id,
56  int $tref_id,
57  int $basic_skill_id,
58  int $level_id,
59  int $wsp_id
60  ): void {
61  $this->ass_mat_repo->assign($user_id, $top_skill_id, $tref_id, $basic_skill_id, $level_id, $wsp_id);
62  }
63 
68  public function getAssignedMaterials(int $user_id, int $tref_id, int $level_id): array
69  {
70  return $this->ass_mat_repo->get($user_id, $tref_id, $level_id);
71  }
72 
77  public function getAllAssignedMaterialsForSkill(int $user_id, int $skill_id, int $tref_id): array
78  {
79  return $this->ass_mat_repo->getAll($user_id, $skill_id, $tref_id);
80  }
81 
85  public function countAssignedMaterials(int $user_id, int $tref_id, int $level_id): int
86  {
87  return $this->ass_mat_repo->count($user_id, $tref_id, $level_id);
88  }
89 
90  public function removeAssignedMaterial(int $user_id, int $tref_id, int $level_id, int $wsp_id): void
91  {
92  $this->ass_mat_repo->remove($user_id, $tref_id, $level_id, $wsp_id);
93  }
94 
95  public function removeAssignedMaterialsForUser(int $user_id): void
96  {
97  $this->ass_mat_repo->removeAllForUser($user_id);
98  }
99 
100  public function removeAssignedMaterialsForSkill(int $skill_node_id, bool $is_reference = false): void
101  {
102  $this->ass_mat_repo->removeAllForSkill($skill_node_id, $is_reference);
103  }
104 
108  public static function getUsageInfo(array $a_cskill_ids): array
109  {
110  global $DIC;
111 
112  $personal_repo = $DIC->skills()->internal()->repo()->getPersonalSkillRepo();
113  $usage_manager = $DIC->skills()->internal()->manager()->getUsageManager();
114 
115  // material
116  $usages = $usage_manager->getUsageInfoGeneric(
117  $a_cskill_ids,
119  "skl_assigned_material",
120  "user_id"
121  );
122 
123  // users that use the skills as personal skills
124  $pskill_ids = [];
125  $tref_ids = [];
126  foreach ($a_cskill_ids as $cs) {
127  $cs["tref_id"] = (int) $cs["tref_id"];
128  $cs["skill_id"] = (int) $cs["skill_id"];
129  if ($cs["tref_id"] > 0) {
130  if (\ilSkillTemplateReference::_lookupTemplateId($cs["tref_id"]) === $cs["skill_id"]) {
131  $pskill_ids[$cs["tref_id"]] = $cs["tref_id"];
132  $tref_ids[$cs["tref_id"]] = $cs["skill_id"];
133  }
134  } else {
135  $pskill_ids[$cs["skill_id"]] = $cs["skill_id"];
136  }
137  }
138  $usages = $personal_repo->getUsages($usages, $pskill_ids, $tref_ids);
139 
140  return $usages;
141  }
142 }
removeAssignedMaterial(int $user_id, int $tref_id, int $level_id, int $wsp_id)
getUsages(array $usages, array $pskill_ids, array $tref_ids)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
removeAssignedMaterialsForSkill(int $skill_node_id, bool $is_reference=false)
__construct(?AssignedMaterialDBRepository $ass_mat_repo=null, ?PersonalSkillDBRepository $personal_repo=null)
global $DIC
Definition: shib_login.php:22
getAllAssignedMaterialsForSkill(int $user_id, int $skill_id, int $tref_id)
Get all assigned materials (for a skill and user)
getAssignedMaterials(int $user_id, int $tref_id, int $level_id)
Get assigned materials (for a skill level and user)
assignMaterial(int $user_id, int $top_skill_id, int $tref_id, int $basic_skill_id, int $level_id, int $wsp_id)
Assign material to skill level.
Get info on usages of skills.
static getUsageInfo(array $a_cskill_ids)
Get title of an assigned item.int, tref_id: int}[] $a_cskill_ids array of common skill idsarray<strin...
countAssignedMaterials(int $user_id, int $tref_id, int $level_id)
Count assigned materials (for a skill level and user)