ILIAS  release_8 Revision v8.24
ilSkillLevelDBRepository Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. 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)
 
 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)
 
 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

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Class ilSkillLevelDBRepository

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

Constructor & Destructor Documentation

◆ __construct()

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

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

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

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 47 of file class.ilSkillLevelDBRepository.php.

47 : void
48 {
50
51 $nr = $this->getMaxLevelNr($skill_id);
52 $nid = $ilDB->nextId("skl_level");
53 $ilDB->insert("skl_level", array(
54 "id" => array("integer", $nid),
55 "skill_id" => array("integer", $skill_id),
56 "nr" => array("integer", $nr + 1),
57 "title" => array("text", $a_title),
58 "description" => array("clob", $a_description),
59 "import_id" => array("text", $a_import_id),
60 "creation_date" => array("timestamp", ilUtil::now())
61 ));
62 }
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 168 of file class.ilSkillLevelDBRepository.php.

168 : void
169 {
171
172 $ilDB->manipulate(
173 "DELETE FROM skl_level WHERE "
174 . " id = " . $ilDB->quote($a_id, "integer")
175 );
176 }

References $db, and $ilDB.

◆ deleteLevelsOfSkill()

ilSkillLevelDBRepository::deleteLevelsOfSkill ( int  $skill_id)

Implements ilSkillLevelRepository.

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

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

References $db, and $ilDB.

◆ fixLevelNumbering()

ilSkillLevelDBRepository::fixLevelNumbering ( int  $skill_id)

Implements ilSkillLevelRepository.

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

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

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 79 of file class.ilSkillLevelDBRepository.php.

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

References $db, and $ilDB.

◆ getMaxLevelNr()

ilSkillLevelDBRepository::getMaxLevelNr ( int  $skill_id)
protected

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

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

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 198 of file class.ilSkillLevelDBRepository.php.

198 : ?ilBasicSkill
199 {
201
202 $set = $ilDB->query(
203 "SELECT * FROM skl_level WHERE " .
204 " id = " . $ilDB->quote($a_level_id, "integer")
205 );
206 $skill = null;
207 if ($rec = $ilDB->fetchAssoc($set)) {
208 if ($this->tree_repo->isInAnyTree((int) $rec["skill_id"])) {
209 $skill = new ilBasicSkill((int) $rec["skill_id"]);
210 }
211 }
212 return $skill;
213 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

References $db, and $ilDB.

◆ lookupLevelDescription()

ilSkillLevelDBRepository::lookupLevelDescription ( int  $a_id)

Implements ilSkillLevelRepository.

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

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

References lookupLevelProperty().

+ Here is the call graph for this function:

◆ lookupLevelProperty()

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

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

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

References $db, and $ilDB.

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

+ Here is the caller graph for this function:

◆ lookupLevelSkillId()

ilSkillLevelDBRepository::lookupLevelSkillId ( int  $a_id)

Implements ilSkillLevelRepository.

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

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

References lookupLevelProperty().

+ Here is the call graph for this function:

◆ lookupLevelTitle()

ilSkillLevelDBRepository::lookupLevelTitle ( int  $a_id)

Implements ilSkillLevelRepository.

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

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

References lookupLevelProperty().

+ Here is the call graph for this function:

◆ updateLevelOrder()

ilSkillLevelDBRepository::updateLevelOrder ( array  $order)

Implements ilSkillLevelRepository.

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

153 : void
154 {
156
157 $cnt = 1;
158 foreach ($order as $id => $o) {
159 $ilDB->manipulate(
160 "UPDATE skl_level SET " .
161 " nr = " . $ilDB->quote($cnt, "integer") .
162 " WHERE id = " . $ilDB->quote($id, "integer")
163 );
164 $cnt++;
165 }
166 }
$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 148 of file class.ilSkillLevelDBRepository.php.

148 : void
149 {
150 $this->writeLevelProperty($a_id, "description", $a_description, "clob");
151 }
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 132 of file class.ilSkillLevelDBRepository.php.

132 : void
133 {
135
136 $ilDB->update("skl_level", array(
137 $a_prop => array($a_type, $a_value),
138 ), array(
139 "id" => array("integer", $a_id),
140 ));
141 }

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 143 of file class.ilSkillLevelDBRepository.php.

143 : void
144 {
145 $this->writeLevelProperty($a_id, "title", $a_title, "text");
146 }

References writeLevelProperty().

+ Here is the call graph for this function:

Field Documentation

◆ $db

◆ $tree_repo

ilSkillTreeRepository ilSkillLevelDBRepository::$tree_repo
protected

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

Referenced by __construct().


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