ILIAS  trunk Revision v11.0_alpha-1769-g99a433fe2dc
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
class.ilSurveyQuestionPoolImporter.php
Go to the documentation of this file.
1 <?php
2 
24 {
25  public function importXmlRepresentation(
26  string $a_entity,
27  string $a_id,
28  string $a_xml,
29  ilImportMapping $a_mapping
30  ): void {
31  // Container import => test object already created
32  if ($new_id = $a_mapping->getMapping('components/ILIAS/Container', 'objs', $a_id)) {
33  $newObj = ilObjectFactory::getInstanceByObjId($new_id, false);
34  } else { // case ii, non container
35  $newObj = new ilObjSurveyQuestionPool();
36  $new_id = $newObj->create();
37  }
38 
39  # Try legacy import
40  $xml_file = $this->getXmlFileName();
41  if (file_exists($xml_file)) {
42  $GLOBALS['ilLog']->write(__METHOD__ . ': Cannot find xml definition: ' . $xml_file);
43  // import qti data
44  $newObj->importObject($xml_file);
45  }
46 
47  $import = new SurveyImportParser($new_id, "", true);
48  $import->setXMLContent($a_xml);
49  $import->startParsing();
50  $a_mapping->addMapping(
51  "components/ILIAS/SurveyQuestionPool",
52  "spl",
53  $a_id,
54  $newObj->getId()
55  );
56  $a_mapping->addMapping(
57  'components/ILIAS/MetaData',
58  'md',
59  $a_id . ':0:spl',
60  $newObj->getId() . ':0:spl'
61  );
62  }
63 
64  protected function getXmlFileName(): string
65  {
66  $basename = basename($this->getImportDirectory());
67  return $this->getImportDirectory() . '/' . $basename . '.xml';
68  }
69 }
Class ilObjSurveyQuestionPool.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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)
$GLOBALS["DIC"]
Definition: wac.php:53
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
importXmlRepresentation(string $a_entity, string $a_id, string $a_xml, ilImportMapping $a_mapping)
Xml importer class.