ILIAS  release_8 Revision v8.24
class.ilTestSkillLevelThresholdXmlParser.php
Go to the documentation of this file.
1<?php
2
26{
27 protected bool $parsingActive = false;
28
29 protected ?string $characterDataBuffer = null;
30
32
33 protected ?int $curSkillBaseId = null;
34
35 protected ?int $curSkillTrefId = null;
36
38
39 public function isParsingActive(): bool
40 {
42 }
43
44 public function setParsingActive(bool $parsingActive): void
45 {
46 $this->parsingActive = $parsingActive;
47 }
48
49 protected function getCharacterDataBuffer(): ?string
50 {
52 }
53
57 protected function resetCharacterDataBuffer(): void
58 {
59 $this->characterDataBuffer = '';
60 }
61
62 protected function appendToCharacterDataBuffer(string $characterData): void
63 {
64 $this->characterDataBuffer .= $characterData;
65 }
66
68 {
70 }
71
74 public function initSkillLevelThresholdImportList(): void
75 {
76 global $DIC;
77 $ilDB = $DIC['ilDB'];
78 $this->skillLevelThresholdImportList = new ilTestSkillLevelThresholdImportList($ilDB);
79 }
80
81 public function getCurSkillBaseId(): ?int
82 {
84 }
85
86 public function setCurSkillBaseId(?int $curSkillBaseId): void
87 {
88 $this->curSkillBaseId = $curSkillBaseId;
89 }
90
91 public function getCurSkillTrefId(): ?int
92 {
94 }
95
96 public function setCurSkillTrefId(?int $curSkillTrefId): void
97 {
98 $this->curSkillTrefId = $curSkillTrefId;
99 }
100
102 {
104 }
105
107 {
108 $this->curSkillLevelThreshold = $curSkillLevelThreshold;
109 }
110
111 public function setHandlers($a_xml_parser): void
112 {
113 xml_set_object($a_xml_parser, $this);
114 xml_set_element_handler($a_xml_parser, 'handlerBeginTag', 'handlerEndTag');
115 xml_set_character_data_handler($a_xml_parser, 'handlerCharacterData');
116 }
117
118 public function handlerBeginTag($xmlParser, $tagName, $tagAttributes): void
119 {
120 if ($tagName != 'SkillsLevelThresholds' && !$this->isParsingActive()) {
121 return;
122 }
123
124 switch ($tagName) {
125 case 'SkillsLevelThresholds':
126 $this->setParsingActive(true);
128 break;
129
130 case 'QuestionsAssignedSkill':
131 $this->setCurSkillBaseId($tagAttributes['BaseId']);
132 $this->setCurSkillTrefId($tagAttributes['TrefId']);
133 break;
134
135 case 'OriginalLevelDescription':
136 case 'OriginalLevelTitle':
137 case 'ThresholdPercentage':
138 case 'OriginalSkillPath':
139 case 'OriginalSkillTitle':
141 break;
142
143 case 'SkillLevel':
144 global $DIC;
145 $ilDB = $DIC['ilDB'];
146 $skillLevelThreshold = new ilTestSkillLevelThresholdImport($ilDB);
147 $skillLevelThreshold->setImportSkillBaseId($this->getCurSkillBaseId());
148 $skillLevelThreshold->setImportSkillTrefId($this->getCurSkillTrefId());
149 $skillLevelThreshold->setImportLevelId($tagAttributes['Id']);
150 $skillLevelThreshold->setOrderIndex($tagAttributes['Nr']);
151 $this->setCurSkillLevelThreshold($skillLevelThreshold);
152 break;
153
154 }
155 }
156
157 public function handlerEndTag($xmlParser, $tagName): void
158 {
159 if (!$this->isParsingActive()) {
160 return;
161 }
162
163 switch ($tagName) {
164 case 'SkillsLevelThresholds':
165 $this->setParsingActive(false);
166 break;
167
168 case 'QuestionsAssignedSkill':
169 $this->setCurSkillBaseId(null);
170 $this->setCurSkillTrefId(null);
171 break;
172
173 case 'OriginalSkillTitle':
174 $this->getSkillLevelThresholdImportList()->addOriginalSkillTitle(
175 $this->getCurSkillBaseId(),
176 $this->getCurSkillTrefId(),
178 );
180 break;
181
182 case 'OriginalSkillPath':
183 $this->getSkillLevelThresholdImportList()->addOriginalSkillPath(
184 $this->getCurSkillBaseId(),
185 $this->getCurSkillTrefId(),
187 );
189 break;
190
191 case 'SkillLevel':
192 $this->getSkillLevelThresholdImportList()->addSkillLevelThreshold(
194 );
195 $this->setCurSkillLevelThreshold(null);
196 break;
197
198 case 'ThresholdPercentage':
199 $this->getCurSkillLevelThreshold()->setThreshold($this->getCharacterDataBuffer());
201 break;
202
203 case 'OriginalLevelTitle':
204 $this->getCurSkillLevelThreshold()->setOriginalLevelTitle($this->getCharacterDataBuffer());
206 break;
207
208 case 'OriginalLevelDescription':
209 $this->getCurSkillLevelThreshold()->setOriginalLevelDescription($this->getCharacterDataBuffer());
211 break;
212 }
213 }
214
215 public function handlerCharacterData($xmlParser, $charData): void
216 {
217 if (!$this->isParsingActive()) {
218 return;
219 }
220
221 if ($charData != "\n") {
222 // Replace multiple tabs with one space
223 $charData = preg_replace("/\t+/", " ", $charData);
224
225 $this->appendToCharacterDataBuffer($charData);
226 }
227 }
228}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ilTestSkillLevelThresholdImportList $skillLevelThresholdImportList
setCurSkillLevelThreshold(?ilTestSkillLevelThresholdImport $curSkillLevelThreshold)
global $DIC
Definition: feed.php:28