ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
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 24 of file class.ilSkillTreeDBRepository.php.

Constructor & Destructor Documentation

◆ __construct()

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

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

References $db, $DIC, and $tree_factory.

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

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 41 of file class.ilSkillTreeDBRepository.php.

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

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

References $db, $ilDB, and $results.

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

◆ getParentNodeIdForNodeId()

ilSkillTreeDBRepository::getParentNodeIdForNodeId ( int  $node_id)

Implements ilSkillTreeRepository.

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

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

155  : int
156  {
157  $db = $this->db;
158 
159  $set = $db->queryF(
160  "SELECT * FROM skl_tree " .
161  " WHERE child = %s ",
162  ["integer"],
163  [$node_id]
164  );
165  $rec = $db->fetchAssoc($set);
166  return (int) ($rec["parent"] ?? 0);
167  }
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 143 of file class.ilSkillTreeDBRepository.php.

References getTreeIdForNodeId().

143  : ilSkillTree
144  {
145  $tree_id = $this->getTreeIdForNodeId($node_id);
146  return $this->tree_factory->getTreeById($tree_id);
147  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:

◆ getTreeIdForNodeId()

ilSkillTreeDBRepository::getTreeIdForNodeId ( int  $node_id)

Implements ilSkillTreeRepository.

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

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

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

129  : int
130  {
131  $db = $this->db;
132 
133  $set = $db->queryF(
134  "SELECT * FROM skl_tree " .
135  " WHERE child = %s ",
136  ["integer"],
137  [$node_id]
138  );
139  $rec = $db->fetchAssoc($set);
140  return (int) ($rec["skl_tree_id"] ?? 0);
141  }
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 149 of file class.ilSkillTreeDBRepository.php.

References getTreeIdForNodeId().

150  {
151  $tree_id = $this->getTreeIdForNodeId($node_id);
152  return $this->tree_factory->getVirtualTreeById($tree_id);
153  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:

◆ isInAnyTree()

ilSkillTreeDBRepository::isInAnyTree ( int  $node_id)

Implements ilSkillTreeRepository.

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

References getTreeIdForNodeId().

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

Field Documentation

◆ $db

◆ $tree_factory

Tree SkillTreeFactory ilSkillTreeDBRepository::$tree_factory
protected

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

Referenced by __construct().


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