11 include_once(
"./Services/Xml/classes/class.ilSaxParser.php");
28 parent::__construct($a_xml_file,
true);
29 $this->tst_obj = &$test_object;
31 $this->active_id_mapping = array();
32 $this->question_id_mapping = array();
33 $this->user_criteria_checked =
false;
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');
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;
61 switch (strtolower($a_name))
69 if (!$this->user_criteria_checked)
71 $this->user_criteria_checked =
true;
72 if ($ilDB->tableColumnExists(
'usr_data', $a_attribs[
'user_criteria']))
74 include_once
'./Services/Database/classes/class.ilDBAnalyzer.php';
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'];
81 $usr_id = ANONYMOUS_USER_ID;
82 if (strlen($this->user_criteria_field))
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])
91 $usr_id =
$row[
'usr_id'];
94 $next_id = $ilDB->nextId(
'tst_active');
96 $ilDB->insert(
'tst_active', array(
97 'active_id' => array(
'integer', $next_id),
98 'user_fi' => array(
'integer', $usr_id),
99 'anonymous_id' => array(
'text', strlen($a_attribs[
'anonymous_id']) ? $a_attribs[
'anonymous_id'] : NULL),
100 'test_fi' => array(
'integer', $this->tst_obj->getTestId()),
101 'lastindex' => array(
'integer', $a_attribs[
'lastindex']),
102 'tries' => array(
'integer', $a_attribs[
'tries']),
103 'submitted' => array(
'integer', $a_attribs[
'submitted']),
104 'submittimestamp' => array(
'timestamp', strlen($a_attribs[
'submittimestamp']) ? $a_attribs[
'submittimestamp'] : NULL),
105 'tstamp' => array(
'integer', $a_attribs[
'tstamp']),
106 'importname' => array(
'text', $a_attribs[
'fullname']),
108 'answerstatusfilter' => array(
'integer', $this->
fetchAttribute($a_attribs,
'answer_status_filter')),
109 'objective_container' => array(
'integer', $this->
fetchAttribute($a_attribs,
'objective_container'))
111 $this->active_id_mapping[$a_attribs[
'active_id']] = $next_id;
113 case 'tst_test_question':
114 $questions = $this->tst_obj->getQuestions();
115 $id = $questions[$a_attribs[
'sequence']];
118 $this->question_id_mapping[$a_attribs[
'question_fi']] = $id;
122 $this->question_id_mapping[$a_attribs[
'question_fi']] = $a_attribs[
'question_fi'];
124 $ilLog->write(
"Error: Could not find question for sequence " . $a_attribs[
'sequence'] .
" of test id " . $this->tst_obj->getTestId());
127 case 'tst_pass_result':
128 $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)",
140 $this->active_id_mapping[$a_attribs[
'active_fi']],
141 strlen($a_attribs[
'pass']) ? $a_attribs[
'pass'] : 0,
142 ($a_attribs[
"points"]) ? $a_attribs[
"points"] : 0,
143 ($a_attribs[
"maxpoints"]) ? $a_attribs[
"maxpoints"] : 0,
144 $a_attribs[
"questioncount"],
145 $a_attribs[
"answeredquestions"],
146 ($a_attribs[
"workingtime"]) ? $a_attribs[
"workingtime"] : 0,
151 case 'tst_result_cache':
152 $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)",
165 $this->active_id_mapping[$a_attribs[
'active_fi']],
166 strlen($a_attribs[
'pass']) ? $a_attribs[
'pass'] : 0,
167 ($a_attribs[
"max_points"]) ? $a_attribs[
"max_points"] : 0,
168 ($a_attribs[
"reached_points"]) ? $a_attribs[
"reached_points"] : 0,
169 strlen($a_attribs[
"mark_short"]) ? $a_attribs[
"mark_short"] :
" ",
170 strlen($a_attribs[
"mark_official"]) ? $a_attribs[
"mark_official"] :
" ",
171 ($a_attribs[
"passed"]) ? 1 : 0,
172 ($a_attribs[
"failed"]) ? 1 : 0,
178 $affectedRows = $ilDB->insert(
"tst_sequence", array(
179 "active_fi" => array(
"integer", $this->active_id_mapping[$a_attribs[
'active_fi']]),
180 "pass" => array(
"integer", $a_attribs[
'pass']),
181 "sequence" => array(
"clob", $a_attribs[
'sequence']),
182 "postponed" => array(
"text", (strlen($a_attribs[
'postponed'])) ? $a_attribs[
'postponed'] : NULL),
183 "hidden" => array(
"text", (strlen($a_attribs[
'hidden'])) ? $a_attribs[
'hidden'] : NULL),
184 "tstamp" => array(
"integer", $a_attribs[
'tstamp'])
187 case 'tst_solutions':
188 $next_id = $ilDB->nextId(
'tst_solutions');
189 $affectedRows = $ilDB->insert(
"tst_solutions", array(
190 "solution_id" => array(
"integer", $next_id),
191 "active_fi" => array(
"integer", $this->active_id_mapping[$a_attribs[
'active_fi']]),
192 "question_fi" => array(
"integer", $this->question_id_mapping[$a_attribs[
'question_fi']]),
193 "value1" => array(
"clob", (strlen($a_attribs[
'value1'])) ? $a_attribs[
'value1'] : NULL),
194 "value2" => array(
"clob", (strlen($a_attribs[
'value2'])) ? $a_attribs[
'value2'] : NULL),
195 "pass" => array(
"integer", $a_attribs[
'pass']),
196 "tstamp" => array(
"integer", $a_attribs[
'tstamp'])
199 case 'tst_test_result':
200 $next_id = $ilDB->nextId(
'tst_test_result');
201 $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)",
202 array(
'integer',
'integer',
'integer',
'float',
'integer',
'integer',
'integer'),
203 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'])
207 $next_id = $ilDB->nextId(
'tst_times');
208 $affectedRows = $ilDB->manipulateF(
"INSERT INTO tst_times (times_id, active_fi, started, finished, pass, tstamp) VALUES (%s, %s, %s, %s, %s, %s)",
209 array(
'integer',
'integer',
'timestamp',
'timestamp',
'integer',
'integer'),
210 array($next_id, $this->active_id_mapping[$a_attribs[
'active_fi']], $a_attribs[
'started'], $a_attribs[
'finished'], $a_attribs[
'pass'], $a_attribs[
'tstamp'])
216 $this->table = $a_name;
226 switch (strtolower($a_name))
230 $ilLog->write(
"active id mapping: " . print_r($this->active_id_mapping,
true));
232 case "tst_test_question":
234 $ilLog->write(
"question id mapping: " . print_r($this->question_id_mapping,
true));
249 if( isset($attributes[$name]) )
251 return $attributes[$name];
259 if( isset($attribs[
'last_finished_pass']) )
261 return $attribs[
'last_finished_pass'];
264 if( $attribs[
'tries'] > 0 )
266 return $attribs[
'tries'] - 1;
handlerParseCharacterData($a_xml_parser, $a_data)
handler for character data
handlerEndTag($a_xml_parser, $a_name)
handler for end of element
Base class for sax-based expat parsing extended classes need to overwrite the method setHandlers and ...
handlerBeginTag($a_xml_parser, $a_name, $a_attribs)
handler for begin of element parser
__construct($a_xml_file, &$test_object)
Constructor.
fetchLastFinishedPass($attribs)
Test results import parser.
fetchAttribute($attributes, $name)
This class gives all kind of DB information using the MDB2 manager and reverse module.
setHandlers($a_xml_parser)
set event handler should be overwritten by inherited class private