ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 13 of file class.ilLearningModuleImporter.php.

Member Function Documentation

◆ finalProcessing()

ilLearningModuleImporter::finalProcessing (   $a_mapping)

Final processing.

Parameters
arraymapping array

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

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

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

◆ importXmlRepresentation()

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

Import XML.

Parameters

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

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

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

◆ init()

ilLearningModuleImporter::init ( )

Initialisation.

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

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

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

Field Documentation

◆ $config

ilLearningModuleImporter::$config
protected

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

◆ $log

ilLearningModuleImporter::$log
protected

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


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