ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
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)
 
 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)
 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.

References $db, and $DIC.

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

Member Function Documentation

◆ addLevel()

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

Implements ilBasicSkillLevelRepository.

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

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

38  {
39  $ilDB = $this->db;
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  }
static now()
Return current timestamp in Y-m-d H:i:s format.
global $ilDB
getMaxLevelNr(int $skill_id)
Get maximum level nr.
+ Here is the call graph for this function:

◆ deleteLevel()

ilBasicSkillLevelDBRepository::deleteLevel ( int  $a_id)

Implements ilBasicSkillLevelRepository.

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

References $db, and $ilDB.

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

◆ deleteLevelsOfSkill()

ilBasicSkillLevelDBRepository::deleteLevelsOfSkill ( int  $skill_id)

Implements ilBasicSkillLevelRepository.

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

References $db, and $ilDB.

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

◆ fixLevelNumbering()

ilBasicSkillLevelDBRepository::fixLevelNumbering ( int  $skill_id)

Implements ilBasicSkillLevelRepository.

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

References $db, and $ilDB.

205  {
206  $ilDB = $this->db;
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  }
global $ilDB

◆ getLevelData()

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

Implements ilBasicSkillLevelRepository.

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

References $db, and $ilDB.

73  : array
74  {
75  $ilDB = $this->db;
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  }
global $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.

References $db, and $ilDB.

Referenced by addLevel().

59  : int
60  {
61  $ilDB = $this->db;
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  }
global $ilDB
+ Here is the caller graph for this function:

◆ getSkillForLevelId()

ilBasicSkillLevelDBRepository::getSkillForLevelId ( int  $a_level_id)

Implements ilBasicSkillLevelRepository.

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

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

226  {
227  $ilDB = $this->db;
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?
global $ilDB
Basic Skill.
+ Here is the call graph for this function:

◆ lookupLevelDescription()

ilBasicSkillLevelDBRepository::lookupLevelDescription ( int  $a_id)

Implements ilBasicSkillLevelRepository.

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

References lookupLevelProperty().

124  : string
125  {
126  return $this->lookupLevelProperty($a_id, "description");
127  }
lookupLevelProperty(int $a_id, string $a_prop)
Lookup level property.
+ 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.

References $db, and $ilDB.

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

103  {
104  $ilDB = $this->db;
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  }
global $ilDB
+ Here is the caller graph for this function:

◆ lookupLevelSkillId()

ilBasicSkillLevelDBRepository::lookupLevelSkillId ( int  $a_id)

Implements ilBasicSkillLevelRepository.

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

References lookupLevelProperty().

132  : int
133  {
134  return $this->lookupLevelProperty($a_id, "skill_id");
135  }
lookupLevelProperty(int $a_id, string $a_prop)
Lookup level property.
+ Here is the call graph for this function:

◆ lookupLevelTitle()

ilBasicSkillLevelDBRepository::lookupLevelTitle ( int  $a_id)

Implements ilBasicSkillLevelRepository.

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

References lookupLevelProperty().

116  : string
117  {
118  return $this->lookupLevelProperty($a_id, "title");
119  }
lookupLevelProperty(int $a_id, string $a_prop)
Lookup level property.
+ Here is the call graph for this function:

◆ updateLevelOrder()

ilBasicSkillLevelDBRepository::updateLevelOrder ( array  $order)

Implements ilBasicSkillLevelRepository.

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

References $db, and $ilDB.

175  {
176  $ilDB = $this->db;
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  }
global $ilDB

◆ writeLevelDescription()

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

Implements ilBasicSkillLevelRepository.

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

References writeLevelProperty().

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.
+ 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.

References $db, and $ilDB.

Referenced by writeLevelDescription(), and writeLevelTitle().

145  {
146  $ilDB = $this->db;
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  }
global $ilDB
+ Here is the caller graph for this function:

◆ writeLevelTitle()

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

Implements ilBasicSkillLevelRepository.

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

References writeLevelProperty().

159  {
160  $this->writeLevelProperty($a_id, "title", $a_title, "text");
161  }
writeLevelProperty(int $a_id, string $a_prop, $a_value, string $a_type)
Write level property.
+ Here is the call graph for this function:

Field Documentation

◆ $db


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