ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilObjTestXMLParser Class Reference
+ Inheritance diagram for ilObjTestXMLParser:
+ Collaboration diagram for ilObjTestXMLParser:

Public Member Functions

 getTestOBJ ()
 
 setTestOBJ ($testOBJ)
 
 getImportMapping ()
 
 setImportMapping ($importMapping)
 
 setHandlers ($xmlParser)
 set event handler should be overwritten by inherited class @access private More...
 
 handlerBeginTag ($xmlParser, $tagName, $tagAttributes)
 
 handlerEndTag ($xmlParser, $tagName)
 
 handlerCharacterData ($xmlParser, $charData)
 
- Public Member Functions inherited from ilSaxParser
 __construct ($a_xml_file='', $throwException=false)
 Constructor setup ILIAS global object @access public. More...
 
 setXMLContent ($a_xml_content)
 
 getXMLContent ()
 
 getInputType ()
 
 startParsing ()
 stores xml data in array More...
 
 createParser ()
 create parser More...
 
 setOptions ($a_xml_parser)
 set parser options More...
 
 setHandlers ($a_xml_parser)
 set event handler should be overwritten by inherited class @access private More...
 
 openXMLFile ()
 open xml file More...
 
 parse ($a_xml_parser, $a_fp=null)
 parse xml file More...
 
 freeParser ($a_xml_parser)
 free xml parser handle More...
 
 setThrowException ($throwException)
 set error handling More...
 
- Public Member Functions inherited from PEAR
 __construct ($error_class=null)
 Constructor. More...
 
 _PEAR ()
 Destructor (the emulated type of...). More...
 
 registerShutdownFunc ($func, $args=array())
 Use this function to register a shutdown method for static classes. More...
 
 isError ($data, $code=null)
 Tell whether a value is a PEAR error. More...
 
 expectError ($code=' *')
 This method is used to tell which errors you expect to get. More...
 
 popExpect ()
 This method pops one element off the expected error codes stack. More...
 
 _checkDelExpect ($error_code)
 This method checks unsets an error code if available. More...
 
 delExpect ($error_code)
 This method deletes all occurences of the specified element from the expected error codes stack. More...
 
raiseError ($message=null, $code=null, $mode=null, $options=null, $userinfo=null, $error_class=null, $skipmsg=false)
 This method is a wrapper that returns an instance of the configured error class with this object's default error handling applied. More...
 
throwError ($message=null, $code=null, $userinfo=null)
 Simpler form of raiseError with fewer options. More...
 
 staticPushErrorHandling ($mode, $options=null)
 
 staticPopErrorHandling ()
 
 pushErrorHandling ($mode, $options=null)
 Push a new error handler on top of the error handler options stack. More...
 
 popErrorHandling ()
 Pop the last error handler used. More...
 
 loadExtension ($ext)
 OS independant PHP extension load. More...
 

Protected Member Functions

 importRandomQuestionSetSettings ($attr)
 
 importRandomQuestionStagingPool ($attr, $cdata)
 
 getRandomQuestionSourcePoolDefinitionInstance ()
 
 importRandomQuestionSourcePoolDefinition (ilTestRandomQuestionSetSourcePoolDefinition $sourcePoolDefinition, $attr)
 
- Protected Member Functions inherited from ilSaxParser
 handleError ($message, $code)
 use given error handler to handle error message or internal ilias error message handle More...
 

Protected Attributes

 $testOBJ
 
 $importMapping
 

Additional Inherited Members

- Static Public Member Functions inherited from PEAR
static & getStaticProperty ($class, $var)
 If you have a class that's mostly/entirely static, and you need static properties, you can use this method to simulate them. More...
 
static setErrorHandling ($mode=null, $options=null)
 Sets how errors generated by this object should be handled. More...
 
- Data Fields inherited from ilSaxParser
 $input_type = null
 
 $xml_content = ''
 
 $ilias
 
 $lng
 
 $xml_file
 
 $throwException = false
 
- Data Fields inherited from PEAR
 $_debug = false
 
 $_default_error_mode = null
 
 $_default_error_options = null
 
 $_default_error_handler = ''
 
 $_error_class = 'PEAR_Error'
 
 $_expected_errors = array()
 

Detailed Description

Definition at line 12 of file class.ilObjTestXMLParser.php.

