ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 $ilDB;
98 $this->skillLevelThresholdImportList = new ilTestSkillLevelThresholdImportList($ilDB);
99 }
100
104 public function getCurSkillBaseId()
105 {
107 }
108
113 {
114 $this->curSkillBaseId = $curSkillBaseId;
115 }
116
120 public function getCurSkillTrefId()
121 {
123 }
124
129 {
130 $this->curSkillTrefId = $curSkillTrefId;
131 }
132
137 {
139 }
140
145 {
146 $this->curSkillLevelThreshold = $curSkillLevelThreshold;
147 }
148
149 public function setHandlers($xmlParser)
150 {
151 xml_set_object($xmlParser, $this);
152 xml_set_element_handler($xmlParser, 'handlerBeginTag', 'handlerEndTag');
153 xml_set_character_data_handler($xmlParser, 'handlerCharacterData');
154 }
155
156 public function handlerBeginTag($xmlParser, $tagName, $tagAttributes)
157 {
158 if ($tagName != 'SkillsLevelThresholds' && !$this->isParsingActive()) {
159 return;
160 }
161
162 switch ($tagName) {
163 case 'SkillsLevelThresholds':
164 $this->setParsingActive(true);
166 break;
167
168 case 'QuestionsAssignedSkill':
169 $this->setCurSkillBaseId($tagAttributes['BaseId']);
170 $this->setCurSkillTrefId($tagAttributes['TrefId']);
171 break;
172
173 case 'OriginalSkillTitle':
175 break;
176
177 case 'OriginalSkillPath':
179 break;
180
181 case 'SkillLevel':
182 global $ilDB;
183 $skillLevelThreshold = new ilTestSkillLevelThresholdImport($ilDB);
184 $skillLevelThreshold->setImportSkillBaseId($this->getCurSkillBaseId());
185 $skillLevelThreshold->setImportSkillTrefId($this->getCurSkillTrefId());
186 $skillLevelThreshold->setImportLevelId($tagAttributes['Id']);
187 $skillLevelThreshold->setOrderIndex($tagAttributes['Nr']);
188 $this->setCurSkillLevelThreshold($skillLevelThreshold);
189 break;
190
191 case 'ThresholdPercentage':
193 break;
194
195 case 'OriginalLevelTitle':
197 break;
198
199 case 'OriginalLevelDescription':
201 break;
202 }
203 }
204
205 public function handlerEndTag($xmlParser, $tagName)
206 {
207 if (!$this->isParsingActive()) {
208 return;
209 }
210
211 switch ($tagName) {
212 case 'SkillsLevelThresholds':
213 $this->setParsingActive(false);
214 break;
215
216 case 'QuestionsAssignedSkill':
217 $this->setCurSkillBaseId(null);
218 $this->setCurSkillTrefId(null);
219 break;
220
221 case 'OriginalSkillTitle':
222 $this->getSkillLevelThresholdImportList()->addOriginalSkillTitle(
223 $this->getCurSkillBaseId(),
224 $this->getCurSkillTrefId(),
226 );
228 break;
229
230 case 'OriginalSkillPath':
231 $this->getSkillLevelThresholdImportList()->addOriginalSkillPath(
232 $this->getCurSkillBaseId(),
233 $this->getCurSkillTrefId(),
235 );
237 break;
238
239 case 'SkillLevel':
240 $this->getSkillLevelThresholdImportList()->addSkillLevelThreshold(
242 );
243 $this->setCurSkillLevelThreshold(null);
244 break;
245
246 case 'ThresholdPercentage':
247 $this->getCurSkillLevelThreshold()->setThreshold($this->getCharacterDataBuffer());
249 break;
250
251 case 'OriginalLevelTitle':
252 $this->getCurSkillLevelThreshold()->setOriginalLevelTitle($this->getCharacterDataBuffer());
254 break;
255
256 case 'OriginalLevelDescription':
257 $this->getCurSkillLevelThreshold()->setOriginalLevelDescription($this->getCharacterDataBuffer());
259 break;
260 }
261 }
262
263 public function handlerCharacterData($xmlParser, $charData)
264 {
265 if (!$this->isParsingActive()) {
266 return;
267 }
268
269 if ($charData != "\n") {
270 // Replace multiple tabs with one space
271 $charData = preg_replace("/\t+/", " ", $charData);
272
273 $this->appendToCharacterDataBuffer($charData);
274 }
275 }
276}
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 $ilDB