ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
DBUpdateTestResultCalculator Class Reference
+ Collaboration diagram for DBUpdateTestResultCalculator:

Static Public Member Functions

static _updateTestResultCache ($active_id, $passScoring)

Data Fields

const QUESTION_SET_TYPE_FIXED = 'FIXED_QUEST_SET'
 type setting value for fixed question set
const QUESTION_SET_TYPE_RANDOM = 'RANDOM_QUEST_SET'
 type setting value for random question set
const QUESTION_SET_TYPE_DYNAMIC = 'DYNAMIC_QUEST_SET'
 type setting value for dynamic question set (continues testing mode)

Static Private Member Functions

static _getQuestionCountAndPointsForPassOfParticipant ($active_id, $pass, $questionSetType)
static _getWorkingTimeOfParticipantForPass ($active_id, $pass)
static getExamId ($active_id, $pass, $obj_id)
static _getResultPass ($active_id, $passScoring)
static _getBestPass ($active_id)
static _getMaxPass ($active_id)

Detailed Description

Definition at line 13 of file class.DBUpdateTestResultCalculator.php.

Member Function Documentation

static DBUpdateTestResultCalculator::_getBestPass (   $active_id)
staticprivate

Definition at line 318 of file class.DBUpdateTestResultCalculator.php.

References $ilDB, $result, and $row.

Referenced by _getResultPass().

{
global $ilDB;
$result = $ilDB->queryF("SELECT * FROM tst_pass_result WHERE active_fi = %s",
array('integer'),
array($active_id)
);
if ($result->numRows())
{
$bestrow = null;
$bestfactor = 0;
while ($row = $ilDB->fetchAssoc($result))
{
if($row["maxpoints"] > 0)
{
$factor = $row["points"] / $row["maxpoints"];
}
else
{
$factor = 0;
}
if($factor > $bestfactor)
{
$bestrow = $row;
$bestfactor = $factor;
}
}
if (is_array($bestrow))
{
return $bestrow["pass"];
}
else
{
return 0;
}
}
else
{
return 0;
}
}

+ Here is the caller graph for this function:

static DBUpdateTestResultCalculator::_getMaxPass (   $active_id)
staticprivate

Definition at line 362 of file class.DBUpdateTestResultCalculator.php.

References $ilDB, $result, and $row.

Referenced by _getResultPass().

{
global $ilDB;
$result = $ilDB->queryF("SELECT MAX(pass) maxpass FROM tst_test_result WHERE active_fi = %s",
array('integer'),
array($active_id)
);
if ($result->numRows())
{
$row = $ilDB->fetchAssoc($result);
$max = $row["maxpass"];
}
else
{
$max = NULL;
}
return $max;
}

+ Here is the caller graph for this function:

static DBUpdateTestResultCalculator::_getQuestionCountAndPointsForPassOfParticipant (   $active_id,
  $pass,
  $questionSetType 
)
staticprivate

Definition at line 117 of file class.DBUpdateTestResultCalculator.php.

References $ilDB, $pass, $res, and $row.

{
global $ilDB;
switch( $questionSetType )
{
case self::QUESTION_SET_TYPE_DYNAMIC:
$res = $ilDB->queryF("
SELECT COUNT(qpl_questions.question_id) qcount,
SUM(qpl_questions.points) qsum
FROM tst_active
INNER JOIN tst_tests
ON tst_tests.test_id = tst_active.test_fi
INNER JOIN tst_dyn_quest_set_cfg
ON tst_dyn_quest_set_cfg.test_fi = tst_tests.test_id
INNER JOIN qpl_questions
ON qpl_questions.obj_fi = tst_dyn_quest_set_cfg.source_qpl_fi
AND qpl_questions.original_id IS NULL
AND qpl_questions.complete = %s
WHERE tst_active.active_id = %s
",
array('integer', 'integer'),
array(1, $active_id)
);
break;
case self::QUESTION_SET_TYPE_RANDOM:
$res = $ilDB->queryF("
SELECT tst_test_rnd_qst.pass,
COUNT(tst_test_rnd_qst.question_fi) qcount,
SUM(qpl_questions.points) qsum
FROM tst_test_rnd_qst,
qpl_questions
WHERE tst_test_rnd_qst.question_fi = qpl_questions.question_id
AND tst_test_rnd_qst.active_fi = %s
AND pass = %s
GROUP BY tst_test_rnd_qst.active_fi,
tst_test_rnd_qst.pass
",
array('integer', 'integer'),
array($active_id, $pass)
);
break;
case self::QUESTION_SET_TYPE_FIXED:
$res = $ilDB->queryF("
SELECT COUNT(tst_test_question.question_fi) qcount,
SUM(qpl_questions.points) qsum
FROM tst_test_question,
qpl_questions,
tst_active
WHERE tst_test_question.question_fi = qpl_questions.question_id
AND tst_test_question.test_fi = tst_active.test_fi
AND tst_active.active_id = %s
GROUP BY tst_test_question.test_fi
",
array('integer'),
array($active_id)
);
break;
default:
throw new ilTestException("not supported question set type: $questionSetType");
}
$row = $ilDB->fetchAssoc($res);
if( is_array($row) )
{
return array("count" => $row["qcount"], "points" => $row["qsum"]);
}
return array("count" => 0, "points" => 0);
}
static DBUpdateTestResultCalculator::_getResultPass (   $active_id,
  $passScoring 
)
staticprivate

