ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables 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('Services/Container', 'objs', $a_id)) {
33  $newObj = ilObjectFactory::getInstanceByObjId($new_id, false);
34  } else { // case ii, non container
35  // Shouldn't happen
36  $GLOBALS['ilLog']->write(__METHOD__ . ': Called in non container mode');
37  return;
38  }
39 
40  $xml_file = $this->getXmlFileName();
41 
42  if (!file_exists($xml_file)) {
43  $GLOBALS['ilLog']->write(__METHOD__ . ': Cannot find xml definition: ' . $xml_file);
44  return;
45  }
46 
47  // import qti data
48  $newObj->importObject($xml_file);
49  $a_mapping->addMapping(
50  "Modules/SurveyQuestionPool",
51  "spl",
52  $a_id,
53  $newObj->getId()
54  );
55  }
56 
57  protected function getXmlFileName(): string
58  {
59  $basename = basename($this->getImportDirectory());
60  return $this->getImportDirectory() . '/' . $basename . '.xml';
61  }
62 }
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)
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
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)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...