103 switch (strtolower($a_name)) {
107 switch ($this->table) {
109 if (!$this->user_criteria_checked) {
110 $this->user_criteria_checked =
true;
111 if (isset($a_attribs[
'user_criteria'])
112 && $this->db->tableColumnExists(
'usr_data', $a_attribs[
'user_criteria'])) {
114 $info = $analyzer->getFieldInformation(
'usr_data');
115 $this->user_criteria_field = $a_attribs[
'user_criteria'];
116 $this->user_criteria_type = $info[$a_attribs[
'user_criteria']][
'type'];
120 if ($this->user_criteria_field !==
'') {
121 $result = $this->db->queryF(
122 'SELECT usr_id FROM usr_data WHERE ' 123 . $this->user_criteria_field .
' = %s',
124 array($this->user_criteria_type),
125 array($a_attribs[$this->user_criteria_field])
127 if ($result->numRows()) {
128 $row = $this->db->fetchAssoc($result);
129 $usr_id = $row[
'usr_id'];
132 $next_id = $this->db->nextId(
'tst_active');
134 $this->db->insert(
'tst_active', array(
135 'active_id' => array(
'integer', $next_id),
136 'user_fi' => array(
'integer', $usr_id),
137 'anonymous_id' => array(
'text', strlen($a_attribs[
'anonymous_id']) ? $a_attribs[
'anonymous_id'] : null),
138 'test_fi' => array(
'integer', $this->test_obj->getTestId()),
139 'lastindex' => array(
'integer', $a_attribs[
'lastindex']),
140 'tries' => array(
'integer', $a_attribs[
'tries']),
141 'submitted' => array(
'integer', $a_attribs[
'submitted']),
142 'submittimestamp' => array(
'timestamp', strlen($a_attribs[
'submittimestamp']) ? $a_attribs[
'submittimestamp'] : null),
143 'tstamp' => array(
'integer', $a_attribs[
'tstamp']),
144 'importname' => array(
'text', $a_attribs[
'fullname']),
147 'answerstatusfilter' => array(
'integer', $this->
fetchAttribute($a_attribs,
'answer_status_filter')),
148 'objective_container' => array(
'integer', $this->
fetchAttribute($a_attribs,
'objective_container'))
150 $this->active_id_mapping[$a_attribs[
'active_id']] = $next_id;
152 case 'tst_test_rnd_qst':
153 $nextId = $this->db->nextId(
'tst_test_rnd_qst');
154 $newActiveId = $this->active_id_mapping[$a_attribs[
'active_fi']];
155 $newQuestionId = $this->question_id_mapping[$a_attribs[
'question_fi']];
156 $newSrcPoolDefId = $this->src_pool_def_id_mapping[$a_attribs[
'src_pool_def_fi']];
157 $this->db->insert(
'tst_test_rnd_qst', array(
158 'test_random_question_id' => array(
'integer', $nextId),
159 'active_fi' => array(
'integer', $newActiveId),
160 'question_fi' => array(
'integer', $newQuestionId),
161 'sequence' => array(
'integer', $a_attribs[
'sequence']),
162 'pass' => array(
'integer', $a_attribs[
'pass']),
163 'tstamp' => array(
'integer', $a_attribs[
'tstamp']),
164 'src_pool_def_fi' => array(
'integer', $newSrcPoolDefId)
167 case 'tst_pass_result':
168 $affectedRows = $this->db->manipulateF(
169 "INSERT INTO tst_pass_result (active_fi, pass, points, maxpoints, questioncount, answeredquestions, workingtime, tstamp) VALUES (%s,%s,%s,%s,%s,%s,%s,%s)",
181 $this->active_id_mapping[$a_attribs[
'active_fi']],
182 strlen($a_attribs[
'pass']) ? $a_attribs[
'pass'] : 0,
183 ($a_attribs[
"points"]) ? $a_attribs[
"points"] : 0,
184 ($a_attribs[
"maxpoints"]) ? $a_attribs[
"maxpoints"] : 0,
185 $a_attribs[
"questioncount"],
186 $a_attribs[
"answeredquestions"],
187 ($a_attribs[
"workingtime"]) ? $a_attribs[
"workingtime"] : 0,
192 case 'tst_result_cache':
193 $affectedRows = $this->db->manipulateF(
194 "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)",
207 $this->active_id_mapping[$a_attribs[
'active_fi']],
208 strlen($a_attribs[
'pass']) ? $a_attribs[
'pass'] : 0,
209 ($a_attribs[
"max_points"]) ? $a_attribs[
"max_points"] : 0,
210 ($a_attribs[
"reached_points"]) ? $a_attribs[
"reached_points"] : 0,
211 strlen($a_attribs[
"mark_short"]) ? $a_attribs[
"mark_short"] :
" ",
212 strlen($a_attribs[
"mark_official"]) ? $a_attribs[
"mark_official"] :
" ",
213 ($a_attribs[
"passed"]) ? 1 : 0,
214 ($a_attribs[
"failed"]) ? 1 : 0,
220 $affectedRows = $this->db->insert(
"tst_sequence", array(
221 "active_fi" => array(
"integer", $this->active_id_mapping[$a_attribs[
'active_fi']]),
222 "pass" => array(
"integer", $a_attribs[
'pass']),
223 "sequence" => array(
"clob", $a_attribs[
'sequence']),
224 "postponed" => array(
"text", (strlen($a_attribs[
'postponed'])) ? $a_attribs[
'postponed'] : null),
225 "hidden" => array(
"text", (strlen($a_attribs[
'hidden'])) ? $a_attribs[
'hidden'] : null),
226 "tstamp" => array(
"integer", $a_attribs[
'tstamp'])
229 case 'tst_solutions':
230 $next_id = $this->db->nextId(
'tst_solutions');
231 $affectedRows = $this->db->insert(
"tst_solutions", array(
232 "solution_id" => array(
"integer", $next_id),
233 "active_fi" => array(
"integer", $this->active_id_mapping[$a_attribs[
'active_fi']]),
234 "question_fi" => array(
"integer", $this->question_id_mapping[$a_attribs[
'question_fi']]),
236 "value2" => array(
"clob", (strlen($a_attribs[
'value2'])) ? $a_attribs[
'value2'] : null),
237 "pass" => array(
"integer", $a_attribs[
'pass']),
238 "tstamp" => array(
"integer", $a_attribs[
'tstamp'])
241 case 'tst_test_result':
242 $next_id = $this->db->nextId(
'tst_test_result');
243 $affectedRows = $this->db->manipulateF(
244 "INSERT INTO tst_test_result (test_result_id, active_fi, question_fi, points, pass, manual, tstamp) VALUES (%s, %s, %s, %s, %s, %s, %s)",
245 array(
'integer',
'integer',
'integer',
'float',
'integer',
'integer',
'integer'),
246 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'])
250 $next_id = $this->db->nextId(
'tst_times');
251 $affectedRows = $this->db->manipulateF(
252 "INSERT INTO tst_times (times_id, active_fi, started, finished, pass, tstamp) VALUES (%s, %s, %s, %s, %s, %s)",
253 array(
'integer',
'integer',
'timestamp',
'timestamp',
'integer',
'integer'),
254 array($next_id, $this->active_id_mapping[$a_attribs[
'active_fi']], $a_attribs[
'started'], $a_attribs[
'finished'], $a_attribs[
'pass'], $a_attribs[
'tstamp'])
260 $this->table = $a_name;
importParticipantsUploadedFiles(array $a_attribs)
fetchLastFinishedPass($attribs)
fetchLastStartedPass($attribs)
fetchAttribute($attributes, $name)
This class gives all kind of DB information using the database manager and reverse module...