4define(
"SCORE_LAST_PASS", 0);
 
    5define(
"SCORE_BEST_PASS", 1);
 
   30        public static function _updateTestPassResults($active_id, 
$pass, $obligationsEnabled, $questionSetType, $objId)
 
   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'),
 
   49                        array($active_id, 
$pass)
 
   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(
 
   70                                        $query, array(
'integer',
'integer',
'integer'), array($active_id, $active_id, 
$pass)
 
   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;
 
   97                        $ilDB->replace(
'tst_pass_result',
 
   99                                        'active_fi'                     => array(
'integer', $active_id),
 
  100                                        'pass'                                  => array(
'integer', strlen(
$pass) ? 
$pass : 0)),
 
  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),
 
  107                                        'tstamp'                                => 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 )
 
  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'),
 
  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'),
 
  163                                        array($active_id, 
$pass)
 
  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'),
 
  211                        array($active_id, 
$pass)
 
  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;
 
  255                        SELECT          tst_pass_result.* 
  262                        $query, array(
'integer',
'integer'), array($active_id, 
$pass)
 
  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(
 
  285                        $query, array(
'integer'), array($active_id)
 
  288                $ilDB->insert(
'tst_result_cache', array(
 
  289                        'active_fi'=> array(
'integer', $active_id),
 
  290                        'pass'=> array(
'integer', strlen(
$pass) ? 
$pass : 0),
 
  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),
 
  297                        'tstamp'=> array(
'integer', time()),
 
  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;
 
  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 _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.