Member Function Documentation

◆ getImportMapping()

ilObjTestXMLParser::getImportMapping ( )
Returns
ilImportMapping

Definition at line 43 of file class.ilObjTestXMLParser.php.

References $importMapping.

Referenced by handlerEndTag(), importRandomQuestionSourcePoolDefinition(), and importRandomQuestionStagingPool().

+ Here is the caller graph for this function:

◆ getRandomQuestionSourcePoolDefinitionInstance()

ilObjTestXMLParser::getRandomQuestionSourcePoolDefinitionInstance ( )
protected

Definition at line 246 of file class.ilObjTestXMLParser.php.

247 {
248 global $ilDB;
249
250 require_once 'Modules/Test/classes/class.ilTestRandomQuestionSetSourcePoolDefinition.php';
251
252 return new ilTestRandomQuestionSetSourcePoolDefinition($ilDB, $this->testOBJ);
253 }
global $ilDB

References $ilDB.

Referenced by handlerBeginTag().

+ Here is the caller graph for this function:

◆ getTestOBJ()

ilObjTestXMLParser::getTestOBJ ( )
Returns
ilObjTest

Definition at line 27 of file class.ilObjTestXMLParser.php.

References $testOBJ.

◆ handlerBeginTag()

ilObjTestXMLParser::handlerBeginTag (   $xmlParser,
  $tagName,
  $tagAttributes 
)

Definition at line 63 of file class.ilObjTestXMLParser.php.

64 {
65 switch ($tagName) {
66 case 'RandomQuestionSetConfig':
67 $this->inRandomQuestionSetConfig = true;
68 break;
69
70 case 'RandomQuestionSetSettings':
71 if ($this->inRandomQuestionSetConfig) {
72 $this->inRandomQuestionSetSettings = true;
73 $this->cdata = '';
74 $this->attr = $tagAttributes;
75 }
76 break;
77
78 case 'RandomQuestionStage':
79 if ($this->inRandomQuestionSetConfig) {
80 $this->inRandomQuestionStage = true;
81 }
82 break;
83
84 case 'RandomQuestionStagingPool':
85 if ($this->inRandomQuestionStage) {
86 $this->cdata = '';
87 $this->attr = $tagAttributes;
88 }
89 break;
90
91 case 'RandomQuestionSelectionDefinitions':
92 if ($this->inRandomQuestionSetConfig) {
93 $this->inRandomQuestionSelectionDefinitions = true;
94 }
95 break;
96
97 case 'RandomQuestionSelectionDefinition':
98 if ($this->inRandomQuestionSelectionDefinitions) {
99 $this->sourcePoolDefinition = $this->getRandomQuestionSourcePoolDefinitionInstance();
100 $this->attr = $tagAttributes;
101 }
102 break;
103
104 case 'RandomQuestionSourcePoolTitle':
105 case 'RandomQuestionSourcePoolPath':
106 if ($this->sourcePoolDefinition instanceof ilTestRandomQuestionSetSourcePoolDefinition) {
107 $this->cdata = '';
108 }
109 break;
110 }
111 }

References getRandomQuestionSourcePoolDefinitionInstance().

+ Here is the call graph for this function:

◆ handlerCharacterData()

ilObjTestXMLParser::handlerCharacterData (   $xmlParser,
  $charData 
)

Definition at line 180 of file class.ilObjTestXMLParser.php.

181 {
182 if ($charData != "\n") {
183 // Replace multiple tabs with one space
184 $charData = preg_replace("/\t+/", " ", $charData);
185
186 $this->cdata .= $charData;
187 }
188 }

◆ handlerEndTag()

ilObjTestXMLParser::handlerEndTag (   $xmlParser,
  $tagName 
)

Definition at line 113 of file class.ilObjTestXMLParser.php.

