ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilTestQuestionPoolExporter.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 include_once("./Services/Export/classes/class.ilXmlExporter.php");
5 
14 {
15  private $ds;
16 
20  public function init()
21  {
22  }
23 
30  public static function lookupExportDirectory($a_obj_type, $a_obj_id, $a_export_type = 'xml', $a_entity = "")
31  {
32  if ($a_export_type == 'xml') {
33  return ilUtil::getDataDir() . "/qpl_data" . "/qpl_" . $a_obj_id . "/export_zip";
34  }
35  return ilUtil::getDataDir() . "/qpl_data" . "/qpl_" . $a_obj_id . "/export_" . $a_export_type;
36  }
37 
38 
47  public function getXmlRepresentation($a_entity, $a_schema_version, $a_id)
48  {
49  include_once './Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php';
50  $qpl = new ilObjQuestionPool($a_id, false);
51  $qpl->loadFromDb();
52 
53  include_once("./Modules/TestQuestionPool/classes/class.ilQuestionpoolExport.php");
54  $qpl_exp = new ilQuestionpoolExport($qpl, 'xml');
55  $zip = $qpl_exp->buildExportFile();
56 
57  global $DIC; /* @var ILIAS\DI\Container $DIC */
58  $DIC['ilLog']->write(__METHOD__ . ': Created zip file ' . $zip);
59  }
60 
69  public function getXmlExportTailDependencies($a_entity, $a_target_release, $a_ids)
70  {
71  if ($a_entity == 'qpl') {
72  $deps = array();
73 
74  $taxIds = $this->getDependingTaxonomyIds($a_ids);
75 
76  if (count($taxIds)) {
77  $deps[] = array(
78  'component' => 'Services/Taxonomy',
79  'entity' => 'tax',
80  'ids' => $taxIds
81  );
82  }
83 
84  return $deps;
85  }
86 
87  return parent::getXmlExportTailDependencies($a_entity, $a_target_release, $a_ids);
88  }
89 
94  private function getDependingTaxonomyIds($poolObjIds)
95  {
96  include_once 'Services/Taxonomy/classes/class.ilObjTaxonomy.php';
97 
98  $taxIds = array();
99 
100  foreach ($poolObjIds as $poolObjId) {
101  foreach (ilObjTaxonomy::getUsageOfObject($poolObjId) as $taxId) {
102  $taxIds[$taxId] = $taxId;
103  }
104  }
105 
106  return $taxIds;
107  }
108 
116  public function getValidSchemaVersions($a_entity)
117  {
118  return array(
119  "4.1.0" => array(
120  "namespace" => "http://www.ilias.de/Modules/TestQuestionPool/htlm/4_1",
121  "xsd_file" => "ilias_qpl_4_1.xsd",
122  "uses_dataset" => false,
123  "min" => "4.1.0",
124  "max" => "")
125  );
126  }
127 }
static getUsageOfObject($a_obj_id, $a_include_titles=false)
Get usage of object.
global $DIC
Definition: saml.php:7
Xml Exporter class.
Export class for questionpools.
getXmlExportTailDependencies($a_entity, $a_target_release, $a_ids)
Get tail dependencies.
static getDataDir()
get data directory (outside webspace)
static lookupExportDirectory($a_obj_type, $a_obj_id, $a_export_type='xml', $a_entity="")
Overwritten for qpl.
getValidSchemaVersions($a_entity)
Returns schema versions that the component can export to.
Used for container export with tests.
getXmlRepresentation($a_entity, $a_schema_version, $a_id)
Get xml representation.