ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilSurveyQuestionPoolImporter.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 include_once("./Services/Export/classes/class.ilXmlImporter.php");
5 
14 {
21  public function importXmlRepresentation($a_entity, $a_id, $a_xml, $a_mapping)
22  {
23  // Container import => test object already created
24  if ($new_id = $a_mapping->getMapping('Services/Container', 'objs', $a_id)) {
25  $newObj = ilObjectFactory::getInstanceByObjId($new_id, false);
26  #$newObj->setImportDirectory(dirname(rtrim($this->getImportDirectory(),'/')));
27  } else { // case ii, non container
28  // Shouldn't happen
29  $GLOBALS['ilLog']->write(__METHOD__ . ': Called in non container mode');
30  return false;
31  }
32 
33 
34  include_once "./Modules/SurveyQuestionPool/classes/class.ilObjSurveyQuestionPool.php";
35 
36  list($xml_file) = $this->parseXmlFileNames();
37 
38  if (!@file_exists($xml_file)) {
39  $GLOBALS['ilLog']->write(__METHOD__ . ': Cannot find xml definition: ' . $xml_file);
40  return false;
41  }
42 
43  // import qti data
44  $qtiresult = $newObj->importObject($xml_file);
45 
46  $a_mapping->addMapping("Modules/SurveyQuestionPool", "spl", $a_id, $newObj->getId());
47 
48  return true;
49  }
50 
51 
56  protected function parseXmlFileNames()
57  {
58  $GLOBALS['ilLog']->write(__METHOD__ . ': ' . $this->getImportDirectory());
59 
60  $basename = basename($this->getImportDirectory());
61  $xml = $this->getImportDirectory() . '/' . $basename . '.xml';
62 
63  return array($xml);
64  }
65 }
getImportDirectory()
Get import directory.
importXmlRepresentation($a_entity, $a_id, $a_xml, $a_mapping)
Import XML.
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
parseXmlFileNames()
Create qti and xml file name.
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.
Xml importer class.