ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ilObjSurveyQuestionPool.
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...
importXmlRepresentation(string $a_entity, string $a_id, string $a_xml, ilImportMapping $a_mapping)
Xml importer class.
if(!file_exists('../ilias.ini.php'))
$GLOBALS["DIC"]
Definition: wac.php:54