ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
ILIAS\Skill\Profile\SkillProfileLevelsDBRepository Class Reference
+ Collaboration diagram for ILIAS\Skill\Profile\SkillProfileLevelsDBRepository:

Public Member Functions

 __construct (\ilDBInterface $db=null, Service\SkillInternalFactoryService $factory_service=null)
 
 getAll (int $profile_id)
 
 get (int $profile_id, int $base_skill_id, int $tref_id)
 
 createOrUpdate (SkillProfileLevel $skill_level_obj)
 
 delete (SkillProfileLevel $skill_level_obj)
 
 deleteAllForProfile (int $profile_id)
 
 deleteAllForSkill (int $skill_node_id, bool $is_reference)
 
 updateSkillOrder (int $profile_id, array $order)
 
 fixSkillOrderNumbering (int $profile_id)
 
 getMaxOrderNr (int $profile_id)
 

Protected Member Functions

 getFromRecord (array $rec)
 

Protected Attributes

ilDBInterface $db
 
Service SkillInternalFactoryService $factory_service
 

Detailed Description

Definition at line 26 of file class.SkillProfileLevelsDBRepository.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Skill\Profile\SkillProfileLevelsDBRepository::__construct ( \ilDBInterface  $db = null,
Service\SkillInternalFactoryService  $factory_service = null 
)

Definition at line 31 of file class.SkillProfileLevelsDBRepository.php.

References ILIAS\Skill\Profile\SkillProfileLevelsDBRepository\$db, $DIC, and ILIAS\Skill\Profile\SkillProfileLevelsDBRepository\$factory_service.

34  {
35  global $DIC;
36 
37  $this->db = ($db) ?: $DIC->database();
38  $this->factory_service = ($factory_service) ?: $DIC->skills()->internal()->factory();
39  }
global $DIC
Definition: shib_login.php:25

Member Function Documentation

◆ createOrUpdate()

ILIAS\Skill\Profile\SkillProfileLevelsDBRepository::createOrUpdate ( SkillProfileLevel  $skill_level_obj)

Definition at line 97 of file class.SkillProfileLevelsDBRepository.php.

References ILIAS\Skill\Profile\SkillProfileLevelsDBRepository\$db, $ilDB, ILIAS\Skill\Profile\SkillProfileLevel\getBaseSkillId(), ILIAS\Skill\Profile\SkillProfileLevel\getLevelId(), ILIAS\Skill\Profile\SkillProfileLevel\getOrderNr(), ILIAS\Skill\Profile\SkillProfileLevel\getProfileId(), and ILIAS\Skill\Profile\SkillProfileLevel\getTrefId().

97  : void
98  {
99  $ilDB = $this->db;
100 
101  $ilDB->replace(
102  "skl_profile_level",
103  array("profile_id" => array("integer", $skill_level_obj->getProfileId()),
104  "tref_id" => array("integer", $skill_level_obj->getTrefId()),
105  "base_skill_id" => array("integer", $skill_level_obj->getBaseSkillId())
106  ),
107  array("order_nr" => array("integer", $skill_level_obj->getOrderNr()),
108  "level_id" => array("integer", $skill_level_obj->getLevelId())
109  )
110  );
111  }
+ Here is the call graph for this function:

◆ delete()

ILIAS\Skill\Profile\SkillProfileLevelsDBRepository::delete ( SkillProfileLevel  $skill_level_obj)

Definition at line 113 of file class.SkillProfileLevelsDBRepository.php.

References ILIAS\Skill\Profile\SkillProfileLevelsDBRepository\$db, and $ilDB.

113  : void
114  {
115  $ilDB = $this->db;
116 
117  $ilDB->manipulate(
118  "DELETE FROM skl_profile_level WHERE " .
119  " base_skill_id = " . $ilDB->quote($skill_level_obj->getBaseSkillId(), "integer") .
120  " AND tref_id = " . $ilDB->quote($skill_level_obj->getTrefId(), "integer") .
121  " AND level_id = " . $ilDB->quote($skill_level_obj->getLevelId(), "integer") .
122  " AND order_nr = " . $ilDB->quote($skill_level_obj->getOrderNr(), "integer")
123  );
124  }

