ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5
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  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  {
26  $newObj = ilObjectFactory::getInstanceByObjId($new_id,false);
27  #$newObj->setImportDirectory(dirname(rtrim($this->getImportDirectory(),'/')));
28  }
29  else // case ii, non container
30  {
31  // Shouldn't happen
32  $GLOBALS['ilLog']->write(__METHOD__.': Called in non container mode');
33  return false;
34  }
35 
36 
37  include_once "./Modules/SurveyQuestionPool/classes/class.ilObjSurveyQuestionPool.php";
38 
39  list($xml_file) = $this->parseXmlFileNames();
40 
41  if(!@file_exists($xml_file))
42  {
43  $GLOBALS['ilLog']->write(__METHOD__.': Cannot find xml definition: '. $xml_file);
44  return false;
45  }
46 
47  // import qti data
48  $qtiresult = $newObj->importObject($xml_file);
49 
50  $a_mapping->addMapping("Modules/SurveyQuestionPool", "spl", $a_id, $newObj->getId());
51 
52  return true;
53  }
54 
55 
60  protected function parseXmlFileNames()
61  {
62  $GLOBALS['ilLog']->write(__METHOD__.': '.$this->getImportDirectory());
63 
64  $basename = basename($this->getImportDirectory());
65  $xml = $this->getImportDirectory().'/'.$basename.'.xml';
66 
67  return array($xml);
68  }
69 }
70 
71 ?>
getImportDirectory()
Get import directory.
importXmlRepresentation($a_entity, $a_id, $a_xml, $a_mapping)
Import XML.
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['PHPCAS_CLIENT']
This global variable is used by the interface class phpCAS.
Definition: CAS.php:276
Xml importer class.