ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
class.AssignedMaterialManager.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
22 namespace ILIAS\Skill\Personal;
23 
25 
30 {
33 
34  public function __construct(
35  AssignedMaterialDBRepository $ass_mat_repo = null,
36  PersonalSkillDBRepository $personal_repo = null
37  ) {
38  global $DIC;
39 
40  $this->ass_mat_repo = ($ass_mat_repo) ?: $DIC->skills()->internal()->repo()->getAssignedMaterialRepo();
41  $this->personal_repo = ($personal_repo) ?: $DIC->skills()->internal()->repo()->getPersonalSkillRepo();
42  }
43 
54  public function assignMaterial(
55  int $user_id,
56  int $top_skill_id,
57  int $tref_id,
58  int $basic_skill_id,
59  int $level_id,
60  int $wsp_id
61  ): void {
62  $this->ass_mat_repo->assign($user_id, $top_skill_id, $tref_id, $basic_skill_id, $level_id, $wsp_id);
63  }
64 
69  public function getAssignedMaterials(int $user_id, int $tref_id, int $level_id): array
70  {
71  return $this->ass_mat_repo->get($user_id, $tref_id, $level_id);
72  }
73 
78  public function getAllAssignedMaterialsForSkill(int $user_id, int $skill_id, int $tref_id): array
79  {
80  return $this->ass_mat_repo->getAll($user_id, $skill_id, $tref_id);
81  }
82 
86  public function countAssignedMaterials(int $user_id, int $tref_id, int $level_id): int
87  {
88  return $this->ass_mat_repo->count($user_id, $tref_id, $level_id);
89  }
90 
91  public function removeAssignedMaterial(int $user_id, int $tref_id, int $level_id, int $wsp_id): void
92  {
93  $this->ass_mat_repo->remove($user_id, $tref_id, $level_id, $wsp_id);
94  }
95 
96  public function removeAssignedMaterialsForUser(int $user_id): void
97  {
98  $this->ass_mat_repo->removeAllForUser($user_id);
99  }
100 
101  public function removeAssignedMaterialsForSkill(int $skill_node_id, bool $is_reference = false): void
102  {
103  $this->ass_mat_repo->removeAllForSkill($skill_node_id, $is_reference);
104  }
105 
109  public static function getUsageInfo(array $a_cskill_ids): array
110  {
111  global $DIC;
112 
113  $personal_repo = $DIC->skills()->internal()->repo()->getPersonalSkillRepo();
114  $usage_manager = $DIC->skills()->internal()->manager()->getUsageManager();
115 
116  // material
117  $usages = $usage_manager->getUsageInfoGeneric(
118  $a_cskill_ids,
120  "skl_assigned_material",
121  "user_id"
122  );
123 
124  // users that use the skills as personal skills
125  $pskill_ids = [];
126  $tref_ids = [];
127  foreach ($a_cskill_ids as $cs) {
128  $cs["tref_id"] = (int) $cs["tref_id"];
129  $cs["skill_id"] = (int) $cs["skill_id"];
130  if ($cs["tref_id"] > 0) {
131  if (\ilSkillTemplateReference::_lookupTemplateId($cs["tref_id"]) === $cs["skill_id"]) {
132  $pskill_ids[$cs["tref_id"]] = $cs["tref_id"];
133  $tref_ids[$cs["tref_id"]] = $cs["skill_id"];
134  }
135  } else {
136  $pskill_ids[$cs["skill_id"]] = $cs["skill_id"];
137  }
138  }
139  $usages = $personal_repo->getUsages($usages, $pskill_ids, $tref_ids);
140 
141  return $usages;
142  }
143 }
__construct(AssignedMaterialDBRepository $ass_mat_repo=null, PersonalSkillDBRepository $personal_repo=null)
removeAssignedMaterial(int $user_id, int $tref_id, int $level_id, int $wsp_id)
getUsages(array $usages, array $pskill_ids, array $tref_ids)
global $DIC
Definition: feed.php:28
removeAssignedMaterialsForSkill(int $skill_node_id, bool $is_reference=false)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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)