ILIAS  release_8 Revision v8.24
class.ilCourseExporter.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=0);
26{
27 public const ENTITY_OBJECTIVE = 'objectives';
28 public const ENTITY_MAIN = 'crs';
29
31 protected ilLogger $logger;
32
33 public function __construct()
34 {
35 global $DIC;
36 $this->logger = $DIC->logger()->crs();
37 }
38
39 public function init(): void
40 {
41 }
42
46 public function getXmlExportHeadDependencies(string $a_entity, string $a_target_release, array $a_ids): array
47 {
48 if ($a_entity != self::ENTITY_MAIN) {
49 return array();
50 }
51
52 // always trigger container because of co-page(s)
53 return array(
54 array(
55 'component' => 'Services/Container',
56 'entity' => 'struct',
57 'ids' => $a_ids
58 )
59 );
60 }
61
62 public function getXmlExportTailDependencies(string $a_entity, string $a_target_release, array $a_ids): array
63 {
64 $dependencies = array();
65 if ($a_entity == self::ENTITY_MAIN) {
66 $obj_id = 0;
67 foreach ($a_ids as $id) {
68 $obj_id = $id;
69 }
70
71 $dependencies[] = array(
72 'component' => 'Modules/Course',
73 'entity' => self::ENTITY_OBJECTIVE,
74 'ids' => $obj_id
75 );
76
77 $page_ids = array();
78 foreach (ilCourseObjective::_getObjectiveIds($obj_id) as $objective_id) {
79 foreach (ilLOPage::getAllPages('lobj', $objective_id) as $page_id) {
80 $page_ids[] = ('lobj:' . $page_id['id']);
81 }
82 }
83
84 if ($page_ids !== []) {
85 $dependencies[] = array(
86 'component' => 'Services/COPage',
87 'entity' => 'pg',
88 'ids' => $page_ids
89 );
90 }
91 }
92 return $dependencies;
93 }
94
95 public function getXmlRepresentation(string $a_entity, string $a_schema_version, string $a_id): string
96 {
97 $refs = ilObject::_getAllReferences((int) $a_id);
98 $course_ref_id = end($refs);
99 $course = ilObjectFactory::getInstanceByRefId($course_ref_id, false);
100
101 // begin-patch optes_lok_export
102 if ($a_entity == self::ENTITY_OBJECTIVE) {
103 try {
104 $writer = new ilLOXmlWriter($course_ref_id);
105 $writer->write();
106 return $writer->getXml();
107 } catch (Exception $ex) {
108 $this->logger->error('Export failed with message: ' . $ex->getMessage());
109 // and throw
110 throw $ex;
111 }
112 }
113 // end-patch optes_lok_export
114
115 if (!$course instanceof ilObjCourse) {
116 $this->logger->warning($a_id . ' is not id of course instance.');
117 return '';
118 }
119
120 $this->writer = new ilCourseXMLWriter($course);
121 $this->writer->setMode(ilCourseXMLWriter::MODE_EXPORT);
122 $this->writer->start();
123 return $this->writer->xmlDumpMem(false);
124 }
125
126 public function getValidSchemaVersions(string $a_entity): array
127 {
128 return array(
129 "4.1.0" => array(
130 "namespace" => "http://www.ilias.de/Modules/Course/crs/4_1",
131 "xsd_file" => "ilias_course_4_1.xsd",
132 "uses_dataset" => false,
133 "min" => "4.1.0",
134 "max" => "4.4.999"
135 ),
136 "5.0.0" => array(
137 "namespace" => "http://www.ilias.de/Modules/Course/crs/5_0",
138 "xsd_file" => "ilias_crs_5_0.xsd",
139 "uses_dataset" => false,
140 "min" => "5.0.0",
141 "max" => ""
142 )
143 );
144 }
145}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getValidSchemaVersions(string $a_entity)
Returns schema versions that the component can export to.
getXmlRepresentation(string $a_entity, string $a_schema_version, string $a_id)
getXmlExportTailDependencies(string $a_entity, string $a_target_release, array $a_ids)
Get tail dependencies.
getXmlExportHeadDependencies(string $a_entity, string $a_target_release, array $a_ids)
Get head dependencies.
static _getObjectiveIds(int $course_id, bool $a_activated_only=false)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Component logger with individual log levels by component id.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getInstanceByRefId(int $ref_id, bool $stop_on_error=true)
get an instance of an Ilias object by reference id
static _getAllReferences(int $id)
get all reference ids for object ID
static getAllPages(string $a_parent_type, int $a_parent_id, string $a_lang="-")
Get all pages for parent object.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: feed.php:28