ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
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 83 of file class.ilLearningSequenceImporter.php.

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

83  : void
84  {
85  $this->updateRefId($mapping);
86  $this->buildLSItems($this->data["item_data"], $mapping);
87  $this->buildLPSettings($this->data["lp_settings"], $mapping);
88 
89  $roles = $this->obj->getLSRoles();
90  $roles->addLSMember(
91  $this->user->getId(),
92  $roles->getDefaultAdminRole()
93  );
94  }
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 142 of file class.ilLearningSequenceImporter.php.

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

Referenced by afterContainerImportProcessing().

142  : void
143  {
144  $collection = ilLPCollection::getInstanceByMode($this->obj->getId(), (int) $lp_settings["lp_mode"]);
145 
146  $new_ref_ids = array_map(function ($old_ref_id) use ($mapping) {
147  return $mapping->getMapping("Services/Container", "refs", $old_ref_id);
148  }, $lp_settings["lp_item_ref_ids"]);
149 
150  if (!is_null($collection)) {
151  $collection->activateEntries($new_ref_ids);
152  }
153 
154  $settings = new ilLPObjSettings($this->obj->getId());
155  $settings->setMode((int) $lp_settings["lp_mode"]);
156  $settings->insert();
157  }
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 104 of file class.ilLearningSequenceImporter.php.

References $data, ILIAS\LTI\ToolProvider\$updated, and ilImportMapping\getMapping().

Referenced by afterContainerImportProcessing().

104  : void
105  {
106  $mapped = [];
107  foreach ($ls_data as $data) {
108  $old_ref_id = $data["ref_id"];
109  $new_ref_id = $mapping->getMapping("Services/Container", "refs", $old_ref_id);
110  $mapped[$new_ref_id] = $data;
111  }
112 
113  $ls_items = $this->obj->getLSItems($this->obj->getRefId());
114  $updated = [];
115  foreach ($ls_items as $item) {
116  $item_ref_id = $item->getRefId();
117  if(array_key_exists($item_ref_id, $mapped)) {
118  $item_data = $mapped[$item_ref_id];
119  $post_condition = new ilLSPostCondition(
120  $item_ref_id,
121  $item_data["condition_type"],
122  $item_data["condition_value"]
123  );
124  $updated[] = $item->withPostCondition($post_condition);
125  }
126  }
127 
128  if($updated) {
129  $this->obj->storeLSItems($updated);
130  }
131  }
int $updated
Timestamp for when the object was last updated.
Definition: System.php:158
getMapping(string $a_comp, string $a_entity, string $a_old_id)
A PostCondition does restrict the progression of a user through the learning sequence.
+ 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 133 of file class.ilLearningSequenceImporter.php.

References ILIAS\LTI\ToolProvider\$settings.

Referenced by finalProcessing().

133  : void
134  {
135  $settings = $this->obj->getLSSettings();
137  ->withMembersGallery($ls_settings["members_gallery"] === 'true' ? true : false)
138  ;
139  $this->obj->updateSettings($settings);
140  }
array $settings
Setting values (LTI parameters, custom parameters and local parameters).
Definition: System.php:200
+ Here is the caller graph for this function:

◆ decodeImageData()

ilLearningSequenceImporter::decodeImageData ( string  $data)
protected

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

159  : string
160  {
161  return base64_decode($data);
162  }

◆ finalProcessing()

ilLearningSequenceImporter::finalProcessing ( ilImportMapping  $a_mapping)

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

References $parts, ilPageObject\_writeParentId(), buildSettings(), and ilImportMapping\getMappingsOfEntity().

65  : void
66  {
67  $this->buildSettings($this->data["settings"]);
68  $this->obj->update();
69 
70  // pages
71  $page_map = $a_mapping->getMappingsOfEntity('Services/COPage', 'pg');
72  foreach ($page_map as $old_pg_id => $new_pg_id) {
73  $parts = explode(':', $old_pg_id);
74  $pg_type = $parts[0];
75  $old_obj_id = $parts[1];
76  $parts = explode(':', $new_pg_id);
77  $new_pg_id = array_pop($parts);
78  $new_obj_id = $this->obj->getId();
79  ilPageObject::_writeParentId($pg_type, (int) $new_pg_id, (int) $new_obj_id);
80  }
81  }
if($clientAssertionType !='urn:ietf:params:oauth:client-assertion-type:jwt-bearer'|| $grantType !='client_credentials') $parts
Definition: ltitoken.php:64
static _writeParentId(string $a_parent_type, int $a_pg_id, int $a_par_id)
getMappingsOfEntity(string $a_comp, string $a_entity)
+ Here is the call graph for this function:

◆ getNewImagePath()

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

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

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

◆ 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(), EXTRO, 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  $a_mapping->addMapping(
51  'Services/COPage',
52  'pg',
53  LSOPageType::INTRO->value . ':' . $a_id,
54  LSOPageType::INTRO->value . ':' . (string) $this->obj->getId()
55  );
56  $a_mapping->addMapping(
57  'Services/COPage',
58  'pg',
59  LSOPageType::EXTRO->value . ':' . $a_id,
60  LSOPageType::EXTRO->value . ':' . (string) $this->obj->getId()
61  );
62 
63  }
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 96 of file class.ilLearningSequenceImporter.php.

References ilImportMapping\getMapping().

Referenced by afterContainerImportProcessing().

96  : void
97  {
98  $old_ref_id = $this->data["object"]["ref_id"];
99  $new_ref_id = $mapping->getMapping("Services/Container", "refs", $old_ref_id);
100 
101  $this->obj->setRefId((int) $new_ref_id);
102  }
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 174 of file class.ilLearningSequenceImporter.php.

174  : void
175  {
176  file_put_contents($path, $data);
177  }
$path
Definition: ltiservices.php:32

Field Documentation

◆ $data

array ilLearningSequenceImporter::$data
protected

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

Referenced by buildLSItems().

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