114 {
115 switch ($tagName) {
116 case 'RandomQuestionSetConfig':
117 $this->inRandomQuestionSetConfig = false;
118 break;
119
120 case 'RandomQuestionSetSettings':
121 if ($this->inRandomQuestionSetConfig) {
122 $this->importRandomQuestionSetSettings($this->attr);
123 $this->attr = null;
124 }
125 break;
126
127 case 'RandomQuestionStage':
128 if ($this->inRandomQuestionSetConfig) {
129 $this->inRandomQuestionStage = false;
130 }
131 break;
132
133 case 'RandomQuestionStagingPool':
134 if ($this->inRandomQuestionSetConfig && $this->inRandomQuestionStage) {
135 $this->importRandomQuestionStagingPool($this->attr, $this->cdata);
136 $this->attr = null;
137 $this->cdata = '';
138 }
139 break;
140
141 case 'RandomQuestionSelectionDefinitions':
142 if ($this->inRandomQuestionSetConfig) {
143 $this->inRandomQuestionSelectionDefinitions = false;
144 }
145 break;
146
147 case 'RandomQuestionSelectionDefinition':
148 if ($this->inRandomQuestionSetConfig && $this->inRandomQuestionSelectionDefinitions) {
149 $this->importRandomQuestionSourcePoolDefinition($this->sourcePoolDefinition, $this->attr);
150 $this->sourcePoolDefinition->saveToDb();
151
152 $this->getImportMapping()->addMapping(
153 'Modules/Test',
154 'rnd_src_pool_def',
155 $this->attr['id'],
156 $this->sourcePoolDefinition->getId()
157 );
158
159 $this->sourcePoolDefinition = null;
160 $this->attr = null;
161 }
162 break;
163
164 case 'RandomQuestionSourcePoolTitle':
165 if ($this->sourcePoolDefinition instanceof ilTestRandomQuestionSetSourcePoolDefinition) {
166 $this->sourcePoolDefinition->setPoolTitle($this->cdata);
167 $this->cdata = '';
168 }
169 break;
170
171 case 'RandomQuestionSourcePoolPath':
172 if ($this->sourcePoolDefinition instanceof ilTestRandomQuestionSetSourcePoolDefinition) {
173 $this->sourcePoolDefinition->setPoolPath($this->cdata);
174 $this->cdata = '';
175 }
176 break;
177 }
178 }
importRandomQuestionStagingPool($attr, $cdata)
importRandomQuestionSourcePoolDefinition(ilTestRandomQuestionSetSourcePoolDefinition $sourcePoolDefinition, $attr)

References getImportMapping(), importRandomQuestionSetSettings(), importRandomQuestionSourcePoolDefinition(), and importRandomQuestionStagingPool().

+ Here is the call graph for this function:

◆ importRandomQuestionSetSettings()

ilObjTestXMLParser::importRandomQuestionSetSettings (   $attr)
protected

Definition at line 190 of file class.ilObjTestXMLParser.php.

191 {
192 global $tree, $ilDB, $ilPluginAdmin;
193
194 require_once 'Modules/Test/classes/class.ilTestRandomQuestionSetConfig.php';
195 $questionSetConfig = new ilTestRandomQuestionSetConfig($tree, $ilDB, $ilPluginAdmin, $this->testOBJ);
196
197 if (!$questionSetConfig->isValidQuestionAmountConfigurationMode($attr['amountMode'])) {
198 require_once 'Modules/Test/exceptions/class.ilTestException.php';
199 throw new ilTestException(
200 'invalid random test question set config amount mode given: "' . $attr['amountMode'] . '"'
201 );
202 }
203
204 $questionSetConfig->setQuestionAmountConfigurationMode($attr['amountMode']);
205 $questionSetConfig->setQuestionAmountPerTest((int) $attr['questAmount']);
206 $questionSetConfig->setPoolsWithHomogeneousScoredQuestionsRequired((bool) $attr['homogeneous']);
207 $questionSetConfig->setLastQuestionSyncTimestamp((int) $attr['synctimestamp']);
208
209 $questionSetConfig->saveToDb();
210 }
Base Exception for all Exceptions relating to Modules/Test.

References $ilDB.

Referenced by handlerEndTag().

+ Here is the caller graph for this function:

◆ importRandomQuestionSourcePoolDefinition()

ilObjTestXMLParser::importRandomQuestionSourcePoolDefinition ( ilTestRandomQuestionSetSourcePoolDefinition  $sourcePoolDefinition,
  $attr 
)
protected

Definition at line 255 of file class.ilObjTestXMLParser.php.

256 {
257 $sourcePoolDefinition->setPoolId($this->getImportMapping()->getMapping(
258 'Modules/Test',
259 'pool',
260 (int) $attr['poolId']
261 ));
262
263 $sourcePoolDefinition->setPoolQuestionCount((int) $attr['poolQuestCount']);
264 $sourcePoolDefinition->setQuestionAmount((int) $attr['questAmount']);
265 $sourcePoolDefinition->setSequencePosition((int) $attr['position']);
266
267 // #21330
268 if (isset($attr['tax']) && isset($attr['taxNode'])) {
269 $mappedTaxFilter = array(
270 (int) $attr['tax'] => array(
271 (int) $attr['taxNode']
272 )
273 );
274 $sourcePoolDefinition->setMappedTaxonomyFilter($mappedTaxFilter);
275 } elseif (isset($attr['taxFilter']) && strlen($attr['taxFilter']) > 0) {
276 $mappedTaxFilter = unserialize($attr['taxFilter']);
277 $sourcePoolDefinition->setMappedTaxonomyFilter($mappedTaxFilter);
278 }
279 }
setMappedTaxonomyFilter($filter=array())
set the original taxonomy filter condition

References getImportMapping(), ilTestRandomQuestionSetSourcePoolDefinition\setMappedTaxonomyFilter(), ilTestRandomQuestionSetSourcePoolDefinition\setPoolId(), ilTestRandomQuestionSetSourcePoolDefinition\setPoolQuestionCount(), ilTestRandomQuestionSetSourcePoolDefinition\setQuestionAmount(), and ilTestRandomQuestionSetSourcePoolDefinition\setSequencePosition().

Referenced by handlerEndTag().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ importRandomQuestionStagingPool()

ilObjTestXMLParser::importRandomQuestionStagingPool (   $attr,
  $cdata 
)
protected

Definition at line 212 of file class.ilObjTestXMLParser.php.

213 {
214 global $ilDB;
215
216 $oldPoolId = $attr['poolId'];
217 $newPoolId = $ilDB->nextId('object_data'); // yes !!
218
219 $this->getImportMapping()->addMapping(
220 'Modules/Test',
221 'pool',
222 $oldPoolId,
223 $newPoolId
224 );
225
226 $oldQuestionIds = explode(',', $cdata);
227
228 require_once 'Modules/Test/classes/class.ilTestRandomQuestionSetStagingPoolQuestion.php';
229
230 foreach ($oldQuestionIds as $oldQuestionId) {
231 $newQuestionId = $this->getImportMapping()->getMapping(
232 'Modules/Test',
233 'quest',
234 $oldQuestionId
235 );
236
238 $stagingQuestion->setTestId($this->testOBJ->getTestId());
239 $stagingQuestion->setPoolId($newPoolId);
240 $stagingQuestion->setQuestionId($newQuestionId);
241
242 $stagingQuestion->saveQuestionStaging();
243 }
244 }

References $ilDB, and getImportMapping().

Referenced by handlerEndTag().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setHandlers()

ilObjTestXMLParser::setHandlers (   $a_xml_parser)

set event handler should be overwritten by inherited class @access private

Reimplemented from ilSaxParser.

Definition at line 56 of file class.ilObjTestXMLParser.php.

57 {
58 xml_set_object($xmlParser, $this);
59 xml_set_element_handler($xmlParser, 'handlerBeginTag', 'handlerEndTag');
60 xml_set_character_data_handler($xmlParser, 'handlerCharacterData');
61 }

◆ setImportMapping()

ilObjTestXMLParser::setImportMapping (   $importMapping)
Parameters
ilImportMapping$importMapping

Definition at line 51 of file class.ilObjTestXMLParser.php.

52 {
53 $this->importMapping = $importMapping;
54 }

References $importMapping.

◆ setTestOBJ()

ilObjTestXMLParser::setTestOBJ (   $testOBJ)
Parameters
ilObjTest$testOBJ

Definition at line 35 of file class.ilObjTestXMLParser.php.

36 {
37 $this->testOBJ = $testOBJ;
38 }

References $testOBJ.

Field Documentation

◆ $importMapping

ilObjTestXMLParser::$importMapping
protected

Definition at line 22 of file class.ilObjTestXMLParser.php.

Referenced by getImportMapping(), and setImportMapping().

◆ $testOBJ

ilObjTestXMLParser::$testOBJ
protected

Definition at line 17 of file class.ilObjTestXMLParser.php.

Referenced by getTestOBJ(), and setTestOBJ().


The documentation for this class was generated from the following file: