ILIAS  release_8 Revision v8.19-1-g4e8f2f9140c
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilLOXmlWriter.php
Go to the documentation of this file.
1 <?php
2 
3 declare(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;
35  protected ilSetting $setting;
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
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 }
array $settings
Setting values (LTI parameters, custom parameters and local parameters).
Definition: System.php:200
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _getObjectiveIds(int $course_id, bool $a_activated_only=false)
__construct(int $a_ref_id)
Constructor.
write()
Write xml.
global $DIC
Definition: feed.php:28
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...
static _lookupObjectId(int $ref_id)
static getInstanceByObjId(int $a_obj_id)
$factory
Definition: metadata.php:75