ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
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)
 
 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

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

Constructor & Destructor Documentation

◆ __construct()

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

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

References $db, $DIC, and $tree_repo.

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

Member Function Documentation

◆ addLevel()

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

Implements ilSkillLevelRepository.

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

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

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

References $db, and $ilDB.

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

◆ deleteLevelsOfSkill()

ilSkillLevelDBRepository::deleteLevelsOfSkill ( int  $skill_id)

Implements ilSkillLevelRepository.

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

References $db, and $ilDB.

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

◆ fixLevelNumbering()

ilSkillLevelDBRepository::fixLevelNumbering ( int  $skill_id)

Implements ilSkillLevelRepository.

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

References $db, and $ilDB.

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

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

References $db, and $ilDB.

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

◆ getMaxLevelNr()

ilSkillLevelDBRepository::getMaxLevelNr ( int  $skill_id)
protected

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

References $db, and $ilDB.

Referenced by addLevel().

66  : int
67  {
68  $ilDB = $this->db;
69 
70  $set = $ilDB->query(
71  "SELECT MAX(nr) mnr FROM skl_level WHERE " .
72  " skill_id = " . $ilDB->quote($skill_id, "integer")
73  );
74  $rec = $ilDB->fetchAssoc($set);
75  return (int) ($rec["mnr"] ?? 0);
76  }
+ Here is the caller graph for this function:

◆ getSkillForLevelId()

ilSkillLevelDBRepository::getSkillForLevelId ( int  $a_level_id)

Implements ilSkillLevelRepository.

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

References $db, and $ilDB.

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

◆ lookupLevelDescription()

ilSkillLevelDBRepository::lookupLevelDescription ( int  $a_id)

Implements ilSkillLevelRepository.

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

References lookupLevelProperty().

124  : string
125  {
126  return $this->lookupLevelProperty($a_id, "description") ?? "";
127  }
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 134 of file class.ilSkillLevelDBRepository.php.

References lookupLevelProperty().

134  : int
135  {
136  return (int) ($this->lookupLevelProperty($a_id, "nr") ?? 0);
137  }
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 106 of file class.ilSkillLevelDBRepository.php.

References $db, and $ilDB.

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

106  : ?string
107  {
108  $ilDB = $this->db;
109 
110  $set = $ilDB->query(
111  "SELECT $a_prop FROM skl_level WHERE " .
112  " id = " . $ilDB->quote($a_id, "integer")
113  );
114  $rec = $ilDB->fetchAssoc($set);
115 
116  return isset($rec[$a_prop]) ? (string) $rec[$a_prop] : null;
117  }
+ Here is the caller graph for this function:

◆ lookupLevelSkillId()

ilSkillLevelDBRepository::lookupLevelSkillId ( int  $a_id)

Implements ilSkillLevelRepository.

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

References lookupLevelProperty().

129  : int
130  {
131  return (int) ($this->lookupLevelProperty($a_id, "skill_id") ?? 0);
132  }
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 119 of file class.ilSkillLevelDBRepository.php.

References lookupLevelProperty().

119  : string
120  {
121  return $this->lookupLevelProperty($a_id, "title") ?? "";
122  }
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 160 of file class.ilSkillLevelDBRepository.php.

References $db, $id, and $ilDB.

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

◆ writeLevelDescription()

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

Implements ilSkillLevelRepository.

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

References writeLevelProperty().

155  : void
156  {
157  $this->writeLevelProperty($a_id, "description", $a_description, "clob");
158  }
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 139 of file class.ilSkillLevelDBRepository.php.

References $db, and $ilDB.

Referenced by writeLevelDescription(), and writeLevelTitle().

139  : void
140  {
141  $ilDB = $this->db;
142 
143  $ilDB->update("skl_level", array(
144  $a_prop => array($a_type, $a_value),
145  ), array(
146  "id" => array("integer", $a_id),
147  ));
148  }
+ Here is the caller graph for this function:

◆ writeLevelTitle()

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

Implements ilSkillLevelRepository.

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

References writeLevelProperty().

150  : void
151  {
152  $this->writeLevelProperty($a_id, "title", $a_title, "text");
153  }
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 28 of file class.ilSkillLevelDBRepository.php.

Referenced by __construct().


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