ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilSkillDataSet Class Reference

Skill Data set class. More...

+ Inheritance diagram for ilSkillDataSet:
+ Collaboration diagram for ilSkillDataSet:

Public Member Functions

 __construct ()
 
 setMode (string $a_val)
 
 getMode ()
 
 setSelectedNodes (array $a_val)
 
 getSelectedNodes ()
 
 setSelectedProfiles (array $a_val)
 
 getSelectedProfiles ()
 
 setSkillTreeId (int $skill_tree_id)
 
 getSkillTreeId ()
 
 getSupportedVersions ()
 
 readData (string $a_entity, string $a_version, array $a_ids)
 Read data from DB. More...
 
 importRecord (string $a_entity, array $a_types, array $a_rec, ilImportMapping $a_mapping, string $a_schema_version)
 Needs to be overwritten for import use case. More...
 
- Public Member Functions inherited from ilDataSet
 __construct ()
 
 init (string $a_entity, string $a_schema_version)
 Init. More...
 
 getSupportedVersions ()
 
 readData (string $a_entity, string $a_version, array $a_ids)
 Read data from DB. More...
 
 initByExporter (ilXmlExporter $xml_exporter)
 
 setImportDirectory (string $a_val)
 
 getImportDirectory ()
 
 setDSPrefix (string $a_val)
 
 getDSPrefix ()
 
 getDSPrefixString ()
 
 getDirectDataFromQuery (string $a_query, bool $a_convert_to_leading_upper=true, bool $a_set=true)
 Get data from query.This is a standard procedure, all db field names are directly mapped to abstract fields. More...
 
 convertToLeadingUpper (string $a_str)
 Make xyz_abc a XyzAbc string. More...
 
 getXmlRepresentation (string $a_entity, string $a_schema_version, ?array $a_ids, string $a_field="", bool $a_omit_header=false, bool $a_omit_types=false)
 Get xml representation <dataset install_id="123" install_url="..."> <types entity="table_name" version="4.0.1"> <ftype name="field_1" type="text" > <ftype name="field_2" type="date" > <ftype name="field_3" type="integer" > </types> <types ...> ... </types> <set entity="table_name"> <rec> <field_1>content</field_1> <field_2>my_date</field_2> <field_3>my_number</field_3> </rec> ... </set> </dataset> More...
 
 addRecordsXml (ilXmlWriter $a_writer, array $a_prefixes, string $a_entity, string $a_schema_version, array $a_ids, ?string $a_field="")
 
 afterXmlRecordWriting (string $a_entity, string $a_version, array $a_set)
 
 getNamespaces (array &$namespaces, string $a_entity, string $a_schema_version)
 
 getXmlRecord (string $a_entity, string $a_version, array $a_set)
 Get xml record for version. More...
 
 getXmlTypes (string $a_entity, string $a_version)
 Get xml types. More...
 
 getXMLEntityName (string $a_entity, string $a_version)
 Get entity name for xml (may be overwritten) More...
 
 getXMLEntityTag (string $a_entity, string $a_schema_version)
 Get entity tag. More...
 
 setImport (ilSurveyImporter $a_val)
 
 getImport ()
 
 setCurrentInstallationId (string $a_val)
 
 getCurrentInstallationId ()
 
 importRecord (string $a_entity, array $a_types, array $a_rec, ilImportMapping $a_mapping, string $a_schema_version)
 Needs to be overwritten for import use case. More...
 
 getCollection (array $record, string $entity, string $schema_version, string $field, string $value)
 
 getContainerExportConfig (array $record, string $entity, string $schema_version, string $field, string $value)
 

Data Fields

const MODE_SKILLS = ""
 
const MODE_PROFILES = "prof"
 
- Data Fields inherited from ilDataSet
const DATASET_NS = 'http://www.ilias.de/Services/DataSet/ds/4_3'
 
const DATASET_NS_PREFIX = 'ds'
 
const EXPORT_NO_INST_ID = 1
 
const EXPORT_ID_ILIAS_LOCAL = 2
 
const EXPORT_ID_ILIAS_LOCAL_INVALID = 3
 
const EXPORT_ID_ILIAS_REMOTE = 4
 
const EXPORT_ID_ILIAS_REMOTE_INVALID = 5
 
const EXPORT_ID = 6
 
const EXPORT_ID_INVALID = 7
 
int $dircnt = 0
 

Protected Member Functions

 getXmlNamespace (string $a_entity, string $a_schema_version)
 
 getTypes (string $a_entity, string $a_version)
 Get field types for entity. More...
 
 getDependencies (string $a_entity, string $a_version, ?array $a_rec=null, ?array $a_ids=null)
 
- Protected Member Functions inherited from ilDataSet
 getTypes (string $a_entity, string $a_version)
 Get (abstract) types for (abstract) field names. More...
 
 getXmlNamespace (string $a_entity, string $a_schema_version)
 
 getExportDirInContainer (string $exp_dir)
 
 getIRSSContainerExportConfig (StorableResource $source_container, string $source_path, string $target_path="")
 
 getDependencies (string $a_entity, string $a_version, ?array $a_rec=null, ?array $a_ids=null)
 
 createObjectExportId (string $a_type, string $a_id)
 Build ilias export id. More...
 
 parseObjectExportId (string $a_id, ?string $a_fallback_id=null)
 Parse export id. More...
 
 stripTags (array $rec, array $omit_keys=[])
 

Protected Attributes

ilSkillTreeRepository $tree_repo
 
int $skill_tree_id = 0
 
int $skill_tree_root_id = 0
 
int $init_top_order_nr = 0
 
int $init_templ_top_order_nr = 0
 
array $selected_nodes = []
 
array $selected_profiles = []
 
string $mode = ""
 
SkillInternalManagerService $skill_manager
 
SkillTreeFactory $skill_tree_factory
 
SkillInternalFactoryService $skill_factory
 
- Protected Attributes inherited from ilDataSet
ILIAS ResourceStorage Services $irss
 
string $current_installation_id = ""
 
array $data = []
 
ilDBInterface $db
 
ilLogger $ds_log
 
string $import_directory = ""
 
string $entity = ""
 
string $schema_version = ""
 
string $component_export_dir = ""
 
string $ds_prefix = "ds"
 
string $version = ""
 
ilSurveyImporter $import
 
ilExport $export
 

Detailed Description

Skill Data set class.

This class implements the following entities:

  • skmg: Skill management top entity (no data, only dependecies)
  • skee: Skill tree
  • skl_subtree: Skill subtree (includes data of skl_tree, skl_tree_node and skl_templ_ref)
  • skl_templ_subtree: Skill template subtree (includes data of skl_tree and skl_tree_node)
  • skl_level: Skill levels
  • skl_prof: skill profiles (different mode)
Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e

Definition at line 38 of file class.ilSkillDataSet.php.

Constructor & Destructor Documentation

◆ __construct()

ilSkillDataSet::__construct ( )

Reimplemented from ilDataSet.

Definition at line 64 of file class.ilSkillDataSet.php.

65 {
66 global $DIC;
67
68 $this->db = $DIC->database();
70
71 $this->skill_manager = $DIC->skills()->internal()->manager();
72 $this->skill_tree_factory = $DIC->skills()->internal()->factory()->tree();
73 $this->skill_factory = $DIC->skills()->internal()->factory();
74 $this->tree_repo = $DIC->skills()->internal()->repo()->getTreeRepo();
75 }
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26

References $DIC, and ILIAS\GlobalScreen\Provider\__construct().

+ Here is the call graph for this function:

Member Function Documentation

◆ getDependencies()

ilSkillDataSet::getDependencies ( string  $a_entity,
string  $a_version,
?array  $a_rec = null,
?array  $a_ids = null 
)
protected
Parameters
array{Idint, Child: int, Type: string} $a_rec
Returns
array<string, array{ids: int[]}>

Reimplemented from ilDataSet.

Definition at line 509 of file class.ilSkillDataSet.php.

