ILIAS  release_8 Revision v8.19-1-g4e8f2f9140c
All Data Structures Namespaces Files Functions Variables Modules Pages
ilLearningSequenceImporter Class Reference
+ Inheritance diagram for ilLearningSequenceImporter:
+ Collaboration diagram for ilLearningSequenceImporter:

Public Member Functions

 init ()
 
 importXmlRepresentation (string $a_entity, string $a_id, string $a_xml, ilImportMapping $a_mapping)
 
 finalProcessing (ilImportMapping $a_mapping)
 
 afterContainerImportProcessing (ilImportMapping $mapping)
 
- Public Member Functions inherited from ilXmlImporter
 __construct ()
 
 setImport (ilImport $a_val)
 
 getImport ()
 
 init ()
 
 setInstallId (string $a_val)
 
 getInstallId ()
 
 setInstallUrl (string $a_val)
 
 getInstallUrl ()
 
 setSchemaVersion (string $a_val)
 
 getSchemaVersion ()
 
 setImportDirectory (string $a_val)
 
 getImportDirectory ()
 
 setSkipEntities (array $a_val)
 
 getSkipEntities ()
 
 exportedFromSameInstallation ()
 
 importXmlRepresentation (string $a_entity, string $a_id, string $a_xml, ilImportMapping $a_mapping)
 
 finalProcessing (ilImportMapping $a_mapping)
 
 afterContainerImportProcessing (ilImportMapping $mapping)
 

Protected Member Functions

 updateRefId (ilImportMapping $mapping)
 
 buildLSItems (array $ls_data, ilImportMapping $mapping)
 
 buildSettings (array $ls_settings)
 
 buildLPSettings (array $lp_settings, ilImportMapping $mapping)
 
 decodeImageData (string $data)
 
 getNewImagePath (string $type, string $path)
 
 writeToFileSystem ($data, string $path)
 

Protected Attributes

ilObjUser $user
 
ilRbacAdmin $rbac_admin
 
ilLogger $log
 
ilObject $obj
 
array $data
 
- Protected Attributes inherited from ilXmlImporter
array $skip_entities = array()
 
ilImport $imp
 
string $install_id
 
string $install_url
 
string $schema_version
 
string $import_directory
 

Detailed Description

Definition at line 21 of file class.ilLearningSequenceImporter.php.

Member Function Documentation

◆ afterContainerImportProcessing()

ilLearningSequenceImporter::afterContainerImportProcessing ( ilImportMapping  $mapping)

Definition at line 59 of file class.ilLearningSequenceImporter.php.

References buildLPSettings(), buildLSItems(), updateRefId(), and ILIAS\Repository\user().

59  : void
60  {
61  $this->updateRefId($mapping);
62  $this->buildLSItems($this->data["item_data"], $mapping);
63  $this->buildLPSettings($this->data["lp_settings"], $mapping);
64 
65  $roles = $this->obj->getLSRoles();
66  $roles->addLSMember(
67  $this->user->getId(),
68  $roles->getDefaultAdminRole()
69  );
70  }
buildLSItems(array $ls_data, ilImportMapping $mapping)
buildLPSettings(array $lp_settings, ilImportMapping $mapping)
+ Here is the call graph for this function:

◆ buildLPSettings()

ilLearningSequenceImporter::buildLPSettings ( array  $lp_settings,
ilImportMapping  $mapping 
)
protected

Definition at line 143 of file class.ilLearningSequenceImporter.php.

References ILIAS\LTI\ToolProvider\$settings, ilLPCollection\getInstanceByMode(), ilImportMapping\getMapping(), and ILIAS\Repository\int().

Referenced by afterContainerImportProcessing().

143  : void
144  {
145  $collection = ilLPCollection::getInstanceByMode($this->obj->getId(), (int) $lp_settings["lp_mode"]);
146 
147  $new_ref_ids = array_map(function ($old_ref_id) use ($mapping) {
148  return $mapping->getMapping("Services/Container", "refs", $old_ref_id);
149  }, $lp_settings["lp_item_ref_ids"]);
150 
151  if (!is_null($collection)) {
152  $collection->activateEntries($new_ref_ids);
153  }
154 
155  $settings = new ilLPObjSettings($this->obj->getId());
156  $settings->setMode((int) $lp_settings["lp_mode"]);
157  $settings->insert();
158  }
array $settings
Setting values (LTI parameters, custom parameters and local parameters).
Definition: System.php:200
static getInstanceByMode(int $a_obj_id, int $a_mode)
getMapping(string $a_comp, string $a_entity, string $a_old_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildLSItems()

ilLearningSequenceImporter::buildLSItems ( array  $ls_data,
ilImportMapping  $mapping 
)
protected

Definition at line 80 of file class.ilLearningSequenceImporter.php.

References ilImportMapping\getMapping().

Referenced by afterContainerImportProcessing().

80  : void
81  {
82  $ls_items = array();
83  foreach ($ls_data as $data) {
84  $old_ref_id = $data["id"];
85  $new_ref_id = $mapping->getMapping("Services/Container", "refs", $old_ref_id);
86 
87  $ls_item_pc_value = null;
88  if (key_exists("ls_item_pc_value", $data)) {
89  $ls_item_pc_value = $data["ls_item_pc_value"];
90  }
91 
92  $post_condition = new ilLSPostCondition(
93  (int) $new_ref_id,
94  $data["ls_item_pc_condition_type"],
95  $ls_item_pc_value
96  );
97 
98  $ls_items[] = new LSItem(
99  $data["ls_item_type"] ?? "",
100  $data["ls_item_title"] ?? "",
101  $data["ls_item_description"] ?? "",
102  $data["ls_item_icon_path"] ?? "",
103  (bool) $data["ls_item_is_online"],
104  (int) $data["ls_item_order_number"],
105  $post_condition,
106  (int) $new_ref_id
107  );
108  }
109 
110  $this->obj->storeLSItems($ls_items);
111  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: LSItem.php:24
getMapping(string $a_comp, string $a_entity, string $a_old_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildSettings()

ilLearningSequenceImporter::buildSettings ( array  $ls_settings)
protected

Definition at line 113 of file class.ilLearningSequenceImporter.php.

References $path, ILIAS\LTI\ToolProvider\$settings, decodeImageData(), getNewImagePath(), ilLearningSequenceFilesystem\IMG_ABSTRACT, ilLearningSequenceFilesystem\IMG_EXTRO, and writeToFileSystem().

Referenced by finalProcessing().

113  : void
114  {
115  $settings = $this->obj->getLSSettings();
117  ->withAbstract($ls_settings["abstract"])
118  ->withExtro($ls_settings["extro"])
119  ->withMembersGallery((bool) $ls_settings["members_gallery"])
120  ;
121 
122  if ($ls_settings["abstract_img"] != "") {
123  $path = $this->getNewImagePath(ilLearningSequenceFilesystem::IMG_ABSTRACT, $ls_settings['abstract_img']);
124  $abstract_img_data = $this->decodeImageData($ls_settings["abstract_img_data"]);
125  $this->writeToFileSystem($abstract_img_data, $path);
127  ->withAbstractImage($path)
128  ;
129  }
130 
131  if ($ls_settings["extro_img"] != "") {
132  $path = $this->getNewImagePath(ilLearningSequenceFilesystem::IMG_EXTRO, $ls_settings['extro_img']);
133  $extro_img_data = $this->decodeImageData($ls_settings["extro_img_data"]);
134  $this->writeToFileSystem($extro_img_data, $path);
136  ->withExtroImage($path)
137  ;
138  }
139 
140  $this->obj->updateSettings($settings);
141  }
array $settings
Setting values (LTI parameters, custom parameters and local parameters).
Definition: System.php:200
getNewImagePath(string $type, string $path)
$path
Definition: ltiservices.php:32
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ decodeImageData()

ilLearningSequenceImporter::decodeImageData ( string  $data)
protected

Definition at line 160 of file class.ilLearningSequenceImporter.php.

Referenced by buildSettings().

160  : string
161  {
162  return base64_decode($data);
163  }
+ Here is the caller graph for this function:

◆ finalProcessing()

ilLearningSequenceImporter::finalProcessing ( ilImportMapping  $a_mapping)

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

References buildSettings().

52  : void
53  {
54  $this->buildSettings($this->data["settings"]);
55 
56  $this->obj->update();
57  }
+ Here is the call graph for this function:

◆ getNewImagePath()

ilLearningSequenceImporter::getNewImagePath ( string  $type,
string  $path 
)
protected

Definition at line 165 of file class.ilLearningSequenceImporter.php.

Referenced by buildSettings().

165  : string
166  {
167  $fs = $this->obj->getDI()['db.filesystem'];
168  return $fs->getStoragePathFor(
169  $type,
170  $this->obj->getId(),
171  $fs->getSuffix($path)
172  );
173  }
$type
$path
Definition: ltiservices.php:32
+ Here is the caller graph for this function:

◆ importXmlRepresentation()

ilLearningSequenceImporter::importXmlRepresentation ( string  $a_entity,
string  $a_id,
string  $a_xml,
ilImportMapping  $a_mapping 
)

Definition at line 37 of file class.ilLearningSequenceImporter.php.

References ilImportMapping\addMapping(), ilObjectFactory\getInstanceByObjId(), and ilImportMapping\getMapping().

37  : void
38  {
39  if ($new_id = $a_mapping->getMapping("Services/Container", "objs", $a_id)) {
40  $this->obj = ilObjectFactory::getInstanceByObjId((int) $new_id, false);
41  } else {
42  $this->obj = new ilObjLearningSequence();
43  $this->obj->create();
44  }
45 
46  $parser = new ilLearningSequenceXMLParser($this->obj, $a_xml);
47  $this->data = $parser->start();
48 
49  $a_mapping->addMapping("Modules/LearningSequence", "lso", $a_id, (string) $this->obj->getId());
50  }
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)
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
+ Here is the call graph for this function:

◆ init()

ilLearningSequenceImporter::init ( )

Definition at line 29 of file class.ilLearningSequenceImporter.php.

References $DIC, and ILIAS\Repository\user().

29  : void
30  {
31  global $DIC;
32  $this->user = $DIC["ilUser"];
33  $this->rbac_admin = $DIC["rbacadmin"];
34  $this->log = $DIC["ilLoggerFactory"]->getRootLogger();
35  }
global $DIC
Definition: feed.php:28
+ Here is the call graph for this function:

◆ updateRefId()

ilLearningSequenceImporter::updateRefId ( ilImportMapping  $mapping)
protected

Definition at line 72 of file class.ilLearningSequenceImporter.php.

References ilImportMapping\getMapping().

Referenced by afterContainerImportProcessing().

72  : void
73  {
74  $old_ref_id = $this->data["object"]["ref_id"];
75  $new_ref_id = $mapping->getMapping("Services/Container", "refs", $old_ref_id);
76 
77  $this->obj->setRefId((int) $new_ref_id);
78  }
getMapping(string $a_comp, string $a_entity, string $a_old_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ writeToFileSystem()

ilLearningSequenceImporter::writeToFileSystem (   $data,
string  $path 
)
protected

Definition at line 175 of file class.ilLearningSequenceImporter.php.

Referenced by buildSettings().

175  : void
176  {
177  file_put_contents($path, $data);
178  }
$path
Definition: ltiservices.php:32
+ Here is the caller graph for this function:

Field Documentation

◆ $data

array ilLearningSequenceImporter::$data
protected

Definition at line 27 of file class.ilLearningSequenceImporter.php.

◆ $log

ilLogger ilLearningSequenceImporter::$log
protected

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

◆ $obj

ilObject ilLearningSequenceImporter::$obj
protected

Definition at line 26 of file class.ilLearningSequenceImporter.php.

◆ $rbac_admin

ilRbacAdmin ilLearningSequenceImporter::$rbac_admin
protected

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

◆ $user

ilObjUser ilLearningSequenceImporter::$user
protected

Definition at line 23 of file class.ilLearningSequenceImporter.php.


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