ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables 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 22 of file class.ilSkillTreeDBRepository.php.

Constructor & Destructor Documentation

◆ __construct()

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

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

References $db, $DIC, and $tree_factory.

28  {
29  global $DIC;
30 
31  $this->tree_factory = $tree_factory;
32  $this->db = ($db)
33  ?: $DIC->database();
34  }
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 39 of file class.ilSkillTreeDBRepository.php.

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

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

References $db, $ilDB, and $results.

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

◆ getParentNodeIdForNodeId()

ilSkillTreeDBRepository::getParentNodeIdForNodeId ( int  $node_id)

Implements ilSkillTreeRepository.

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

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

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

References getTreeIdForNodeId().

141  : ilSkillTree
142  {
143  $tree_id = $this->getTreeIdForNodeId($node_id);
144  return $this->tree_factory->getTreeById($tree_id);
145  }
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 127 of file class.ilSkillTreeDBRepository.php.

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

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

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

References getTreeIdForNodeId().

148  {
149  $tree_id = $this->getTreeIdForNodeId($node_id);
150  return $this->tree_factory->getVirtualTreeById($tree_id);
151  }
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 118 of file class.ilSkillTreeDBRepository.php.

References getTreeIdForNodeId().

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

Field Documentation

◆ $db

◆ $tree_factory

Tree SkillTreeFactory ilSkillTreeDBRepository::$tree_factory
protected

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

Referenced by __construct().


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