ILIAS  trunk Revision v11.0_alpha-1769-g99a433fe2dc
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilSkillTreeDBRepository Class Reference
+ Inheritance diagram for ilSkillTreeDBRepository:
+ Collaboration diagram for ilSkillTreeDBRepository:

Public Member Functions

 __construct (Tree\SkillTreeFactory $tree_factory, ?ilDBInterface $db=null)
 
 getCommonSkillIdForImportId (int $a_source_inst_id, int $a_skill_import_id, int $a_tref_import_id=0)
 
 getLevelIdForImportId (int $a_source_inst_id, int $a_level_import_id)
 
 isInAnyTree (int $node_id)
 
 getTreeIdForNodeId (int $node_id)
 
 getTreeForNodeId (int $node_id)
 
 getVirtualTreeForNodeId (int $node_id)
 
 getParentNodeIdForNodeId (int $node_id)
 

Protected Attributes

ilDBInterface $db
 
Tree SkillTreeFactory $tree_factory
 

Detailed Description

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

Constructor & Destructor Documentation

◆ __construct()

ilSkillTreeDBRepository::__construct ( Tree\SkillTreeFactory  $tree_factory,
?ilDBInterface  $db = null 
)

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

References $db, $DIC, and $tree_factory.

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

Member Function Documentation

◆ getCommonSkillIdForImportId()

ilSkillTreeDBRepository::getCommonSkillIdForImportId ( int  $a_source_inst_id,
int  $a_skill_import_id,
int  $a_tref_import_id = 0 
)

Implements ilSkillTreeRepository.

Definition at line 40 of file class.ilSkillTreeDBRepository.php.

References $db, $ilDB, $results, ilSkillTemplateReference\_lookupTemplateId(), and ILIAS\Repository\int().

44  : array {
45  $ilDB = $this->db;
46 
47  $template_ids = [];
48  if ($a_tref_import_id > 0) {
49  $skill_node_type = "sktp";
50 
51  // get all matching tref nodes
52  $set = $ilDB->query("SELECT * FROM skl_tree_node n JOIN skl_tree t ON (n.obj_id = t.child) " .
53  " WHERE n.import_id = " . $ilDB->quote(
54  "il_" . ($a_source_inst_id) . "_sktr_" . $a_tref_import_id,
55  "text"
56  ) .
57  " ORDER BY n.creation_date DESC ");
58  while ($rec = $ilDB->fetchAssoc($set)) {
59  if (($t = ilSkillTemplateReference::_lookupTemplateId((int) $rec["obj_id"])) > 0) {
60  $template_ids[$t] = (int) $rec["obj_id"];
61  }
62  }
63  } else {
64  $skill_node_type = "skll";
65  }
66  $set = $ilDB->query("SELECT * FROM skl_tree_node n JOIN skl_tree t ON (n.obj_id = t.child) " .
67  " WHERE n.import_id = " . $ilDB->quote(
68  "il_" . ($a_source_inst_id) . "_" . $skill_node_type . "_" . $a_skill_import_id,
69  "text"
70  ) .
71  " ORDER BY n.creation_date DESC ");
72  $results = [];
73  while ($rec = $ilDB->fetchAssoc($set)) {
74  $matching_trefs = [];
75  if ($a_tref_import_id > 0) {
76  $tree = $this->tree_factory->getTreeById((int) $rec["skl_tree_id"]);
77  $skill_template_id = $tree->getTopParentNodeId((int) $rec["obj_id"]);
78 
79  // check of skill is in template
80  foreach ($template_ids as $templ => $tref) {
81  if ($skill_template_id == $templ) {
82  $matching_trefs[] = $tref;
83  }
84  }
85  } else {
86  $matching_trefs = array(0);
87  }
88 
89  foreach ($matching_trefs as $t) {
90  $results[] = array("skill_id" => (int) $rec["obj_id"],
91  "tref_id" => $t,
92  "creation_date" => $rec["creation_date"]
93  );
94  }
95  }
96  return $results;
97  }
$results
+ Here is the call graph for this function:

◆ getLevelIdForImportId()

ilSkillTreeDBRepository::getLevelIdForImportId ( int  $a_source_inst_id,
int  $a_level_import_id 
)

Implements ilSkillTreeRepository.

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

References $db, $ilDB, and $results.

102  : array
103  {
104  $ilDB = $this->db;
105 
106  $set = $ilDB->query("SELECT * FROM skl_level l JOIN skl_tree t ON (l.skill_id = t.child) " .
107  " WHERE l.import_id = " . $ilDB->quote(
108  "il_" . $a_source_inst_id . "_sklv_" . $a_level_import_id,
109  "text"
110  ) .
111  " ORDER BY l.creation_date DESC ");
112  $results = [];
113  while ($rec = $ilDB->fetchAssoc($set)) {
114  $results[] = array("level_id" => (int) $rec["id"], "creation_date" => $rec["creation_date"]);
115  }
116  return $results;
117  }
$results

◆ getParentNodeIdForNodeId()

ilSkillTreeDBRepository::getParentNodeIdForNodeId ( int  $node_id)

Implements ilSkillTreeRepository.

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

References $db, ilDBInterface\fetchAssoc(), and ilDBInterface\queryF().

154  : int
155  {
156  $db = $this->db;
157 
158  $set = $db->queryF(
159  "SELECT * FROM skl_tree " .
160  " WHERE child = %s ",
161  ["integer"],
162  [$node_id]
163  );
164  $rec = $db->fetchAssoc($set);
165  return (int) ($rec["parent"] ?? 0);
166  }
fetchAssoc(ilDBStatement $statement)
queryF(string $query, array $types, array $values)
+ Here is the call graph for this function:

◆ getTreeForNodeId()

ilSkillTreeDBRepository::getTreeForNodeId ( int  $node_id)

Implements ilSkillTreeRepository.

Definition at line 142 of file class.ilSkillTreeDBRepository.php.

References getTreeIdForNodeId().

142  : ilSkillTree
143  {
144  $tree_id = $this->getTreeIdForNodeId($node_id);
145  return $this->tree_factory->getTreeById($tree_id);
146  }
Skill tree.
+ Here is the call graph for this function:

◆ getTreeIdForNodeId()

ilSkillTreeDBRepository::getTreeIdForNodeId ( int  $node_id)

Implements ilSkillTreeRepository.

Definition at line 128 of file class.ilSkillTreeDBRepository.php.

References $db, ilDBInterface\fetchAssoc(), and ilDBInterface\queryF().

Referenced by getTreeForNodeId(), getVirtualTreeForNodeId(), and isInAnyTree().

128  : int
129  {
130  $db = $this->db;
131 
132  $set = $db->queryF(
133  "SELECT * FROM skl_tree " .
134  " WHERE child = %s ",
135  ["integer"],
136  [$node_id]
137  );
138  $rec = $db->fetchAssoc($set);
139  return (int) ($rec["skl_tree_id"] ?? 0);
140  }
fetchAssoc(ilDBStatement $statement)
queryF(string $query, array $types, array $values)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getVirtualTreeForNodeId()

ilSkillTreeDBRepository::getVirtualTreeForNodeId ( int  $node_id)

Implements ilSkillTreeRepository.

Definition at line 148 of file class.ilSkillTreeDBRepository.php.

References getTreeIdForNodeId().

149  {
150  $tree_id = $this->getTreeIdForNodeId($node_id);
151  return $this->tree_factory->getVirtualTreeById($tree_id);
152  }
+ Here is the call graph for this function:

◆ isInAnyTree()

ilSkillTreeDBRepository::isInAnyTree ( int  $node_id)

Implements ilSkillTreeRepository.

Definition at line 119 of file class.ilSkillTreeDBRepository.php.

References getTreeIdForNodeId().

119  : bool
120  {
121  $tree_id = $this->getTreeIdForNodeId($node_id);
122  if ($tree_id > 0) {
123  return true;
124  }
125  return false;
126  }
+ Here is the call graph for this function:

Field Documentation

◆ $db

◆ $tree_factory

Tree SkillTreeFactory ilSkillTreeDBRepository::$tree_factory
protected

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

Referenced by __construct().


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