ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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 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.

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:26

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

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

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

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

References $ilDB, and $results.

◆ getParentNodeIdForNodeId()

ilSkillTreeDBRepository::getParentNodeIdForNodeId ( int  $node_id)

Implements ilSkillTreeRepository.

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

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)

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

143 {
144 $tree_id = $this->getTreeIdForNodeId($node_id);
145 return $this->tree_factory->getTreeById($tree_id);
146 }

◆ getTreeIdForNodeId()

ilSkillTreeDBRepository::getTreeIdForNodeId ( int  $node_id)

Implements ilSkillTreeRepository.

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

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 }

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

149 {
150 $tree_id = $this->getTreeIdForNodeId($node_id);
151 return $this->tree_factory->getVirtualTreeById($tree_id);
152 }

◆ isInAnyTree()

ilSkillTreeDBRepository::isInAnyTree ( int  $node_id)

Implements ilSkillTreeRepository.

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

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

Field Documentation

◆ $db

ilDBInterface ilSkillTreeDBRepository::$db
protected

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

Referenced by __construct().

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