ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilBasicSkillTemplate.php
Go to the documentation of this file.
1 <?php
2 
26 {
27  public function __construct(int $a_id = 0)
28  {
29  parent::__construct($a_id);
30  $this->setType("sktp");
31  }
32 
36  public function copy(): ilBasicSkillTemplate
37  {
38  $skill = new ilBasicSkillTemplate();
39  $skill->setTitle($this->getTitle());
40  $skill->setDescription($this->getDescription());
41  $skill->setType($this->getType());
42  $skill->setOrderNr($this->getOrderNr());
43  $skill->create();
44 
45  $levels = $this->getLevelData();
46  if (sizeof($levels)) {
47  foreach ($levels as $item) {
48  $skill->addLevel($item["title"], $item["description"]);
49  }
50  }
51  $skill->update();
52 
53  return $skill;
54  }
55 
56  public function delete(): void
57  {
58  $ilDB = $this->db;
59 
60  foreach (\ilSkillTemplateReference::_lookupTrefIdsForTopTemplateId($this->getId()) as $tref_id) {
61  $obj = ilSkillTreeNodeFactory::getInstance($tref_id);
62  $skill_tree = $this->skill_service->internal()->repo()->getTreeRepo()->getTreeForNodeId($tref_id);
63  $node_data = $skill_tree->getNodeData($tref_id);
64  if (is_object($obj)) {
65  $obj->delete();
66  }
67  if ($skill_tree->isInTree($tref_id)) {
68  $skill_tree->deleteTree($node_data);
69  }
70  }
71 
72  $ilDB->manipulate(
73  "DELETE FROM skl_templ_ref WHERE "
74  . " templ_id = " . $ilDB->quote($this->getId(), "integer")
75  );
76 
77  parent::delete();
78  }
79 }
setType(string $a_type)
static _lookupTrefIdsForTopTemplateId(int $a_template_id)
getLevelData(int $a_id=0)
__construct(Container $dic, ilPlugin $plugin)
copy()
Copy basic skill template.
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...