4 define(
"SCORE_LAST_PASS", 0);
5 define(
"SCORE_BEST_PASS", 1);
30 public static function _updateTestPassResults($active_id,
$pass, $obligationsEnabled, $questionSetType, $objId)
34 $data = self::_getQuestionCountAndPointsForPassOfParticipant($active_id,
$pass, $questionSetType);
35 $time = self::_getWorkingTimeOfParticipantForPass($active_id,
$pass);
40 SELECT SUM(points) reachedpoints, 41 SUM(hint_count) hint_count, 42 SUM(hint_points) hint_points, 43 COUNT(DISTINCT(question_fi)) answeredquestions 48 array(
'integer',
'integer'),
54 if( $obligationsEnabled )
59 FROM tst_test_question 62 AND tst_test_question.test_fi = tst_active.test_fi 63 LEFT JOIN tst_test_result 64 ON tst_test_result.active_fi = %s 65 AND tst_test_result.pass = %s 66 AND tst_test_question.question_fi = tst_test_result.question_fi 67 WHERE obligatory = 1';
69 $result_obligatory = $ilDB->queryF(
73 $row_obligatory = $ilDB->fetchAssoc($result_obligatory);
75 if ($row_obligatory[
'cnt'] == 0)
77 $obligations_answered = 1;
81 $obligations_answered = (int) $row_obligatory[
'answ'];
86 $obligations_answered = 1;
91 if(
$row[
'hint_count'] === null )
$row[
'hint_count'] = 0;
92 if(
$row[
'hint_points'] === null )
$row[
'hint_points'] = 0;
94 $exam_identifier = self::getExamId( $active_id,
$pass, $objId );
97 $ilDB->replace(
'tst_pass_result',
99 'active_fi' =>
array(
'integer', $active_id),
102 'points' =>
array(
'float',
$row[
'reachedpoints'] ?
$row[
'reachedpoints'] : 0),
103 'maxpoints' =>
array(
'float',
$data[
'points']),
104 'questioncount' =>
array(
'integer',
$data[
'count']),
105 'answeredquestions' =>
array(
'integer', $row[
'answeredquestions']),
106 'workingtime' =>
array(
'integer', $time),
108 'hint_count' =>
array(
'integer', $row[
'hint_count']),
109 'hint_points' =>
array(
'float', $row[
'hint_points']),
110 'obligations_answered' =>
array(
'integer', $obligations_answered),
111 'exam_id' =>
array(
'text', $exam_identifier)
121 switch( $questionSetType )
123 case self::QUESTION_SET_TYPE_DYNAMIC:
125 $res = $ilDB->queryF(
" 126 SELECT COUNT(qpl_questions.question_id) qcount, 127 SUM(qpl_questions.points) qsum 130 ON tst_tests.test_id = tst_active.test_fi 131 INNER JOIN tst_dyn_quest_set_cfg 132 ON tst_dyn_quest_set_cfg.test_fi = tst_tests.test_id 133 INNER JOIN qpl_questions 134 ON qpl_questions.obj_fi = tst_dyn_quest_set_cfg.source_qpl_fi 135 AND qpl_questions.original_id IS NULL 136 AND qpl_questions.complete = %s 137 WHERE tst_active.active_id = %s 139 array(
'integer',
'integer'),
145 case self::QUESTION_SET_TYPE_RANDOM:
147 $res = $ilDB->queryF(
" 148 SELECT tst_test_rnd_qst.pass, 149 COUNT(tst_test_rnd_qst.question_fi) qcount, 150 SUM(qpl_questions.points) qsum 152 FROM tst_test_rnd_qst, 155 WHERE tst_test_rnd_qst.question_fi = qpl_questions.question_id 156 AND tst_test_rnd_qst.active_fi = %s 159 GROUP BY tst_test_rnd_qst.active_fi, 160 tst_test_rnd_qst.pass 162 array(
'integer',
'integer'),
168 case self::QUESTION_SET_TYPE_FIXED:
170 $res = $ilDB->queryF(
" 171 SELECT COUNT(tst_test_question.question_fi) qcount, 172 SUM(qpl_questions.points) qsum 174 FROM tst_test_question, 178 WHERE tst_test_question.question_fi = qpl_questions.question_id 179 AND tst_test_question.test_fi = tst_active.test_fi 180 AND tst_active.active_id = %s 182 GROUP BY tst_test_question.test_fi 192 throw new ilTestException(
"not supported question set type: $questionSetType");
199 return array(
"count" =>
$row[
"qcount"],
"points" =>
$row[
"qsum"]);
202 return array(
"count" => 0,
"points" => 0);
209 $result = $ilDB->queryF(
"SELECT * FROM tst_times WHERE active_fi = %s AND pass = %s ORDER BY started",
210 array(
'integer',
'integer'),
216 preg_match(
"/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/",
$row[
"started"], $matches);
217 $epoch_1 = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
218 preg_match(
"/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/",
$row[
"finished"], $matches);
219 $epoch_2 = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
220 $time += ($epoch_2 - $epoch_1);
232 $exam_id_query =
'SELECT exam_id FROM tst_pass_result WHERE active_fi = %s AND pass = %s';
233 $exam_id_result = $ilDB->queryF( $exam_id_query,
array(
'integer',
'integer' ),
array( $active_id,
$pass ) );
234 if ($ilDB->numRows( $exam_id_result ) == 1)
236 $exam_id_row = $ilDB->fetchAssoc( $exam_id_result );
238 if ($exam_id_row[
'exam_id'] != null)
240 return $exam_id_row[
'exam_id'];
244 $inst_id =
$ilSetting->get(
'inst_id', null );
245 return 'I' . $inst_id .
'_T' . $obj_id .
'_A' . $active_id .
'_P' .
$pass;
252 $pass = self::_getResultPass($active_id, $passScoring);
255 SELECT tst_pass_result.* 267 $max =
$row[
'maxpoints'];
268 $reached =
$row[
'points'];
270 $obligationsAnswered = (int)
$row[
'obligations_answered'];
272 $percentage = (!$max) ? 0 : ($reached / $max) * 100.0;
274 $mark = self::_getMatchingMarkFromActiveId($active_id, $percentage);
276 $isPassed = ( $mark[
"passed"] ? 1 : 0 );
277 $isFailed = ( !$mark[
"passed"] ? 1 : 0 );
280 DELETE FROM tst_result_cache 284 $affectedRows = $ilDB->manipulateF(
288 $ilDB->insert(
'tst_result_cache',
array(
289 'active_fi'=>
array(
'integer', $active_id),
291 'max_points'=>
array(
'float', strlen($max) ? $max : 0),
292 'reached_points'=>
array(
'float', strlen($reached) ? $reached : 0),
293 'mark_short'=>
array(
'text', strlen($mark[
"short_name"]) ? $mark[
"short_name"] :
" "),
294 'mark_official'=>
array(
'text', strlen($mark[
"official_name"]) ? $mark[
"official_name"] :
" "),
295 'passed'=>
array(
'integer', $isPassed),
296 'failed'=>
array(
'integer', $isFailed),
298 'hint_count'=>
array(
'integer',
$row[
'hint_count']),
299 'hint_points'=>
array(
'float',
$row[
'hint_points']),
300 'obligations_answered' =>
array(
'integer', $obligationsAnswered)
306 $counted_pass = NULL;
309 $counted_pass = self::_getBestPass($active_id);
313 $counted_pass = self::_getMaxPass($active_id);
315 return $counted_pass;
322 $result = $ilDB->queryF(
"SELECT * FROM tst_pass_result WHERE active_fi = %s",
332 if(
$row[
"maxpoints"] > 0)
334 $factor =
$row[
"points"] /
$row[
"maxpoints"];
341 if($factor > $bestfactor)
344 $bestfactor = $factor;
347 if (is_array($bestrow))
349 return $bestrow[
"pass"];
365 $result = $ilDB->queryF(
"SELECT MAX(pass) maxpass FROM tst_test_result WHERE active_fi = %s",
372 $max =
$row[
"maxpass"];
381 private static function _getMatchingMarkFromActiveId($active_id, $percentage)
385 $result = $ilDB->queryF(
"SELECT tst_mark.* FROM tst_active, tst_mark, tst_tests WHERE tst_mark.test_fi = tst_tests.test_id AND tst_tests.test_id = tst_active.test_fi AND tst_active.active_id = %s ORDER BY minimum_level DESC",
393 if ($percentage >=
$row[
"minimum_level"])
static _getMaxPass($active_id)
static _getResultPass($active_id, $passScoring)
Base Exception for all Exceptions relating to Modules/Test.
static _getBestPass($active_id)
static _getWorkingTimeOfParticipantForPass($active_id, $pass)
const QUESTION_SET_TYPE_DYNAMIC
type setting value for dynamic question set (continues testing mode)
static getExamId($active_id, $pass, $obj_id)
Create styles array
The data for the language used.
static _getQuestionCountAndPointsForPassOfParticipant($active_id, $pass, $questionSetType)
const QUESTION_SET_TYPE_RANDOM
type setting value for random question set
const QUESTION_SET_TYPE_FIXED
type setting value for fixed question set
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
static _updateTestResultCache($active_id, $passScoring)