ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
ilLearningModuleImporter Class Reference

Importer class for files. More...

+ Inheritance diagram for ilLearningModuleImporter:
+ Collaboration diagram for ilLearningModuleImporter:

Public Member Functions

 init ()
 Initialisation. More...
 
 importXmlRepresentation ($a_entity, $a_id, $a_xml, $a_mapping)
 Import XML. More...
 
 finalProcessing ($a_mapping)
 Final processing. More...
 
- Public Member Functions inherited from ilXmlImporter
 __construct ()
 Constructor. More...
 
 setImport ($a_val)
 Set import. More...
 
 getImport ()
 Get import. More...
 
 init ()
 Init. More...
 
 setInstallId ($a_val)
 Set installation id. More...
 
 getInstallId ()
 Get installation id. More...
 
 setInstallUrl ($a_val)
 Set installation url. More...
 
 getInstallUrl ()
 Get installation url. More...
 
 setSchemaVersion ($a_val)
 Set schema version. More...
 
 getSchemaVersion ()
 Get schema version. More...
 
 setImportDirectory ($a_val)
 Set import directory. More...
 
 getImportDirectory ()
 Get import directory. More...
 
 setSkipEntities ($a_val)
 Set skip entities. More...
 
 getSkipEntities ()
 Get skip entities. More...
 
 exportedFromSameInstallation ()
 Is exporting and importing installation identical? More...
 
 importXmlRepresentation ($a_entity, $a_id, $a_xml, $a_mapping)
 Import xml representation. More...
 
 finalProcessing ($a_mapping)
 Final processing. More...
 
 afterContainerImportProcessing (ilImportMapping $mapping)
 Called after all container objects have been implemented. More...
 

Protected Attributes

 $config
 
 $log
 
- Protected Attributes inherited from ilXmlImporter
 $skip_entities = array()
 
 $imp
 

Detailed Description

Importer class for files.

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
Id

Definition at line 12 of file class.ilLearningModuleImporter.php.

Member Function Documentation

◆ finalProcessing()

ilLearningModuleImporter::finalProcessing (   $a_mapping)

Final processing.

Parameters
arraymapping array

Reimplemented from ilXmlImporter.

Definition at line 119 of file class.ilLearningModuleImporter.php.

