ILIAS  release_8 Revision v8.24
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)
 @inheritDoc More...
 
 getLevelIdForImportId (int $a_source_inst_id, int $a_level_import_id)
 @inheritDoc More...
 
 isInAnyTree (int $node_id)
 
 getTreeIdForNodeId (int $node_id)
 
 getTreeForNodeId (int $node_id)
 
 getVirtualTreeForNodeId (int $node_id)
 
 getParentNodeIdForNodeId (int $node_id)
 
 getCommonSkillIdForImportId (int $a_source_inst_id, int $a_skill_import_id, int $a_tref_import_id=0)
 Get common skill ids for import IDs (newest first) More...
 
 getLevelIdForImportId (int $a_source_inst_id, int $a_level_import_id)
 Get level ids for import IDs (newest first) More...
 
 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.

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

References $db, $DIC, and $tree_factory.

Member Function Documentation

◆ getCommonSkillIdForImportId()

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

@inheritDoc

Implements ilSkillTreeRepository.

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

43 : array {
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

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

+ Here is the call graph for this function:

◆ getLevelIdForImportId()

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

@inheritDoc

Implements ilSkillTreeRepository.

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

101 : array
102 {
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 }

References $ilDB, and $results.

◆ getParentNodeIdForNodeId()

ilSkillTreeDBRepository::getParentNodeIdForNodeId ( int  $node_id)

Implements ilSkillTreeRepository.

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

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)

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

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

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

◆ getTreeIdForNodeId()

ilSkillTreeDBRepository::getTreeIdForNodeId ( int  $node_id)

Implements ilSkillTreeRepository.

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

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 }

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

+ Here is the call graph for this function:

◆ getVirtualTreeForNodeId()

ilSkillTreeDBRepository::getVirtualTreeForNodeId ( int  $node_id)

Implements ilSkillTreeRepository.

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

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

◆ isInAnyTree()

ilSkillTreeDBRepository::isInAnyTree ( int  $node_id)

Implements ilSkillTreeRepository.

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

118 : bool
119 {
120 $tree_id = $this->getTreeIdForNodeId($node_id);
121 if ($tree_id > 0) {
122 return true;
123 }
124 return false;
125 }

Field Documentation

◆ $db

ilDBInterface ilSkillTreeDBRepository::$db
protected

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

Referenced by __construct().

◆ $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: