ILIAS  trunk Revision v11.0_alpha-1769-g99a433fe2dc
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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)
 

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.

References $db, $DIC, and $tree_repo.

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:22

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.

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

48  : void
49  {
50  $ilDB = $this->db;
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.
+ 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.

References $db, and $ilDB.

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

◆ deleteLevelsOfSkill()

ilSkillLevelDBRepository::deleteLevelsOfSkill ( int  $skill_id)

Implements ilSkillLevelRepository.

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

References $db, and $ilDB.

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

◆ fixLevelNumbering()

ilSkillLevelDBRepository::fixLevelNumbering ( int  $skill_id)

Implements ilSkillLevelRepository.

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

References $db, and $ilDB.

184  : void
185  {
186  $ilDB = $this->db;
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  }

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

References $db, and $ilDB.

80  : array
81  {
82  $ilDB = $this->db;
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  }

◆ getMaxLevelNr()

ilSkillLevelDBRepository::getMaxLevelNr ( int  $skill_id)
protected

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

References $db, and $ilDB.

Referenced by addLevel().

65  : int
66  {
67  $ilDB = $this->db;
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  }
+ 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.

References $db, $ilDB, and null.

204  : ?ilBasicSkill
205  {
206  $ilDB = $this->db;
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  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
Basic Skill.

◆ lookupLevelDescription()

ilSkillLevelDBRepository::lookupLevelDescription ( int  $a_id)

Implements ilSkillLevelRepository.

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

References lookupLevelProperty().

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

References lookupLevelProperty().

133  : int
134  {
135  return (int) ($this->lookupLevelProperty($a_id, "nr") ?? 0);
136  }
lookupLevelProperty(int $a_id, string $a_prop)
+ 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.

References $db, $ilDB, and null.

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

105  : ?string
106  {
107  $ilDB = $this->db;
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  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ 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.

References lookupLevelProperty().

128  : int
129  {
130  return (int) ($this->lookupLevelProperty($a_id, "skill_id") ?? 0);
131  }
lookupLevelProperty(int $a_id, string $a_prop)
+ 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.

References lookupLevelProperty().

118  : string
119  {
120  return $this->lookupLevelProperty($a_id, "title") ?? "";
121  }
lookupLevelProperty(int $a_id, string $a_prop)
+ Here is the call graph for this function:

◆ updateLevelOrder()

ilSkillLevelDBRepository::updateLevelOrder ( array  $order)

Implements ilSkillLevelRepository.

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

References $db, $id, and $ilDB.

159  : void
160  {
161  $ilDB = $this->db;
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

◆ writeLevelDescription()

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

Implements ilSkillLevelRepository.

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

References writeLevelProperty().

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

References $db, and $ilDB.

Referenced by writeLevelDescription(), and writeLevelTitle().

138  : void
139  {
140  $ilDB = $this->db;
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  }
+ 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.

References writeLevelProperty().

149  : void
150  {
151  $this->writeLevelProperty($a_id, "title", $a_title, "text");
152  }
writeLevelProperty(int $a_id, string $a_prop, ?string $a_value, string $a_type)
+ 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: