1<?php 2/* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */ 3 4include_once("./Services/Export/classes/class.ilXmlExporter.php"); 5 6/** 7 * Used for container export with tests 8 * 9 * @author Stefan Meyer <meyer@leifos.com> 10 * @version $Id$ 11 * @ingroup ModulesTest 12 */ 13class ilTestExporter extends ilXmlExporter 14{ 15 private $ds; 16 17 /** 18 * Initialisation 19 */ 20 public function init() 21 { 22 } 23 24 25 /** 26 * Get xml representation 27 * 28 * @param string entity 29 * @param string schema version 30 * @param string id 31 * @return string xml string 32 */ 33 public function getXmlRepresentation($a_entity, $a_schema_version, $a_id) 34 { 35 include_once './Modules/Test/classes/class.ilObjTest.php'; 36 $tst = new ilObjTest($a_id, false); 37 38 require_once 'Modules/Test/classes/class.ilTestExportFactory.php'; 39 $expFactory = new ilTestExportFactory($tst); 40 $testExport = $expFactory->getExporter('xml'); 41 $zip = $testExport->buildExportFile(); 42 43 global $DIC; /* @var ILIAS\DI\Container $DIC */ 44 $DIC['ilLog']->write(__METHOD__ . ': Created zip file ' . $zip); 45 } 46 47 /** 48 * Get tail dependencies 49 * 50 * @param string entity 51 * @param string target release 52 * @param array ids 53 * @return array array of array with keys "component", entity", "ids" 54 */ 55 public function getXmlExportTailDependencies($a_entity, $a_target_release, $a_ids) 56 { 57 if ($a_entity == 'tst') { 58 $deps = array(); 59 60 $taxIds = $this->getDependingTaxonomyIds($a_ids); 61 62 if (count($taxIds)) { 63 $deps[] = array( 64 'component' => 'Services/Taxonomy', 65 'entity' => 'tax', 66 'ids' => $taxIds 67 ); 68 } 69 70 // service settings 71 $deps[] = array( 72 "component" => "Services/Object", 73 "entity" => "common", 74 "ids" => $a_ids 75 ); 76 77 return $deps; 78 } 79 80 return parent::getXmlExportTailDependencies($a_entity, $a_target_release, $a_ids); 81 } 82 83 /** 84 * @param array $testObjIds 85 * @return array $taxIds 86 */ 87 private function getDependingTaxonomyIds($testObjIds) 88 { 89 include_once 'Services/Taxonomy/classes/class.ilObjTaxonomy.php'; 90 91 $taxIds = array(); 92 93 foreach ($testObjIds as $testObjId) { 94 foreach (ilObjTaxonomy::getUsageOfObject($testObjId) as $taxId) { 95 $taxIds[$taxId] = $taxId; 96 } 97 } 98 99 return $taxIds; 100 } 101 102 /** 103 * Returns schema versions that the component can export to. 104 * ILIAS chooses the first one, that has min/max constraints which 105 * fit to the target release. Please put the newest on top. 106 * 107 * @return 108 */ 109 public function getValidSchemaVersions($a_entity) 110 { 111 return array( 112 "4.1.0" => array( 113 "namespace" => "http://www.ilias.de/Modules/Test/htlm/4_1", 114 "xsd_file" => "ilias_tst_4_1.xsd", 115 "uses_dataset" => false, 116 "min" => "4.1.0", 117 "max" => "") 118 ); 119 } 120} 121