ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilTestSkillLevelThresholdXmlParser.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4require_once 'Modules/Test/classes/class.ilTestSkillLevelThresholdImport.php';
5require_once 'Modules/Test/classes/class.ilTestSkillLevelThresholdImportList.php';
6
14{
18 protected $parsingActive = false;
19
23 protected $characterDataBuffer = null;
24
29
33 protected $curSkillBaseId = null;
34
38 protected $curSkillTrefId = null;
39
43 protected $curSkillLevelThreshold = null;
44
48 public function isParsingActive()
49 {
51 }
52
57 {
58 $this->parsingActive = $parsingActive;
59 }
60
64 protected function getCharacterDataBuffer()
65 {
67 }
68
72 protected function resetCharacterDataBuffer()
73 {
74 $this->characterDataBuffer = '';
75 }
76
80 protected function appendToCharacterDataBuffer($characterData)
81 {
82 $this->characterDataBuffer .= $characterData;
83 }
84
89 {
91 }
92
96 {
97 global $DIC;
98 $ilDB = $DIC['ilDB'];
99 $this->skillLevelThresholdImportList = new ilTestSkillLevelThresholdImportList($ilDB);
100 }
101
105 public function getCurSkillBaseId()
106 {
108 }
109
114 {
115 $this->curSkillBaseId = $curSkillBaseId;
116 }
117
121 public function getCurSkillTrefId()
122 {
124 }
125
130 {
131 $this->curSkillTrefId = $curSkillTrefId;
132 }
133
138 {
140 }
141
146 {
147 $this->curSkillLevelThreshold = $curSkillLevelThreshold;
148 }
149
150 public function setHandlers($xmlParser)
151 {
152 xml_set_object($xmlParser, $this);
153 xml_set_element_handler($xmlParser, 'handlerBeginTag', 'handlerEndTag');
154 xml_set_character_data_handler($xmlParser, 'handlerCharacterData');
155 }
156
157 public function handlerBeginTag($xmlParser, $tagName, $tagAttributes)
158 {
159 if ($tagName != 'SkillsLevelThresholds' && !$this->isParsingActive()) {
160 return;
161 }
162
163 switch ($tagName) {
164 case 'SkillsLevelThresholds':
165 $this->setParsingActive(true);
167 break;
168
169 case 'QuestionsAssignedSkill':
170 $this->setCurSkillBaseId($tagAttributes['BaseId']);
171 $this->setCurSkillTrefId($tagAttributes['TrefId']);
172 break;
173
174 case 'OriginalSkillTitle':
176 break;
177
178 case 'OriginalSkillPath':
180 break;
181
182 case 'SkillLevel':
183 global $DIC;
184 $ilDB = $DIC['ilDB'];
185 $skillLevelThreshold = new ilTestSkillLevelThresholdImport($ilDB);
186 $skillLevelThreshold->setImportSkillBaseId($this->getCurSkillBaseId());
187 $skillLevelThreshold->setImportSkillTrefId($this->getCurSkillTrefId());
188 $skillLevelThreshold->setImportLevelId($tagAttributes['Id']);
189 $skillLevelThreshold->setOrderIndex($tagAttributes['Nr']);
190 $this->setCurSkillLevelThreshold($skillLevelThreshold);
191 break;
192
193 case 'ThresholdPercentage':
195 break;
196
197 case 'OriginalLevelTitle':
199 break;
200
201 case 'OriginalLevelDescription':
203 break;
204 }
205 }
206
207 public function handlerEndTag($xmlParser, $tagName)
208 {
209 if (!$this->isParsingActive()) {
210 return;
211 }
212
213 switch ($tagName) {
214 case 'SkillsLevelThresholds':
215 $this->setParsingActive(false);
216 break;
217
218 case 'QuestionsAssignedSkill':
219 $this->setCurSkillBaseId(null);
220 $this->setCurSkillTrefId(null);
221 break;
222
223 case 'OriginalSkillTitle':
224 $this->getSkillLevelThresholdImportList()->addOriginalSkillTitle(
225 $this->getCurSkillBaseId(),
226 $this->getCurSkillTrefId(),
228 );
230 break;
231
232 case 'OriginalSkillPath':
233 $this->getSkillLevelThresholdImportList()->addOriginalSkillPath(
234 $this->getCurSkillBaseId(),
235 $this->getCurSkillTrefId(),
237 );
239 break;
240
241 case 'SkillLevel':
242 $this->getSkillLevelThresholdImportList()->addSkillLevelThreshold(
244 );
245 $this->setCurSkillLevelThreshold(null);
246 break;
247
248 case 'ThresholdPercentage':
249 $this->getCurSkillLevelThreshold()->setThreshold($this->getCharacterDataBuffer());
251 break;
252
253 case 'OriginalLevelTitle':
254 $this->getCurSkillLevelThreshold()->setOriginalLevelTitle($this->getCharacterDataBuffer());
256 break;
257
258 case 'OriginalLevelDescription':
259 $this->getCurSkillLevelThreshold()->setOriginalLevelDescription($this->getCharacterDataBuffer());
261 break;
262 }
263 }
264
265 public function handlerCharacterData($xmlParser, $charData)
266 {
267 if (!$this->isParsingActive()) {
268 return;
269 }
270
271 if ($charData != "\n") {
272 // Replace multiple tabs with one space
273 $charData = preg_replace("/\t+/", " ", $charData);
274
275 $this->appendToCharacterDataBuffer($charData);
276 }
277 }
278}
An exception for terminatinating execution or to throw for unit testing.
Base class for sax-based expat parsing extended classes need to overwrite the method setHandlers and ...
setHandlers($xmlParser)
set event handler should be overwritten by inherited class @access private
global $DIC
Definition: goto.php:24
global $ilDB