ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilSurveyQuestionPoolImporter.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
11 {
18  public function importXmlRepresentation($a_entity, $a_id, $a_xml, $a_mapping)
19  {
20  // Container import => test object already created
21  if ($new_id = $a_mapping->getMapping('Services/Container', 'objs', $a_id)) {
22  $newObj = ilObjectFactory::getInstanceByObjId($new_id, false);
23  #$newObj->setImportDirectory(dirname(rtrim($this->getImportDirectory(),'/')));
24  } else { // case ii, non container
25  // Shouldn't happen
26  $GLOBALS['ilLog']->write(__METHOD__ . ': Called in non container mode');
27  return false;
28  }
29 
30 
31  list($xml_file) = $this->parseXmlFileNames();
32 
33  if (!@file_exists($xml_file)) {
34  $GLOBALS['ilLog']->write(__METHOD__ . ': Cannot find xml definition: ' . $xml_file);
35  return false;
36  }
37 
38  // import qti data
39  $qtiresult = $newObj->importObject($xml_file);
40 
41  $a_mapping->addMapping("Modules/SurveyQuestionPool", "spl", $a_id, $newObj->getId());
42 
43  return true;
44  }
45 
46 
51  protected function parseXmlFileNames()
52  {
53  $GLOBALS['ilLog']->write(__METHOD__ . ': ' . $this->getImportDirectory());
54 
55  $basename = basename($this->getImportDirectory());
56  $xml = $this->getImportDirectory() . '/' . $basename . '.xml';
57 
58  return array($xml);
59  }
60 }
getImportDirectory()
Get import directory.
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
importXmlRepresentation($a_entity, $a_id, $a_xml, $a_mapping)
Import XML.
$xml
Definition: metadata.php:332
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.
Xml importer class.