ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilObjTestXMLParser Class Reference
+ Inheritance diagram for ilObjTestXMLParser:
+ Collaboration diagram for ilObjTestXMLParser:

Public Member Functions

 getTestOBJ ()
 
 setTestOBJ ($testOBJ)
 
 getImportMapping ()
 
 setImportMapping ($importMapping)
 
 setHandlers ($xmlParser)
 
 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 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 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 255 of file class.ilObjTestXMLParser.php.

References $ilDB.

Referenced by handlerBeginTag().

256  {
257  global $ilDB;
258 
259  require_once 'Modules/Test/classes/class.ilTestRandomQuestionSetSourcePoolDefinition.php';
260 
261  return new ilTestRandomQuestionSetSourcePoolDefinition($ilDB, $this->testOBJ);
262  }
global $ilDB
+ Here is the caller graph for this function:

◆ getTestOBJ()

ilObjTestXMLParser::getTestOBJ ( )
Returns
ilObjTest

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

References $testOBJ.

28  {
29  return $this->testOBJ;
30  }

◆ handlerBeginTag()

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

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

References getRandomQuestionSourcePoolDefinitionInstance().

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

◆ handlerCharacterData()

ilObjTestXMLParser::handlerCharacterData (   $xmlParser,
  $charData 
)

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

193  {
194  if( $charData != "\n" )
195  {
196  // Replace multiple tabs with one space
197  $charData = preg_replace("/\t+/"," ",$charData);
198 
199  $this->cdata .= $charData;
200  }
201  }

◆ handlerEndTag()

ilObjTestXMLParser::handlerEndTag (   $xmlParser,
  $tagName 
)

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

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

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

◆ importRandomQuestionSetSettings()

ilObjTestXMLParser::importRandomQuestionSetSettings (   $attr)
protected

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

References $ilDB.

Referenced by handlerEndTag().

204  {
205  global $tree, $ilDB, $ilPluginAdmin;
206 
207  require_once 'Modules/Test/classes/class.ilTestRandomQuestionSetConfig.php';
208  $questionSetConfig = new ilTestRandomQuestionSetConfig($tree, $ilDB, $ilPluginAdmin, $this->testOBJ);
209 
210  if( !$questionSetConfig->isValidQuestionAmountConfigurationMode($attr['amountMode']) )
211  {
212  require_once 'Modules/Test/exceptions/class.ilTestException.php';
213  throw new ilTestException(
214  'invalid random test question set config amount mode given: "'.$attr['amountMode'].'"'
215  );
216  }
217 
218  $questionSetConfig->setQuestionAmountConfigurationMode($attr['amountMode']);
219  $questionSetConfig->setQuestionAmountPerTest((int)$attr['questAmount']);
220  $questionSetConfig->setPoolsWithHomogeneousScoredQuestionsRequired((bool)$attr['homogeneous']);
221 
222  $questionSetConfig->saveToDb();
223  }
Base Exception for all Exceptions relating to Modules/Test.
global $ilDB
+ Here is the caller graph for this function:

◆ importRandomQuestionSourcePoolDefinition()

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

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

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

Referenced by handlerEndTag().

265  {
266  $sourcePoolDefinition->setPoolId($this->getImportMapping()->getMapping(
267  'Modules/Test', 'pool', (int)$attr['poolId']
268  ));
269 
270  $sourcePoolDefinition->setPoolQuestionCount((int)$attr['poolQuestCount']);
271  $sourcePoolDefinition->setQuestionAmount((int)$attr['questAmount']);
272  $sourcePoolDefinition->setSequencePosition((int)$attr['position']);
273 
274  if( isset($attr['tax']) && isset($attr['taxNode']) )
275  {
276  $sourcePoolDefinition->setMappedFilterTaxId((int)$attr['tax']);
277  $sourcePoolDefinition->setMappedFilterTaxNodeId((int)$attr['taxNode']);
278  }
279  }
+ 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 225 of file class.ilObjTestXMLParser.php.

References $ilDB, and getImportMapping().

Referenced by handlerEndTag().

226  {
227  global $ilDB;
228 
229  $oldPoolId = $attr['poolId'];
230  $newPoolId = $ilDB->nextId('object_data'); // yes !!
231 
232  $this->getImportMapping()->addMapping(
233  'Modules/Test', 'pool', $oldPoolId, $newPoolId
234  );
235 
236  $oldQuestionIds = explode(',', $cdata);
237 
238  require_once 'Modules/Test/classes/class.ilTestRandomQuestionSetStagingPoolQuestion.php';
239 
240  foreach($oldQuestionIds as $oldQuestionId)
241  {
242  $newQuestionId = $this->getImportMapping()->getMapping(
243  'Modules/Test', 'quest', $oldQuestionId
244  );
245 
246  $stagingQuestion = new ilTestRandomQuestionSetStagingPoolQuestion($ilDB);
247  $stagingQuestion->setTestId($this->testOBJ->getTestId());
248  $stagingQuestion->setPoolId($newPoolId);
249  $stagingQuestion->setQuestionId($newQuestionId);
250 
251  $stagingQuestion->saveQuestionStaging();
252  }
253  }
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setHandlers()

ilObjTestXMLParser::setHandlers (   $xmlParser)

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.

References $importMapping.

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

◆ setTestOBJ()

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

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

References $testOBJ.

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

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: