3 declare(strict_types=1);
69 $this->db = $DIC->database();
72 $this->skill_manager = $DIC->skills()->internal()->manager();
73 $this->skill_tree_factory = $DIC->skills()->internal()->factory()->tree();
74 $this->skill_factory = $DIC->skills()->internal()->factory();
75 $this->tree_repo = $DIC->skills()->internal()->repo()->getTreeRepo();
78 public function setMode(
string $a_val): void
93 $this->selected_nodes = $a_val;
109 $this->selected_profiles = $a_val;
135 return array(
"5.1.0",
"7.0",
"8.0");
138 protected function getXmlNamespace(
string $a_entity,
string $a_schema_version): string
140 return "http://www.ilias.de/xml/Services/Skill/" . $a_entity;
146 protected function getTypes(
string $a_entity,
string $a_version): array
148 if ($a_entity ==
"skmg") {
149 switch ($a_version) {
161 if ($a_entity ==
"skee") {
162 switch ($a_version) {
170 if ($a_entity ==
"skl_subtree") {
171 switch ($a_version) {
176 "SklTreeId" =>
"integer",
177 "TopNode" =>
"integer",
178 "Child" =>
"integer",
179 "Parent" =>
"integer",
180 "Depth" =>
"integer",
183 "Description" =>
"text",
184 "SelfEval" =>
"integer",
185 "OrderNr" =>
"integer",
186 "Status" =>
"integer",
187 "TemplateId" =>
"integer" 191 if ($a_entity ==
"skl_templ_subtree") {
192 switch ($a_version) {
197 "SklTreeId" =>
"integer",
198 "TopNode" =>
"integer",
199 "Child" =>
"integer",
200 "Parent" =>
"integer",
201 "Depth" =>
"integer",
204 "Description" =>
"text",
205 "SelfEval" =>
"integer",
206 "OrderNr" =>
"integer",
207 "Status" =>
"integer" 211 if ($a_entity ==
"skl_level") {
212 switch ($a_version) {
217 "LevelId" =>
"integer",
218 "SkillId" =>
"integer",
221 "Description" =>
"text" 225 if ($a_entity ==
"skl_prof") {
226 switch ($a_version) {
232 "Description" =>
"text" 238 "Description" =>
"text",
239 "SkillTreeId" =>
"integer" 243 if ($a_entity ==
"skl_local_prof") {
244 switch ($a_version) {
249 "Description" =>
"text",
256 "Description" =>
"text",
257 "RefId" =>
"integer",
258 "SkillTreeId" =>
"integer" 262 if ($a_entity ==
"skl_prof_level") {
263 switch ($a_version) {
266 "ProfileId" =>
"integer",
267 "BaseSkillId" =>
"integer",
268 "TrefId" =>
"integer",
269 "LevelId" =>
"integer" 274 "ProfileId" =>
"integer",
275 "BaseSkillId" =>
"integer",
276 "TrefId" =>
"integer",
277 "LevelId" =>
"integer",
278 "OrderNr" =>
"integer" 285 public function readData(
string $a_entity,
string $a_version, array $a_ids): void
291 if (!is_array($a_ids)) {
292 $a_ids = array($a_ids);
294 if ($a_entity ==
"skmg") {
295 switch ($a_version) {
298 if ($this->
getMode() == self::MODE_SKILLS) {
299 $this->data[] = array(
"Mode" =>
"Skills");
300 } elseif ($this->
getMode() == self::MODE_PROFILES) {
301 $this->data[] = array(
"Mode" =>
"Profiles");
311 if ($a_entity ==
"skee") {
312 switch ($a_version) {
314 foreach ($a_ids as
$id) {
315 if ($this->
getMode() == self::MODE_SKILLS) {
316 $this->data[] = array(
320 } elseif ($this->
getMode() == self::MODE_PROFILES) {
321 $this->data[] = array(
330 if ($a_entity ==
"skl_subtree") {
331 switch ($a_version) {
335 foreach ($a_ids as
$id) {
336 $skill_tree = $this->tree_repo->getTreeForNodeId($id);
337 $sub = $skill_tree->getSubTree($skill_tree->getNodeData($id));
338 foreach ($sub as $s) {
340 "SELECT * FROM skl_templ_ref " .
341 " WHERE skl_node_id = " .
$ilDB->quote($s[
"child"],
"integer")
343 $rec =
$ilDB->fetchAssoc($set);
345 $top_node = ($s[
"child"] ==
$id)
348 $this->data[] = array(
349 "SklTreeId" => $s[
"skl_tree_id"],
350 "TopNode" => $top_node,
351 "Child" => $s[
"child"],
352 "Parent" => $s[
"parent"],
353 "Depth" => $s[
"depth"],
354 "Type" => $s[
"type"],
355 "Title" => $s[
"title"],
356 "Description" => $s[
"description"],
357 "SelfEval" => $s[
"self_eval"],
358 "OrderNr" => $s[
"order_nr"],
359 "Status" => $s[
"status"],
360 "TemplateId" => (
int) ($rec[
"templ_id"] ?? 0)
368 if ($a_entity ==
"skl_templ_subtree") {
369 switch ($a_version) {
373 foreach ($a_ids as
$id) {
374 $skill_tree = $this->tree_repo->getTreeForNodeId($id);
375 $sub = $skill_tree->getSubTree($skill_tree->getNodeData($id));
376 foreach ($sub as $s) {
377 $top_node = ($s[
"child"] ==
$id)
380 $this->data[] = array(
381 "SklTreeId" => $s[
"skl_tree_id"],
382 "TopNode" => $top_node,
383 "Child" => $s[
"child"],
384 "Parent" => $s[
"parent"],
385 "Depth" => $s[
"depth"],
386 "Type" => $s[
"type"],
387 "Title" => $s[
"title"],
388 "Description" => $s[
"description"],
389 "SelfEval" => $s[
"self_eval"],
390 "OrderNr" => $s[
"order_nr"],
391 "Status" => $s[
"status"]
399 if ($a_entity ==
"skl_level") {
400 switch ($a_version) {
405 " FROM skl_level WHERE " .
406 $ilDB->in(
"skill_id", $a_ids,
false,
"integer") .
" ORDER BY skill_id ASC, nr ASC");
411 if ($a_entity ==
"skl_prof") {
412 switch ($a_version) {
416 " FROM skl_profile WHERE " .
417 $ilDB->in(
"id", $a_ids,
false,
"integer"));
421 "SELECT id, title, description FROM skl_profile " .
422 " WHERE " .
$ilDB->in(
"id", $a_ids,
false,
"integer")
424 while ($rec =
$ilDB->fetchAssoc($set)) {
427 "Title" => $rec[
"title"],
428 "Description" => $rec[
"description"],
436 if ($a_entity ==
"skl_local_prof") {
437 switch ($a_version) {
439 foreach ($a_ids as $obj_id) {
441 $obj_ref_id = end($obj_ref_id);
442 $profiles = $this->skill_manager->getProfileManager()->getLocalProfilesForObject($obj_ref_id);
444 foreach ($profiles as $p) {
445 $profile_ids[] = $p->getId();
448 "SELECT * FROM skl_profile " .
449 " WHERE " .
$ilDB->in(
"id", $profile_ids,
false,
"integer")
451 while ($rec =
$ilDB->fetchAssoc($set)) {
454 "Title" => $rec[
"title"],
455 "Description" => $rec[
"description"],
456 "RefId" => $obj_ref_id
462 foreach ($a_ids as $obj_id) {
464 $obj_ref_id = end($obj_ref_id);
465 $profiles = $this->skill_manager->getProfileManager()->getLocalProfilesForObject($obj_ref_id);
467 foreach ($profiles as $p) {
468 $profile_ids[] = $p->getId();
471 "SELECT * FROM skl_profile " .
472 " WHERE " .
$ilDB->in(
"id", $profile_ids,
false,
"integer")
474 while ($rec =
$ilDB->fetchAssoc($set)) {
477 "Title" => $rec[
"title"],
478 "Description" => $rec[
"description"],
479 "RefId" => $obj_ref_id,
488 if ($a_entity ==
"skl_prof_level") {
489 switch ($a_version) {
492 " FROM skl_profile_level WHERE " .
493 $ilDB->in(
"profile_id", $a_ids,
false,
"integer"));
498 " FROM skl_profile_level WHERE " .
499 $ilDB->in(
"profile_id", $a_ids,
false,
"integer"));
513 ?array $a_rec = null,
521 $deps[
"skee"][
"ids"] = $a_ids;
525 if (!isset($a_rec[
"Id"]) || is_null($a_rec[
"Id"])) {
528 $skill_tree = $this->skill_tree_factory->getTreeById((
int) $a_rec[
"Id"]);
531 if ($this->
getMode() == self::MODE_SKILLS) {
534 $exp_types = array(
"skll",
"scat",
"sctr",
"sktr");
535 if (!isset($sel_nodes) || count($sel_nodes) === 0) {
536 $childs = $skill_tree->getChildsByTypeFilter($skill_tree->readRootId(), $exp_types);
537 $skl_subtree_deps = [];
538 foreach ($childs as
$c) {
539 $skl_subtree_deps[] = (
int) $c[
"child"];
542 $skl_subtree_deps = [];
543 foreach ($sel_nodes as $n) {
545 $skl_subtree_deps[] = $n;
552 if (is_array($skl_subtree_deps)) {
553 foreach ($skl_subtree_deps as
$id) {
557 $sub = $skill_tree->getSubTree($skill_tree->getNodeData($id),
true, [
"sktr"]);
558 foreach ($sub as $s) {
559 $ref_nodes[$s[
"child"]] = $s[
"child"];
565 $set =
$ilDB->query(
"SELECT DISTINCT(templ_id) FROM skl_templ_ref " .
566 " WHERE " .
$ilDB->in(
"skl_node_id", $ref_nodes,
false,
"integer"));
567 while ($rec =
$ilDB->fetchAssoc($set)) {
568 $deps[
"skl_templ_subtree"][
"ids"][] = (
int) $rec[
"templ_id"];
572 $deps[
"skl_subtree"][
"ids"] = $skl_subtree_deps;
573 } elseif ($this->
getMode() == self::MODE_PROFILES) {
575 $deps[
"skl_prof"][
"ids"][] = $p_id;
581 case "skl_templ_subtree":
583 if (in_array($a_rec[
"Type"], array(
"skll",
"sktp"))) {
584 $deps[
"skl_level"][
"ids"][] = $a_rec[
"Child"];
589 case "skl_local_prof":
590 $deps[
"skl_prof_level"][
"ids"][] = $a_rec[
"Id"] ?? null;
602 string $a_schema_version
604 $skill_tree = $this->skill_tree_factory->getTreeById($this->
getSkillTreeId());
605 $skill_tree_root_id = $skill_tree->readRootId();
606 $tree_node_manager = $this->skill_manager->getTreeNodeManager($this->
getSkillTreeId());
608 $init_top_order_nr = $skill_tree->getMaxOrderNr($skill_tree_root_id);
609 $init_templ_top_order_nr = $skill_tree->getMaxOrderNr($skill_tree_root_id,
true);
614 if ((
int) $a_rec[
"TopNode"] === 1) {
617 $order = (
int) $a_rec[
"OrderNr"] + $init_top_order_nr;
619 $parent = (
int) $a_mapping->
getMapping(
"components/ILIAS/Skill",
"skl_tree", $a_rec[
"Parent"]);
620 $status = (
int) $a_rec[
"Status"];
621 $order = (
int) $a_rec[
"OrderNr"];
623 switch ($a_rec[
"Type"]) {
626 $scat->setTitle($a_rec[
"Title"]);
627 $scat->setDescription($a_rec[
"Description"] ??
"");
628 $scat->setImportId(
"il_" . $source_inst_id .
"_scat_" . $a_rec[
"Child"]);
629 $scat->setSelfEvaluation((
bool) $a_rec[
"SelfEval"]);
630 $scat->setOrderNr($order);
631 $scat->setStatus($status);
633 $tree_node_manager->putIntoTree($scat, $parent);
634 $a_mapping->
addMapping(
"components/ILIAS/Skill",
"skl_tree", $a_rec[
"Child"], (
string) $scat->getId());
639 $skll->setTitle($a_rec[
"Title"]);
640 $skll->setDescription($a_rec[
"Description"] ??
"");
641 $skll->setImportId(
"il_" . $source_inst_id .
"_skll_" . $a_rec[
"Child"]);
642 $skll->setSelfEvaluation((
bool) $a_rec[
"SelfEval"]);
643 $skll->setOrderNr($order);
644 $skll->setStatus($status);
646 $tree_node_manager->putIntoTree($skll, $parent);
647 $a_mapping->
addMapping(
"components/ILIAS/Skill",
"skl_tree", $a_rec[
"Child"], (
string) $skll->getId());
651 $template_id = (
int) $a_mapping->
getMapping(
"components/ILIAS/Skill",
"skl_tree", $a_rec[
"TemplateId"]);
653 if ($template_id > 0) {
655 $sktr->setTitle($a_rec[
"Title"]);
656 $sktr->setDescription($a_rec[
"Description"] ??
"");
657 $sktr->setImportId(
"il_" . $source_inst_id .
"_sktr_" . $a_rec[
"Child"]);
658 $sktr->setSelfEvaluation((
bool) $a_rec[
"SelfEval"]);
659 $sktr->setOrderNr($order);
660 $sktr->setSkillTemplateId($template_id);
661 $sktr->setStatus($status);
663 $tree_node_manager->putIntoTree($sktr, $parent);
664 $a_mapping->
addMapping(
"components/ILIAS/Skill",
"skl_tree", $a_rec[
"Child"], (
string) $sktr->getId());
670 case "skl_templ_subtree":
671 if ((
int) $a_rec[
"TopNode"] === 1) {
673 $order = (
int) $a_rec[
"OrderNr"] + $init_templ_top_order_nr;
675 $parent = (
int) $a_mapping->
getMapping(
"components/ILIAS/Skill",
"skl_tree", $a_rec[
"Parent"]);
676 $order = (
int) $a_rec[
"OrderNr"];
678 switch ($a_rec[
"Type"]) {
681 $sctp->setTitle($a_rec[
"Title"]);
682 $sctp->setDescription($a_rec[
"Description"] ??
"");
683 $sctp->setImportId(
"il_" . $source_inst_id .
"_sctp_" . $a_rec[
"Child"]);
684 $sctp->setOrderNr($order);
686 $tree_node_manager->putIntoTree($sctp, $parent);
687 $a_mapping->
addMapping(
"components/ILIAS/Skill",
"skl_tree", $a_rec[
"Child"], (
string) $sctp->getId());
692 $sktp->setTitle($a_rec[
"Title"]);
693 $sktp->setDescription($a_rec[
"Description"] ??
"");
694 $sktp->setImportId(
"il_" . $source_inst_id .
"_sktp_" . $a_rec[
"Child"]);
695 $sktp->setOrderNr($order);
697 $tree_node_manager->putIntoTree($sktp, $parent);
698 $a_mapping->
addMapping(
"components/ILIAS/Skill",
"skl_tree", $a_rec[
"Child"], (
string) $sktp->getId());
704 $skill_id = (
int) $a_mapping->
getMapping(
"components/ILIAS/Skill",
"skl_tree", $a_rec[
"SkillId"]);
706 if (in_array($type, array(
"skll",
"sktp"))) {
707 if ($type ==
"skll") {
712 $skill->addLevel($a_rec[
"Title"], $a_rec[
"Description"],
"il_" . $source_inst_id .
"_sklv_" . $a_rec[
"LevelId"]);
718 $profile = $this->skill_factory->profile()->profile(
721 $a_rec[
"Description"] ??
"",
724 $new_profile = $this->skill_manager->getProfileManager()->createProfile($profile);
726 $a_mapping->
addMapping(
"components/ILIAS/Skill",
"skl_prof", $a_rec[
"Id"], (
string) $new_profile->getId());
729 case "skl_local_prof":
730 $profile = $this->skill_factory->profile()->profile(
733 $a_rec[
"Description"] ??
"",
736 (
int) $a_rec[
"RefId"]
738 $new_profile = $this->skill_manager->getProfileManager()->createProfile($profile);
740 $a_mapping->
addMapping(
"components/ILIAS/Skill",
"skl_local_prof", $a_rec[
"Id"], (
string) $new_profile->getId());
743 case "skl_prof_level":
744 $profile_id = (
int) $a_mapping->
getMapping(
"components/ILIAS/Skill",
"skl_prof", $a_rec[
"ProfileId"])
745 ? (
int) $a_mapping->
getMapping(
"components/ILIAS/Skill",
"skl_prof", $a_rec[
"ProfileId"])
746 : (
int) $a_mapping->
getMapping(
"components/ILIAS/Skill",
"skl_local_prof", $a_rec[
"ProfileId"]);
747 if ($profile_id > 0) {
750 $level_id = $tref_id = $base_skill = 0;
751 foreach ($level_id_data as $l) {
753 foreach ($skill_data as $s) {
757 $level_id = $l[
"level_id"];
758 $base_skill = $s[
"skill_id"];
759 $tref_id = $s[
"tref_id"];
764 $level = $this->skill_factory->profile()->profileLevel(
769 (
int) $a_rec[
"OrderNr"]
771 $this->skill_manager->getProfileManager()->addSkillLevel($level);
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
importRecord(string $a_entity, array $a_types, array $a_rec, ilImportMapping $a_mapping, string $a_schema_version)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
SkillInternalManagerService $skill_manager
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static lookupLevelSkillId(int $a_id)
static _getAllReferences(int $id)
get all reference ids for object ID
setSelectedNodes(array $a_val)
SkillTreeFactory $skill_tree_factory
readData(string $a_entity, string $a_version, array $a_ids)
static getCommonSkillIdForImportId(int $a_source_inst_id, int $a_skill_import_id, int $a_tref_import_id=0)
addMapping(string $a_comp, string $a_entity, string $a_old_id, string $a_new_id)
static _lookupType(int $a_obj_id)
getDependencies(string $a_entity, string $a_version, ?array $a_rec=null, ?array $a_ids=null)
int $init_templ_top_order_nr
getMapping(string $a_comp, string $a_entity, string $a_old_id)
Skill internal manager service.
getCurrentInstallationId()
Skill internal factory service.
getTypes(string $a_entity, string $a_version)
Get field types for entity.
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 ...
ilSkillTreeRepository $tree_repo
setSkillTreeId(int $skill_tree_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setSelectedProfiles(array $a_val)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
__construct(Container $dic, ilPlugin $plugin)
getXmlNamespace(string $a_entity, string $a_schema_version)
SkillInternalFactoryService $skill_factory
static getLevelIdForImportId(int $a_source_inst_id, int $a_level_import_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...