12include_once 
"./Services/Object/classes/class.ilObjectAccess.php";
 
   13include_once 
"./Modules/Test/classes/inc.AssessmentConstants.php";
 
   14include_once 
'./Services/Conditions/interfaces/interface.ilConditionHandling.php';
 
   41        return !$can_it->isOk() || $can_it->value();
 
   47            return $result->except(
static function () use ($access, $path): 
Result {
 
   50        }, 
new Error(
'Not a known path.'));
 
   68    public function _checkAccess($a_cmd, $a_permission, $a_ref_id, $a_obj_id, $a_user_id = 
"")
 
   73        $rbacsystem = 
$DIC[
'rbacsystem'];
 
   74        $ilAccess = 
$DIC[
'ilAccess'];
 
   76        if ($a_user_id == 
"") {
 
   80        $is_admin = $rbacsystem->checkAccessOfUser($a_user_id, 
'write', $a_ref_id);
 
   83        switch ($a_permission) {
 
  120            "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",
 
  121            array(
'integer',
'integer'),
 
  122            array($user_id, $a_obj_id)
 
  126                "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",
 
  127                array(
'integer',
'integer'),
 
  128                array($user_id, $a_obj_id)
 
  131            if ($row[
'active_id'] > 0) {
 
  132                include_once 
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
 
  139            "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",
 
  140            array(
'integer',
'integer'),
 
  141            array($user_id, $a_obj_id)
 
  145                "SELECT tst_pass_result.*, tst_tests.pass_scoring, 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",
 
  146                array(
'integer',
'integer'),
 
  147                array($user_id, $a_obj_id)
 
  156                array_push($points, $row);
 
  160            if ($points[0][
"pass_scoring"] == 0) {
 
  161                $reached = $points[count($points) - 1][
"points"];
 
  162                $max = $points[count($points) - 1][
"maxpoints"];
 
  164                    $active_id = $points[count($points) - 1][
"active_fi"];
 
  165                    $pass = $points[count($points) - 1][
"pass"];
 
  166                    if (strlen($active_id) && strlen(
$pass)) {
 
  167                        include_once 
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
 
  168                        $res = assQuestion::_updateTestPassResults($active_id, 
$pass, 
null, $a_obj_id);
 
  169                        $max = 
$res[
'maxpoints'];
 
  170                        $reached = 
$res[
'points'];
 
  174                foreach ($points as $row) {
 
  175                    if ($row[
"points"] > $reached) {
 
  176                        $reached = $row[
"points"];
 
  177                        $max = $row[
"maxpoints"];
 
  179                            $active_id = $row[
"active_fi"];
 
  180                            $pass = $row[
"pass"];
 
  181                            if (strlen($active_id) && strlen(
$pass)) {
 
  182                                include_once 
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
 
  183                                $res = assQuestion::_updateTestPassResults($active_id, 
$pass, 
null, $a_obj_id);
 
  184                                $max = 
$res[
'maxpoints'];
 
  185                                $reached = 
$res[
'points'];
 
  191            include_once 
"./Modules/Test/classes/class.assMarkSchema.php";
 
  192            $percentage = (!$max) ? 0 : ($reached / $max) * 100.0;
 
  194            return ($mark[
"passed"]) ? 
true : 
false;
 
  197            return ($row[
'passed']) ? 
true : 
false;
 
  208    public static function isFailed($user_id, $a_obj_id)
 
  220            "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",
 
  221            array(
'integer',
'integer'),
 
  222            array($user_id, $a_obj_id)
 
  227                "SELECT tst_pass_result.*, tst_tests.pass_scoring 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",
 
  228                array(
'integer',
'integer'),
 
  229                array($user_id, $a_obj_id)
 
  233                array_push($points, $row);
 
  237            if ($points[0][
"pass_scoring"] == 0) {
 
  238                $reached = $points[count($points) - 1][
"points"];
 
  239                $max = $points[count($points) - 1][
"maxpoints"];
 
  241                    $active_id = $points[count($points) - 1][
"active_fi"];
 
  242                    $pass = $points[count($points) - 1][
"pass"];
 
  243                    if (strlen($active_id) && strlen(
$pass)) {
 
  244                        include_once 
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
 
  245                        $res = assQuestion::_updateTestPassResults($active_id, 
$pass, 
null, $a_obj_id);
 
  246                        $max = 
$res[
'maxpoints'];
 
  247                        $reached = 
$res[
'points'];
 
  251                foreach ($points as $row) {
 
  252                    if ($row[
"points"] > $reached) {
 
  253                        $reached = $row[
"points"];
 
  254                        $max = $row[
"maxpoints"];
 
  256                            $active_id = $row[
"active_fi"];
 
  257                            $pass = $row[
"pass"];
 
  258                            if (strlen($active_id) && strlen(
$pass)) {
 
  259                                include_once 
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
 
  260                                $res = assQuestion::_updateTestPassResults($active_id, 
$pass, 
null, $a_obj_id);
 
  261                                $max = 
$res[
'maxpoints'];
 
  262                                $reached = 
$res[
'points'];
 
  268            include_once 
"./Modules/Test/classes/class.assMarkSchema.php";
 
  269            $percentage = (!$max) ? 0 : ($reached / $max) * 100.0;
 
  271            return ($mark[
"failed"]) ? 
true : 
false;
 
  274            return ($row[
'failed']) ? 
true : 
false;
 
  289            "SELECT tst_result_cache.* FROM tst_result_cache, tst_active, tst_tests " .
 
  290                "WHERE tst_active.test_fi = tst_tests.test_id AND tst_active.user_fi = %s " .
 
  291                "AND tst_tests.obj_fi = %s AND tst_result_cache.active_fi = tst_active.active_id",
 
  292            array(
'integer',
'integer'),
 
  293            array($a_user_id, $a_obj_id)
 
  297                "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",
 
  298                array(
'integer',
'integer'),
 
  299                array($a_user_id, $a_obj_id)
 
  302            if ($row[
'active_id'] > 0) {
 
  303                include_once 
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
 
  320        include_once 
'./Services/Conditions/classes/class.ilConditionHandler.php';
 
  335    public static function checkCondition($a_obj_id, $a_operator, $a_value, $a_usr_id)
 
  337        include_once 
'./Services/Conditions/classes/class.ilConditionHandler.php';
 
  339        switch ($a_operator) {
 
  374        $DIC->language()->loadLanguageModule(
'assessment');
 
  377            array(
"permission" => 
"write", 
"cmd" => 
"questionsTabGateway", 
"lang_var" => 
"tst_edit_questions"),
 
  378            array(
"permission" => 
"write", 
"cmd" => 
"ilObjTestSettingsGeneralGUI::showForm", 
"lang_var" => 
"settings"),
 
  379            array(
"permission" => 
"read", 
"cmd" => 
"infoScreen", 
"lang_var" => 
"tst_run",
 
  382            array(
"permission" => 
"tst_statistics", 
"cmd" => 
"outEvaluation", 
"lang_var" => 
"tst_statistical_evaluation"),
 
  383            array(
"permission" => 
"read", 
"cmd" => 
"userResultsGateway", 
"lang_var" => 
"tst_user_results"),
 
  384            array(
"permission" => 
"write", 
"cmd" => 
"testResultsGateway", 
"lang_var" => 
"results"),
 
  385            array(
"permission" => 
"eval_a", 
"cmd" => 
"testResultsGateway", 
"lang_var" => 
"results")
 
  404            "SELECT complete FROM tst_tests WHERE obj_fi=%s",
 
  412        return ($row[
'complete']) ? 
true : 
false;
 
  431        if (!isset(self::$hasFinishedCache[
"{$a_user_id}:{$a_obj_id}"])) {
 
  432            require_once 
'Modules/Test/classes/class.ilTestParticipantData.php';
 
  433            require_once 
'Modules/Test/classes/class.ilTestSessionFactory.php';
 
  434            require_once 
'Modules/Test/classes/class.ilTestPassesSelector.php';
 
  443            $partData->setUserIdsFilter(array($a_user_id));
 
  444            $partData->load($testOBJ->getTestId());
 
  446            $activeId = $partData->getActiveIdByUserId($a_user_id);
 
  449            $testSession = $testSessionFactory->getSession($activeId);
 
  452            $testPassesSelector->setActiveId($activeId);
 
  453            $testPassesSelector->setLastFinishedPass($testSession->getLastFinishedPass());
 
  455            self::$hasFinishedCache[
"{$a_user_id}:{$a_obj_id}"] = count($testPassesSelector->getClosedPasses());
 
  458        return (
bool) self::$hasFinishedCache[
"{$a_user_id}:{$a_obj_id}"];
 
  474            "SELECT test_id FROM tst_tests WHERE obj_fi = %s",
 
  480            $test_id = $row[
"test_id"];
 
  497            "SELECT obj_fi FROM tst_tests WHERE test_id = %s",
 
  503        return $row[
"obj_fi"];
 
  519                        SELECT DISTINCT t.obj_fi 
  521                        INNER JOIN tst_rnd_quest_set_qpls r 
  522                        ON t.test_id = r.test_fi 
  530            $tests[] = $row[
'obj_fi'];
 
  550            "SELECT tst_tests.* FROM tst_tests WHERE tst_tests.obj_fi = %s",
 
  556            if ($row[
"fixed_participants"]) {
 
  558                    "SELECT * FROM tst_invited_user WHERE test_fi = %s AND user_fi = %s",
 
  559                    array(
'integer',
'integer'),
 
  560                    array($row[
"test_id"], $a_user_id)
 
  564                    if (trim($row[
'clientip']) != 
"") {
 
  565                        $row[
'clientip'] = preg_replace(
"/[^0-9.?*,:]+/", 
"", $row[
'clientip']);
 
  566                        $row[
'clientip'] = str_replace(
".", 
"\\.", $row[
'clientip']);
 
  567                        $row[
'clientip'] = str_replace(array(
"?",
"*",
","), array(
"[0-9]",
"[0-9]*",
"|"), $row[
'clientip']);
 
  568                        if (!preg_match(
"/^" . $row[
'clientip'] . 
"$/", 
$_SERVER[
"REMOTE_ADDR"])) {
 
  569                            $lng->loadLanguageModule(
'assessment');
 
  570                            return $lng->txt(
"user_wrong_clientip");
 
  578                    return $lng->txt(
"tst_user_not_invited");
 
  602            "SELECT * FROM tst_active WHERE active_id = %s",
 
  607        $user_id = $row[
"user_fi"];
 
  608        $test_id = $row[
"test_fi"];
 
  609        $importname = $row[
'importname'];
 
  612            "SELECT obj_fi FROM tst_tests WHERE test_id = %s",
 
  617        $obj_id = $row[
"obj_fi"];
 
  619        include_once 
"./Modules/Test/classes/class.ilObjTest.php";
 
  622        include_once 
'./Services/User/classes/class.ilObjUser.php';
 
  626        if (strlen($importname)) {
 
  627            $name = $importname . 
' (' . 
$lng->txt(
'imported') . 
')';
 
  628        } elseif (strlen($uname[
"firstname"] . $uname[
"lastname"]) == 0) {
 
  634                $name = trim($uname[
"lastname"] . 
", " . $uname[
"firstname"]);
 
  656            "SELECT user_fi FROM tst_active WHERE active_id = %s",
 
  661        return $row[
"user_fi"];
 
  684        $passed_users = array();
 
  686        $userresult = 
$ilDB->queryF(
 
  688                        SELECT tst_active.active_id, COUNT(tst_sequence.active_fi) sequences, tst_active.last_finished_pass, 
  690                                        (tst_tests.nr_of_tries - 1) = tst_active.last_finished_pass 
  695                        INNER JOIN tst_active 
  696                        ON tst_active.test_fi = tst_tests.test_id 
  697                        LEFT JOIN tst_sequence 
  698                        ON tst_sequence.active_fi = tst_active.active_id 
  699                        WHERE tst_tests.obj_fi = %s 
  700                        GROUP BY tst_active.active_id 
  705        $all_participants = array();
 
  706        $notAttempted = array();
 
  707        $lastPassUsers = array();
 
  708        while ($row = 
$ilDB->fetchAssoc($userresult)) {
 
  709            if ($row[
'sequences'] == 0) {
 
  710                $notAttempted[$row[
'active_id']] = $row[
'active_id'];
 
  712            if ($row[
'is_last_pass']) {
 
  713                $lastPassUsers[$row[
'active_id']] = $row[
'active_id'];
 
  716            $all_participants[$row[
'active_id']] = $row[
'active_id'];
 
  719        $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'));
 
  720        $found_all = (
$result->numRows() == count($all_participants)) ? 
true : 
false;
 
  723            $found_participants = array();
 
  725                array_push($found_participants, 
$data[
'active_fi']);
 
  727            foreach ($all_participants as $active_id) {
 
  728                if (!in_array($active_id, $found_participants)) {
 
  729                    include_once 
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
 
  733            $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'));
 
  736            if (isset($notAttempted[
$data[
'active_fi']])) {
 
  739                $data[
'not_attempted'] = 1;
 
  742            if (
$data[
'failed'] && !isset($lastPassUsers[
$data[
'active_fi']])) {
 
  745                $data[
'in_progress'] = 1;
 
  749            array_push($passed_users, 
$data);
 
  751        return $passed_users;
 
  760        $ilAccess = 
$DIC[
'ilAccess'];
 
  762        $t_arr = explode(
"_", $a_target);
 
  764        if ($t_arr[0] != 
"tst" || ((
int) $t_arr[1]) <= 0) {
 
  768        if ($ilAccess->checkAccess(
"read", 
"", $t_arr[1]) ||
 
  769            $ilAccess->checkAccess(
"visible", 
"", $t_arr[1])) {
 
  801        require_once 
'Modules/Test/classes/class.ilTestSessionFactory.php';
 
  803        $testSession = $testSessionFactory->getSessionByUserId($userId);
 
  805        return $testOBJ->canShowTestResults($testSession);
 
  819        if (!($testOBJ instanceof 
ilObjTest) || !$userId) {
 
  823        require_once 
'Modules/Test/classes/class.ilTestSessionFactory.php';
 
  825        $testSession = $testSessionFactory->getSessionByUserId($userId);
 
  827        if (!$testSession->getActiveId()) {
 
  831        return $testOBJ->canShowCertificate($testSession, $testSession->getUserId(), $testSession->getActiveId());
 
static _getMatchingMarkFromObjId($a_obj_id, $percentage)
Returns the matching mark for a given percentage.
An exception for terminatinating execution or to throw for unit testing.
A result encapsulates a value or an error and simplifies the handling of those.
const IL_NO_OBJECT_ACCESS
return true
Flag indicating whether or not HTTP headers will be sent when outputting captcha image/audio.
static _updateTestResultCache($active_id, ilAssQuestionProcessLocker $processLocker=null)
@TODO Move this to a proper place.
const OPERATOR_NOT_FINISHED
canBeDelivered(ilWACPath $ilWACPath)
bool
static _lookupOnlineTestAccess($a_test_id, $a_user_id)
Checks if a user is allowd to run an online exam.
static _getTestIDFromObjectID($object_id)
Returns the ILIAS test id for a given object id.
static hasFinished($a_user_id, $a_obj_id)
Returns (request cached) information if a specific user has finished at least one test pass.
findMatch(string $path, array $array)
static getConditionOperators()
Get possible conditions operators.
static hasVisibleCertificate($testObjId, $userId)
@ideaof Andre Michels amichels@databay.de
static _getParticipantData($active_id)
Retrieves a participant name from active id.
static checkCondition($a_obj_id, $a_operator, $a_value, $a_usr_id)
check condition
static _getParticipantId($active_id)
Get user id for active id.
static _getPassedUsers($a_obj_id)
Returns an array containing the users who passed the test.
static _isOffline($a_obj_id)
returns the objects's OFFline status
static _getCommands()
get commands
static _checkGoto($a_target)
check whether goto script will succeed
static updateTestResultCache($a_user_id, $a_obj_id)
Update test result cache.
static _lookupObjIdForTestId($a_test_id)
Lookup object id for test id.
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...
static _lookupCreationComplete($a_obj_id)
checks wether all necessary parts of the test are given
static _getRandomTestsForQuestionPool($qpl_id)
Get all tests using a question pool for random selection.
static _lookupAnonymity($a_obj_id)
Returns the anonymity status of a test with a given object id.
static _lookupName($a_user_id)
lookup user name
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
static lookupOfflineStatus($a_obj_id)
Lookup offline status using objectDataCache.
A result encapsulates a value or an error and simplifies the handling of those.
isPermitted(string $path)
Interface for condition handling.
foreach($_POST as $key=> $value) $res