ILIAS  release_4-4 Revision
All Data Structures Namespaces Files Functions Variables Modules Pages
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...
 
 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
 ilSaxParser ($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
 PEAR ($error_class=null)
 Constructor. More...
 
 _PEAR ()
 Destructor (the emulated type of...). More...
 
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...
 
 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...
 
 setErrorHandling ($mode=null, $options=null)
 Sets how errors generated by this object should be handled. 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...
 

Private Attributes

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

Additional Inherited Members

- 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 26 of file class.ilTestResultsImportParser.php.

27  {
28  parent::__construct($a_xml_file, true);
29  $this->tst_obj = &$test_object;
30  $this->table = '';
31  $this->active_id_mapping = array();
32  $this->question_id_mapping = array();
33  $this->user_criteria_checked = false;
34  }

Member Function Documentation

◆ handlerBeginTag()

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

handler for begin of element parser

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

References $ilLog, $result, $row, and $usr_id.

52  {
53  global $ilDB;
54 
55  $this->sametag = FALSE;
56  $this->characterbuffer = "";
57  $this->depth[$a_xml_parser]++;
58  $this->path[$this->depth[$a_xml_parser]] = strtolower($a_name);
59  $this->qti_element = $a_name;
60 
61  switch (strtolower($a_name))
62  {
63  case "results":
64  break;
65  case "row":
66  switch ($this->table)
67  {
68  case 'tst_active':
69  if (!$this->user_criteria_checked)
70  {
71  $this->user_criteria_checked = true;
72  if ($ilDB->tableColumnExists('usr_data', $a_attribs['user_criteria']))
73  {
74  include_once './Services/Database/classes/class.ilDBAnalyzer.php';
75  $analyzer = new ilDBAnalyzer();
76  $info = $analyzer->getFieldInformation('usr_data');
77  $this->user_criteria_field = $a_attribs['user_criteria'];
78  $this->user_criteria_type = $info[$a_attribs['user_criteria']]['type'];
79  }
80  }
81  $usr_id = ANONYMOUS_USER_ID;
82  if (strlen($this->user_criteria_field))
83  {
84  $result = $ilDB->queryF("SELECT usr_id FROM usr_data WHERE " . $this->user_criteria_field . " = %s",
85  array($this->user_criteria_type),
86  array($a_attribs[$this->user_criteria_field])
87  );
88  if ($result->numRows())
89  {
90  $row = $ilDB->fetchAssoc($result);
91  $usr_id = $row['usr_id'];
92  }
93  }
94  $next_id = $ilDB->nextId('tst_active');
95  $affectedRows = $ilDB->manipulateF("INSERT INTO tst_active (active_id, user_fi, anonymous_id, test_fi, lastindex, tries, submitted, submittimestamp, tstamp, importname) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
96  array('integer', 'integer', 'text', 'integer', 'integer', 'integer', 'integer', 'timestamp', 'integer', 'text'),
97  array(
98  $next_id,
99  $usr_id,
100  strlen($a_attribs['anonymous_id']) ? $a_attribs['anonymous_id'] : NULL,
101  $this->tst_obj->getTestId(),
102  $a_attribs['lastindex'],
103  $a_attribs['tries'],
104  $a_attribs['submitted'],
105  (strlen($a_attribs['submittimestamp'])) ? $a_attribs['submittimestamp'] : NULL,
106  $a_attribs['tstamp'],
107  $a_attribs['fullname']
108  )
109  );
110  $this->active_id_mapping[$a_attribs['active_id']] = $next_id;
111  break;
112  case 'tst_test_question':
113  $questions = $this->tst_obj->getQuestions();
114  $id = $questions[$a_attribs['sequence']];
115  if ($id > 0)
116  {
117  $this->question_id_mapping[$a_attribs['question_fi']] = $id;
118  }
119  else
120  {
121  $this->question_id_mapping[$a_attribs['question_fi']] = $a_attribs['question_fi'];
122  global $ilLog;
123  $ilLog->write("Error: Could not find question for sequence " . $a_attribs['sequence'] . " of test id " . $this->tst_obj->getTestId());
124  }
125  break;
126  case 'tst_pass_result':
127  $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)",
128  array(
129  'integer',
130  'integer',
131  'float',
132  'float',
133  'integer',
134  'integer',
135  'integer',
136  'integer'
137  ),
138  array(
139  $this->active_id_mapping[$a_attribs['active_fi']],
140  strlen($a_attribs['pass']) ? $a_attribs['pass'] : 0,
141  ($a_attribs["points"]) ? $a_attribs["points"] : 0,
142  ($a_attribs["maxpoints"]) ? $a_attribs["maxpoints"] : 0,
143  $a_attribs["questioncount"],
144  $a_attribs["answeredquestions"],
145  ($a_attribs["workingtime"]) ? $a_attribs["workingtime"] : 0,
146  $a_attribs["tstamp"]
147  )
148  );
149  break;
150  case 'tst_result_cache':
151  $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)",
152  array(
153  'integer',
154  'integer',
155  'float',
156  'float',
157  'text',
158  'text',
159  'integer',
160  'integer',
161  'integer'
162  ),
163  array(
164  $this->active_id_mapping[$a_attribs['active_fi']],
165  strlen($a_attribs['pass']) ? $a_attribs['pass'] : 0,
166  ($a_attribs["max_points"]) ? $a_attribs["max_points"] : 0,
167  ($a_attribs["reached_points"]) ? $a_attribs["reached_points"] : 0,
168  strlen($a_attribs["mark_short"]) ? $a_attribs["mark_short"] : " ",
169  strlen($a_attribs["mark_official"]) ? $a_attribs["mark_official"] : " ",
170  ($a_attribs["passed"]) ? 1 : 0,
171  ($a_attribs["failed"]) ? 1 : 0,
172  $a_attribs["tstamp"]
173  )
174  );
175  break;
176  case 'tst_sequence':
177  $affectedRows = $ilDB->insert("tst_sequence", array(
178  "active_fi" => array("integer", $this->active_id_mapping[$a_attribs['active_fi']]),
179  "pass" => array("integer", $a_attribs['pass']),
180  "sequence" => array("clob", $a_attribs['sequence']),
181  "postponed" => array("text", (strlen($a_attribs['postponed'])) ? $a_attribs['postponed'] : NULL),
182  "hidden" => array("text", (strlen($a_attribs['hidden'])) ? $a_attribs['hidden'] : NULL),
183  "tstamp" => array("integer", $a_attribs['tstamp'])
184  ));
185  break;
186  case 'tst_solutions':
187  $next_id = $ilDB->nextId('tst_solutions');
188  $affectedRows = $ilDB->insert("tst_solutions", array(
189  "solution_id" => array("integer", $next_id),
190  "active_fi" => array("integer", $this->active_id_mapping[$a_attribs['active_fi']]),
191  "question_fi" => array("integer", $this->question_id_mapping[$a_attribs['question_fi']]),
192  "value1" => array("clob", (strlen($a_attribs['value1'])) ? $a_attribs['value1'] : NULL),
193  "value2" => array("clob", (strlen($a_attribs['value2'])) ? $a_attribs['value2'] : NULL),
194  "pass" => array("integer", $a_attribs['pass']),
195  "tstamp" => array("integer", $a_attribs['tstamp'])
196  ));
197  break;
198  case 'tst_test_result':
199  $next_id = $ilDB->nextId('tst_test_result');
200  $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)",
201  array('integer', 'integer','integer', 'float', 'integer', 'integer','integer'),
202  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'])
203  );
204  break;
205  case 'tst_times':
206  $next_id = $ilDB->nextId('tst_times');
207  $affectedRows = $ilDB->manipulateF("INSERT INTO tst_times (times_id, active_fi, started, finished, pass, tstamp) VALUES (%s, %s, %s, %s, %s, %s)",
208  array('integer', 'integer', 'timestamp', 'timestamp', 'integer', 'integer'),
209  array($next_id, $this->active_id_mapping[$a_attribs['active_fi']], $a_attribs['started'], $a_attribs['finished'], $a_attribs['pass'], $a_attribs['tstamp'])
210  );
211  break;
212  }
213  break;
214  default:
215  $this->table = $a_name;
216  break;
217  }
218  }
$result
This class gives all kind of DB information using the MDB2 manager and reverse module.

◆ handlerEndTag()

ilTestResultsImportParser::handlerEndTag (   $a_xml_parser,
  $a_name 
)

handler for end of element

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

References $ilLog.

224  {
225  switch (strtolower($a_name))
226  {
227  case "tst_active":
228  global $ilLog;
229  $ilLog->write("active id mapping: " . print_r($this->active_id_mapping, true));
230  break;
231  case "tst_test_question":
232  global $ilLog;
233  $ilLog->write("question id mapping: " . print_r($this->question_id_mapping, true));
234  break;
235  }
236  }

◆ handlerParseCharacterData()

ilTestResultsImportParser::handlerParseCharacterData (   $a_xml_parser,
  $a_data 
)

handler for character data

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

242  {
243  // do nothing
244  }

◆ setHandlers()

ilTestResultsImportParser::setHandlers (   $a_xml_parser)

set event handler should be overwritten by inherited class private

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

42  {
43  xml_set_object($a_xml_parser,$this);
44  xml_set_element_handler($a_xml_parser,'handlerBeginTag','handlerEndTag');
45  xml_set_character_data_handler($a_xml_parser,'handlerParseCharacterData');
46  }

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

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

◆ $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: