ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilExerciseExporter.php
Go to the documentation of this file.
1<?php
2
25{
27
28 public function init(): void
29 {
30 $this->ds = new ilExerciseDataSet();
31 $this->ds->initByExporter($this);
32 $this->ds->setDSPrefix("ds");
33 }
34
42 public function getXmlRepresentation(string $a_entity, string $a_schema_version, string $a_id): string
43 {
44 $this->ds->initByExporter($this);
45 return $this->ds->getXmlRepresentation($a_entity, $a_schema_version, [$a_id], "", true, true);
46 }
47
53 public function getValidSchemaVersions(string $a_entity): array
54 {
55 return array(
56 "9.0" => array(
57 "namespace" => "https://www.ilias.de/Modules/Exercise/exc/9",
58 "xsd_file" => "ilias_exc_9.xsd",
59 "uses_dataset" => true,
60 "min" => "9.0",
61 "max" => "9.99"),
62 "4.1.0" => array(
63 "namespace" => "https://www.ilias.de/Modules/Exercise/exc/4_1",
64 "xsd_file" => "ilias_exc_4_1.xsd",
65 "uses_dataset" => true,
66 "min" => "4.1.0",
67 "max" => "4.3.99"),
68 "4.4.0" => array(
69 "namespace" => "https://www.ilias.de/Modules/Exercise/exc/4_4",
70 "xsd_file" => "ilias_exc_4_4.xsd",
71 "uses_dataset" => true,
72 "min" => "4.4.0",
73 "max" => "4.4.99"),
74 "5.0.0" => array(
75 "namespace" => "https://www.ilias.de/Modules/Exercise/exc/5_0",
76 "xsd_file" => "ilias_exc_5_0.xsd",
77 "uses_dataset" => true,
78 "min" => "5.0.0",
79 "max" => "5.0.99"),
80 "5.1.0" => array(
81 "namespace" => "https://www.ilias.de/Modules/Exercise/exc/5_1",
82 "xsd_file" => "ilias_exc_5_1.xsd",
83 "uses_dataset" => true,
84 "min" => "5.1.0",
85 "max" => "5.1.99"),
86 "5.2.0" => array(
87 "namespace" => "https://www.ilias.de/Modules/Exercise/exc/5_2",
88 "xsd_file" => "ilias_exc_5_2.xsd",
89 "uses_dataset" => true,
90 "min" => "5.2.0",
91 "max" => "5.2.99"),
92 "5.3.0" => array(
93 "namespace" => "https://www.ilias.de/Modules/Exercise/exc/5_3",
94 "xsd_file" => "ilias_exc_5_3.xsd",
95 "uses_dataset" => true,
96 "min" => "5.3.0",
97 "max" => "")
98 );
99 }
100
101 public function getXmlExportTailDependencies(string $a_entity, string $a_target_release, array $a_ids): array
102 {
103 $deps = [];
104
105 if ($a_entity == "exc") {
106 // service settings
107 $deps[] = array(
108 "component" => "components/ILIAS/ILIASObject",
109 "entity" => "common",
110 "ids" => $a_ids
111 );
112
113 $advmd_ids = array();
114 foreach ($a_ids as $id) {
115 $rec_ids = $this->getActiveAdvMDRecords($id);
116 foreach ($rec_ids as $rec_id) {
117 $advmd_ids[] = $id . ":" . $rec_id;
118 }
119 }
120
121 if ($advmd_ids !== []) {
122 $deps[] = array(
123 "component" => "components/ILIAS/AdvancedMetaData",
124 "entity" => "advmd",
125 "ids" => $advmd_ids
126 );
127 }
128
129 $md_ids = array();
130 foreach ($a_ids as $exc_id) {
131 $md_ids[] = $exc_id . ":0:exc";
132 }
133 if ($md_ids !== []) {
134 $deps[] =
135 array(
136 "component" => "components/ILIAS/MetaData",
137 "entity" => "md",
138 "ids" => $md_ids
139 );
140 }
141
142 // service settings
143 $deps[] = array(
144 "component" => "components/ILIAS/ILIASObject",
145 "entity" => "service_settings",
146 "ids" => $a_ids
147 );
148 }
149
150 return $deps;
151 }
152
156 protected function getActiveAdvMDRecords($a_id): array
157 {
158 $active = array();
159
160 foreach (ilAdvancedMDRecord::_getActivatedRecordsByObjectType("exc") as $record_obj) {
161 foreach ($record_obj->getAssignedObjectTypes() as $obj_info) {
162 if ($obj_info['obj_type'] == 'exc' && $obj_info['optional'] == 0) {
163 $active[] = $record_obj->getRecordId();
164 }
165 // local activation
166 if (
167 $obj_info['obj_type'] == 'exc' &&
168 $obj_info['optional'] == 1 &&
169 $a_id == $record_obj->getParentObject()
170 ) {
171 $active[] = $record_obj->getRecordId();
172 }
173 }
174 }
175
176 return $active;
177 }
178}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
static _getActivatedRecordsByObjectType(string $a_obj_type, string $a_sub_type="", bool $a_only_optional=false)
Get activated records by object type.
Exercise data set class.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getXmlExportTailDependencies(string $a_entity, string $a_target_release, array $a_ids)
Get tail dependencies.
getXmlRepresentation(string $a_entity, string $a_schema_version, string $a_id)
Get xml representation.
getValidSchemaVersions(string $a_entity)
Returns schema versions that the component can export to.
Xml Exporter class.