120 {
121 $pg_map = $a_mapping->getMappingsOfEntity("Modules/LearningModule", "pg");
122
123 $this->log->debug("pg map entries: " . count($pg_map));
124 foreach ($pg_map as $pg_id) {
125 $lm_id = ilLMPageObject::_lookupContObjID($pg_id);
126 ilLMPage::_writeParentId("lm", $pg_id, $lm_id);
127 $this->log->debug("write parent id, pg id: " . $pg_id . ", lm id: " . $lm_id);
128 }
129
130 // header footer page
131 foreach ($a_mapping->getMappingsOfEntity("Modules/LearningModule", "lm_header_page") as $old_id => $dummy) {
132 $new_page_id = (int) $a_mapping->getMapping("Modules/LearningModule", "pg", $old_id);
133 if ($new_page_id > 0) {
134 $lm_id = ilLMPageObject::_lookupContObjID($new_page_id);
135 ilObjLearningModule::writeHeaderPage($lm_id, $new_page_id);
136 }
137 }
138 foreach ($a_mapping->getMappingsOfEntity("Modules/LearningModule", "lm_footer_page") as $old_id => $dummy) {
139 $new_page_id = (int) $a_mapping->getMapping("Modules/LearningModule", "pg", $old_id);
140 if ($new_page_id > 0) {
141 $lm_id = ilLMPageObject::_lookupContObjID($new_page_id);
142 ilObjLearningModule::writeFooterPage($lm_id, $new_page_id);
143 }
144 }
145
146
147 $link_map = $a_mapping->getMappingsOfEntity("Modules/LearningModule", "link");
148 $pages = $a_mapping->getMappingsOfEntity("Services/COPage", "pgl");
149 foreach ($pages as $p) {
150 $id = explode(":", $p);
151 if (count($id) == 3) {
152 if (ilPageObject::_exists($id[0], $id[1], $id[2], true)) {
153 $new_page = ilPageObjectFactory::getInstance($id[0], $id[1], 0, $id[2]);
154 $new_page->buildDom();
155
156 // fix question references
157 $updated = $new_page->resolveQuestionReferences($this->qtis);
158
159 // in translation mode use link mapping to fix internal links
160 //$a_mapping->addMapping("Modules/LearningModule", "link",
161 if ($this->config->getTranslationImportMode()) {
162 $il = $new_page->resolveIntLinks($link_map);
163 if ($il) {
164 $updated = true;
165 }
166 }
167
168 if ($updated) {
169 $new_page->update(false, true);
170 }
171 }
172 }
173 }
174
175 // assign style
176 $alls_map = $a_mapping->getMappingsOfEntity("Modules/LearningModule", "lm_style");
177 foreach ($alls_map as $new_lm_id => $old_style_id) {
178 $new_style_id = (int) $a_mapping->getMapping("Services/Style", "sty", $old_style_id);
179 if ($new_lm_id > 0 && $new_style_id > 0) {
180 $lm = new ilObjLearningModule($new_lm_id, false);
181 $lm->writeStyleSheetId($new_style_id);
182 }
183 }
184
185 // menu item ref ids
186 $ref_mapping = $a_mapping->getMappingsOfEntity('Services/Container', 'refs');
187 $lm_map = $a_mapping->getMappingsOfEntity("Modules/LearningModule", "lm");
188 foreach ($lm_map as $old_lm_id => $new_lm_id) {
189 ilLMMenuEditor::fixImportMenuItems($new_lm_id, $ref_mapping);
190 }
191 }
static fixImportMenuItems(int $new_lm_id, array $ref_mapping)
Fix ref ids on import.
static _lookupContObjID($a_id)
get learning module / digibook id for lm object
static writeHeaderPage($a_lm_id, $a_page_id)
Write header page.
static writeFooterPage($a_lm_id, $a_page_id)
Write footer page.
Class ilObjLearningModule.
static getInstance($a_parent_type, $a_id=0, $a_old_nr=0, $a_lang="-")
Get page object instance.
static _exists($a_parent_type, $a_id, $a_lang="", $a_no_cache=false)
Checks whether page exists.
static _writeParentId($a_parent_type, $a_pg_id, $a_par_id)
Write parent id.

References ilPageObject\_exists(), ilLMObject\_lookupContObjID(), ilPageObject\_writeParentId(), ilLMMenuEditor\fixImportMenuItems(), ilPageObjectFactory\getInstance(), ilObjContentObject\writeFooterPage(), and ilObjContentObject\writeHeaderPage().

+ Here is the call graph for this function:

◆ importXmlRepresentation()

ilLearningModuleImporter::importXmlRepresentation (   $a_entity,
  $a_id,
  $a_xml,
  $a_mapping 
)

Import XML.

Parameters

return

Reimplemented from ilXmlImporter.

Definition at line 55 of file class.ilLearningModuleImporter.php.

56 {
57 $this->log->debug("import XML Representation");
58
59 // case i container
60 if ($new_id = $a_mapping->getMapping('Services/Container', 'objs', $a_id)) {
61 $newObj = ilObjectFactory::getInstanceByObjId($new_id, false);
62 $newObj->createLMTree();
63 $this->log->debug("got mapping, new id is: " . $new_id);
64 }
65
66 // in the new version (5.1) we are also here, but the following file should not exist
67 // if being exported with 5.1 or higher
68 $xml_file = $this->getImportDirectory() . '/' . basename($this->getImportDirectory()) . '.xml';
69
70 // old school import
71 // currently this means we got a container and mapping, too, since
72 // for single lms the processing in ilObjContentObjectGUI->importFileObject is used
73 // (this should be streamlined, see glossary)
74 if (file_exists($xml_file)) {
75 $newObj->setImportDirectory(dirname(rtrim($this->getImportDirectory(), '/')));
76 $mess = $newObj->importFromDirectory($this->getImportDirectory(), true, $a_mapping);
77 $this->log->debug("imported from directory ($mess)");
78 $a_mapping->addMapping("Modules/LearningModule", "lm", $a_id, $newObj->getId());
79 $a_mapping->addMapping("Services/Object", "obj", $a_id, $newObj->getId());
80 } else { // new import version (does mapping, too)
81 $this->log->debug("create ilDataSetIportParser instance");
83 $a_entity,
84 $this->getSchemaVersion(),
85 $a_xml,
86 $this->ds,
87 $a_mapping
88 );
89 }
90
91 // import qti stuff
92 $this->log->debug("import qti data");
93 $qti_file = $this->getImportDirectory() . '/qti.xml';
94 $this->qtis = array();
95 if (is_file($qti_file)) {
96 $qtiParser = new ilQTIParser(
97 $qti_file,
99 0,
100 ""
101 );
102 $result = $qtiParser->startParsing();
103 $founditems = &$qtiParser->getFoundItems();
104 $testObj = new ilObjTest(0, true);
105 if (count($founditems) > 0) {
106 $qtiParser = new ilQTIParser($qti_file, IL_MO_PARSE_QTI, 0, "");
107 $qtiParser->setTestObject($testObj);
108 $result = $qtiParser->startParsing();
109 $this->qtis = array_merge($this->qtis, $qtiParser->getImportMapping());
110 }
111 }
112 }
$parser
Definition: BPMN2Parser.php:23
$result
const IL_MO_VERIFY_QTI
const IL_MO_PARSE_QTI
Manifest parser for ILIAS standard export files.
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
getSchemaVersion()
Get schema version.
getImportDirectory()
Get import directory.

References $parser, $result, ilXmlImporter\getImportDirectory(), ilObjectFactory\getInstanceByObjId(), ilXmlImporter\getSchemaVersion(), IL_MO_PARSE_QTI, and IL_MO_VERIFY_QTI.

+ Here is the call graph for this function:

◆ init()

ilLearningModuleImporter::init ( )

Initialisation.

Reimplemented from ilXmlImporter.

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

25 {
26 $this->ds = new ilLearningModuleDataSet();
27 $this->ds->setDSPrefix("ds");
28
29 $this->log = ilLoggerFactory::getLogger('lm');
30
31 $this->config = $this->getImport()->getConfig("Modules/LearningModule");
32 if ($this->config->getTranslationImportMode()) {
33 $this->ds->setTranslationImportMode(
34 $this->config->getTranslationLM(),
35 $this->config->getTranslationLang()
36 );
37 $cop_config = $this->getImport()->getConfig("Services/COPage");
38 $cop_config->setUpdateIfExists(true);
39 $cop_config->setForceLanguage($this->config->getTranslationLang());
40 $cop_config->setReuseOriginallyExportedMedia(true);
41 $cop_config->setSkipInternalLinkResolve(true);
42
43 $mob_config = $this->getImport()->getConfig("Services/MediaObjects");
44 $mob_config->setUsePreviousImportIds(true);
45 }
46 }
LearningModule Data set class.
static getLogger($a_component_id)
Get component logger.
getImport()
Get import.

References ilXmlImporter\getImport(), and ilLoggerFactory\getLogger().

+ Here is the call graph for this function:

Field Documentation

◆ $config

ilLearningModuleImporter::$config
protected

Definition at line 14 of file class.ilLearningModuleImporter.php.

◆ $log

ilLearningModuleImporter::$log
protected

Definition at line 19 of file class.ilLearningModuleImporter.php.


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