◆ deleteAllForProfile()

ILIAS\Skill\Profile\SkillProfileLevelsDBRepository::deleteAllForProfile ( int  $profile_id)

Definition at line 126 of file class.SkillProfileLevelsDBRepository.php.

References ILIAS\Skill\Profile\SkillProfileLevelsDBRepository\$db, and $ilDB.

126  : void
127  {
128  $ilDB = $this->db;
129 
130  $ilDB->manipulate(
131  "DELETE FROM skl_profile_level WHERE " .
132  " profile_id = " . $ilDB->quote($profile_id, "integer")
133  );
134  }

◆ deleteAllForSkill()

ILIAS\Skill\Profile\SkillProfileLevelsDBRepository::deleteAllForSkill ( int  $skill_node_id,
bool  $is_reference 
)

Definition at line 136 of file class.SkillProfileLevelsDBRepository.php.

References ILIAS\Skill\Profile\SkillProfileLevelsDBRepository\$db, and $ilDB.

136  : void
137  {
138  $ilDB = $this->db;
139 
140  if (!$is_reference) {
141  $ilDB->manipulate(
142  "DELETE FROM skl_profile_level WHERE " .
143  " base_skill_id = " . $ilDB->quote($skill_node_id, "integer")
144  );
145  } else {
146  $ilDB->manipulate(
147  "DELETE FROM skl_profile_level WHERE " .
148  " tref_id = " . $ilDB->quote($skill_node_id, "integer")
149  );
150  }
151  }

◆ fixSkillOrderNumbering()

ILIAS\Skill\Profile\SkillProfileLevelsDBRepository::fixSkillOrderNumbering ( int  $profile_id)

Definition at line 171 of file class.SkillProfileLevelsDBRepository.php.

References ILIAS\Skill\Profile\SkillProfileLevelsDBRepository\$db, and $ilDB.

171  : void
172  {
173  $ilDB = $this->db;
174 
175  $set = $ilDB->query(
176  "SELECT profile_id, base_skill_id, tref_id, order_nr FROM skl_profile_level WHERE " .
177  " profile_id = " . $ilDB->quote($profile_id, "integer") .
178  " ORDER BY order_nr ASC"
179  );
180  $cnt = 1;
181  while ($rec = $ilDB->fetchAssoc($set)) {
182  $ilDB->manipulate(
183  "UPDATE skl_profile_level SET " .
184  " order_nr = " . $ilDB->quote(($cnt * 10), "integer") .
185  " WHERE profile_id = " . $ilDB->quote($rec["profile_id"], "integer") .
186  " AND base_skill_id = " . $ilDB->quote($rec["base_skill_id"], "integer") .
187  " AND tref_id = " . $ilDB->quote($rec["tref_id"], "integer")
188  );
189  $cnt++;
190  }
191  }

◆ get()

ILIAS\Skill\Profile\SkillProfileLevelsDBRepository::get ( int  $profile_id,
int  $base_skill_id,
int  $tref_id 
)

Definition at line 61 of file class.SkillProfileLevelsDBRepository.php.

References ILIAS\Skill\Profile\SkillProfileLevelsDBRepository\$db, $ilDB, and ILIAS\Skill\Profile\SkillProfileLevelsDBRepository\getFromRecord().

61  : SkillProfileLevel
62  {
63  $ilDB = $this->db;
64 
65  $set = $ilDB->query(
66  "SELECT * FROM skl_profile_level " .
67  " WHERE profile_id = " . $ilDB->quote($profile_id, "integer") .
68  " AND base_skill_id = " . $ilDB->quote($base_skill_id, "integer") .
69  " AND tref_id = " . $ilDB->quote($tref_id, "integer")
70  );
71 
72  $level = [];
73  if ($rec = $ilDB->fetchAssoc($set)) {
74  $level = $this->getFromRecord($rec);
75  }
76 
77  return $level;
78  }
+ Here is the call graph for this function:

◆ getAll()

ILIAS\Skill\Profile\SkillProfileLevelsDBRepository::getAll ( int  $profile_id)
Returns
SkillProfileLevel[]

Definition at line 44 of file class.SkillProfileLevelsDBRepository.php.

References ILIAS\Skill\Profile\SkillProfileLevelsDBRepository\$db, $ilDB, and ILIAS\Skill\Profile\SkillProfileLevelsDBRepository\getFromRecord().

44  : array
45  {
46  $ilDB = $this->db;
47 
48  $set = $ilDB->query(
49  "SELECT * FROM skl_profile_level " .
50  " WHERE profile_id = " . $ilDB->quote($profile_id, "integer")
51  );
52 
53  $levels = [];
54  while ($rec = $ilDB->fetchAssoc($set)) {
55  $levels[] = $this->getFromRecord($rec);
56  }
57 
58  return $levels;
59  }
+ Here is the call graph for this function:

◆ getFromRecord()

ILIAS\Skill\Profile\SkillProfileLevelsDBRepository::getFromRecord ( array  $rec)
protected

Definition at line 80 of file class.SkillProfileLevelsDBRepository.php.

References ILIAS\Repository\int().

Referenced by ILIAS\Skill\Profile\SkillProfileLevelsDBRepository\get(), and ILIAS\Skill\Profile\SkillProfileLevelsDBRepository\getAll().

80  : SkillProfileLevel
81  {
82  $rec["profile_id"] = (int) $rec["profile_id"];
83  $rec["base_skill_id"] = (int) $rec["base_skill_id"];
84  $rec["tref_id"] = (int) $rec["tref_id"];
85  $rec["level_id"] = (int) $rec["level_id"];
86  $rec["order_nr"] = (int) $rec["order_nr"];
87 
88  return $this->factory_service->profile()->profileLevel(
89  $rec["profile_id"],
90  $rec["base_skill_id"],
91  $rec["tref_id"],
92  $rec["level_id"],
93  $rec["order_nr"]
94  );
95  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getMaxOrderNr()

ILIAS\Skill\Profile\SkillProfileLevelsDBRepository::getMaxOrderNr ( int  $profile_id)

Definition at line 193 of file class.SkillProfileLevelsDBRepository.php.

References ILIAS\Skill\Profile\SkillProfileLevelsDBRepository\$db, and $ilDB.

193  : int
194  {
195  $ilDB = $this->db;
196 
197  $set = $ilDB->query(
198  "SELECT MAX(order_nr) mnr FROM skl_profile_level WHERE " .
199  " profile_id = " . $ilDB->quote($profile_id, "integer")
200  );
201  $rec = $ilDB->fetchAssoc($set);
202  return (int) $rec["mnr"];
203  }

◆ updateSkillOrder()

ILIAS\Skill\Profile\SkillProfileLevelsDBRepository::updateSkillOrder ( int  $profile_id,
array  $order 
)

Definition at line 153 of file class.SkillProfileLevelsDBRepository.php.

References ILIAS\Skill\Profile\SkillProfileLevelsDBRepository\$db, $id, and $ilDB.

153  : void
154  {
155  $ilDB = $this->db;
156 
157  $cnt = 1;
158  foreach ($order as $id => $o) {
159  $id_arr = explode("_", $id);
160  $ilDB->manipulate(
161  "UPDATE skl_profile_level SET " .
162  " order_nr = " . $ilDB->quote(($cnt * 10), "integer") .
163  " WHERE base_skill_id = " . $ilDB->quote($id_arr[0], "integer") .
164  " AND tref_id = " . $ilDB->quote($id_arr[1], "integer") .
165  " AND profile_id = " . $ilDB->quote($profile_id, "integer")
166  );
167  $cnt++;
168  }
169  }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:24

Field Documentation

◆ $db

◆ $factory_service

Service SkillInternalFactoryService ILIAS\Skill\Profile\SkillProfileLevelsDBRepository::$factory_service
protected

The documentation for this class was generated from the following file: