4define(
"SCORE_LAST_PASS", 0);
 
    5define(
"SCORE_BEST_PASS", 1);
 
   30    public static function _updateTestPassResults($active_id, 
$pass, $obligationsEnabled, $questionSetType, 
$objId)
 
   41                        SELECT          SUM(points) reachedpoints, 
   42                                                SUM(hint_count) hint_count, 
   43                                                SUM(hint_points) hint_points, 
   44                                                COUNT(DISTINCT(question_fi)) answeredquestions 
   49            array(
'integer',
'integer'),
 
   50            array($active_id, 
$pass)
 
   54            if ($obligationsEnabled) {
 
   58                                        FROM            tst_test_question 
   61                                        AND                     tst_test_question.test_fi = tst_active.test_fi 
   62                                        LEFT JOIN       tst_test_result 
   63                                        ON                      tst_test_result.active_fi = %s 
   64                                        AND                     tst_test_result.pass = %s 
   65                                        AND                     tst_test_question.question_fi = tst_test_result.question_fi 
   66                                        WHERE           obligatory = 1';
 
   68                $result_obligatory = 
$ilDB->queryF(
 
   70                    array(
'integer',
'integer',
'integer'),
 
   71                    array($active_id, $active_id, 
$pass)
 
   74                $row_obligatory = 
$ilDB->fetchAssoc($result_obligatory);
 
   76                if ($row_obligatory[
'cnt'] == 0) {
 
   77                    $obligations_answered = 1;
 
   79                    $obligations_answered = (int) $row_obligatory[
'answ'];
 
   82                $obligations_answered = 1;
 
   87            if ($row[
'hint_count'] === 
null) {
 
   88                $row[
'hint_count'] = 0;
 
   90            if ($row[
'hint_points'] === 
null) {
 
   91                $row[
'hint_points'] = 0;
 
  100                    'active_fi' => array(
'integer', $active_id),
 
  101                    'pass' => array(
'integer', strlen(
$pass) ? 
$pass : 0)),
 
  103                    'points' => array(
'float',  $row[
'reachedpoints'] ? $row[
'reachedpoints'] : 0),
 
  104                    'maxpoints' => array(
'float',       
$data[
'points']),
 
  105                    'questioncount' => array(
'integer', 
$data[
'count']),
 
  106                    'answeredquestions' => array(
'integer', $row[
'answeredquestions']),
 
  107                    'workingtime' => array(
'integer', $time),
 
  108                    'tstamp' => array(
'integer', time()),
 
  109                    'hint_count' => array(
'integer', $row[
'hint_count']),
 
  110                    'hint_points' => array(
'float',     $row[
'hint_points']),
 
  111                    'obligations_answered' => array(
'integer', $obligations_answered),
 
  112                    'exam_id' => array(
'text',  $exam_identifier)
 
  122        switch ($questionSetType) {
 
  127                                                SELECT          COUNT(qpl_questions.question_id) qcount, 
  128                                                                        SUM(qpl_questions.points) qsum 
  131                                                ON                      tst_tests.test_id = tst_active.test_fi 
  132                                                INNER JOIN      tst_dyn_quest_set_cfg 
  133                                                ON          tst_dyn_quest_set_cfg.test_fi = tst_tests.test_id 
  134                                                INNER JOIN  qpl_questions 
  135                                                ON          qpl_questions.obj_fi = tst_dyn_quest_set_cfg.source_qpl_fi 
  136                                                AND         qpl_questions.original_id IS NULL 
  137                                                AND         qpl_questions.complete = %s 
  138                                                WHERE           tst_active.active_id = %s 
  140                    array(
'integer', 
'integer'),
 
  150                                                SELECT          tst_test_rnd_qst.pass, 
  151                                                                        COUNT(tst_test_rnd_qst.question_fi) qcount, 
  152                                                                        SUM(qpl_questions.points) qsum 
  154                                                FROM            tst_test_rnd_qst, 
  157                                                WHERE           tst_test_rnd_qst.question_fi = qpl_questions.question_id 
  158                                                AND                     tst_test_rnd_qst.active_fi = %s 
  161                                                GROUP BY        tst_test_rnd_qst.active_fi, 
  162                                                                        tst_test_rnd_qst.pass 
  164                    array(
'integer', 
'integer'),
 
  165                    array($active_id, 
$pass)
 
  174                                                SELECT          COUNT(tst_test_question.question_fi) qcount, 
  175                                                                        SUM(qpl_questions.points) qsum 
  177                                                FROM            tst_test_question, 
  181                                                WHERE           tst_test_question.question_fi = qpl_questions.question_id 
  182                                                AND                     tst_test_question.test_fi = tst_active.test_fi 
  183                                                AND                     tst_active.active_id = %s 
  185                                                GROUP BY        tst_test_question.test_fi 
  195                throw new ilTestException(
"not supported question set type: $questionSetType");
 
  200        if (is_array($row)) {
 
  201            return array(
"count" => $row[
"qcount"], 
"points" => $row[
"qsum"]);
 
  204        return array(
"count" => 0, 
"points" => 0);
 
  212            "SELECT * FROM tst_times WHERE active_fi = %s AND pass = %s ORDER BY started",
 
  213            array(
'integer',
'integer'),
 
  214            array($active_id, 
$pass)
 
  218            preg_match(
"/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/", $row[
"started"], $matches);
 
  219            $epoch_1 = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
 
  220            preg_match(
"/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/", $row[
"finished"], $matches);
 
  221            $epoch_2 = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
 
  222            $time += ($epoch_2 - $epoch_1);
 
  234        $exam_id_query = 
'SELECT exam_id FROM tst_pass_result WHERE active_fi = %s AND pass = %s';
 
  235        $exam_id_result = 
$ilDB->queryF($exam_id_query, array( 
'integer', 
'integer' ), array( $active_id, 
$pass ));
 
  236        if (
$ilDB->numRows($exam_id_result) == 1) {
 
  237            $exam_id_row = 
$ilDB->fetchAssoc($exam_id_result);
 
  239            if ($exam_id_row[
'exam_id'] != 
null) {
 
  240                return $exam_id_row[
'exam_id'];
 
  245        return 'I' . $inst_id . 
'_T' . $obj_id . 
'_A' . $active_id . 
'_P' . 
$pass;
 
  255                        SELECT          tst_pass_result.* 
  263            array(
'integer',
'integer'),
 
  264            array($active_id, 
$pass)
 
  269        $max = $row[
'maxpoints'];
 
  270        $reached = $row[
'points'];
 
  272        $obligationsAnswered = (int) $row[
'obligations_answered'];
 
  274        $percentage = (!$max) ? 0 : ($reached / $max) * 100.0;
 
  276        $mark = self::_getMatchingMarkFromActiveId($active_id, $percentage);
 
  278        $isPassed = ($mark[
"passed"] ? 1 : 0);
 
  279        $isFailed = (!$mark[
"passed"] ? 1 : 0);
 
  282                        DELETE FROM             tst_result_cache 
  286        $affectedRows = 
$ilDB->manipulateF(
 
  292        $ilDB->insert(
'tst_result_cache', array(
 
  293            'active_fi' => array(
'integer', $active_id),
 
  294            'pass' => array(
'integer', strlen(
$pass) ? 
$pass : 0),
 
  295            'max_points' => array(
'float', strlen($max) ? $max : 0),
 
  296            'reached_points' => array(
'float', strlen($reached) ? $reached : 0),
 
  297            'mark_short' => array(
'text', strlen($mark[
"short_name"]) ? $mark[
"short_name"] : 
" "),
 
  298            'mark_official' => array(
'text', strlen($mark[
"official_name"]) ? $mark[
"official_name"] : 
" "),
 
  299            'passed' => array(
'integer', $isPassed),
 
  300            'failed' => array(
'integer', $isFailed),
 
  301            'tstamp' => array(
'integer', time()),
 
  302            'hint_count' => array(
'integer', $row[
'hint_count']),
 
  303            'hint_points' => array(
'float', $row[
'hint_points']),
 
  304            'obligations_answered' => array(
'integer', $obligationsAnswered)
 
  310        $counted_pass = 
null;
 
  316        return $counted_pass;
 
  324            "SELECT * FROM tst_pass_result WHERE active_fi = %s",
 
  332                if ($row[
"maxpoints"] > 0) {
 
  333                    $factor = $row[
"points"] / $row[
"maxpoints"];
 
  338                if ($factor > $bestfactor) {
 
  340                    $bestfactor = $factor;
 
  343            if (is_array($bestrow)) {
 
  344                return $bestrow[
"pass"];
 
  357            "SELECT MAX(pass) maxpass FROM tst_test_result WHERE active_fi = %s",
 
  363            $max = $row[
"maxpass"];
 
  370    private static function _getMatchingMarkFromActiveId($active_id, $percentage)
 
  375            "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",
 
  382            if ($percentage >= $row[
"minimum_level"]) {
 
An exception for terminatinating execution or to throw for unit testing.
static _getResultPass($active_id, $passScoring)
static _getBestPass($active_id)
static _getMaxPass($active_id)
static _updateTestResultCache($active_id, $passScoring)
const QUESTION_SET_TYPE_FIXED
type setting value for fixed question set
static getExamId($active_id, $pass, $obj_id)
static _getWorkingTimeOfParticipantForPass($active_id, $pass)
static _getQuestionCountAndPointsForPassOfParticipant($active_id, $pass, $questionSetType)
const QUESTION_SET_TYPE_RANDOM
type setting value for random question set
const QUESTION_SET_TYPE_DYNAMIC
type setting value for dynamic question set (continues testing mode)
Base Exception for all Exceptions relating to Modules/Test.
foreach($_POST as $key=> $value) $res