ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilExerciseExporter.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2012 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
11 {
12  private $ds;
13 
17  public function init()
18  {
19  $this->ds = new ilExerciseDataSet();
20  $this->ds->setExportDirectories($this->dir_relative, $this->dir_absolute);
21  $this->ds->setDSPrefix("ds");
22  }
23 
32  public function getXmlRepresentation($a_entity, $a_schema_version, $a_id)
33  {
34  $this->ds->setExportDirectories($this->dir_relative, $this->dir_absolute);
35  return $this->ds->getXmlRepresentation($a_entity, $a_schema_version, $a_id, "", true, true);
36  }
37 
45  public function getValidSchemaVersions($a_entity)
46  {
47  return array(
48  "4.1.0" => array(
49  "namespace" => "http://www.ilias.de/Modules/Exercise/exc/4_1",
50  "xsd_file" => "ilias_exc_4_1.xsd",
51  "uses_dataset" => true,
52  "min" => "4.1.0",
53  "max" => "4.3.99"),
54  "4.4.0" => array(
55  "namespace" => "http://www.ilias.de/Modules/Exercise/exc/4_4",
56  "xsd_file" => "ilias_exc_4_4.xsd",
57  "uses_dataset" => true,
58  "min" => "4.4.0",
59  "max" => "4.4.99"),
60  "5.0.0" => array(
61  "namespace" => "http://www.ilias.de/Modules/Exercise/exc/5_0",
62  "xsd_file" => "ilias_exc_5_0.xsd",
63  "uses_dataset" => true,
64  "min" => "5.0.0",
65  "max" => "5.0.99"),
66  "5.1.0" => array(
67  "namespace" => "http://www.ilias.de/Modules/Exercise/exc/5_1",
68  "xsd_file" => "ilias_exc_5_1.xsd",
69  "uses_dataset" => true,
70  "min" => "5.1.0",
71  "max" => "5.1.99"),
72  "5.2.0" => array(
73  "namespace" => "http://www.ilias.de/Modules/Exercise/exc/5_2",
74  "xsd_file" => "ilias_exc_5_2.xsd",
75  "uses_dataset" => true,
76  "min" => "5.2.0",
77  "max" => "5.2.99"),
78  "5.3.0" => array(
79  "namespace" => "http://www.ilias.de/Modules/Exercise/exc/5_3",
80  "xsd_file" => "ilias_exc_5_3.xsd",
81  "uses_dataset" => true,
82  "min" => "5.3.0",
83  "max" => "")
84  );
85  }
86 
87  public function getXmlExportTailDependencies($a_entity, $a_target_release, $a_ids)
88  {
89  $deps = [];
90 
91  if ($a_entity == "exc") {
92  // service settings
93  $deps[] = array(
94  "component" => "Services/Object",
95  "entity" => "common",
96  "ids" => $a_ids
97  );
98 
99  $advmd_ids = array();
100  foreach ($a_ids as $id) {
101  $rec_ids = $this->getActiveAdvMDRecords($id);
102  if (sizeof($rec_ids)) {
103  foreach ($rec_ids as $rec_id) {
104  $advmd_ids[] = $id . ":" . $rec_id;
105  }
106  }
107  }
108 
109  if (sizeof($advmd_ids)) {
110  $deps[] = array(
111  "component" => "Services/AdvancedMetaData",
112  "entity" => "advmd",
113  "ids" => $advmd_ids
114  );
115  }
116 
117  $md_ids = array();
118  foreach ($a_ids as $exc_id) {
119  $md_ids[] = $exc_id . ":0:exc";
120  }
121  if ($md_ids) {
122  $deps[] =
123  array(
124  "component" => "Services/MetaData",
125  "entity" => "md",
126  "ids" => $md_ids
127  );
128  }
129 
130  // service settings
131  $deps[] = array(
132  "component" => "Services/Object",
133  "entity" => "service_settings",
134  "ids" => $a_ids
135  );
136  }
137 
138  return $deps;
139  }
140 
141  protected function getActiveAdvMDRecords($a_id)
142  {
143  $active = array();
144 
145  foreach (ilAdvancedMDRecord::_getActivatedRecordsByObjectType("exc") as $record_obj) {
146  foreach ($record_obj->getAssignedObjectTypes() as $obj_info) {
147  if ($obj_info['obj_type'] == 'exc' && $obj_info['optional'] == 0) {
148  $active[] = $record_obj->getRecordId();
149  }
150  // local activation
151  if (
152  $obj_info['obj_type'] == 'exc' &&
153  $obj_info['optional'] == 1 &&
154  $a_id == $record_obj->getParentObject()
155  ) {
156  $active[] = $record_obj->getRecordId();
157  }
158  }
159  }
160 
161  return $active;
162  }
163 }
Xml Exporter class.
getXmlRepresentation($a_entity, $a_schema_version, $a_id)
Get xml representation.
Exercise data set class.
static _getActivatedRecordsByObjectType($a_obj_type, $a_sub_type="", $a_only_optional=false)
Get activated records by object type.
Exporter class for exercise.
getXmlExportTailDependencies($a_entity, $a_target_release, $a_ids)
getValidSchemaVersions($a_entity)
Returns schema versions that the component can export to.