ILIAS  release_7 Revision v7.30-3-g800a261c036
ilBasicSkillLevelDBRepository Class Reference

Class ilBasicSkillLevelDBRepository. More...

+ Inheritance diagram for ilBasicSkillLevelDBRepository:
+ Collaboration diagram for ilBasicSkillLevelDBRepository:

Public Member Functions

 __construct (ilDBInterface $db=null)
 
 deleteLevelsOfSkill (int $skill_id)
 @inheritDoc More...
 
 addLevel (int $skill_id, string $a_title, string $a_description, string $a_import_id="")
 @inheritDoc More...
 
 getLevelData (int $skill_id, int $a_id=0)
 @inheritDoc More...
 
 lookupLevelTitle (int $a_id)
 @inheritDoc More...
 
 lookupLevelDescription (int $a_id)
 @inheritDoc More...
 
 lookupLevelSkillId (int $a_id)
 @inheritDoc More...
 
 writeLevelTitle (int $a_id, string $a_title)
 @inheritDoc More...
 
 writeLevelDescription (int $a_id, string $a_description)
 @inheritDoc More...
 
 updateLevelOrder (array $order)
 @inheritDoc More...
 
 deleteLevel (int $a_id)
 @inheritDoc More...
 
 fixLevelNumbering (int $skill_id)
 @inheritDoc More...
 
 getSkillForLevelId (int $a_level_id)
 @inheritDoc More...
 
 deleteLevelsOfSkill (int $skill_id)
 Delete levels of a skill. More...
 
 addLevel (int $skill_id, string $a_title, string $a_description, string $a_import_id="")
 Add new level. More...
 
 getLevelData (int $skill_id, int $a_id=0)
 Get level data. More...
 
 lookupLevelTitle (int $a_id)
 Lookup level title. More...
 
 lookupLevelDescription (int $a_id)
 Lookup level description. More...
 
 lookupLevelSkillId (int $a_id)
 Lookup level skill id. More...
 
 writeLevelTitle (int $a_id, string $a_title)
 Write level title. More...
 
 writeLevelDescription (int $a_id, string $a_description)
 Write level description. More...
 
 updateLevelOrder (array $order)
 Update level order. More...
 
 deleteLevel (int $a_id)
 Delete level. More...
 
 fixLevelNumbering (int $skill_id)
 Fix level numbering. More...
 
 getSkillForLevelId (int $a_level_id)
 Get skill for level id. More...
 

Protected Member Functions

 getMaxLevelNr (int $skill_id)
 Get maximum level nr. More...
 
 lookupLevelProperty (int $a_id, string $a_prop)
 Lookup level property. More...
 
 writeLevelProperty (int $a_id, string $a_prop, $a_value, string $a_type)
 Write level property. More...
 

Protected Attributes

 $db
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilBasicSkillLevelDBRepository::__construct ( ilDBInterface  $db = null)

Definition at line 13 of file class.ilBasicSkillLevelDBRepository.php.

14 {
15 global $DIC;
16
17 $this->db = ($db)
18 ? $db
19 : $DIC->database();
20 }
global $DIC
Definition: goto.php:24

References $db, and $DIC.

Member Function Documentation

◆ addLevel()

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

@inheritDoc

Implements ilBasicSkillLevelRepository.

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

38 {
40
41 $nr = $this->getMaxLevelNr($skill_id);
42 $nid = $ilDB->nextId("skl_level");
43 $ilDB->insert("skl_level", array(
44 "id" => array("integer", $nid),
45 "skill_id" => array("integer", $skill_id),
46 "nr" => array("integer", $nr + 1),
47 "title" => array("text", $a_title),
48 "description" => array("clob", $a_description),
49 "import_id" => array("text", $a_import_id),
50 "creation_date" => array("timestamp", ilUtil::now())
51 ));
52
53 }
getMaxLevelNr(int $skill_id)
Get maximum level nr.
static now()
Return current timestamp in Y-m-d H:i:s format.
global $ilDB

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

+ Here is the call graph for this function:

◆ deleteLevel()

ilBasicSkillLevelDBRepository::deleteLevel ( int  $a_id)

@inheritDoc

Implements ilBasicSkillLevelRepository.

Definition at line 191 of file class.ilBasicSkillLevelDBRepository.php.

192 {
194
195 $ilDB->manipulate("DELETE FROM skl_level WHERE "
196 . " id = " . $ilDB->quote($a_id, "integer")
197 );
198
199 }

References $db, and $ilDB.

◆ deleteLevelsOfSkill()

ilBasicSkillLevelDBRepository::deleteLevelsOfSkill ( int  $skill_id)

@inheritDoc

Implements ilBasicSkillLevelRepository.

Definition at line 25 of file class.ilBasicSkillLevelDBRepository.php.

26 {
28
29 $ilDB->manipulate("DELETE FROM skl_level WHERE "
30 . " skill_id = " . $ilDB->quote($skill_id, "integer")
31 );
32 }

References $db, and $ilDB.

◆ fixLevelNumbering()

ilBasicSkillLevelDBRepository::fixLevelNumbering ( int  $skill_id)

@inheritDoc

Implements ilBasicSkillLevelRepository.

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

205 {
207
208 $set = $ilDB->query("SELECT id, nr FROM skl_level WHERE " .
209 " skill_id = " . $ilDB->quote($skill_id, "integer") .
210 " ORDER BY nr ASC"
211 );
212 $cnt = 1;
213 while ($rec = $ilDB->fetchAssoc($set)) {
214 $ilDB->manipulate("UPDATE skl_level SET " .
215 " nr = " . $ilDB->quote($cnt, "integer") .
216 " WHERE id = " . $ilDB->quote($rec["id"], "integer")
217 );
218 $cnt++;
219 }
220 }

References $db, and $ilDB.

◆ getLevelData()

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

@inheritDoc

Implements ilBasicSkillLevelRepository.

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

73 : array
74 {
76
77 if ($a_id > 0) {
78 $and = " AND id = " . $ilDB->quote($a_id, "integer");
79 }
80
81 $set = $ilDB->query("SELECT * FROM skl_level WHERE " .
82 " skill_id = " . $ilDB->quote($skill_id, "integer") .
83 $and .
84 " ORDER BY nr"
85 );
86 $levels = array();
87 while ($rec = $ilDB->fetchAssoc($set)) {
88 if ($a_id > 0) {
89 return $rec;
90 }
91 $levels[] = $rec;
92 }
93 return $levels;
94 }

References $db, and $ilDB.

◆ getMaxLevelNr()

ilBasicSkillLevelDBRepository::getMaxLevelNr ( int  $skill_id)
protected

Get maximum level nr.

Returns
int maximum level nr of skill

Definition at line 59 of file class.ilBasicSkillLevelDBRepository.php.

59 : int
60 {
62
63 $set = $ilDB->query("SELECT MAX(nr) mnr FROM skl_level WHERE " .
64 " skill_id = " . $ilDB->quote($skill_id, "integer")
65 );
66 $rec = $ilDB->fetchAssoc($set);
67 return (int) $rec["mnr"];
68 }

References $db, and $ilDB.

Referenced by addLevel().

+ Here is the caller graph for this function:

◆ getSkillForLevelId()

ilBasicSkillLevelDBRepository::getSkillForLevelId ( int  $a_level_id)

@inheritDoc

Implements ilBasicSkillLevelRepository.

Definition at line 225 of file class.ilBasicSkillLevelDBRepository.php.

226 {
228
229 $set = $ilDB->query("SELECT * FROM skl_level WHERE " .
230 " id = " . $ilDB->quote($a_level_id, "integer")
231 );
232 $skill = null;
233 if ($rec = $ilDB->fetchAssoc($set)) {
234 if (ilSkillTreeNode::isInTree($rec["skill_id"])) {
235 $skill = new ilBasicSkill($rec["skill_id"]);
236 }
237 }
238 return $skill;
239 }
static isInTree($a_id)
Is id in tree?

References $db, $ilDB, and ilSkillTreeNode\isInTree().

+ Here is the call graph for this function:

◆ lookupLevelDescription()

ilBasicSkillLevelDBRepository::lookupLevelDescription ( int  $a_id)

@inheritDoc

Implements ilBasicSkillLevelRepository.

Definition at line 124 of file class.ilBasicSkillLevelDBRepository.php.

124 : string
125 {
126 return $this->lookupLevelProperty($a_id, "description");
127 }
lookupLevelProperty(int $a_id, string $a_prop)
Lookup level property.

References lookupLevelProperty().

+ Here is the call graph for this function:

◆ lookupLevelProperty()

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

Lookup level property.

Parameters
int$a_idlevel id
string$a_prop
Returns
mixed property value

Definition at line 102 of file class.ilBasicSkillLevelDBRepository.php.

103 {
105
106 $set = $ilDB->query("SELECT $a_prop FROM skl_level WHERE " .
107 " id = " . $ilDB->quote($a_id, "integer")
108 );
109 $rec = $ilDB->fetchAssoc($set);
110 return $rec[$a_prop];
111 }

References $db, and $ilDB.

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

+ Here is the caller graph for this function:

◆ lookupLevelSkillId()

ilBasicSkillLevelDBRepository::lookupLevelSkillId ( int  $a_id)

@inheritDoc

Implements ilBasicSkillLevelRepository.

Definition at line 132 of file class.ilBasicSkillLevelDBRepository.php.

132 : int
133 {
134 return $this->lookupLevelProperty($a_id, "skill_id");
135 }

References lookupLevelProperty().

+ Here is the call graph for this function:

◆ lookupLevelTitle()

ilBasicSkillLevelDBRepository::lookupLevelTitle ( int  $a_id)

@inheritDoc

Implements ilBasicSkillLevelRepository.

Definition at line 116 of file class.ilBasicSkillLevelDBRepository.php.

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

References lookupLevelProperty().

+ Here is the call graph for this function:

◆ updateLevelOrder()

ilBasicSkillLevelDBRepository::updateLevelOrder ( array  $order)

@inheritDoc

Implements ilBasicSkillLevelRepository.

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

175 {
177
178 $cnt = 1;
179 foreach ($order as $id => $o) {
180 $ilDB->manipulate("UPDATE skl_level SET " .
181 " nr = " . $ilDB->quote($cnt, "integer") .
182 " WHERE id = " . $ilDB->quote($id, "integer")
183 );
184 $cnt++;
185 }
186 }

References $db, and $ilDB.

◆ writeLevelDescription()

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

@inheritDoc

Implements ilBasicSkillLevelRepository.

Definition at line 166 of file class.ilBasicSkillLevelDBRepository.php.

167 {
168 $this->writeLevelProperty($a_id, "description", $a_description, "clob");
169 }
writeLevelProperty(int $a_id, string $a_prop, $a_value, string $a_type)
Write level property.

References writeLevelProperty().

+ Here is the call graph for this function:

◆ writeLevelProperty()

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

Write level property.

Parameters
int$a_id
string$a_prop
$a_value
string$a_type

Definition at line 144 of file class.ilBasicSkillLevelDBRepository.php.

145 {
147
148 $ilDB->update("skl_level", array(
149 $a_prop => array($a_type, $a_value),
150 ), array(
151 "id" => array("integer", $a_id),
152 ));
153 }

References $db, and $ilDB.

Referenced by writeLevelDescription(), and writeLevelTitle().

+ Here is the caller graph for this function:

◆ writeLevelTitle()

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

@inheritDoc

Implements ilBasicSkillLevelRepository.

Definition at line 158 of file class.ilBasicSkillLevelDBRepository.php.

159 {
160 $this->writeLevelProperty($a_id, "title", $a_title, "text");
161 }

References writeLevelProperty().

+ Here is the call graph for this function:

Field Documentation

◆ $db


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