ILIAS  release_8 Revision v8.24
ILIAS\Skill\Profile\SkillProfileLevelsDBRepository Class Reference
+ Collaboration diagram for ILIAS\Skill\Profile\SkillProfileLevelsDBRepository:

Public Member Functions

 __construct (\ilDBInterface $db=null)
 
 getProfileLevels (int $profile_id)
 
 createProfileLevels (int $profile_id, array $levels)
 
 updateProfileLevels (int $profile_id, array $levels)
 
 deleteProfileLevels (int $profile_id)
 
 updateSkillOrder (int $profile_id, array $order)
 
 fixSkillOrderNumbering (int $profile_id)
 
 getMaxLevelOrderNr (int $profile_id)
 

Protected Attributes

ilDBInterface $db
 

Detailed Description

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

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Skill\Profile\SkillProfileLevelsDBRepository::__construct ( \ilDBInterface  $db = null)

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

27 {
28 global $DIC;
29
30 $this->db = ($db) ?: $DIC->database();
31 }
global $DIC
Definition: feed.php:28

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

Member Function Documentation

◆ createProfileLevels()

ILIAS\Skill\Profile\SkillProfileLevelsDBRepository::createProfileLevels ( int  $profile_id,
array  $levels 
)

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

55 : void
56 {
58
59 foreach ($levels as $level) {
60 $ilDB->replace(
61 "skl_profile_level",
62 array("profile_id" => array("integer", $profile_id),
63 "tref_id" => array("integer", (int) $level["tref_id"]),
64 "base_skill_id" => array("integer", (int) $level["base_skill_id"])
65 ),
66 array("order_nr" => array("integer", (int) $level["order_nr"]),
67 "level_id" => array("integer", (int) $level["level_id"])
68 )
69 );
70 }
71 }

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

◆ deleteProfileLevels()

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

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

95 : void
96 {
98
99 $ilDB->manipulate(
100 "DELETE FROM skl_profile_level WHERE " .
101 " profile_id = " . $ilDB->quote($profile_id, "integer")
102 );
103 }

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

◆ fixSkillOrderNumbering()

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

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

123 : void
124 {
126
127 $set = $ilDB->query(
128 "SELECT profile_id, base_skill_id, tref_id, order_nr FROM skl_profile_level WHERE " .
129 " profile_id = " . $ilDB->quote($profile_id, "integer") .
130 " ORDER BY order_nr ASC"
131 );
132 $cnt = 1;
133 while ($rec = $ilDB->fetchAssoc($set)) {
134 $ilDB->manipulate(
135 "UPDATE skl_profile_level SET " .
136 " order_nr = " . $ilDB->quote(($cnt * 10), "integer") .
137 " WHERE profile_id = " . $ilDB->quote($rec["profile_id"], "integer") .
138 " AND base_skill_id = " . $ilDB->quote($rec["base_skill_id"], "integer") .
139 " AND tref_id = " . $ilDB->quote($rec["tref_id"], "integer")
140 );
141 $cnt++;
142 }
143 }

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

◆ getMaxLevelOrderNr()

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

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

145 : int
146 {
148
149 $set = $ilDB->query(
150 "SELECT MAX(order_nr) mnr FROM skl_profile_level WHERE " .
151 " profile_id = " . $ilDB->quote($profile_id, "integer")
152 );
153 $rec = $ilDB->fetchAssoc($set);
154 return (int) $rec["mnr"];
155 }

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

◆ getProfileLevels()

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

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

33 : array
34 {
36
37 $set = $ilDB->query(
38 "SELECT * FROM skl_profile_level " .
39 " WHERE profile_id = " . $ilDB->quote($profile_id, "integer")
40 );
41
42 $levels = [];
43 while ($rec = $ilDB->fetchAssoc($set)) {
44 $levels[] = [
45 "base_skill_id" => (int) $rec["base_skill_id"],
46 "tref_id" => (int) $rec["tref_id"],
47 "level_id" => (int) $rec["level_id"],
48 "order_nr" => (int) $rec["order_nr"]
49 ];
50 }
51
52 return $levels;
53 }

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

+ Here is the call graph for this function:

◆ updateProfileLevels()

ILIAS\Skill\Profile\SkillProfileLevelsDBRepository::updateProfileLevels ( int  $profile_id,
array  $levels 
)

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

73 : void
74 {
76
77 $ilDB->manipulate(
78 "DELETE FROM skl_profile_level WHERE " .
79 " profile_id = " . $ilDB->quote($profile_id, "integer")
80 );
81 foreach ($levels as $level) {
82 $ilDB->replace(
83 "skl_profile_level",
84 array("profile_id" => array("integer", $profile_id),
85 "tref_id" => array("integer", (int) $level["tref_id"]),
86 "base_skill_id" => array("integer", (int) $level["base_skill_id"])
87 ),
88 array("order_nr" => array("integer", (int) $level["order_nr"]),
89 "level_id" => array("integer", (int) $level["level_id"])
90 )
91 );
92 }
93 }

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

◆ updateSkillOrder()

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

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

105 : void
106 {
108
109 $cnt = 1;
110 foreach ($order as $id => $o) {
111 $id_arr = explode("_", $id);
112 $ilDB->manipulate(
113 "UPDATE skl_profile_level SET " .
114 " order_nr = " . $ilDB->quote(($cnt * 10), "integer") .
115 " WHERE base_skill_id = " . $ilDB->quote($id_arr[0], "integer") .
116 " AND tref_id = " . $ilDB->quote($id_arr[1], "integer") .
117 " AND profile_id = " . $ilDB->quote($profile_id, "integer")
118 );
119 $cnt++;
120 }
121 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23

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

Field Documentation

◆ $db


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