Definition at line 304 of file class.DBUpdateTestResultCalculator.php.

References _getBestPass(), _getMaxPass(), and SCORE_BEST_PASS.

Referenced by _updateTestResultCache().

{
$counted_pass = NULL;
if ($passScoring == SCORE_BEST_PASS)
{
$counted_pass = self::_getBestPass($active_id);
}
else
{
$counted_pass = self::_getMaxPass($active_id);
}
return $counted_pass;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static DBUpdateTestResultCalculator::_getWorkingTimeOfParticipantForPass (   $active_id,
  $pass 
)
staticprivate

Definition at line 205 of file class.DBUpdateTestResultCalculator.php.

References $ilDB, $pass, $result, and $row.

{
global $ilDB;
$result = $ilDB->queryF("SELECT * FROM tst_times WHERE active_fi = %s AND pass = %s ORDER BY started",
array('integer','integer'),
array($active_id, $pass)
);
$time = 0;
while ($row = $ilDB->fetchAssoc($result))
{
preg_match("/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/", $row["started"], $matches);
$epoch_1 = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
preg_match("/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/", $row["finished"], $matches);
$epoch_2 = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
$time += ($epoch_2 - $epoch_1);
}
return $time;
}
static DBUpdateTestResultCalculator::_updateTestResultCache (   $active_id,
  $passScoring 
)
static

Definition at line 248 of file class.DBUpdateTestResultCalculator.php.

References $ilDB, $pass, $query, $result, $row, and _getResultPass().

{
global $ilDB;
$pass = self::_getResultPass($active_id, $passScoring);
$query = "
SELECT tst_pass_result.*
FROM tst_pass_result
WHERE active_fi = %s
AND pass = %s
";
$result = $ilDB->queryF(
$query, array('integer','integer'), array($active_id, $pass)
);
$row = $ilDB->fetchAssoc($result);
$max = $row['maxpoints'];
$reached = $row['points'];
$obligationsAnswered = (int)$row['obligations_answered'];
$percentage = (!$max) ? 0 : ($reached / $max) * 100.0;
$mark = self::_getMatchingMarkFromActiveId($active_id, $percentage);
$isPassed = ( $mark["passed"] ? 1 : 0 );
$isFailed = ( !$mark["passed"] ? 1 : 0 );
$query = "
DELETE FROM tst_result_cache
WHERE active_fi = %s
";
$affectedRows = $ilDB->manipulateF(
$query, array('integer'), array($active_id)
);
$ilDB->insert('tst_result_cache', array(
'active_fi'=> array('integer', $active_id),
'pass'=> array('integer', strlen($pass) ? $pass : 0),
'max_points'=> array('float', strlen($max) ? $max : 0),
'reached_points'=> array('float', strlen($reached) ? $reached : 0),
'mark_short'=> array('text', strlen($mark["short_name"]) ? $mark["short_name"] : " "),
'mark_official'=> array('text', strlen($mark["official_name"]) ? $mark["official_name"] : " "),
'passed'=> array('integer', $isPassed),
'failed'=> array('integer', $isFailed),
'tstamp'=> array('integer', time()),
'hint_count'=> array('integer', $row['hint_count']),
'hint_points'=> array('float', $row['hint_points']),
'obligations_answered' => array('integer', $obligationsAnswered)
));
}

+ Here is the call graph for this function:

static DBUpdateTestResultCalculator::getExamId (   $active_id,
  $pass,
  $obj_id 
)
staticprivate

Move this to a proper place.

Definition at line 225 of file class.DBUpdateTestResultCalculator.php.

References $ilDB, $ilSetting, and $pass.

{
global $ilDB;
$exam_id_query = 'SELECT exam_id FROM tst_pass_result WHERE active_fi = %s AND pass = %s';
$exam_id_result = $ilDB->queryF( $exam_id_query, array( 'integer', 'integer' ), array( $active_id, $pass ) );
if ($ilDB->numRows( $exam_id_result ) == 1)
{
$exam_id_row = $ilDB->fetchAssoc( $exam_id_result );
if ($exam_id_row['exam_id'] != null)
{
return $exam_id_row['exam_id'];
}
}
$inst_id = $ilSetting->get( 'inst_id', null );
return 'I' . $inst_id . '_T' . $obj_id . '_A' . $active_id . '_P' . $pass;
}

Field Documentation

const DBUpdateTestResultCalculator::QUESTION_SET_TYPE_DYNAMIC = 'DYNAMIC_QUEST_SET'

type setting value for dynamic question set (continues testing mode)

Definition at line 28 of file class.DBUpdateTestResultCalculator.php.

const DBUpdateTestResultCalculator::QUESTION_SET_TYPE_FIXED = 'FIXED_QUEST_SET'

type setting value for fixed question set

Definition at line 18 of file class.DBUpdateTestResultCalculator.php.

const DBUpdateTestResultCalculator::QUESTION_SET_TYPE_RANDOM = 'RANDOM_QUEST_SET'

type setting value for random question set

Definition at line 23 of file class.DBUpdateTestResultCalculator.php.


The documentation for this class was generated from the following file: