ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilSkillLevelDBRepository Class Reference

Class ilSkillLevelDBRepository. More...

+ Inheritance diagram for ilSkillLevelDBRepository:
+ Collaboration diagram for ilSkillLevelDBRepository:

Public Member Functions

 __construct (ilSkillTreeRepository $tree_repo, ?ilDBInterface $db=null)
 
 deleteLevelsOfSkill (int $skill_id)
 
 addLevel (int $skill_id, string $a_title, string $a_description, string $a_import_id="")
 
 getLevelData (int $skill_id, int $a_id=0)
 Returns multiple rows when $a_id is 0 else one or []. More...
 
 lookupLevelTitle (int $a_id)
 
 lookupLevelDescription (int $a_id)
 
 lookupLevelSkillId (int $a_id)
 
 lookupLevelNumber (int $a_id)
 
 writeLevelTitle (int $a_id, string $a_title)
 
 writeLevelDescription (int $a_id, string $a_description)
 
 updateLevelOrder (array $order)
 
 deleteLevel (int $a_id)
 
 fixLevelNumbering (int $skill_id)
 
 getSkillForLevelId (int $a_level_id)
 
 deleteLevelsOfSkill (int $skill_id)
 
 addLevel (int $skill_id, string $a_title, string $a_description, string $a_import_id="")
 
 getLevelData (int $skill_id, int $a_id=0)
 
 lookupLevelTitle (int $a_id)
 
 lookupLevelDescription (int $a_id)
 
 lookupLevelSkillId (int $a_id)
 
 lookupLevelNumber (int $a_id)
 
 writeLevelTitle (int $a_id, string $a_title)
 
 writeLevelDescription (int $a_id, string $a_description)
 
 updateLevelOrder (array $order)
 
 deleteLevel (int $a_id)
 
 fixLevelNumbering (int $skill_id)
 
 getSkillForLevelId (int $a_level_id)
 

Protected Member Functions

 getMaxLevelNr (int $skill_id)
 
 lookupLevelProperty (int $a_id, string $a_prop)
 
 writeLevelProperty (int $a_id, string $a_prop, ?string $a_value, string $a_type)
 

Protected Attributes

ilDBInterface $db
 
ilSkillTreeRepository $tree_repo
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilSkillLevelDBRepository::__construct ( ilSkillTreeRepository  $tree_repo,
?ilDBInterface  $db = null 
)

Definition at line 29 of file class.ilSkillLevelDBRepository.php.

30 {
31 global $DIC;
32
33 $this->tree_repo = $tree_repo;
34 $this->db = ($db)
35 ?: $DIC->database();
36 }
global $DIC
Definition: shib_login.php:26

References $db, $DIC, and $tree_repo.

Member Function Documentation

◆ addLevel()

ilSkillLevelDBRepository::addLevel ( int  $skill_id,
string  $a_title,
string  $a_description,
string  $a_import_id = "" 
)

Implements ilSkillLevelRepository.

Definition at line 48 of file class.ilSkillLevelDBRepository.php.

48 : void
49 {
51
52 $nr = $this->getMaxLevelNr($skill_id);
53 $nid = $ilDB->nextId("skl_level");
54 $ilDB->insert("skl_level", array(
55 "id" => array("integer", $nid),
56 "skill_id" => array("integer", $skill_id),
57 "nr" => array("integer", $nr + 1),
58 "title" => array("text", $a_title),
59 "description" => array("clob", $a_description),
60 "import_id" => array("text", $a_import_id),
61 "creation_date" => array("timestamp", ilUtil::now())
62 ));
63 }
static now()
Return current timestamp in Y-m-d H:i:s format.

References $db, $ilDB, getMaxLevelNr(), and ilUtil\now().

+ Here is the call graph for this function:

◆ deleteLevel()

ilSkillLevelDBRepository::deleteLevel ( int  $a_id)

Implements ilSkillLevelRepository.

Definition at line 174 of file class.ilSkillLevelDBRepository.php.

174 : void
175 {
177
178 $ilDB->manipulate(
179 "DELETE FROM skl_level WHERE "
180 . " id = " . $ilDB->quote($a_id, "integer")
181 );
182 }

References $db, and $ilDB.

◆ deleteLevelsOfSkill()

ilSkillLevelDBRepository::deleteLevelsOfSkill ( int  $skill_id)

Implements ilSkillLevelRepository.

Definition at line 38 of file class.ilSkillLevelDBRepository.php.

38 : void
39 {
41
42 $ilDB->manipulate(
43 "DELETE FROM skl_level WHERE "
44 . " skill_id = " . $ilDB->quote($skill_id, "integer")
45 );
46 }

References $db, and $ilDB.

◆ fixLevelNumbering()

ilSkillLevelDBRepository::fixLevelNumbering ( int  $skill_id)

Implements ilSkillLevelRepository.

Definition at line 184 of file class.ilSkillLevelDBRepository.php.

184 : void
185 {
187
188 $set = $ilDB->query(
189 "SELECT id, nr FROM skl_level WHERE " .
190 " skill_id = " . $ilDB->quote($skill_id, "integer") .
191 " ORDER BY nr ASC"
192 );
193 $cnt = 1;
194 while ($rec = $ilDB->fetchAssoc($set)) {
195 $ilDB->manipulate(
196 "UPDATE skl_level SET " .
197 " nr = " . $ilDB->quote($cnt, "integer") .
198 " WHERE id = " . $ilDB->quote($rec["id"], "integer")
199 );
200 $cnt++;
201 }
202 }

References $db, and $ilDB.

◆ getLevelData()

ilSkillLevelDBRepository::getLevelData ( int  $skill_id,
int  $a_id = 0 
)

Returns multiple rows when $a_id is 0 else one or [].

Implements ilSkillLevelRepository.

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

80 : array
81 {
83
84 $and = "";
85 if ($a_id > 0) {
86 $and = " AND id = " . $ilDB->quote($a_id, "integer");
87 }
88
89 $set = $ilDB->query(
90 "SELECT * FROM skl_level WHERE " .
91 " skill_id = " . $ilDB->quote($skill_id, "integer") .
92 $and .
93 " ORDER BY nr"
94 );
95 $levels = [];
96 while ($rec = $ilDB->fetchAssoc($set)) {
97 if ($a_id > 0) {
98 return $rec ?? [];
99 }
100 $levels[] = $rec;
101 }
102 return $levels;
103 }

References $db, and $ilDB.

◆ getMaxLevelNr()

ilSkillLevelDBRepository::getMaxLevelNr ( int  $skill_id)
protected

Definition at line 65 of file class.ilSkillLevelDBRepository.php.

65 : int
66 {
68
69 $set = $ilDB->query(
70 "SELECT MAX(nr) mnr FROM skl_level WHERE " .
71 " skill_id = " . $ilDB->quote($skill_id, "integer")
72 );
73 $rec = $ilDB->fetchAssoc($set);
74 return (int) ($rec["mnr"] ?? 0);
75 }

References $db, and $ilDB.

Referenced by addLevel().

+ Here is the caller graph for this function:

◆ getSkillForLevelId()

ilSkillLevelDBRepository::getSkillForLevelId ( int  $a_level_id)

Implements ilSkillLevelRepository.

Definition at line 204 of file class.ilSkillLevelDBRepository.php.

204 : ?ilBasicSkill
205 {
207
208 $set = $ilDB->query(
209 "SELECT * FROM skl_level WHERE " .
210 " id = " . $ilDB->quote($a_level_id, "integer")
211 );
212 $skill = null;
213 if ($rec = $ilDB->fetchAssoc($set)) {
214 if ($this->tree_repo->isInAnyTree((int) $rec["skill_id"])) {
215 $skill = new ilBasicSkill((int) $rec["skill_id"]);
216 }
217 }
218 return $skill;
219 }

References $db, and $ilDB.

◆ lookupLevelDescription()

ilSkillLevelDBRepository::lookupLevelDescription ( int  $a_id)

Implements ilSkillLevelRepository.

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

123 : string
124 {
125 return $this->lookupLevelProperty($a_id, "description") ?? "";
126 }
lookupLevelProperty(int $a_id, string $a_prop)

References lookupLevelProperty().

+ Here is the call graph for this function:

◆ lookupLevelNumber()

ilSkillLevelDBRepository::lookupLevelNumber ( int  $a_id)

Implements ilSkillLevelRepository.

