ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilLearningModuleImporter Class Reference

Importer class for files. More...

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

Public Member Functions

 init ()
 
 importXmlRepresentation (string $a_entity, string $a_id, string $a_xml, ilImportMapping $a_mapping)
 
 finalProcessing (ilImportMapping $a_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 Attributes

ReadingTimeManager $reading_time_manager
 
array $qtis
 
ilLearningModuleDataSet $ds
 
ilImportConfig $config
 
ilLogger $log
 
- 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

Importer class for files.

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

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

Member Function Documentation

◆ finalProcessing()

ilLearningModuleImporter::finalProcessing ( ilImportMapping  $a_mapping)

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

References $id, ILIAS\LTI\ToolProvider\$updated, ilPageObject\_exists(), ilLMObject\_lookupContObjID(), ilPageObject\_writeParentId(), ilLMMenuEditor\fixImportMenuItems(), ilPageObjectFactory\getInstance(), ilImportMapping\getMapping(), ilImportMapping\getMappingsOfEntity(), ILIAS\Repository\int(), ilObjContentObject\writeFooterPage(), and ilObjContentObject\writeHeaderPage().

118  : void
119  {
120  $pg_map = $a_mapping->getMappingsOfEntity("Modules/LearningModule", "pg");
121 
122  $this->log->debug("pg map entries: " . count($pg_map));
123  foreach ($pg_map as $pg_id) {
124  $lm_id = ilLMPageObject::_lookupContObjID($pg_id);
125  ilLMPage::_writeParentId("lm", $pg_id, $lm_id);
126  $this->log->debug("write parent id, pg id: " . $pg_id . ", lm id: " . $lm_id);
127  }
128 
129  // header footer page
130  foreach ($a_mapping->getMappingsOfEntity("Modules/LearningModule", "lm_header_page") as $old_id => $dummy) {
131  $new_page_id = (int) $a_mapping->getMapping("Modules/LearningModule", "pg", $old_id);
132  if ($new_page_id > 0) {
133  $lm_id = ilLMPageObject::_lookupContObjID($new_page_id);
134  ilObjLearningModule::writeHeaderPage($lm_id, $new_page_id);
135  }
136  }
137  foreach ($a_mapping->getMappingsOfEntity("Modules/LearningModule", "lm_footer_page") as $old_id => $dummy) {
138  $new_page_id = (int) $a_mapping->getMapping("Modules/LearningModule", "pg", $old_id);
139  if ($new_page_id > 0) {
140  $lm_id = ilLMPageObject::_lookupContObjID($new_page_id);
141  ilObjLearningModule::writeFooterPage($lm_id, $new_page_id);
142  }
143  }
144 
145 
146  $link_map = $a_mapping->getMappingsOfEntity("Modules/LearningModule", "link");
147  $pages = $a_mapping->getMappingsOfEntity("Services/COPage", "pgl");
148  foreach ($pages as $p) {
149  $id = explode(":", $p);
150  if (count($id) == 3) {
151  if (ilPageObject::_exists($id[0], $id[1], $id[2], true)) {
152  $new_page = ilPageObjectFactory::getInstance($id[0], $id[1], 0, $id[2]);
153  $new_page->buildDom();
154 
155  // fix question references
156  $updated = $new_page->resolveQuestionReferences($this->qtis);
157 
158  // in translation mode use link mapping to fix internal links
159  //$a_mapping->addMapping("Modules/LearningModule", "link",
160  if ($this->config->getTranslationImportMode()) {
161  $il = $new_page->resolveIntLinks($link_map);
162  if ($il) {
163  $updated = true;
164  }
165  }
166 
167  if ($updated) {
168  $new_page->update(false, true);
169  }
170  }
171  }
172  }
173 
174  // assign style
175  /*
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 
192  // typical reading time
193  $lm_map = $a_mapping->getMappingsOfEntity("Modules/LearningModule", "lm");
194  foreach ($lm_map as $old_lm_id => $new_lm_id) {
195  $this->reading_time_manager->updateReadingTime($new_lm_id);
196  }
197  }
static writeFooterPage(int $a_lm_id, int $a_page_id)
static fixImportMenuItems(int $new_lm_id, array $ref_mapping)
static _writeParentId(string $a_parent_type, int $a_pg_id, int $a_par_id)
static writeHeaderPage(int $a_lm_id, int $a_page_id)
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)
getMappingsOfEntity(string $a_comp, string $a_entity)
static _exists(string $a_parent_type, int $a_id, string $a_lang="", bool $a_no_cache=false)
Checks whether page exists.
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
static _lookupContObjID(int $a_id)
get learning module id for lm object
static getInstance(string $a_parent_type, int $a_id=0, int $a_old_nr=0, string $a_lang="-")
Get page object instance.
+ Here is the call graph for this function:

◆ importXmlRepresentation()

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

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

References ilXmlImporter\getImportDirectory(), ilObjectFactory\getInstanceByObjId(), ilImportMapping\getMapping(), ilXmlImporter\getSchemaVersion(), ilQTIParser\IL_MO_PARSE_QTI, and ilQTIParser\IL_MO_VERIFY_QTI.

64  : void {
65  $this->log->debug("import XML Representation");
66 
67  // case i container
68  if ($new_id = $a_mapping->getMapping('Services/Container', 'objs', $a_id)) {
69  $newObj = ilObjectFactory::getInstanceByObjId($new_id, false);
70  $newObj->createLMTree();
71  $this->log->debug("got mapping, new id is: " . $new_id);
72  }
73 
74  // in the new version (5.1) we are also here, but the following file should not exist
75  // if being exported with 5.1 or higher
76  $xml_file = $this->getImportDirectory() . '/' . basename($this->getImportDirectory()) . '.xml';
77 
78  // old school import
79  // currently this means we got a container and mapping, too, since
80  // for single lms the processing in ilObjContentObjectGUI->importFileObject is used
81  // (this should be streamlined, see glossary)
82  if (file_exists($xml_file)) {
83  throw new ilLMOldExportFileException("This file seems to be from ILIAS version 5.0.x or lower. Import is not supported anymore.");
84  } else { // new import version (does mapping, too)
85  $this->log->debug("create ilDataSetIportParser instance");
86  $parser = new ilDataSetImportParser(
87  $a_entity,
88  $this->getSchemaVersion(),
89  $a_xml,
90  $this->ds,
91  $a_mapping
92  );
93  }
94 
95  // import qti stuff
96  $this->log->debug("import qti data");
97  $qti_file = $this->getImportDirectory() . '/qti.xml';
98  $this->qtis = array();
99  if (is_file($qti_file)) {
100  $qtiParser = new ilQTIParser(
101  $qti_file,
103  0,
104  ""
105  );
106  $result = $qtiParser->startParsing();
107  $founditems = &$qtiParser->getFoundItems();
108  $testObj = new ilObjTest(0, true);
109  if (count($founditems) > 0) {
110  $qtiParser = new ilQTIParser($qti_file, ilQTIParser::IL_MO_PARSE_QTI, 0, "");
111  $qtiParser->setTestObject($testObj);
112  $result = $qtiParser->startParsing();
113  $this->qtis = array_merge($this->qtis, $qtiParser->getImportMapping());
114  }
115  }
116  }
Manifest parser for ILIAS standard export files.
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
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:

◆ init()

ilLearningModuleImporter::init ( )

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

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

34  : void
35  {
36  $this->ds = new ilLearningModuleDataSet();
37  $this->ds->setDSPrefix("ds");
38 
39  $this->log = ilLoggerFactory::getLogger('lm');
40 
41  $this->config = $this->getImport()->getConfig("Modules/LearningModule");
42  if ($this->config->getTranslationImportMode()) {
43  $this->ds->setTranslationImportMode(
44  $this->config->getTranslationLM(),
45  $this->config->getTranslationLang()
46  );
47  $cop_config = $this->getImport()->getConfig("Services/COPage");
48  $cop_config->setUpdateIfExists(true);
49  $cop_config->setForceLanguage($this->config->getTranslationLang());
50  $cop_config->setReuseOriginallyExportedMedia(true);
51  $cop_config->setSkipInternalLinkResolve(true);
52 
53  $mob_config = $this->getImport()->getConfig("Services/MediaObjects");
54  $mob_config->setUsePreviousImportIds(true);
55  }
56  $this->reading_time_manager = new ReadingTimeManager();
57  }
static getLogger(string $a_component_id)
Get component logger.
LearningModule Data set class.
+ Here is the call graph for this function:

Field Documentation

◆ $config

ilImportConfig ilLearningModuleImporter::$config
protected

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

◆ $ds

ilLearningModuleDataSet ilLearningModuleImporter::$ds
protected

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

◆ $log

ilLogger ilLearningModuleImporter::$log
protected

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

◆ $qtis

array ilLearningModuleImporter::$qtis
protected

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

◆ $reading_time_manager

ReadingTimeManager ilLearningModuleImporter::$reading_time_manager
protected

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


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