ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 250 of file class.ilObjTestXMLParser.php.

251 {
252 global $DIC;
253 $ilDB = $DIC['ilDB'];
254
255 require_once 'Modules/Test/classes/class.ilTestRandomQuestionSetSourcePoolDefinition.php';
256
257 return new ilTestRandomQuestionSetSourcePoolDefinition($ilDB, $this->testOBJ);
258 }
global $DIC
Definition: saml.php:7
global $ilDB

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

References $DIC, $ilDB, and $tree.

Referenced by handlerEndTag().

+ Here is the caller graph for this function:

◆ importRandomQuestionSourcePoolDefinition()

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

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

261 {
262 $source_pool_id = (int) $attr['poolId'];
263 $effective_pool_id = (int) $this->getImportMapping()->getMapping(
264 'Modules/Test',
265 'pool',
266 $source_pool_id
267 );
268 $sourcePoolDefinition->setPoolId($effective_pool_id);
269
270 $derive_from_obj_id = true;
271 // The ref_id might not be given in old export files, so we have to check for existence
272 if (isset($attr['ref_id']) && is_numeric($attr['ref_id'])) {
273 if ($source_pool_id === $effective_pool_id) {
274 $derive_from_obj_id = false;
275 $sourcePoolDefinition->setPoolRefId((int) $attr['ref_id']);
276 }
277 }
278
279 if ($derive_from_obj_id) {
280 $ref_ids = ilObject::_getAllReferences($effective_pool_id);
281 $ref_id = current($ref_ids);
282 $sourcePoolDefinition->setPoolRefId($ref_id ? (int) $ref_id : null);
283 }
284
285 $sourcePoolDefinition->setPoolQuestionCount((int) $attr['poolQuestCount']);
286 $sourcePoolDefinition->setQuestionAmount((int) $attr['questAmount']);
287 $sourcePoolDefinition->setSequencePosition((int) $attr['position']);
288
289 // #21330
290 if (isset($attr['tax']) && isset($attr['taxNode'])) {
291 $mappedTaxFilter = array(
292 (int) $attr['tax'] => array(
293 (int) $attr['taxNode']
294 )
295 );
296 $sourcePoolDefinition->setMappedTaxonomyFilter($mappedTaxFilter);
297 } elseif (isset($attr['taxFilter']) && strlen($attr['taxFilter']) > 0) {
298 $mappedTaxFilter = unserialize($attr['taxFilter']);
299 $sourcePoolDefinition->setMappedTaxonomyFilter($mappedTaxFilter);
300 }
301 }
static _getAllReferences($a_id)
get all reference ids of object
setMappedTaxonomyFilter($filter=array())
set the original taxonomy filter condition

References ilObject\_getAllReferences(), getImportMapping(), ilTestRandomQuestionSetSourcePoolDefinition\setMappedTaxonomyFilter(), ilTestRandomQuestionSetSourcePoolDefinition\setPoolId(), ilTestRandomQuestionSetSourcePoolDefinition\setPoolQuestionCount(), ilTestRandomQuestionSetSourcePoolDefinition\setPoolRefId(), 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 215 of file class.ilObjTestXMLParser.php.

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

References $DIC, $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: