ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilTestResultsImportParser Class Reference

Test results import parser. More...

+ Inheritance diagram for ilTestResultsImportParser:
+ Collaboration diagram for ilTestResultsImportParser:

Public Member Functions

 __construct ($a_xml_file, &$test_object)
 Constructor. More...
 
 getQuestionIdMapping ()
 
 setQuestionIdMapping ($question_id_mapping)
 
 getSrcPoolDefIdMapping ()
 
 setSrcPoolDefIdMapping ($src_pool_def_id_mapping)
 
 setHandlers ($a_xml_parser)
 set event handler should be overwritten by inherited class private More...
 
 handlerBeginTag ($a_xml_parser, $a_name, $a_attribs)
 handler for begin of element parser More...
 
 handlerEndTag ($a_xml_parser, $a_name)
 handler for end of element More...
 
 handlerParseCharacterData ($a_xml_parser, $a_data)
 handler for character data More...
 
- 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 Attributes

 $src_pool_def_id_mapping
 

Private Member Functions

 fetchAttribute ($attributes, $name)
 
 fetchLastFinishedPass ($attribs)
 
 fetchLastStartedPass ($attribs)
 

Private Attributes

 $tst_obj
 
 $table
 
 $active_id_mapping
 
 $question_id_mapping
 
 $user_criteria_field
 
 $user_criteria_type
 
 $user_criteria_checked = false
 

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()
 
- Protected Member Functions inherited from ilSaxParser
 handleError ($message, $code)
 use given error handler to handle error message or internal ilias error message handle More...
 

Detailed Description

Test results import parser.

Author
Helmut Schottmüller ilias.nosp@m.@aur.nosp@m.ealis.nosp@m..de
Version
$Id$

Definition at line 13 of file class.ilTestResultsImportParser.php.

Constructor & Destructor Documentation

◆ __construct()

ilTestResultsImportParser::__construct (   $a_xml_file,
$test_object 
)

Constructor.

Definition at line 28 of file class.ilTestResultsImportParser.php.

References array.

29  {
30  parent::__construct($a_xml_file, true);
31  $this->tst_obj = &$test_object;
32  $this->table = '';
33  $this->active_id_mapping = array();
34  $this->question_id_mapping = array();
35  $this->user_criteria_checked = false;
36  $this->src_pool_def_id_mapping = array();
37  }
Create styles array
The data for the language used.

Member Function Documentation

◆ fetchAttribute()

ilTestResultsImportParser::fetchAttribute (   $attributes,
  $name 
)
private

Definition at line 284 of file class.ilTestResultsImportParser.php.

Referenced by handlerBeginTag().

285  {
286  if( isset($attributes[$name]) )
287  {
288  return $attributes[$name];
289  }
290 
291  return null;
292  }
+ Here is the caller graph for this function:

◆ fetchLastFinishedPass()

ilTestResultsImportParser::fetchLastFinishedPass (   $attribs)
private

Definition at line 294 of file class.ilTestResultsImportParser.php.

Referenced by handlerBeginTag().

295  {
296  if( isset($attribs['last_finished_pass']) )
297  {
298  return $attribs['last_finished_pass'];
299  }
300 
301  if( $attribs['tries'] > 0 )
302  {
303  return $attribs['tries'] - 1;
304  }
305 
306  return null;
307  }
+ Here is the caller graph for this function:

◆ fetchLastStartedPass()

ilTestResultsImportParser::fetchLastStartedPass (   $attribs)
private

Definition at line 309 of file class.ilTestResultsImportParser.php.

Referenced by handlerBeginTag().

310  {
311  if( isset($attribs['last_started_pass']) )
312  {
313  return $attribs['last_started_pass'];
314  }
315 
316  if( $attribs['tries'] > 0 )
317  {
318  return $attribs['tries'] - 1;
319  }
320 
321  return null;
322  }
+ Here is the caller graph for this function:

◆ getQuestionIdMapping()

ilTestResultsImportParser::getQuestionIdMapping ( )
Returns
array

Definition at line 42 of file class.ilTestResultsImportParser.php.

References $question_id_mapping.

◆ getSrcPoolDefIdMapping()

ilTestResultsImportParser::getSrcPoolDefIdMapping ( )
Returns
array

Definition at line 58 of file class.ilTestResultsImportParser.php.

References $src_pool_def_id_mapping.

◆ handlerBeginTag()

ilTestResultsImportParser::handlerBeginTag (   $a_xml_parser,
  $a_name,
  $a_attribs 
)

handler for begin of element parser

Definition at line 86 of file class.ilTestResultsImportParser.php.

References $ilDB, $info, $result, $row, array, fetchAttribute(), fetchLastFinishedPass(), and fetchLastStartedPass().

87  {
88  global $ilDB;
89 
90  $this->sametag = FALSE;
91  $this->characterbuffer = "";
92  $this->depth[$a_xml_parser]++;
93  $this->path[$this->depth[$a_xml_parser]] = strtolower($a_name);
94  $this->qti_element = $a_name;
95 
96  switch (strtolower($a_name))
97  {
98  case "results":
99  break;
100  case "row":
101  switch ($this->table)
102  {
103  case 'tst_active':
104  if (!$this->user_criteria_checked)
105  {
106  $this->user_criteria_checked = true;
107  if ($ilDB->tableColumnExists('usr_data', $a_attribs['user_criteria']))
108  {
109  include_once './Services/Database/classes/class.ilDBAnalyzer.php';
110  $analyzer = new ilDBAnalyzer();
111  $info = $analyzer->getFieldInformation('usr_data');
112  $this->user_criteria_field = $a_attribs['user_criteria'];
113  $this->user_criteria_type = $info[$a_attribs['user_criteria']]['type'];
114  }
115  }
116  $usr_id = ANONYMOUS_USER_ID;
117  if (strlen($this->user_criteria_field))
118  {
119  $result = $ilDB->queryF("SELECT usr_id FROM usr_data WHERE " . $this->user_criteria_field . " = %s",
120  array($this->user_criteria_type),
121  array($a_attribs[$this->user_criteria_field])
122  );
123  if ($result->numRows())
124  {
125  $row = $ilDB->fetchAssoc($result);
126  $usr_id = $row['usr_id'];
127  }
128  }
129  $next_id = $ilDB->nextId('tst_active');
130 
131  $ilDB->insert('tst_active', array(
132  'active_id' => array('integer', $next_id),
133  'user_fi' => array('integer', $usr_id),
134  'anonymous_id' => array('text', strlen($a_attribs['anonymous_id']) ? $a_attribs['anonymous_id'] : NULL),
135  'test_fi' => array('integer', $this->tst_obj->getTestId()),
136  'lastindex' => array('integer', $a_attribs['lastindex']),
137  'tries' => array('integer', $a_attribs['tries']),
138  'submitted' => array('integer', $a_attribs['submitted']),
139  'submittimestamp' => array('timestamp', strlen($a_attribs['submittimestamp']) ? $a_attribs['submittimestamp'] : NULL),
140  'tstamp' => array('integer', $a_attribs['tstamp']),
141  'importname' => array('text', $a_attribs['fullname']),
142  'last_finished_pass' => array('integer', $this->fetchLastFinishedPass($a_attribs)),
143  'last_started_pass' => array('integer', $this->fetchLastStartedPass($a_attribs)),
144  'answerstatusfilter' => array('integer', $this->fetchAttribute($a_attribs, 'answer_status_filter')),
145  'objective_container' => array('integer', $this->fetchAttribute($a_attribs, 'objective_container'))
146  ));
147  $this->active_id_mapping[$a_attribs['active_id']] = $next_id;
148  break;
149  case 'tst_test_rnd_qst':
150  $nextId = $ilDB->nextId('tst_test_rnd_qst');
151  $newActiveId = $this->active_id_mapping[$a_attribs['active_fi']];
152  $newQuestionId = $this->question_id_mapping[$a_attribs['question_fi']];
153  $newSrcPoolDefId = $this->src_pool_def_id_mapping[$a_attribs['src_pool_def_fi']];
154  $ilDB->insert('tst_test_rnd_qst', array(
155  'test_random_question_id' => array('integer', $nextId),
156  'active_fi' => array('integer', $newActiveId),
157  'question_fi' => array('integer', $newQuestionId),
158  'sequence' => array('integer', $a_attribs['sequence']),
159  'pass' => array('integer', $a_attribs['pass']),
160  'tstamp' => array('integer', $a_attribs['tstamp']),
161  'src_pool_def_fi' => array('integer', $newSrcPoolDefId)
162  ));
163  break;
164  case 'tst_pass_result':
165  $affectedRows = $ilDB->manipulateF("INSERT INTO tst_pass_result (active_fi, pass, points, maxpoints, questioncount, answeredquestions, workingtime, tstamp) VALUES (%s,%s,%s,%s,%s,%s,%s,%s)",
166  array(
167  'integer',
168  'integer',
169  'float',
170  'float',
171  'integer',
172  'integer',
173  'integer',
174  'integer'
175  ),
176  array(
177  $this->active_id_mapping[$a_attribs['active_fi']],
178  strlen($a_attribs['pass']) ? $a_attribs['pass'] : 0,
179  ($a_attribs["points"]) ? $a_attribs["points"] : 0,
180  ($a_attribs["maxpoints"]) ? $a_attribs["maxpoints"] : 0,
181  $a_attribs["questioncount"],
182  $a_attribs["answeredquestions"],
183  ($a_attribs["workingtime"]) ? $a_attribs["workingtime"] : 0,
184  $a_attribs["tstamp"]
185  )
186  );
187  break;
188  case 'tst_result_cache':
189  $affectedRows = $ilDB->manipulateF("INSERT INTO tst_result_cache (active_fi, pass, max_points, reached_points, mark_short, mark_official, passed, failed, tstamp) VALUES (%s,%s,%s,%s,%s,%s,%s,%s,%s)",
190  array(
191  'integer',
192  'integer',
193  'float',
194  'float',
195  'text',
196  'text',
197  'integer',
198  'integer',
199  'integer'
200  ),
201  array(
202  $this->active_id_mapping[$a_attribs['active_fi']],
203  strlen($a_attribs['pass']) ? $a_attribs['pass'] : 0,
204  ($a_attribs["max_points"]) ? $a_attribs["max_points"] : 0,
205  ($a_attribs["reached_points"]) ? $a_attribs["reached_points"] : 0,
206  strlen($a_attribs["mark_short"]) ? $a_attribs["mark_short"] : " ",
207  strlen($a_attribs["mark_official"]) ? $a_attribs["mark_official"] : " ",
208  ($a_attribs["passed"]) ? 1 : 0,
209  ($a_attribs["failed"]) ? 1 : 0,
210  $a_attribs["tstamp"]
211  )
212  );
213  break;
214  case 'tst_sequence':
215  $affectedRows = $ilDB->insert("tst_sequence", array(
216  "active_fi" => array("integer", $this->active_id_mapping[$a_attribs['active_fi']]),
217  "pass" => array("integer", $a_attribs['pass']),
218  "sequence" => array("clob", $a_attribs['sequence']),
219  "postponed" => array("text", (strlen($a_attribs['postponed'])) ? $a_attribs['postponed'] : NULL),
220  "hidden" => array("text", (strlen($a_attribs['hidden'])) ? $a_attribs['hidden'] : NULL),
221  "tstamp" => array("integer", $a_attribs['tstamp'])
222  ));
223  break;
224  case 'tst_solutions':
225  $next_id = $ilDB->nextId('tst_solutions');
226  $affectedRows = $ilDB->insert("tst_solutions", array(
227  "solution_id" => array("integer", $next_id),
228  "active_fi" => array("integer", $this->active_id_mapping[$a_attribs['active_fi']]),
229  "question_fi" => array("integer", $this->question_id_mapping[$a_attribs['question_fi']]),
230  "value1" => array("clob", (strlen($a_attribs['value1'])) ? $a_attribs['value1'] : NULL),
231  "value2" => array("clob", (strlen($a_attribs['value2'])) ? $a_attribs['value2'] : NULL),
232  "pass" => array("integer", $a_attribs['pass']),
233  "tstamp" => array("integer", $a_attribs['tstamp'])
234  ));
235  break;
236  case 'tst_test_result':
237  $next_id = $ilDB->nextId('tst_test_result');
238  $affectedRows = $ilDB->manipulateF("INSERT INTO tst_test_result (test_result_id, active_fi, question_fi, points, pass, manual, tstamp) VALUES (%s, %s, %s, %s, %s, %s, %s)",
239  array('integer', 'integer','integer', 'float', 'integer', 'integer','integer'),
240  array($next_id, $this->active_id_mapping[$a_attribs['active_fi']], $this->question_id_mapping[$a_attribs['question_fi']], $a_attribs['points'], $a_attribs['pass'], (strlen($a_attribs['manual'])) ? $a_attribs['manual'] : 0, $a_attribs['tstamp'])
241  );
242  break;
243  case 'tst_times':
244  $next_id = $ilDB->nextId('tst_times');
245  $affectedRows = $ilDB->manipulateF("INSERT INTO tst_times (times_id, active_fi, started, finished, pass, tstamp) VALUES (%s, %s, %s, %s, %s, %s)",
246  array('integer', 'integer', 'timestamp', 'timestamp', 'integer', 'integer'),
247  array($next_id, $this->active_id_mapping[$a_attribs['active_fi']], $a_attribs['started'], $a_attribs['finished'], $a_attribs['pass'], $a_attribs['tstamp'])
248  );
249  break;
250  }
251  break;
252  default:
253  $this->table = $a_name;
254  break;
255  }
256  }
$result
$info
Definition: example_052.php:80
Create styles array
The data for the language used.
global $ilDB
This class gives all kind of DB information using the MDB2 manager and reverse module.
+ Here is the call graph for this function:

◆ handlerEndTag()

ilTestResultsImportParser::handlerEndTag (   $a_xml_parser,
  $a_name 
)

handler for end of element

Definition at line 261 of file class.ilTestResultsImportParser.php.

References $ilLog.

262  {
263  switch (strtolower($a_name))
264  {
265  case "tst_active":
266  global $ilLog;
267  $ilLog->write("active id mapping: " . print_r($this->active_id_mapping, true));
268  break;
269  case "tst_test_question":
270  global $ilLog;
271  $ilLog->write("question id mapping: " . print_r($this->question_id_mapping, true));
272  break;
273  }
274  }

◆ handlerParseCharacterData()

ilTestResultsImportParser::handlerParseCharacterData (   $a_xml_parser,
  $a_data 
)

handler for character data

Definition at line 279 of file class.ilTestResultsImportParser.php.

280  {
281  // do nothing
282  }

◆ setHandlers()

ilTestResultsImportParser::setHandlers (   $a_xml_parser)

set event handler should be overwritten by inherited class private

Definition at line 76 of file class.ilTestResultsImportParser.php.

77  {
78  xml_set_object($a_xml_parser,$this);
79  xml_set_element_handler($a_xml_parser,'handlerBeginTag','handlerEndTag');
80  xml_set_character_data_handler($a_xml_parser,'handlerParseCharacterData');
81  }

◆ setQuestionIdMapping()

ilTestResultsImportParser::setQuestionIdMapping (   $question_id_mapping)
Parameters
array$question_id_mapping

Definition at line 50 of file class.ilTestResultsImportParser.php.

References $question_id_mapping.

51  {
52  $this->question_id_mapping = $question_id_mapping;
53  }

◆ setSrcPoolDefIdMapping()

ilTestResultsImportParser::setSrcPoolDefIdMapping (   $src_pool_def_id_mapping)
Parameters
array$src_pool_def_id_mapping

Definition at line 66 of file class.ilTestResultsImportParser.php.

References $src_pool_def_id_mapping.

67  {
68  $this->src_pool_def_id_mapping = $src_pool_def_id_mapping;
69  }

Field Documentation

◆ $active_id_mapping

ilTestResultsImportParser::$active_id_mapping
private

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

◆ $question_id_mapping

ilTestResultsImportParser::$question_id_mapping
private

◆ $src_pool_def_id_mapping

ilTestResultsImportParser::$src_pool_def_id_mapping
protected

◆ $table

ilTestResultsImportParser::$table
private

Definition at line 16 of file class.ilTestResultsImportParser.php.

◆ $tst_obj

ilTestResultsImportParser::$tst_obj
private

Definition at line 15 of file class.ilTestResultsImportParser.php.

◆ $user_criteria_checked

ilTestResultsImportParser::$user_criteria_checked = false
private

Definition at line 21 of file class.ilTestResultsImportParser.php.

◆ $user_criteria_field

ilTestResultsImportParser::$user_criteria_field
private

Definition at line 19 of file class.ilTestResultsImportParser.php.

◆ $user_criteria_type

ilTestResultsImportParser::$user_criteria_type
private

Definition at line 20 of file class.ilTestResultsImportParser.php.


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