ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilLOXmlWriter.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=0);
25{
26 public const TYPE_TST_PO = 1;
27 public const TYPE_TST_ALL = 2;
28 public const TYPE_TST_RND = 3;
29
30 private int $ref_id = 0;
31 private int $obj_id = 0;
33
34 private ilLogger $log;
36
40 public function __construct(int $a_ref_id)
41 {
42 global $DIC;
43
44 $this->ref_id = $a_ref_id;
45 $this->obj_id = ilObject::_lookupObjectId($a_ref_id);
46 $this->writer = new ilXmlWriter();
47 $this->setting = $DIC->settings();
48 $this->log = $DIC->logger()->crs();
49 }
50
51 protected function getWriter(): ilXmlWriter
52 {
53 return $this->writer;
54 }
55
59 public function write(): void
60 {
61 $this->getWriter()->xmlStartTag('Objectives');
62
63 // export settings
64 $settings = ilLOSettings::getInstanceByObjId($this->obj_id);
65 $settings->toXml($this->getWriter());
66
67 $factory = new ilObjectFactory();
68 $course = $factory->getInstanceByRefId($this->ref_id, false);
69 if (!$course instanceof ilObjCourse) {
70 $this->log->warning('Cannot create course instance for ref_id: ' . $this->ref_id);
71 return;
72 }
73 $this->log->debug('Writing objective xml');
74 foreach (ilCourseObjective::_getObjectiveIds($this->obj_id) as $objective_id) {
75 $this->log->debug('Handling objective_id: ' . $objective_id);
76 $objective = new ilCourseObjective($course, $objective_id);
77 $objective->toXml($this->getWriter());
78 }
79
80 $this->getWriter()->xmlEndTag('Objectives');
81 }
82
83 public function getXml(): string
84 {
85 return $this->getWriter()->xmlDumpMem(false);
86 }
87}
class ilcourseobjective
static _getObjectiveIds(int $course_id, bool $a_activated_only=false)
static getInstanceByObjId(int $a_obj_id)
Class ilLOXmlWriter.
__construct(int $a_ref_id)
Constructor.
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...
Class ilObjectFactory This class offers methods to get instances of the type-specific object classes ...
static _lookupObjectId(int $ref_id)
ILIAS Setting Class.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: shib_login.php:26