Definition at line 133 of file class.ilSkillLevelDBRepository.php.

133 : int
134 {
135 return (int) ($this->lookupLevelProperty($a_id, "nr") ?? 0);
136 }

References lookupLevelProperty().

+ Here is the call graph for this function:

◆ lookupLevelProperty()

ilSkillLevelDBRepository::lookupLevelProperty ( int  $a_id,
string  $a_prop 
)
protected

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

105 : ?string
106 {
108
109 $set = $ilDB->query(
110 "SELECT $a_prop FROM skl_level WHERE " .
111 " id = " . $ilDB->quote($a_id, "integer")
112 );
113 $rec = $ilDB->fetchAssoc($set);
114
115 return isset($rec[$a_prop]) ? (string) $rec[$a_prop] : null;
116 }

References $db, and $ilDB.

Referenced by lookupLevelDescription(), lookupLevelNumber(), lookupLevelSkillId(), and lookupLevelTitle().

+ Here is the caller graph for this function:

◆ lookupLevelSkillId()

ilSkillLevelDBRepository::lookupLevelSkillId ( int  $a_id)

Implements ilSkillLevelRepository.

Definition at line 128 of file class.ilSkillLevelDBRepository.php.

128 : int
129 {
130 return (int) ($this->lookupLevelProperty($a_id, "skill_id") ?? 0);
131 }

References lookupLevelProperty().

+ Here is the call graph for this function:

◆ lookupLevelTitle()

ilSkillLevelDBRepository::lookupLevelTitle ( int  $a_id)

Implements ilSkillLevelRepository.

Definition at line 118 of file class.ilSkillLevelDBRepository.php.

118 : string
119 {
120 return $this->lookupLevelProperty($a_id, "title") ?? "";
121 }

References lookupLevelProperty().

+ Here is the call graph for this function:

◆ updateLevelOrder()

ilSkillLevelDBRepository::updateLevelOrder ( array  $order)

Implements ilSkillLevelRepository.

Definition at line 159 of file class.ilSkillLevelDBRepository.php.

159 : void
160 {
162
163 $cnt = 1;
164 foreach ($order as $id => $o) {
165 $ilDB->manipulate(
166 "UPDATE skl_level SET " .
167 " nr = " . $ilDB->quote($cnt, "integer") .
168 " WHERE id = " . $ilDB->quote($id, "integer")
169 );
170 $cnt++;
171 }
172 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23

References $db, $id, and $ilDB.

◆ writeLevelDescription()

ilSkillLevelDBRepository::writeLevelDescription ( int  $a_id,
string  $a_description 
)

Implements ilSkillLevelRepository.

Definition at line 154 of file class.ilSkillLevelDBRepository.php.

154 : void
155 {
156 $this->writeLevelProperty($a_id, "description", $a_description, "clob");
157 }
writeLevelProperty(int $a_id, string $a_prop, ?string $a_value, string $a_type)

References writeLevelProperty().

+ Here is the call graph for this function:

◆ writeLevelProperty()

ilSkillLevelDBRepository::writeLevelProperty ( int  $a_id,
string  $a_prop,
?string  $a_value,
string  $a_type 
)
protected

Definition at line 138 of file class.ilSkillLevelDBRepository.php.

138 : void
139 {
141
142 $ilDB->update("skl_level", array(
143 $a_prop => array($a_type, $a_value),
144 ), array(
145 "id" => array("integer", $a_id),
146 ));
147 }

References $db, and $ilDB.

Referenced by writeLevelDescription(), and writeLevelTitle().

+ Here is the caller graph for this function:

◆ writeLevelTitle()

ilSkillLevelDBRepository::writeLevelTitle ( int  $a_id,
string  $a_title 
)

Implements ilSkillLevelRepository.

Definition at line 149 of file class.ilSkillLevelDBRepository.php.

149 : void
150 {
151 $this->writeLevelProperty($a_id, "title", $a_title, "text");
152 }

References writeLevelProperty().

+ Here is the call graph for this function:

Field Documentation

◆ $db

◆ $tree_repo

ilSkillTreeRepository ilSkillLevelDBRepository::$tree_repo
protected

Definition at line 27 of file class.ilSkillLevelDBRepository.php.

Referenced by __construct().


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