ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilTestExporter Class Reference

Used for container export with tests. More...

+ Inheritance diagram for ilTestExporter:
+ Collaboration diagram for ilTestExporter:

Public Member Functions

 __construct ()
 
 init ()
 Initialisation. More...
 
 getXmlRepresentation (string $a_entity, string $a_schema_version, string $id)
 
 getXmlExportHeadDependencies (string $entity, string $target_release, array $ids)
 Get head dependencies. More...
 
 getXmlExportTailDependencies (string $a_entity, string $a_target_release, array $a_ids)
 
 getValidSchemaVersions (string $a_entity)
 Returns schema versions that the component can export to. More...
 
- Public Member Functions inherited from ilXmlExporter
 __construct ()
 
 setExport (ilExport $a_exp)
 
 getExport ()
 
 getXmlRepresentation (string $a_entity, string $a_schema_version, string $a_id)
 
 init ()
 
 setExportDirectories (string $a_dir_relative, string $a_dir_absolute)
 
 getRelativeExportDirectory ()
 
 getAbsoluteExportDirectory ()
 
 getXmlExportHeadDependencies (string $a_entity, string $a_target_release, array $a_ids)
 Get head dependencies. More...
 
 getXmlExportTailDependencies (string $a_entity, string $a_target_release, array $a_ids)
 Get tail dependencies. More...
 
 getValidSchemaVersions (string $a_entity)
 Returns schema versions that the component can export to. More...
 
 determineSchemaVersion (string $a_entity, string $a_target_release)
 

Private Member Functions

 getDependingTaxonomyIds (array $test_obj_ids)
 

Private Attributes

readonly ilLanguage $lng
 
readonly ExportImportFactory $export_factory
 
readonly TestLogger $logger
 
readonly ilTree $tree
 
readonly ilCtrl $ctrl
 
readonly ilComponentRepository $component_repository
 
readonly GeneralQuestionPropertiesRepository $questionrepository
 

Additional Inherited Members

- Static Public Member Functions inherited from ilXmlExporter
static lookupExportDirectory (string $a_obj_type, int $a_obj_id, string $a_export_type='xml', string $a_entity="")
 
- Protected Attributes inherited from ilXmlExporter
ilExport $exp
 

Detailed Description

Used for container export with tests.

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
$Id$ \

Definition at line 34 of file class.ilTestExporter.php.

Constructor & Destructor Documentation

◆ __construct()

ilTestExporter::__construct ( )

Reimplemented from ilXmlExporter.

Definition at line 44 of file class.ilTestExporter.php.

45 {
46 global $DIC;
47 $this->lng = $DIC['lng'];
48 $local_dic = TestDIC::dic();
49 $this->export_factory = $local_dic['exportimport.factory'];
50 $this->logger = $local_dic['logging.logger'];
51 $this->questionrepository = $local_dic['question.general_properties.repository'];
52 $this->tree = $DIC['tree'];
53 $this->ctrl = $DIC['ilCtrl'];
54 $this->component_repository = $DIC['component.repository'];
55
57 }
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26

References $DIC, ILIAS\GlobalScreen\Provider\__construct(), ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), and ILIAS\Repository\logger().

+ Here is the call graph for this function:

Member Function Documentation

◆ getDependingTaxonomyIds()

ilTestExporter::getDependingTaxonomyIds ( array  $test_obj_ids)
private
Parameters
array<int>$testObjIds
Returns
array<int> $taxIds

Definition at line 171 of file class.ilTestExporter.php.

171 : array
172 {
173 $tax_ids = [];
174
175 foreach ($test_obj_ids as $test_obj_id) {
176 foreach (ilObjTaxonomy::getUsageOfObject($test_obj_id) as $tax_id) {
177 $tax_ids[$tax_id] = $tax_id;
178 }
179 }
180
181 return $tax_ids;
182 }
static getUsageOfObject(int $a_obj_id, bool $a_include_titles=false)

References ilObjTaxonomy\getUsageOfObject().

Referenced by getXmlExportTailDependencies().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getValidSchemaVersions()

ilTestExporter::getValidSchemaVersions ( string  $a_entity)

Returns schema versions that the component can export to.

ILIAS chooses the first one, that has min/max constraints which fit to the target release. Please put the newest on top.

Parameters
string$a_entity
Returns
array

Reimplemented from ilXmlExporter.

Definition at line 191 of file class.ilTestExporter.php.

191 : array
192 {
193 return [
194 '4.1.0' => [
195 'namespace' => 'http://www.ilias.de/Modules/Test/htlm/4_1',
196 'xsd_file' => 'ilias_tst_4_1.xsd',
197 'uses_dataset' => false,
198 'min' => '4.1.0',
199 'max' => ''
200 ]
201 ];
202 }

◆ getXmlExportHeadDependencies()

ilTestExporter::getXmlExportHeadDependencies ( string  $a_entity,
string  $a_target_release,
array  $a_ids 
)

Get head dependencies.

Returns
array array of array with keys "component", entity", "ids"

Reimplemented from ilXmlExporter.

Definition at line 84 of file class.ilTestExporter.php.

84 : array
85 {
86 if ($entity === 'tst') {
87 $mobs = [];
88 $files = [];
89 foreach ($ids as $id) {
90 $tst = new ilObjTest((int) $id, false);
91 $tst->read();
92
93 $intro_page_id = $tst->getMainSettings()->getIntroductionSettings()->getIntroductionPageId();
94 if ($intro_page_id !== null) {
95 $mobs = array_merge($mobs, ilObjMediaObject::_getMobsOfObject('tst:pg', $intro_page_id));
96 $files = array_merge($files, ilObjFile::_getFilesOfObject('tst:pg', $intro_page_id));
97 }
98
99 $concluding_remarks_page_id = $tst->getMainSettings()->getFinishingSettings()->getConcludingRemarksPageId();
100 if ($concluding_remarks_page_id !== null) {
101 $mobs = array_merge($mobs, ilObjMediaObject::_getMobsOfObject('tst:pg', $concluding_remarks_page_id));
102 $files = array_merge($files, ilObjFile::_getFilesOfObject('tst:pg', $concluding_remarks_page_id));
103 }
104 }
105
106 return [
107 [
108 'component' => 'components/ILIAS/MediaObjects',
109 'entity' => 'mob',
110 'ids' => $mobs
111 ],
112 [
113 'component' => 'components/ILIAS/File',
114 'entity' => 'file',
115 'ids' => $files
116 ]
117 ];
118 }
119
120 return parent::getXmlExportTailDependencies($entity, $target_release, $ids);
121 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
static _getMobsOfObject(string $a_type, int $a_id, int $a_usage_hist_nr=0, string $a_lang="-")

References $id, and ilObjMediaObject\_getMobsOfObject().

+ Here is the call graph for this function:

◆ getXmlExportTailDependencies()

ilTestExporter::getXmlExportTailDependencies ( string  $a_entity,
string  $a_target_release,
array  $a_ids 
)
Parameters
array<int>ids
Returns
array<array> array of array with keys 'component', 'entity', 'ids'

Reimplemented from ilXmlExporter.

Definition at line 127 of file class.ilTestExporter.php.

127 : array
128 {
129 if ($a_entity == 'tst') {
130 $deps = [];
131
132 $tax_ids = $this->getDependingTaxonomyIds($a_ids);
133
134 if (count($tax_ids)) {
135 $deps[] = [
136 'component' => 'components/ILIAS/Taxonomy',
137 'entity' => 'tax',
138 'ids' => $tax_ids
139 ];
140 }
141
142 $deps[] = [
143 'component' => 'components/ILIAS/ILIASObject',
144 'entity' => 'common',
145 'ids' => $a_ids
146 ];
147
148
149 $md_ids = [];
150 foreach ($a_ids as $id) {
151 $md_ids[] = $id . ':0:tst';
152 }
153 if ($md_ids !== []) {
154 $deps[] = [
155 'component' => 'components/ILIAS/MetaData',
156 'entity' => 'md',
157 'ids' => $md_ids
158 ];
159 }
160
161 return $deps;
162 }
163
164 return parent::getXmlExportTailDependencies($a_entity, $a_target_release, $a_ids);
165 }
getDependingTaxonomyIds(array $test_obj_ids)

References $id, and getDependingTaxonomyIds().

+ Here is the call graph for this function:

◆ getXmlRepresentation()

ilTestExporter::getXmlRepresentation ( string  $a_entity,
string  $a_schema_version,
string  $id 
)

Reimplemented from ilXmlExporter.

Definition at line 66 of file class.ilTestExporter.php.

66 : string
67 {
68 $parameters = $this->ctrl->getParameterArrayByClass(ilTestExportGUI::class);
69 $export_type = ExportImportTypes::XML;
70 if (!empty($parameters['export_results'])) {
71 $export_type = ExportImportTypes::XML_WITH_RESULTS;
72 $this->ctrl->clearParameterByClass(ilTestExportGUI::class, 'export_results');
73 }
74 $tst = new ilObjTest((int) $id, false);
75 $tst->read();
76 $zip = $this->export_factory->getExporter($tst, $export_type)
77 ->withExportDirInfo($this->getAbsoluteExportDirectory())
78 ->write();
79
80 $this->logger->info(__METHOD__ . ': Created zip file ' . $zip);
81 return '';
82 }

References $id, ILIAS\Repository\ctrl(), ilXmlExporter\getAbsoluteExportDirectory(), and ILIAS\Repository\logger().

+ Here is the call graph for this function:

◆ init()

ilTestExporter::init ( )

Initialisation.

Reimplemented from ilXmlExporter.

Definition at line 62 of file class.ilTestExporter.php.

62 : void
63 {
64 }

Field Documentation

◆ $component_repository

readonly ilComponentRepository ilTestExporter::$component_repository
private

Definition at line 41 of file class.ilTestExporter.php.

◆ $ctrl

readonly ilCtrl ilTestExporter::$ctrl
private

Definition at line 40 of file class.ilTestExporter.php.

◆ $export_factory

readonly ExportImportFactory ilTestExporter::$export_factory
private

Definition at line 37 of file class.ilTestExporter.php.

◆ $lng

readonly ilLanguage ilTestExporter::$lng
private

Definition at line 36 of file class.ilTestExporter.php.

◆ $logger

readonly TestLogger ilTestExporter::$logger
private

Definition at line 38 of file class.ilTestExporter.php.

◆ $questionrepository

readonly GeneralQuestionPropertiesRepository ilTestExporter::$questionrepository
private

Definition at line 42 of file class.ilTestExporter.php.

◆ $tree

readonly ilTree ilTestExporter::$tree
private

Definition at line 39 of file class.ilTestExporter.php.


The documentation for this class was generated from the following file: