ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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)

Reimplemented from ilXmlImporter.

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

82 : void
83 {
84 $this->updateRefId($mapping);
85 $this->buildLSItems($this->data["item_data"], $mapping);
86 $this->buildLPSettings($this->data["lp_settings"], $mapping);
87
88 $roles = $this->obj->getLSRoles();
89 $roles->addLSMember(
90 $this->user->getId(),
91 $roles->getDefaultAdminRole()
92 );
93 }
buildLSItems(array $ls_data, ilImportMapping $mapping)
buildLPSettings(array $lp_settings, ilImportMapping $mapping)

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

+ Here is the call graph for this function:

◆ buildLPSettings()

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

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

141 : void
142 {
143 $collection = ilLPCollection::getInstanceByMode($this->obj->getId(), (int) $lp_settings["lp_mode"]);
144
145 $new_ref_ids = array_map(function ($old_ref_id) use ($mapping) {
146 return $mapping->getMapping("components/ILIAS/Container", "refs", $old_ref_id);
147 }, $lp_settings["lp_item_ref_ids"]);
148
149 if (!is_null($collection)) {
150 $collection->activateEntries($new_ref_ids);
151 }
152
153 $settings = new ilLPObjSettings($this->obj->getId());
154 $settings->setMode((int) $lp_settings["lp_mode"]);
155 $settings->insert();
156 }
getMapping(string $a_comp, string $a_entity, string $a_old_id)
static getInstanceByMode(int $a_obj_id, int $a_mode)

References ilLPCollection\getInstanceByMode(), and ilImportMapping\getMapping().

Referenced by afterContainerImportProcessing().

+ 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 103 of file class.ilLearningSequenceImporter.php.

103 : void
104 {
105 $mapped = [];
106 foreach ($ls_data as $data) {
107 $old_ref_id = $data["ref_id"];
108 $new_ref_id = $mapping->getMapping("components/ILIAS/Container", "refs", $old_ref_id);
109 $mapped[$new_ref_id] = $data;
110 }
111
112 $ls_items = $this->obj->getLSItems($this->obj->getRefId());
113 $updated = [];
114 foreach ($ls_items as $item) {
115 $item_ref_id = $item->getRefId();
116 if(array_key_exists($item_ref_id, $mapped)) {
117 $item_data = $mapped[$item_ref_id];
118 $post_condition = new ilLSPostCondition(
119 $item_ref_id,
120 $item_data["condition_type"],
121 $item_data["condition_value"]
122 );
123 $updated[] = $item->withPostCondition($post_condition);
124 }
125 }
126
127 if($updated) {
128 $this->obj->storeLSItems($updated);
129 }
130 }
A PostCondition does restrict the progression of a user through the learning sequence.

References $data, and ilImportMapping\getMapping().

Referenced by afterContainerImportProcessing().

+ 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 132 of file class.ilLearningSequenceImporter.php.

132 : void
133 {
134 $settings = $this->obj->getLSSettings();
135 $settings = $settings
136 ->withMembersGallery($ls_settings["members_gallery"] === 'true' ? true : false)
137 ;
138 $this->obj->updateSettings($settings);
139 }

Referenced by finalProcessing().

+ Here is the caller graph for this function:

◆ decodeImageData()

ilLearningSequenceImporter::decodeImageData ( string  $data)
protected

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

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

References $data.

◆ finalProcessing()

ilLearningSequenceImporter::finalProcessing ( ilImportMapping  $a_mapping)

Reimplemented from ilXmlImporter.

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

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

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

+ Here is the call graph for this function:

◆ getNewImagePath()

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

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

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

References $path.

◆ importXmlRepresentation()

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

Reimplemented from ilXmlImporter.

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

37 : void
38 {
39 if ($new_id = $a_mapping->getMapping("components/ILIAS/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("components/ILIAS/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 }
@ EXTRO
Definition: LSOPageType.php:24
addMapping(string $a_comp, string $a_entity, string $a_old_id, string $a_new_id)
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id

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

+ Here is the call graph for this function:

◆ init()

ilLearningSequenceImporter::init ( )

Reimplemented from ilXmlImporter.

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

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: shib_login.php:26

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

+ Here is the call graph for this function:

◆ updateRefId()

ilLearningSequenceImporter::updateRefId ( ilImportMapping  $mapping)
protected

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

95 : void
96 {
97 $old_ref_id = $this->data["object"]["ref_id"];
98 $new_ref_id = $mapping->getMapping("components/ILIAS/Container", "refs", $old_ref_id);
99
100 $this->obj->setRefId((int) $new_ref_id);
101 }

References ilImportMapping\getMapping().

Referenced by afterContainerImportProcessing().

+ 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 173 of file class.ilLearningSequenceImporter.php.

173 : void
174 {
175 file_put_contents($path, $data);
176 }

References $data, and $path.

Field Documentation

◆ $data

array ilLearningSequenceImporter::$data
protected

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