/** * Determine status * * @param integer object id * @param integer user id * @param object object (optional depends on object type) * @return integer status */ function determineStatus($a_obj_id, $a_user_id, $a_obj = null) { global $ilDB; include_once './Modules/Test/classes/class.ilObjTestAccess.php'; $res = $ilDB->query("\n\t\t\tSELECT active_id, user_fi, tries, COUNT(tst_sequence.active_fi) sequences\n\t\t\tFROM tst_active\n\t\t\tLEFT JOIN tst_sequence\n\t\t\tON tst_sequence.active_fi = tst_active.active_id\n\t\t\tWHERE user_fi = {$ilDB->quote($a_user_id, "integer")}\n\t\t\tAND test_fi = {$ilDB->quote(ilObjTestAccess::_getTestIDFromObjectID($a_obj_id))}\n\t\t\tGROUP BY active_id, user_fi, tries\n\t\t"); $status = self::LP_STATUS_NOT_ATTEMPTED_NUM; if ($rec = $ilDB->fetchAssoc($res)) { if ($rec['sequences'] > 0) { $status = self::LP_STATUS_IN_PROGRESS_NUM; if ($rec['tries'] > 0) { $status = self::LP_STATUS_COMPLETED_NUM; } } } return $status; }
/** * Determine status * * @param integer object id * @param integer user id * @param object object (optional depends on object type) * @return integer status */ function determineStatus($a_obj_id, $a_user_id, $a_obj = null) { global $ilObjDataCache, $ilDB, $ilLog; $status = self::LP_STATUS_NOT_ATTEMPTED_NUM; include_once './Modules/Test/classes/class.ilObjTestAccess.php'; $res = $ilDB->query("SELECT tries FROM tst_active" . " WHERE user_fi = " . $ilDB->quote($a_user_id, "integer") . " AND test_fi = " . $ilDB->quote(ilObjTestAccess::_getTestIDFromObjectID($a_obj_id))); if ($rec = $ilDB->fetchAssoc($res)) { if ($rec["tries"] == 0) { $status = self::LP_STATUS_IN_PROGRESS_NUM; } else { if ($rec["tries"] > 0) { $status = self::LP_STATUS_COMPLETED_NUM; } } } return $status; }
/** * Returns information if a specific user has finished a test * * @param integer $user_id Database id of the user * @param integer test obj_id * @return bool * @access public * @static */ function _hasFinished($a_user_id, $a_obj_id) { global $ilDB; $res = $ilDB->queryF("SELECT active_id FROM tst_active WHERE user_fi = %s AND test_fi = %s AND tries > '0'", array('integer', 'integer'), array($a_user_id, ilObjTestAccess::_getTestIDFromObjectID($a_obj_id))); return $res->numRows() ? true : false; }
/** * Returns true, if a test is complete for use * * @return boolean True, if the test is complete for use, otherwise false * @access public */ function _isComplete($a_obj_id) { global $ilDB; $test_id = ilObjTestAccess::_getTestIDFromObjectID($a_obj_id); $result = $ilDB->queryF("SELECT tst_mark.*, tst_tests.* FROM tst_tests, tst_mark WHERE tst_mark.test_fi = tst_tests.test_id AND tst_tests.test_id = %s", array('integer'), array($test_id)); $found = $result->numRows(); if ($found) { $row = $ilDB->fetchAssoc($result); // check for at least: title, author and minimum of 1 mark step if (strlen($row["title"]) && strlen($row["author"]) && $found) { // check also for minmum of 1 question if (ilObjTestAccess::_getQuestionCount($test_id) > 0) { return true; } else { return false; } } else { return false; } } else { return false; } $test = new ilObjTest($obj_id, false); $test->loadFromDb(); if ($test->getTitle() and $test->author and count($test->mark_schema->mark_steps) and count($test->questions)) { return true; } else { return false; } }
/** * Determine status. * * Behaviour of "old" 4.0 learning progress: * * Setting "Multiple Pass Scoring": Score the last pass * - Test not started: No entry * - First question opened: Icon/Text: Failed, Score 0% * - First question answered (correct, points enough for passing): Icon/Text: Completed, Score 66% * - No change after successfully finishing the pass. (100%) * - 2nd Pass, first question opened: Still Completed/Completed * - First question answered (incorrect, success possible): Icon/Text Failed, Score 33% * - Second question answered (correct): Icon/Text completed * - 3rd pass, like 2nd, but two times wrong answer: Icon/Text: Failed * * Setting "Multiple Pass Scoring": Score the best pass * - Test not started: No entry * - First question opened: Icon/Text: Failed, Score 0% * - First question answered (correct, points enough for passing): Icon/Text: Completed, Score 66% * - No change after successfully finishing the pass. (100%) * - 2nd Pass, first question opened: Still Completed/Completed * - First question answered (incorrect, success possible): Still Completed/Completed * * Due to this behaviour in 4.0 we do not have a "in progress" status. During the test * the status is "failed" unless the score is enough to pass the test, which makes the * learning progress status "completed". * * @param integer object id * @param integer user id * @param object object (optional depends on object type) * @return integer status */ function determineStatus($a_obj_id, $a_user_id, $a_obj = null) { global $ilObjDataCache, $ilDB, $ilLog; $status = self::LP_STATUS_NOT_ATTEMPTED_NUM; include_once './Modules/Test/classes/class.ilObjTestAccess.php'; $res = $ilDB->query("\n\t\t\tSELECT tst_active.active_id, tst_active.tries, count(tst_sequence.active_fi) sequences\n\t\t\tFROM tst_active\n\t\t\tLEFT JOIN tst_sequence\n\t\t\tON tst_sequence.active_fi = tst_active.active_id\n\t\t\tWHERE tst_active.user_fi = {$ilDB->quote($a_user_id, "integer")}\n\t\t\tAND tst_active.test_fi = {$ilDB->quote(ilObjTestAccess::_getTestIDFromObjectID($a_obj_id))}\n\t\t\tGROUP BY tst_active.active_id, tst_active.tries\n\t\t"); if ($rec = $ilDB->fetchAssoc($res)) { if ($rec['sequences'] > 0) { include_once './Modules/Test/classes/class.ilObjTestAccess.php'; if (ilObjTestAccess::_isPassed($a_user_id, $a_obj_id)) { $status = self::LP_STATUS_COMPLETED_NUM; } else { $status = self::LP_STATUS_FAILED_NUM; } } else { $status = self::LP_STATUS_NOT_ATTEMPTED_NUM; } } return $status; }