4include_once 
"./Services/Object/classes/class.ilObjectAccess.php";
 
    5include_once 
"./Modules/Test/classes/inc.AssessmentConstants.php";
 
    6include_once 
'./Services/AccessControl/interfaces/interface.ilConditionHandling.php';
 
   37        function _checkAccess($a_cmd, $a_permission, $a_ref_id, $a_obj_id, $a_user_id = 
"")
 
   46                $is_admin = $rbacsystem->checkAccessOfUser($a_user_id,
'write',$a_ref_id);               
 
   49                if(!self::_isOnline($a_obj_id) && !$is_admin)
 
   55                switch ($a_permission)
 
   98                        $result = 
$ilDB->queryF(
"SELECT SUM(qpl_questions.points) maxpoints FROM tst_test_rnd_qst, qpl_questions, tst_active WHERE tst_active.active_id = tst_test_rnd_qst.active_fi AND tst_test_rnd_qst.question_fi = qpl_questions.question_id AND tst_active.test_fi = %s AND tst_test_rnd_qst.pass = %s AND tst_active.user_fi = %s",
 
   99                                array(
'integer',
'integer',
'integer'),
 
  100                                array($test_id, 
$pass, $user_id)
 
  105                                $max = 
$row[
"maxpoints"];
 
  110                        $result = 
$ilDB->queryF(
"SELECT SUM(qpl_questions.points) maxpoints FROM tst_test_question, qpl_questions WHERE tst_test_question.question_fi = qpl_questions.question_id AND tst_test_question.test_fi = %s",
 
  117                                $max = 
$row[
"maxpoints"];
 
  133                $result = 
$ilDB->queryF(
"SELECT tst_result_cache.* FROM tst_result_cache, tst_active, tst_tests WHERE tst_active.test_fi = tst_tests.test_id AND tst_active.user_fi = %s AND tst_tests.obj_fi = %s AND tst_result_cache.active_fi = tst_active.active_id",
 
  134                        array(
'integer',
'integer'),
 
  135                        array($user_id, $a_obj_id)
 
  139                        $result = 
$ilDB->queryF(
"SELECT tst_active.active_id FROM tst_active, tst_tests WHERE tst_active.test_fi = tst_tests.test_id AND tst_active.user_fi = %s AND tst_tests.obj_fi = %s",
 
  140                                array(
'integer',
'integer'),
 
  141                                array($user_id, $a_obj_id)
 
  144                        if (
$row[
'active_id'] > 0)
 
  146                                include_once 
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
 
  154                $result = 
$ilDB->queryF(
"SELECT tst_result_cache.* FROM tst_result_cache, tst_active, tst_tests WHERE tst_active.test_fi = tst_tests.test_id AND tst_active.user_fi = %s AND tst_tests.obj_fi = %s AND tst_result_cache.active_fi = tst_active.active_id",
 
  155                        array(
'integer',
'integer'),
 
  156                        array($user_id, $a_obj_id)
 
  160                        $result = 
$ilDB->queryF(
"SELECT tst_pass_result.*, tst_tests.pass_scoring, tst_tests.random_test, tst_tests.test_id FROM tst_pass_result, tst_active, tst_tests WHERE tst_active.test_fi = tst_tests.test_id AND tst_active.user_fi = %s AND tst_tests.obj_fi = %s AND tst_pass_result.active_fi = tst_active.active_id ORDER BY tst_pass_result.pass",
 
  161                                array(
'integer',
'integer'),
 
  162                                array($user_id, $a_obj_id)
 
  167                                array_push($points, 
$row);
 
  171                        if ($points[0][
"pass_scoring"] == 0)
 
  173                                $reached = $points[count($points)-1][
"points"];
 
  174                                $max = $points[count($points)-1][
"maxpoints"];
 
  177                                        $active_id = $points[count($points)-1][
"active_fi"];
 
  178                                        $pass = $points[count($points)-1][
"pass"];
 
  179                                        if (strlen($active_id) && strlen(
$pass))
 
  181                                                include_once 
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
 
  182                                                $res = assQuestion::_updateTestPassResults($active_id, 
$pass, 
null, $a_obj_id);
 
  183                                                $max = 
$res[
'maxpoints'];
 
  184                                                $reached = 
$res[
'points'];
 
  190                                foreach ($points as 
$row)
 
  192                                        if (
$row[
"points"] > $reached) 
 
  194                                                $reached = 
$row[
"points"];
 
  195                                                $max = 
$row[
"maxpoints"];
 
  198                                                        $active_id = 
$row[
"active_fi"];
 
  200                                                        if (strlen($active_id) && strlen(
$pass))
 
  202                                                                include_once 
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
 
  203                                                                $res = assQuestion::_updateTestPassResults($active_id, 
$pass, 
null, $a_obj_id);
 
  204                                                                $max = 
$res[
'maxpoints'];
 
  205                                                                $reached = 
$res[
'points'];
 
  211                        include_once 
"./Modules/Test/classes/class.assMarkSchema.php";
 
  212                        $percentage = (!$max) ? 0 : ($reached / $max) * 100.0;
 
  214                        return ($mark[
"passed"]) ? TRUE : FALSE;
 
  219                        return (
$row[
'passed']) ? true : 
false;
 
  230        public static function isFailed($user_id, $a_obj_id)
 
  241                $result = 
$ilDB->queryF(
"SELECT tst_result_cache.* FROM tst_result_cache, tst_active, tst_tests WHERE tst_active.test_fi = tst_tests.test_id AND tst_active.user_fi = %s AND tst_tests.obj_fi = %s AND tst_result_cache.active_fi = tst_active.active_id",
 
  242                        array(
'integer',
'integer'),
 
  243                        array($user_id, $a_obj_id)
 
  248                        $result = 
$ilDB->queryF(
"SELECT tst_pass_result.*, tst_tests.pass_scoring, tst_tests.random_test, tst_tests.test_id FROM tst_pass_result, tst_active, tst_tests WHERE tst_active.test_fi = tst_tests.test_id AND tst_active.user_fi = %s AND tst_tests.obj_fi = %s AND tst_pass_result.active_fi = tst_active.active_id ORDER BY tst_pass_result.pass",
 
  249                                array(
'integer',
'integer'),
 
  250                                array($user_id, $a_obj_id)
 
  255                                array_push($points, 
$row);
 
  259                        if ($points[0][
"pass_scoring"] == 0)
 
  261                                $reached = $points[count($points)-1][
"points"];
 
  262                                $max = $points[count($points)-1][
"maxpoints"];
 
  265                                        $active_id = $points[count($points)-1][
"active_fi"];
 
  266                                        $pass = $points[count($points)-1][
"pass"];
 
  267                                        if (strlen($active_id) && strlen(
$pass))
 
  269                                                include_once 
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
 
  270                                                $res = assQuestion::_updateTestPassResults($active_id, 
$pass, 
null, $a_obj_id);
 
  271                                                $max = 
$res[
'maxpoints'];
 
  272                                                $reached = 
$res[
'points'];
 
  278                                foreach ($points as 
$row)
 
  280                                        if (
$row[
"points"] > $reached) 
 
  282                                                $reached = 
$row[
"points"];
 
  283                                                $max = 
$row[
"maxpoints"];
 
  286                                                        $active_id = 
$row[
"active_fi"];
 
  288                                                        if (strlen($active_id) && strlen(
$pass))
 
  290                                                                include_once 
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
 
  291                                                                $res = assQuestion::_updateTestPassResults($active_id, 
$pass, 
null, $a_obj_id);
 
  292                                                                $max = 
$res[
'maxpoints'];
 
  293                                                                $reached = 
$res[
'points'];
 
  299                        include_once 
"./Modules/Test/classes/class.assMarkSchema.php";
 
  300                        $percentage = (!$max) ? 0 : ($reached / $max) * 100.0;
 
  302                        return ($mark[
"failed"]) ? TRUE : FALSE;
 
  307                        return (
$row[
'failed']) ? TRUE : FALSE;
 
  321                                "SELECT tst_result_cache.* FROM tst_result_cache, tst_active, tst_tests ".
 
  322                                "WHERE tst_active.test_fi = tst_tests.test_id AND tst_active.user_fi = %s ".
 
  323                                "AND tst_tests.obj_fi = %s AND tst_result_cache.active_fi = tst_active.active_id",
 
  324                        array(
'integer',
'integer'),
 
  325                        array($a_user_id, $a_obj_id)
 
  329                        $result = 
$ilDB->queryF(
"SELECT tst_active.active_id FROM tst_active, tst_tests WHERE tst_active.test_fi = tst_tests.test_id AND tst_active.user_fi = %s AND tst_tests.obj_fi = %s",
 
  330                                array(
'integer',
'integer'),
 
  331                                array($a_user_id, $a_obj_id)
 
  334                        if (
$row[
'active_id'] > 0)
 
  336                                include_once 
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
 
  358                include_once 
'./Services/AccessControl/classes/class.ilConditionHandler.php';
 
  373        public static function checkCondition($a_obj_id, $a_operator, $a_value, $a_usr_id)
 
  375                include_once 
'./Services/AccessControl/classes/class.ilConditionHandler.php';
 
  414            array(
"permission" => 
"write", 
"cmd" => 
"questionsTabGateway", 
"lang_var" => 
"tst_edit_questions"),
 
  415                        array(
"permission" => 
"write", 
"cmd" => 
"ilObjTestSettingsGeneralGUI::showForm", 
"lang_var" => 
"settings"),
 
  416                        array(
"permission" => 
"read", 
"cmd" => 
"infoScreen", 
"lang_var" => 
"tst_run",
 
  419                        array(
"permission" => 
"tst_statistics", 
"cmd" => 
"outEvaluation", 
"lang_var" => 
"tst_statistical_evaluation"),
 
  420                        array(
"permission" => 
"read", 
"cmd" => 
"userResultsGateway", 
"lang_var" => 
"tst_test_results")
 
  437                $result = 
$ilDB->queryF(
"SELECT complete FROM tst_tests WHERE obj_fi=%s",
 
  446                return (
$row[
'complete']) ? true : 
false;
 
  465                if( !isset(self::$hasFinishedCache[
"{$a_user_id}:{$a_obj_id}"]) )
 
  467                        require_once 
'Modules/Test/classes/class.ilTestParticipantData.php';
 
  468                        require_once 
'Modules/Test/classes/class.ilTestSessionFactory.php';
 
  469                        require_once 
'Modules/Test/classes/class.ilTestPassesSelector.php';
 
  476                        $partData->setUserIds(array($a_user_id));
 
  477                        $partData->load($testOBJ->getTestId());
 
  479                        $activeId = $partData->getActiveIdByUserId($a_user_id);
 
  482                        $testSession = $testSessionFactory->getSession($activeId);
 
  485                        $testPassesSelector->setActiveId($activeId);
 
  486                        $testPassesSelector->setLastFinishedPass($testSession->getLastFinishedPass());
 
  488                        self::$hasFinishedCache[
"{$a_user_id}:{$a_obj_id}"] = count($testPassesSelector->getClosedPasses());
 
  491                return self::$hasFinishedCache[
"{$a_user_id}:{$a_obj_id}"];
 
  505                $result = 
$ilDB->queryF(
"SELECT test_id FROM tst_tests WHERE obj_fi = %s",
 
  512                        $test_id = 
$row[
"test_id"];
 
  523                $questions = array();
 
  526                $result = 
$ilDB->queryF(
"SELECT test_fi FROM tst_active WHERE active_id = %s",
 
  534                        $test_id = 
$row[
"test_fi"];
 
  540                $result = 
$ilDB->queryF(
"SELECT qpl_questions.question_id, qpl_questions.points FROM qpl_questions, tst_test_question WHERE tst_test_question.question_fi = qpl_questions.question_id AND tst_test_question.test_fi = %s ORDER BY tst_test_question.sequence",
 
  549                                array_push($questions, 
$row);
 
  555                        $result = 
$ilDB->queryF(
"SELECT qpl_questions.question_id, qpl_questions.points FROM qpl_questions, tst_test_rnd_qst WHERE tst_test_rnd_qst.question_fi = qpl_questions.question_id AND tst_test_rnd_qst.active_fi = %s AND tst_test_rnd_qst.pass = %s ORDER BY tst_test_rnd_qst.sequence",
 
  556                                array(
'integer',
'integer'),
 
  557                                array($active_id, 
$pass)
 
  563                                        array_push($questions, 
$row);
 
  581                        SELECT tst_tests.complete 
  584                        ON tst_tests.obj_fi = object_data.obj_id 
  585                        WHERE object_data.obj_id = %s 
  592                        return (
bool)
$row[
'complete'];
 
  608                $result = 
$ilDB->queryF(
"SELECT * FROM tst_tests WHERE test_id = %s",
 
  629                $result = 
$ilDB->queryF(
"SELECT obj_fi FROM tst_tests WHERE test_id = %s",
 
  635                return $row[
"obj_fi"];
 
  650                        SELECT DISTINCT t.obj_fi 
  652                        INNER JOIN tst_rnd_quest_set_qpls r 
  653                        ON t.test_id = r.test_fi 
  679                $result = 
$ilDB->queryF(
"SELECT tst_tests.* FROM tst_tests WHERE tst_tests.obj_fi = %s",
 
  686                        if (
$row[
"fixed_participants"])
 
  688                                $result = 
$ilDB->queryF(
"SELECT * FROM tst_invited_user WHERE test_fi = %s AND user_fi = %s",
 
  689                                        array(
'integer',
'integer'),
 
  690                                        array(
$row[
"test_id"], $a_user_id)
 
  695                                        if (trim(
$row[
'clientip']) != 
"")
 
  697                                                $row[
'clientip'] = preg_replace(
"/[^0-9.?*,:]+/",
"",
$row[
'clientip']);
 
  698                                                $row[
'clientip'] = str_replace(
".",
"\\.",
$row[
'clientip']);
 
  699                                                $row[
'clientip'] = str_replace(Array(
"?",
"*",
","), Array(
"[0-9]",
"[0-9]*",
"|"), 
$row[
'clientip']);
 
  700                                                if (!preg_match(
"/^".
$row[
'clientip'].
"$/", 
$_SERVER[
"REMOTE_ADDR"])) 
 
  702                                                        return $lng->txt(
"tst_user_wrong_clientip");
 
  716                                        return $lng->txt(
"tst_user_not_invited");
 
  741                $result = 
$ilDB->queryF(
"SELECT * FROM tst_active WHERE active_id = %s",
 
  746                $user_id = 
$row[
"user_fi"];
 
  747                $test_id = 
$row[
"test_fi"];
 
  748                $importname = 
$row[
'importname'];
 
  750                $result = 
$ilDB->queryF(
"SELECT obj_fi FROM tst_tests WHERE test_id = %s",
 
  755                $obj_id = 
$row[
"obj_fi"];
 
  757                include_once 
"./Modules/Test/classes/class.ilObjTest.php";
 
  760                include_once 
'./Services/User/classes/class.ilObjUser.php';
 
  764                if (strlen($importname))
 
  766                        $name = $importname . 
' (' . 
$lng->txt(
'imported') . 
')';
 
  768                else if (strlen($uname[
"firstname"].$uname[
"lastname"]) == 0)
 
  770                        $name = 
$lng->txt(
"deleted_user");
 
  774                        if ($user_id == ANONYMOUS_USER_ID)
 
  780                                $name = trim($uname[
"lastname"] . 
", " . $uname[
"firstname"] . 
" " .  $uname[
"title"]);
 
  784                                $name = 
$lng->txt(
"anonymous");
 
  800                $result = 
$ilDB->queryF(
"SELECT user_fi FROM tst_active WHERE active_id = %s",
 
  805                return $row[
"user_fi"];
 
  827                $passed_users = array();
 
  829                $userresult = 
$ilDB->queryF(
" 
  830                        SELECT tst_active.active_id, COUNT(tst_sequence.active_fi) sequences 
  832                        INNER JOIN tst_active 
  833                        ON tst_active.test_fi = tst_tests.test_id 
  834                        LEFT JOIN tst_sequence 
  835                        ON tst_sequence.active_fi = tst_active.active_id 
  836                        WHERE tst_tests.obj_fi = %s 
  837                        GROUP BY tst_active.active_id 
  839                        array(
'integer'), array($a_obj_id)
 
  841                $all_participants = array();
 
  842                $notAttempted = array();
 
  843                while (
$row = 
$ilDB->fetchAssoc($userresult))
 
  845                        if(
$row[
'sequences'] == 0)
 
  847                                $notAttempted[
$row[
'active_id']] = 
$row[
'active_id'];
 
  850                        $all_participants[
$row[
'active_id']] = 
$row[
'active_id'];
 
  853                $result = 
$ilDB->query(
"SELECT tst_result_cache.*, tst_active.user_fi FROM tst_result_cache, tst_active WHERE tst_active.active_id = tst_result_cache.active_fi AND " . 
$ilDB->in(
'active_fi', $all_participants, 
false, 
'integer'));
 
  854                $found_all = (
$result->numRows() == count($all_participants)) ? 
true : 
false;
 
  858                        $found_participants = array();
 
  861                                array_push($found_participants, 
$data[
'active_fi']);
 
  863                        foreach ($all_participants as $active_id)
 
  865                                if (!in_array($active_id, $found_participants))
 
  867                                        include_once 
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
 
  871                        $result = 
$ilDB->query(
"SELECT tst_result_cache.*, tst_active.user_fi FROM tst_result_cache, tst_active WHERE tst_active.active_id = tst_result_cache.active_fi AND " . 
$ilDB->in(
'active_fi', $all_participants, 
false, 
'integer'));
 
  875                        if( isset($notAttempted[
$data[
'active_fi']]) )
 
  882                        array_push($passed_users, 
$data);
 
  884                return $passed_users;
 
  894                $t_arr = explode(
"_", $a_target);
 
  896                if ($t_arr[0] != 
"tst" || ((
int) $t_arr[1]) <= 0)
 
  901                if ($ilAccess->checkAccess(
"read", 
"", $t_arr[1]))
 
  938                        AND                     online_status = 1 
  943                return $result->numRows() == 1;
 
  955                require_once 
'Modules/Test/classes/class.ilTestSessionFactory.php';
 
  957                $testSession = $testSessionFactory->getSessionByUserId($userId);
 
  959                return $testOBJ->canShowTestResults($testSession);
 
_getMatchingMarkFromObjId($a_obj_id, $percentage)
Returns the matching mark for a given percentage.
const IL_NO_OBJECT_ACCESS
_updateTestResultCache($active_id, ilAssQuestionProcessLocker $processLocker=null)
@TODO Move this to a proper place.
const OPERATOR_NOT_FINISHED
_lookupCreationComplete($a_obj_id)
checks wether all necessary parts of the test are given
static hasFinished($a_user_id, $a_obj_id)
Returns (request cached) information if a specific user has finished at least one test pass.
_lookupOnlineTestAccess($a_test_id, $a_user_id)
Checks if a user is allowd to run an online exam.
_getTestIDFromObjectID($object_id)
Returns the ILIAS test id for a given object id.
_getRandomTestsForQuestionPool($qpl_id)
Get all tests using a question pool for random selection.
static getConditionOperators()
Get possible conditions operators.
& _getTestQuestions($active_id, $pass=NULL)
_checkGoto($a_target)
check whether goto script will succeed
static checkCondition($a_obj_id, $a_operator, $a_value, $a_usr_id)
check condition
_getParticipantId($active_id)
Get user id for active id.
static _isOffline($a_obj_id)
returns the objects's OFFline status
static _isPassed($user_id, $a_obj_id)
Returns TRUE if the user with the user id $user_id passed the test with the object id $a_obj_id.
static visibleUserResultExists($testObjId, $userId)
static isFailed($user_id, $a_obj_id)
Returns TRUE if the user with the user id $user_id failed the test with the object id $a_obj_id.
_checkAccess($a_cmd, $a_permission, $a_ref_id, $a_obj_id, $a_user_id="")
Checks wether a user may invoke a command or not (this method is called by ilAccessHandler::checkAcce...
_getCommands()
get commands
_lookupObjIdForTestId($a_test_id)
Lookup object id for test id.
_getParticipantData($active_id)
Retrieves a participant name from active id.
static _isOnline($a_obj_id)
returns the objects's ONline status
_isComplete($a_obj_id)
Returns true, if a test is complete for use.
& _getPassedUsers($a_obj_id)
Returns an array containing the users who passed the test.
updateTestResultCache($a_user_id, $a_obj_id)
Update test result cache.
_getMaxPointsForTestPass($random, $user_id, $test_id, $pass)
Returns the maximum number of points available for a test pass.
& _getTestData($test_id)
Returns the database content of a test with a given id.
_lookupAnonymity($a_obj_id)
Returns the anonymity status of a test with a given object id.
static _lookupName($a_user_id)
lookup user name
getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
Interface for condition handling.
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']