11 include_once(
"./Services/Xml/classes/class.ilSaxParser.php");
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'];
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])
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'),
100 strlen($a_attribs[
'anonymous_id']) ? $a_attribs[
'anonymous_id'] : NULL,
101 $this->tst_obj->getTestId(),
102 $a_attribs[
'lastindex'],
104 $a_attribs[
'submitted'],
105 (strlen($a_attribs[
'submittimestamp'])) ? $a_attribs[
'submittimestamp'] : NULL,
106 $a_attribs[
'tstamp'],
107 $a_attribs[
'fullname']
110 $this->active_id_mapping[$a_attribs[
'active_id']] = $next_id;
112 case 'tst_test_question':
113 $questions = $this->tst_obj->getQuestions();
114 $id = $questions[$a_attribs[
'sequence']];
117 $this->question_id_mapping[$a_attribs[
'question_fi']] = $id;
121 $this->question_id_mapping[$a_attribs[
'question_fi']] = $a_attribs[
'question_fi'];
123 $ilLog->write(
"Error: Could not find question for sequence " . $a_attribs[
'sequence'] .
" of test id " . $this->tst_obj->getTestId());
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)",
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,
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)",
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,
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'])
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'])
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'])
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'])
215 $this->table = $a_name;
225 switch (strtolower($a_name))
229 $ilLog->write(
"active id mapping: " . print_r($this->active_id_mapping,
true));
231 case "tst_test_question":
233 $ilLog->write(
"question id mapping: " . print_r($this->question_id_mapping,
true));