514 : array {
516
517
518 switch ($a_entity) {
519 case "skmg":
520 $deps["skee"]["ids"] = $a_ids;
521 return $deps;
522
523 case "skee":
524 if (!isset($a_rec["Id"]) || is_null($a_rec["Id"])) {
525 return [];
526 }
527 $skill_tree = $this->skill_tree_factory->getTreeById((int) $a_rec["Id"]);
528
529 $deps = [];
530 if ($this->getMode() == self::MODE_SKILLS) {
531 // determine top nodes of main tree to be exported and all referenced template nodes
532 $sel_nodes = $this->getSelectedNodes();
533 $exp_types = array("skll", "scat", "sctr", "sktr");
534 if (!isset($sel_nodes) || count($sel_nodes) === 0) {
535 $childs = $skill_tree->getChildsByTypeFilter($skill_tree->readRootId(), $exp_types);
536 $skl_subtree_deps = [];
537 foreach ($childs as $c) {
538 $skl_subtree_deps[] = (int) $c["child"];
539 }
540 } else {
541 $skl_subtree_deps = [];
542 foreach ($sel_nodes as $n) {
543 if (in_array(ilSkillTreeNode::_lookupType($n), $exp_types)) {
544 $skl_subtree_deps[] = $n;
545 }
546 }
547 }
548
549 // determine template subtrees
550 $ref_nodes = [];
551 if (is_array($skl_subtree_deps)) {
552 foreach ($skl_subtree_deps as $id) {
553 if (ilSkillTreeNode::_lookupType($id) == "sktr") {
554 $ref_nodes[$id] = $id;
555 } else {
556 $sub = $skill_tree->getSubTree($skill_tree->getNodeData($id), true, ["sktr"]);
557 foreach ($sub as $s) {
558 $ref_nodes[$s["child"]] = $s["child"];
559 }
560 }
561 }
562 }
563
564 $set = $ilDB->query("SELECT DISTINCT(templ_id) FROM skl_templ_ref " .
565 " WHERE " . $ilDB->in("skl_node_id", $ref_nodes, false, "integer"));
566 while ($rec = $ilDB->fetchAssoc($set)) {
567 $deps["skl_templ_subtree"]["ids"][] = (int) $rec["templ_id"];
568 }
569
570 // export subtree after templates
571 $deps["skl_subtree"]["ids"] = $skl_subtree_deps;
572 } elseif ($this->getMode() == self::MODE_PROFILES) {
573 foreach ($this->getSelectedProfiles() as $p_id) {
574 $deps["skl_prof"]["ids"][] = $p_id;
575 }
576 }
577 return $deps;
578
579 case "skl_subtree":
580 case "skl_templ_subtree":
581 $deps = [];
582 if (in_array($a_rec["Type"], array("skll", "sktp"))) {
583 $deps["skl_level"]["ids"][] = $a_rec["Child"];
584 }
585 return $deps;
586
587 case "skl_prof":
588 case "skl_local_prof":
589 $deps["skl_prof_level"]["ids"][] = $a_rec["Id"] ?? null;
590 return $deps;
591 }
592
593 return [];
594 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
ilDBInterface $db
static _lookupType(int $a_obj_id)
$c
Definition: deliver.php:25

References $c, $id, $ilDB, ilSkillTreeNode\_lookupType(), getMode(), getSelectedNodes(), getSelectedProfiles(), and ILIAS\Repository\int().

+ Here is the call graph for this function:

◆ getMode()

ilSkillDataSet::getMode ( )

Definition at line 82 of file class.ilSkillDataSet.php.

82 : string
83 {
84 return $this->mode;
85 }

References $mode.

Referenced by getDependencies(), and readData().

+ Here is the caller graph for this function:

◆ getSelectedNodes()

ilSkillDataSet::getSelectedNodes ( )
Returns
int[]

Definition at line 98 of file class.ilSkillDataSet.php.

98 : array
99 {
101 }

References $selected_nodes.

Referenced by getDependencies().

+ Here is the caller graph for this function:

◆ getSelectedProfiles()

ilSkillDataSet::getSelectedProfiles ( )
Returns
int[] (profile ids)

Definition at line 114 of file class.ilSkillDataSet.php.

114 : array
115 {
117 }

References $selected_profiles.

Referenced by getDependencies().

+ Here is the caller graph for this function:

◆ getSkillTreeId()

ilSkillDataSet::getSkillTreeId ( )

Definition at line 124 of file class.ilSkillDataSet.php.

124 : int
125 {
127 }

References $skill_tree_id.

Referenced by readData().

+ Here is the caller graph for this function:

◆ getSupportedVersions()

ilSkillDataSet::getSupportedVersions ( )
Returns
string[]

Reimplemented from ilDataSet.

Definition at line 132 of file class.ilSkillDataSet.php.

132 : array
133 {
134 return array("5.1.0", "7.0", "8.0");
135 }

◆ getTypes()

ilSkillDataSet::getTypes ( string  $a_entity,
string  $a_version 
)
protected

Get field types for entity.

Reimplemented from ilDataSet.

Definition at line 145 of file class.ilSkillDataSet.php.

145 : array
146 {
147 if ($a_entity == "skmg") {
148 switch ($a_version) {
149 case "5.1.0":
150 case "7.0":
151 return array(
152 "Mode" => "text"
153 );
154 case "8.0":
155 return array(
156 "Id" => "integer"
157 );
158 }
159 }
160 if ($a_entity == "skee") {
161 switch ($a_version) {
162 case "8.0":
163 return array(
164 "Id" => "integer",
165 "Mode" => "text"
166 );
167 }
168 }
169 if ($a_entity == "skl_subtree") {
170 switch ($a_version) {
171 case "5.1.0":
172 case "7.0":
173 case "8.0":
174 return array(
175 "SklTreeId" => "integer",
176 "TopNode" => "integer",
177 "Child" => "integer",
178 "Parent" => "integer",
179 "Depth" => "integer",
180 "Type" => "text",
181 "Title" => "text",
182 "Description" => "text",
183 "SelfEval" => "integer",
184 "OrderNr" => "integer",
185 "Status" => "integer",
186 "TemplateId" => "integer"
187 );
188 }
189 }
190 if ($a_entity == "skl_templ_subtree") {
191 switch ($a_version) {
192 case "5.1.0":
193 case "7.0":
194 case "8.0":
195 return array(
196 "SklTreeId" => "integer",
197 "TopNode" => "integer",
198 "Child" => "integer",
199 "Parent" => "integer",
200 "Depth" => "integer",
201 "Type" => "text",
202 "Title" => "text",
203 "Description" => "text",
204 "SelfEval" => "integer",
205 "OrderNr" => "integer",
206 "Status" => "integer"
207 );
208 }
209 }
210 if ($a_entity == "skl_level") {
211 switch ($a_version) {
212 case "5.1.0":
213 case "7.0":
214 case "8.0":
215 return array(
216 "LevelId" => "integer",
217 "SkillId" => "integer",
218 "Nr" => "integer",
219 "Title" => "text",
220 "Description" => "text"
221 );
222 }
223 }
224 if ($a_entity == "skl_prof") {
225 switch ($a_version) {
226 case "5.1.0":
227 case "7.0":
228 return array(
229 "Id" => "integer",
230 "Title" => "text",
231 "Description" => "text"
232 );
233 case "8.0":
234 return array(
235 "Id" => "integer",
236 "Title" => "text",
237 "Description" => "text",
238 "SkillTreeId" => "integer"
239 );
240 }
241 }
242 if ($a_entity == "skl_local_prof") {
243 switch ($a_version) {
244 case "7.0":
245 return array(
246 "Id" => "integer",
247 "Title" => "text",
248 "Description" => "text",
249 "RefId" => "integer"
250 );
251 case "8.0":
252 return array(
253 "Id" => "integer",
254 "Title" => "text",
255 "Description" => "text",
256 "RefId" => "integer",
257 "SkillTreeId" => "integer"
258 );
259 }
260 }
261 if ($a_entity == "skl_prof_level") {
262 switch ($a_version) {
263 case "5.1.0":
264 return array(
265 "ProfileId" => "integer",
266 "BaseSkillId" => "integer",
267 "TrefId" => "integer",
268 "LevelId" => "integer"
269 );
270 case "7.0":
271 case "8.0":
272 return array(
273 "ProfileId" => "integer",
274 "BaseSkillId" => "integer",
275 "TrefId" => "integer",
276 "LevelId" => "integer",
277 "OrderNr" => "integer"
278 );
279 }
280 }
281 return [];
282 }

◆ getXmlNamespace()

ilSkillDataSet::getXmlNamespace ( string  $a_entity,
string  $a_schema_version 
)
protected

Reimplemented from ilDataSet.

Definition at line 137 of file class.ilSkillDataSet.php.

137 : string
138 {
139 return "http://www.ilias.de/xml/Services/Skill/" . $a_entity;
140 }

◆ importRecord()

ilSkillDataSet::importRecord ( string  $a_entity,
array  $a_types,
array  $a_rec,
ilImportMapping  $a_mapping,
string  $a_schema_version 
)

Needs to be overwritten for import use case.

Reimplemented from ilDataSet.

Definition at line 596 of file class.ilSkillDataSet.php.

602 : void {
603 $skill_tree = $this->skill_tree_factory->getTreeById($this->getSkillTreeId());
604 $skill_tree_root_id = $skill_tree->readRootId();
605 $tree_node_manager = $this->skill_manager->getTreeNodeManager($this->getSkillTreeId());
606
607 $init_top_order_nr = $skill_tree->getMaxOrderNr($skill_tree_root_id);
608 $init_templ_top_order_nr = $skill_tree->getMaxOrderNr($skill_tree_root_id, true);
609
610 $source_inst_id = $a_mapping->getInstallId();
611 switch ($a_entity) {
612 case "skl_subtree":
613 if ((int) $a_rec["TopNode"] === 1) {
614 $parent = $skill_tree_root_id;
616 $order = (int) $a_rec["OrderNr"] + $init_top_order_nr;
617 } else {
618 $parent = (int) $a_mapping->getMapping("components/ILIAS/Skill", "skl_tree", $a_rec["Parent"]);
619 $status = (int) $a_rec["Status"];
620 $order = (int) $a_rec["OrderNr"];
621 }
622 switch ($a_rec["Type"]) {
623 case "scat":
624 $scat = new ilSkillCategory();
625 $scat->setTitle($a_rec["Title"]);
626 $scat->setDescription($a_rec["Description"] ?? "");
627 $scat->setImportId("il_" . $source_inst_id . "_scat_" . $a_rec["Child"]);
628 $scat->setSelfEvaluation((bool) $a_rec["SelfEval"]);
629 $scat->setOrderNr($order);
630 $scat->setStatus($status);
631 $scat->create();
632 $tree_node_manager->putIntoTree($scat, $parent);
633 $a_mapping->addMapping("components/ILIAS/Skill", "skl_tree", $a_rec["Child"], (string) $scat->getId());
634 break;
635
636 case "skll":
637 $skll = new ilBasicSkill();
638 $skll->setTitle($a_rec["Title"]);
639 $skll->setDescription($a_rec["Description"] ?? "");
640 $skll->setImportId("il_" . $source_inst_id . "_skll_" . $a_rec["Child"]);
641 $skll->setSelfEvaluation((bool) $a_rec["SelfEval"]);
642 $skll->setOrderNr($order);
643 $skll->setStatus($status);
644 $skll->create();
645 $tree_node_manager->putIntoTree($skll, $parent);
646 $a_mapping->addMapping("components/ILIAS/Skill", "skl_tree", $a_rec["Child"], (string) $skll->getId());
647 break;
648
649 case "sktr":
650 $template_id = (int) $a_mapping->getMapping("components/ILIAS/Skill", "skl_tree", $a_rec["TemplateId"]);
651 // only create template references, if referenced template is found (template trees are imported first)
652 if ($template_id > 0) {
653 $sktr = new ilSkillTemplateReference();
654 $sktr->setTitle($a_rec["Title"]);
655 $sktr->setDescription($a_rec["Description"] ?? "");
656 $sktr->setImportId("il_" . $source_inst_id . "_sktr_" . $a_rec["Child"]);
657 $sktr->setSelfEvaluation((bool) $a_rec["SelfEval"]);
658 $sktr->setOrderNr($order);
659 $sktr->setSkillTemplateId($template_id);
660 $sktr->setStatus($status);
661 $sktr->create();
662 $tree_node_manager->putIntoTree($sktr, $parent);
663 $a_mapping->addMapping("components/ILIAS/Skill", "skl_tree", $a_rec["Child"], (string) $sktr->getId());
664 }
665 break;
666 }
667 break;
668
669 case "skl_templ_subtree":
670 if ((int) $a_rec["TopNode"] === 1) {
671 $parent = $skill_tree_root_id;
672 $order = (int) $a_rec["OrderNr"] + $init_templ_top_order_nr;
673 } else {
674 $parent = (int) $a_mapping->getMapping("components/ILIAS/Skill", "skl_tree", $a_rec["Parent"]);
675 $order = (int) $a_rec["OrderNr"];
676 }
677 switch ($a_rec["Type"]) {
678 case "sctp":
679 $sctp = new ilSkillTemplateCategory();
680 $sctp->setTitle($a_rec["Title"]);
681 $sctp->setDescription($a_rec["Description"] ?? "");
682 $sctp->setImportId("il_" . $source_inst_id . "_sctp_" . $a_rec["Child"]);
683 $sctp->setOrderNr($order);
684 $sctp->create();
685 $tree_node_manager->putIntoTree($sctp, $parent);
686 $a_mapping->addMapping("components/ILIAS/Skill", "skl_tree", $a_rec["Child"], (string) $sctp->getId());
687 break;
688
689 case "sktp":
690 $sktp = new ilBasicSkillTemplate();
691 $sktp->setTitle($a_rec["Title"]);
692 $sktp->setDescription($a_rec["Description"] ?? "");
693 $sktp->setImportId("il_" . $source_inst_id . "_sktp_" . $a_rec["Child"]);
694 $sktp->setOrderNr($order);
695 $sktp->create();
696 $tree_node_manager->putIntoTree($sktp, $parent);
697 $a_mapping->addMapping("components/ILIAS/Skill", "skl_tree", $a_rec["Child"], (string) $sktp->getId());
698 break;
699 }
700 break;
701
702 case "skl_level":
703 $skill_id = (int) $a_mapping->getMapping("components/ILIAS/Skill", "skl_tree", $a_rec["SkillId"]);
704 $type = ilSkillTreeNode::_lookupType($skill_id);
705 if (in_array($type, array("skll", "sktp"))) {
706 if ($type == "skll") {
707 $skill = new ilBasicSkill($skill_id);
708 } else {
709 $skill = new ilBasicSkillTemplate($skill_id);
710 }
711 $skill->addLevel($a_rec["Title"], $a_rec["Description"], "il_" . $source_inst_id . "_sklv_" . $a_rec["LevelId"]);
712 $skill->update();
713 }
714 break;
715
716 case "skl_prof":
717 $profile = $this->skill_factory->profile()->profile(
718 0,
719 $a_rec["Title"],
720 $a_rec["Description"] ?? "",
721 $this->getSkillTreeId()
722 );
723 $new_profile = $this->skill_manager->getProfileManager()->createProfile($profile);
724
725 $a_mapping->addMapping("components/ILIAS/Skill", "skl_prof", $a_rec["Id"], (string) $new_profile->getId());
726 break;
727
728 case "skl_local_prof":
729 $profile = $this->skill_factory->profile()->profile(
730 0,
731 $a_rec["Title"],
732 $a_rec["Description"] ?? "",
733 $this->getSkillTreeId(),
734 "",
735 (int) $a_rec["RefId"]
736 );
737 $new_profile = $this->skill_manager->getProfileManager()->createProfile($profile);
738
739 $a_mapping->addMapping("components/ILIAS/Skill", "skl_local_prof", $a_rec["Id"], (string) $new_profile->getId());
740 break;
741
742 case "skl_prof_level":
743 $profile_id = (int) $a_mapping->getMapping("components/ILIAS/Skill", "skl_prof", $a_rec["ProfileId"])
744 ? (int) $a_mapping->getMapping("components/ILIAS/Skill", "skl_prof", $a_rec["ProfileId"])
745 : (int) $a_mapping->getMapping("components/ILIAS/Skill", "skl_local_prof", $a_rec["ProfileId"]);
746 if ($profile_id > 0) {
747 $level_id_data = ilBasicSkill::getLevelIdForImportId((int) $this->getCurrentInstallationId(), (int) $a_rec["LevelId"]);
748 $skill_data = ilBasicSkill::getCommonSkillIdForImportId((int) $this->getCurrentInstallationId(), (int) $a_rec["BaseSkillId"], (int) $a_rec["TrefId"]);
749 $level_id = $tref_id = $base_skill = 0;
750 foreach ($level_id_data as $l) {
751 reset($skill_data);
752 foreach ($skill_data as $s) {
753 // echo "<br>=".ilBasicSkill::lookupLevelSkillId($l["level_id"])."=".$s["skill_id"]."=";
754
755 if ($level_id == 0 && ilBasicSkill::lookupLevelSkillId($l["level_id"]) == $s["skill_id"]) {
756 $level_id = $l["level_id"];
757 $base_skill = $s["skill_id"];
758 $tref_id = $s["tref_id"];
759 }
760 }
761 }
762 if ($level_id > 0) {
763 $level = $this->skill_factory->profile()->profileLevel(
764 $profile_id,
765 $base_skill,
766 $tref_id,
767 $level_id,
768 (int) $a_rec["OrderNr"]
769 );
770 $this->skill_manager->getProfileManager()->addSkillLevel($level);
771 }
772 }
773 break;
774 }
775 }
static lookupLevelSkillId(int $a_id)
static getCommonSkillIdForImportId(int $a_source_inst_id, int $a_skill_import_id, int $a_tref_import_id=0)
static getLevelIdForImportId(int $a_source_inst_id, int $a_level_import_id)
getCurrentInstallationId()
addMapping(string $a_comp, string $a_entity, string $a_old_id, string $a_new_id)
getMapping(string $a_comp, string $a_entity, string $a_old_id)

References ilSkillTreeNode\_lookupType(), ilImportMapping\addMapping(), ilBasicSkill\getCommonSkillIdForImportId(), ilBasicSkill\getLevelIdForImportId(), ilImportMapping\getMapping(), ILIAS\Repository\int(), ilBasicSkill\lookupLevelSkillId(), and ilSkillTreeNode\STATUS_DRAFT.

+ Here is the call graph for this function:

◆ readData()

ilSkillDataSet::readData ( string  $a_entity,
string  $a_version,
array  $a_ids 
)

Read data from DB.

This should result in the abstract field structure of the version set in the constructor.

Reimplemented from ilDataSet.

Definition at line 284 of file class.ilSkillDataSet.php.

284 : void
285 {
287
288 $this->data = [];
289
290 if (!is_array($a_ids)) {
291 $a_ids = array($a_ids);
292 }
293 if ($a_entity == "skmg") {
294 switch ($a_version) {
295 case "5.1.0":
296 case "7.0":
297 if ($this->getMode() == self::MODE_SKILLS) {
298 $this->data[] = array("Mode" => "Skills");
299 } elseif ($this->getMode() == self::MODE_PROFILES) {
300 $this->data[] = array("Mode" => "Profiles");
301 }
302 break;
303 case "8.0":
304 $this->data[] = [
305 "Id" => $this->getSkillTreeId()
306 ];
307 break;
308 }
309 }
310 if ($a_entity == "skee") { // dummy node
311 switch ($a_version) {
312 case "8.0":
313 foreach ($a_ids as $id) {
314 if ($this->getMode() == self::MODE_SKILLS) {
315 $this->data[] = array(
316 "Id" => $id,
317 "Mode" => "Skills"
318 );
319 } elseif ($this->getMode() == self::MODE_PROFILES) {
320 $this->data[] = array(
321 "Id" => $id,
322 "Mode" => "Profiles"
323 );
324 }
325 }
326 break;
327 }
328 }
329 if ($a_entity == "skl_subtree") { // get subtree for top node
330 switch ($a_version) {
331 case "5.1.0":
332 case "7.0":
333 case "8.0":
334 foreach ($a_ids as $id) {
335 $skill_tree = $this->tree_repo->getTreeForNodeId($id);
336 $sub = $skill_tree->getSubTree($skill_tree->getNodeData($id));
337 foreach ($sub as $s) {
338 $set = $ilDB->query(
339 "SELECT * FROM skl_templ_ref " .
340 " WHERE skl_node_id = " . $ilDB->quote($s["child"], "integer")
341 );
342 $rec = $ilDB->fetchAssoc($set);
343
344 $top_node = ($s["child"] == $id)
345 ? 1
346 : 0;
347 $this->data[] = array(
348 "SklTreeId" => $s["skl_tree_id"],
349 "TopNode" => $top_node,
350 "Child" => $s["child"],
351 "Parent" => $s["parent"],
352 "Depth" => $s["depth"],
353 "Type" => $s["type"],
354 "Title" => $s["title"],
355 "Description" => $s["description"],
356 "SelfEval" => $s["self_eval"],
357 "OrderNr" => $s["order_nr"],
358 "Status" => $s["status"],
359 "TemplateId" => (int) ($rec["templ_id"] ?? 0)
360 );
361 }
362 }
363 break;
364 }
365 }
366
367 if ($a_entity == "skl_templ_subtree") { // get template subtree for template id
368 switch ($a_version) {
369 case "5.1.0":
370 case "7.0":
371 case "8.0":
372 foreach ($a_ids as $id) {
373 $skill_tree = $this->tree_repo->getTreeForNodeId($id);
374 $sub = $skill_tree->getSubTree($skill_tree->getNodeData($id));
375 foreach ($sub as $s) {
376 $top_node = ($s["child"] == $id)
377 ? 1
378 : 0;
379 $this->data[] = array(
380 "SklTreeId" => $s["skl_tree_id"],
381 "TopNode" => $top_node,
382 "Child" => $s["child"],
383 "Parent" => $s["parent"],
384 "Depth" => $s["depth"],
385 "Type" => $s["type"],
386 "Title" => $s["title"],
387 "Description" => $s["description"],
388 "SelfEval" => $s["self_eval"],
389 "OrderNr" => $s["order_nr"],
390 "Status" => $s["status"]
391 );
392 }
393 }
394 break;
395 }
396 }
397
398 if ($a_entity == "skl_level") {
399 switch ($a_version) {
400 case "5.1.0":
401 case "7.0":
402 case "8.0":
403 $this->getDirectDataFromQuery("SELECT id level_id, skill_id, nr, title, description" .
404 " FROM skl_level WHERE " .
405 $ilDB->in("skill_id", $a_ids, false, "integer") . " ORDER BY skill_id ASC, nr ASC");
406 break;
407 }
408 }
409
410 if ($a_entity == "skl_prof") {
411 switch ($a_version) {
412 case "5.1.0":
413 case "7.0":
414 $this->getDirectDataFromQuery("SELECT id, title, description" .
415 " FROM skl_profile WHERE " .
416 $ilDB->in("id", $a_ids, false, "integer"));
417 break;
418 case "8.0":
419 $set = $ilDB->query(
420 "SELECT id, title, description FROM skl_profile " .
421 " WHERE " . $ilDB->in("id", $a_ids, false, "integer")
422 );
423 while ($rec = $ilDB->fetchAssoc($set)) {
424 $this->data[] = [
425 "Id" => $rec["id"],
426 "Title" => $rec["title"],
427 "Description" => $rec["description"],
428 "SkillTreeId" => $this->getSkillTreeId()
429 ];
430 }
431 break;
432 }
433 }
434
435 if ($a_entity == "skl_local_prof") {
436 switch ($a_version) {
437 case "7.0":
438 foreach ($a_ids as $obj_id) {
439 $obj_ref_id = ilObject::_getAllReferences($obj_id);
440 $obj_ref_id = end($obj_ref_id);
441 $profiles = $this->skill_manager->getProfileManager()->getLocalProfilesForObject($obj_ref_id);
442 $profile_ids = [];
443 foreach ($profiles as $p) {
444 $profile_ids[] = $p->getId();
445 }
446 $set = $ilDB->query(
447 "SELECT * FROM skl_profile " .
448 " WHERE " . $ilDB->in("id", $profile_ids, false, "integer")
449 );
450 while ($rec = $ilDB->fetchAssoc($set)) {
451 $this->data[] = [
452 "Id" => $rec["id"],
453 "Title" => $rec["title"],
454 "Description" => $rec["description"],
455 "RefId" => $obj_ref_id
456 ];
457 }
458 }
459 break;
460 case "8.0":
461 foreach ($a_ids as $obj_id) {
462 $obj_ref_id = ilObject::_getAllReferences((int)$obj_id);
463 $obj_ref_id = end($obj_ref_id);
464 $profiles = $this->skill_manager->getProfileManager()->getLocalProfilesForObject($obj_ref_id);
465 $profile_ids = [];
466 foreach ($profiles as $p) {
467 $profile_ids[] = $p->getId();
468 }
469 $set = $ilDB->query(
470 "SELECT * FROM skl_profile " .
471 " WHERE " . $ilDB->in("id", $profile_ids, false, "integer")
472 );
473 while ($rec = $ilDB->fetchAssoc($set)) {
474 $this->data[] = [
475 "Id" => $rec["id"],
476 "Title" => $rec["title"],
477 "Description" => $rec["description"],
478 "RefId" => $obj_ref_id,
479 "SkillTreeId" => $this->getSkillTreeId()
480 ];
481 }
482 }
483 break;
484 }
485 }
486
487 if ($a_entity == "skl_prof_level") {
488 switch ($a_version) {
489 case "5.1.0":
490 $this->getDirectDataFromQuery("SELECT profile_id, base_skill_id, tref_id, level_id" .
491 " FROM skl_profile_level WHERE " .
492 $ilDB->in("profile_id", $a_ids, false, "integer"));
493 break;
494 case "7.0":
495 case "8.0":
496 $this->getDirectDataFromQuery("SELECT profile_id, base_skill_id, tref_id, level_id, order_nr" .
497 " FROM skl_profile_level WHERE " .
498 $ilDB->in("profile_id", $a_ids, false, "integer"));
499 break;
500 }
501 }
502 }
getDirectDataFromQuery(string $a_query, bool $a_convert_to_leading_upper=true, bool $a_set=true)
Get data from query.This is a standard procedure, all db field names are directly mapped to abstract ...
static _getAllReferences(int $id)
get all reference ids for object ID

References ilDataSet\$db, $id, $ilDB, ilObject\_getAllReferences(), ilDataSet\getDirectDataFromQuery(), getMode(), and getSkillTreeId().

+ Here is the call graph for this function:

◆ setMode()

ilSkillDataSet::setMode ( string  $a_val)

Definition at line 77 of file class.ilSkillDataSet.php.

77 : void
78 {
79 $this->mode = $a_val;
80 }

◆ setSelectedNodes()

ilSkillDataSet::setSelectedNodes ( array  $a_val)
Parameters
int[]$a_val

Definition at line 90 of file class.ilSkillDataSet.php.

90 : void
91 {
92 $this->selected_nodes = $a_val;
93 }

◆ setSelectedProfiles()

ilSkillDataSet::setSelectedProfiles ( array  $a_val)
Parameters
int[]$a_val(profile ids)

Definition at line 106 of file class.ilSkillDataSet.php.

106 : void
107 {
108 $this->selected_profiles = $a_val;
109 }

◆ setSkillTreeId()

ilSkillDataSet::setSkillTreeId ( int  $skill_tree_id)

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

119 : void
120 {
121 $this->skill_tree_id = $skill_tree_id;
122 }

References $skill_tree_id.

Field Documentation

◆ $init_templ_top_order_nr

int ilSkillDataSet::$init_templ_top_order_nr = 0
protected

Definition at line 47 of file class.ilSkillDataSet.php.

◆ $init_top_order_nr

int ilSkillDataSet::$init_top_order_nr = 0
protected

Definition at line 46 of file class.ilSkillDataSet.php.

◆ $mode

string ilSkillDataSet::$mode = ""
protected

Definition at line 58 of file class.ilSkillDataSet.php.

Referenced by getMode().

◆ $selected_nodes

array ilSkillDataSet::$selected_nodes = []
protected

Definition at line 52 of file class.ilSkillDataSet.php.

Referenced by getSelectedNodes().

◆ $selected_profiles

array ilSkillDataSet::$selected_profiles = []
protected

Definition at line 57 of file class.ilSkillDataSet.php.

Referenced by getSelectedProfiles().

◆ $skill_factory

SkillInternalFactoryService ilSkillDataSet::$skill_factory
protected

Definition at line 62 of file class.ilSkillDataSet.php.

◆ $skill_manager

SkillInternalManagerService ilSkillDataSet::$skill_manager
protected

Definition at line 60 of file class.ilSkillDataSet.php.

◆ $skill_tree_factory

SkillTreeFactory ilSkillDataSet::$skill_tree_factory
protected

Definition at line 61 of file class.ilSkillDataSet.php.

◆ $skill_tree_id

int ilSkillDataSet::$skill_tree_id = 0
protected

Definition at line 44 of file class.ilSkillDataSet.php.

Referenced by getSkillTreeId(), and setSkillTreeId().

◆ $skill_tree_root_id

int ilSkillDataSet::$skill_tree_root_id = 0
protected

Definition at line 45 of file class.ilSkillDataSet.php.

◆ $tree_repo

ilSkillTreeRepository ilSkillDataSet::$tree_repo
protected

Definition at line 42 of file class.ilSkillDataSet.php.

◆ MODE_PROFILES

const ilSkillDataSet::MODE_PROFILES = "prof"

Definition at line 41 of file class.ilSkillDataSet.php.

◆ MODE_SKILLS

const ilSkillDataSet::MODE_SKILLS = ""

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


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