Public Member Functions | Static Public Member Functions

ilObjTestAccess Class Reference
[Modules/Test]

Class ilObjTestAccess. More...

Inheritance diagram for ilObjTestAccess:
Collaboration diagram for ilObjTestAccess:

Public Member Functions

 _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::checkAccess).
 _getMaxPointsForTestPass ($random, $user_id, $test_id, $pass)
 Returns the maximum number of points available for a test pass.
 _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.
 _checkCondition ($a_obj_id, $a_operator, $a_value)
 check condition
 _getCommands ()
 get commands
 _lookupCreationComplete ($a_obj_id)
 checks wether all necessary parts of the test are given
 _getTestIDFromObjectID ($object_id)
 Returns the ILIAS test id for a given object id.
_getTestQuestions ($active_id, $pass=NULL)
 _isComplete ($a_obj_id)
 Returns true, if a test is complete for use.
_getTestData ($test_id)
 Returns the database content of a test with a given id.
 _getQuestionCount ($test_id)
 Calculates the number of questions in a test.
 _lookupOnlineTestAccess ($a_test_id, $a_user_id)
 Checks if a user is allowd to run an online exam.
_getPassedUsers ($a_obj_id)
 Returns an array containing the users who passed the test.
 _checkGoto ($a_target)
 check whether goto script will succeed
 _getParticipantData ($active_id)
 Retrieves a participant name from active id.

Static Public Member Functions

 _hasFinished ($a_user_id, $a_obj_id)
 Returns information if a specific user has finished a test.

Detailed Description

Class ilObjTestAccess.

This class contains methods that check object specific conditions for accessing test objects.

Author:
Helmut Schottmueller <helmut.schottmueller@mac.com>
Alex Killing <alex.killing@gmx.de>
Version:
Id:
class.ilObjTestAccess.php 22004 2009-10-01 11:16:20Z hschottm

Definition at line 39 of file class.ilObjTestAccess.php.


Member Function Documentation

ilObjTestAccess::_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::checkAccess).

Please do not check any preconditions handled by ilConditionHandler here.

Parameters:
string $a_cmd command (not permission!)
string $a_permission permission
int $a_ref_id reference id
int $a_obj_id object id
int $a_user_id user id (if not provided, current user is taken)
Returns:
boolean true, if everything is ok

Reimplemented from ilObjectAccess.

Definition at line 56 of file class.ilObjTestAccess.php.

References $lng, and _lookupCreationComplete().

        {
                global $ilUser, $lng, $rbacsystem, $ilAccess;
                if ($a_user_id == "")
                {
                        $a_user_id = $ilUser->getId();
                }

                switch ($a_permission)
                {
                        case "read":
                        case "visible":
                                if (!ilObjTestAccess::_lookupCreationComplete($a_obj_id) &&
                                        (!$rbacsystem->checkAccess('write', $a_ref_id)))
                                {
                                        $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("tst_warning_test_not_complete"));
                                        return false;
                                }
                                break;
                }
                switch ($a_cmd)
                {
                        case "eval_a":
                        case "eval_stat":
                                if (!ilObjTestAccess::_lookupCreationComplete($a_obj_id))
                                {
                                        $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("tst_warning_test_not_complete"));
                                        return false;
                                }
                                break;

                }

                return true;
        }

Here is the call graph for this function:

ilObjTestAccess::_checkCondition ( a_obj_id,
a_operator,
a_value 
)

check condition

this method is called by ilConditionHandler

Reimplemented from ilObjectAccess.

Definition at line 215 of file class.ilObjTestAccess.php.

References $ilias, _hasFinished(), and _isPassed().

Referenced by ilCourseStart::isFullfilled().

        {
                global $ilias;
                switch($a_operator)
                {
                        case 'passed':
                                return ilObjTestAccess::_isPassed($ilias->account->getId(), $a_obj_id);
                                break;

                        case 'finished':
                                return ilObjTestAccess::_hasFinished($ilias->account->getId(),$a_obj_id);

                        case 'not_finished':
                                return !ilObjTestAccess::_hasFinished($ilias->account->getId(),$a_obj_id);

                        default:
                                return true;
                }
                return true;
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilObjTestAccess::_checkGoto ( a_target  ) 

check whether goto script will succeed

Reimplemented from ilObjectAccess.

Definition at line 679 of file class.ilObjTestAccess.php.

        {
                global $ilAccess;
                
                $t_arr = explode("_", $a_target);

                if ($t_arr[0] != "tst" || ((int) $t_arr[1]) <= 0)
                {
                        return false;
                }

                if ($ilAccess->checkAccess("visible", "", $t_arr[1]))
                {
                        return true;
                }
                return false;
        }

ilObjTestAccess::_getCommands (  ) 

get commands

this method returns an array of all possible commands/permission combinations

example: $commands = array ( array("permission" => "read", "cmd" => "view", "lang_var" => "show"), array("permission" => "write", "cmd" => "edit", "lang_var" => "edit"), );

Reimplemented from ilObjectAccess.

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

Referenced by ilObjTestListGUI::init().

        {
                $commands = array
                (
                        array("permission" => "read", "cmd" => "infoScreen", "lang_var" => "tst_run",
                                "default" => true),
                        array("permission" => "write", "cmd" => "", "lang_var" => "edit"),
                        array("permission" => "tst_statistics", "cmd" => "outEvaluation", "lang_var" => "tst_statistical_evaluation")
                );
                
                return $commands;
        }

Here is the caller graph for this function:

ilObjTestAccess::_getMaxPointsForTestPass ( random,
user_id,
test_id,
pass 
)

Returns the maximum number of points available for a test pass.

Returns the maximum number of points available for a test pass

Parameters:
boolean $random TRUE if the test is a random test, otherwise FALSE
int $test_id The test id
int $pass The test pass
Returns:
int The available points for the test pass

Definition at line 102 of file class.ilObjTestAccess.php.

Referenced by _getPassedUsers(), and _isPassed().

        {
                global $ilDB;
                $max = 0;

                if ($random)
                {
                        $query = sprintf("SELECT SUM(qpl_questions.points) AS maxpoints FROM tst_test_random_question, qpl_questions, tst_active WHERE tst_active.active_id = tst_test_random_question.active_fi AND tst_test_random_question.question_fi = qpl_questions.question_id AND tst_active.test_fi = %s AND tst_test_random_question.pass = %s AND tst_active.user_fi = %s",
                                $ilDB->quote($test_id . ""),
                                $ilDB->quote($pass . ""),
                                $ilDB->quote($user_id . "")
                        );
                        $result = $ilDB->query($query);
                        if ($result->numRows())
                        {
                                $row = $result->fetchRow(DB_FETCHMODE_ASSOC);
                                $max = $row["maxpoints"];
                        }
                }
                else
                {
                        $query = sprintf("SELECT SUM(qpl_questions.points) AS maxpoints FROM tst_test_question, qpl_questions WHERE tst_test_question.question_fi = qpl_questions.question_id AND tst_test_question.test_fi = %s",
                                $ilDB->quote($test_id . "")
                        );
                        $result = $ilDB->query($query);
                        if ($result->numRows())
                        {
                                $row = $result->fetchRow(DB_FETCHMODE_ASSOC);
                                $max = $row["maxpoints"];
                        }
                }
                return $max;
        }

Here is the caller graph for this function:

ilObjTestAccess::_getParticipantData ( active_id  ) 

Retrieves a participant name from active id.

Parameters:
integer $active_id Active ID of the participant
Returns:
string The output name of the user public

Definition at line 704 of file class.ilObjTestAccess.php.

References $lng, ilObjTest::_lookupAnonymity(), and ilObjUser::_lookupName().

Referenced by assQuestion::_setReachedPoints().

        {
                global $lng, $ilDB;

                $query = sprintf("SELECT user_fi, test_fi FROM tst_active WHERE active_id = %s",
                        $ilDB->quote($active_id)
                );
                $result = $ilDB->query($query);
                $row = $result->fetchRow(DB_FETCHMODE_ASSOC);
                $user_id = $row["user_fi"];
                $test_id = $row["test_fi"];

                $query = sprintf("SELECT obj_fi FROM tst_tests WHERE test_id = %s",
                        $ilDB->quote($test_id)
                );
                $result = $ilDB->query($query);
                $row = $result->fetchRow(DB_FETCHMODE_ASSOC);
                $obj_id = $row["obj_fi"];
                
                include_once "./Modules/Test/classes/class.ilObjTest.php";
                $is_anonymous = ilObjTest::_lookupAnonymity($obj_id);
                
                include_once './Services/User/classes/class.ilObjUser.php';
                $uname = ilObjUser::_lookupName($user_id);

                $name = "";
                if (strlen($uname["firstname"].$uname["lastname"]) == 0)
                {
                        $name = $lng->txt("deleted_user");
                }
                else
                {
                        if ($user_id == ANONYMOUS_USER_ID)
                        {
                                $name = $lastname;
                        }
                        else
                        {
                                $name = trim($uname["lastname"] . ", " . $uname["firstname"] . " " .  $uname["title"]);
                        }
                        if ($is_anonymous)
                        {
                                $name = $lng->txt("anonymous");
                        }
                }
                return $name;
        }

Here is the call graph for this function:

Here is the caller graph for this function:

& ilObjTestAccess::_getPassedUsers ( a_obj_id  ) 

Returns an array containing the users who passed the test.

Returns an array containing the users who passed the test

Returns:
array An array containing the users who passed the test. Format of the values of the resulting array: array( "user_id" => user ID, "max_points" => maximum available points in the test "reached_points" => maximum reached points of the user "mark_short" => short text of the passed mark "mark_official" => official text of the passed mark ) public

Definition at line 587 of file class.ilObjTestAccess.php.

References $user, ilObjTest::_getCompleteEvaluationData(), ASS_MarkSchema::_getMatchingMarkFromObjId(), and _getMaxPointsForTestPass().

Referenced by ilLPStatusTestPassed::_getStatusInfo().

        {
                global $ilDB;

                $passed_users = array();
                $query = sprintf("SELECT tst_active.user_fi FROM tst_active, tst_tests WHERE tst_tests.test_id = tst_active.test_fi AND tst_tests.obj_fi = %s",
                        $ilDB->quote($a_obj_id . "")
                );
                $userresult = $ilDB->query($query);
                if ($userresult->numRows())
                {
                        while ($userrow = $userresult->fetchRow(DB_FETCHMODE_ASSOC))
                        {
                                $user_id = $userrow["user_fi"];
                                $query = sprintf("SELECT tst_test_pass_result.*, tst_tests.pass_scoring, tst_tests.random_test, tst_tests.test_id FROM tst_test_pass_result, tst_active, tst_tests, object_data WHERE object_data.obj_id = tst_tests.obj_fi AND tst_active.test_fi = tst_tests.test_id AND tst_active.user_fi = %s AND object_data.obj_id = %s AND tst_test_pass_result.active_fi = tst_active.active_id ORDER BY tst_test_pass_result.pass",
                                        $ilDB->quote($user_id . ""),
                                        $ilDB->quote($a_obj_id . "")
                                );
                                $result = $ilDB->query($query);
                                $points = array();
                                while ($row = $result->fetchRow(DB_FETCHMODE_ASSOC))
                                {
                                        array_push($points, $row);
                                }
                                $reached = 0;
                                $max = 0;
                                if ($points[0]["pass_scoring"] == 0)
                                {
                                        $reached = $points[count($points)-1]["points"];
                                        $max = ilObjTestAccess::_getMaxPointsForTestPass($points[count($points)-1]["random_test"], $user_id, $points[count($points)-1]["test_id"], $points[count($points)-1]["pass"]);
                                        if (!strlen($max))
                                        {
                                                include_once "./Modules/Test/classes/class.ilObjTest.php";
                                                $r = ilObjTest::_getCompleteEvaluationData($points[count($points)-1]["test_id"], false, $points[count($points)-1]["active_fi"]);
                                                $p = $r->getParticipants();
                                                if (!is_null($p))
                                                {
                                                        $user = $p[$points[count($points)-1]["active_fi"]];
                                                        if (!is_null($user))
                                                        {
                                                                $max = $user->getMaxpoints();
                                                        }
                                                }
                                        }
                                }
                                else
                                {
                                        foreach ($points as $row)
                                        {
                                                if ($row["points"] > $reached) 
                                                {
                                                        $max = ilObjTestAccess::_getMaxPointsForTestPass($row["random_test"], $user_id, $row["test_id"], $row["pass"]);
                                                        if (!strlen($max))
                                                        {
                                                                include_once "./Modules/Test/classes/class.ilObjTest.php";
                                                                $r = ilObjTest::_getCompleteEvaluationData($points[count($points)-1]["test_id"], false, $points[count($points)-1]["active_fi"]);
                                                                $p = $r->getParticipants();
                                                                if (!is_null($p))
                                                                {
                                                                        $user = $p[$points[count($points)-1]["active_fi"]];
                                                                        if (!is_null($user))
                                                                        {
                                                                                $max = $user->getMaxpoints();
                                                                        }
                                                                }
                                                        }
                                                        $reached = $row["points"];
                                                }
                                        }
                                }
                                include_once "./Modules/Test/classes/class.assMarkSchema.php";
                                $percentage = (!$max) ? 0 : ($reached / $max) * 100.0;
                                $mark = ASS_MarkSchema::_getMatchingMarkFromObjId($a_obj_id, $percentage);
                                array_push($passed_users, 
                                        array(
                                                "user_id" => $user_id,
                                                "max_points" => $max,
                                                "reached_points" => $reached,
                                                "mark_short" => $mark["short_name"],
                                                "mark_official" => $mark["official_name"],
                                                "passed" => ($mark["passed"]) ? TRUE : FALSE,
                                                "failed" => (!$mark["passed"]) ? TRUE : FALSE
                                        )
                                );
                        }
                }
                return $passed_users;
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilObjTestAccess::_getQuestionCount ( test_id  ) 

Calculates the number of questions in a test.

Calculates the number of questions in a test

Returns:
int The number of questions in the test public

Definition at line 479 of file class.ilObjTestAccess.php.

References _getTestData().

Referenced by _isComplete().

{
        global $ilDB;

        $num = 0;

        $test =& ilObjTestAccess::_getTestData($test_id);

        if ($test["random_test"] == 1)
        {
                if ($test["random_question_count"] > 0)
                {
                        $num = $test["random_question_count"];
                }
                else
                {
                        $query = sprintf("SELECT SUM(num_of_q) AS questioncount FROM tst_test_random WHERE test_fi = %s ORDER BY test_random_id",
                                $ilDB->quote($test_id . "")
                        );
                        $result = $ilDB->query($query);
                        if ($result->numRows())
                        {
                                $row = $result->fetchRow(DB_FETCHMODE_ASSOC);
                                $num = $row["questioncount"];
                        }
                }
        }
        else
        {
                $query = sprintf("SELECT test_question_id FROM tst_test_question WHERE test_fi = %s",
                        $ilDB->quote($test_id . "")
                );
                $result = $ilDB->query($query);
                $num = $result->numRows();
        }
        return $num;
}

Here is the call graph for this function:

Here is the caller graph for this function:

& ilObjTestAccess::_getTestData ( test_id  ) 

Returns the database content of a test with a given id.

Returns the database content of a test with a given id

Parameters:
int $test_id Database id of the test
Returns:
array An associative array with the contents of the tst_tests database row public

Definition at line 456 of file class.ilObjTestAccess.php.

Referenced by _getQuestionCount().

        {
                global $ilDB;
                $query = sprintf("SELECT * FROM tst_tests WHERE test_id = %s",
                        $ilDB->quote($test_id . "")
                );
                $result = $ilDB->query($query);
                if (!$result->numRows())
                {
                        return 0;
                }
                $test = $result->fetchRow(DB_FETCHMODE_ASSOC);
                return $test;
        }

Here is the caller graph for this function:

ilObjTestAccess::_getTestIDFromObjectID ( object_id  ) 

Returns the ILIAS test id for a given object id.

Returns the ILIAS test id for a given object id

Parameters:
integer $object_id The object id
Returns:
mixed The ILIAS test id or FALSE if the query was not successful public

Definition at line 320 of file class.ilObjTestAccess.php.

Referenced by _hasFinished(), and _isComplete().

        {
                global $ilDB;
                $test_id = FALSE;
                $query = sprintf("SELECT test_id FROM tst_tests WHERE obj_fi = %s",
                        $ilDB->quote($object_id . "")
                );
                $result = $ilDB->query($query);
                if ($result->numRows())
                {
                        $row = $result->fetchRow(DB_FETCHMODE_ASSOC);
                        $test_id = $row["test_id"];
                }
                return $test_id;
        }

Here is the caller graph for this function:

& ilObjTestAccess::_getTestQuestions ( active_id,
pass = NULL 
)

Definition at line 336 of file class.ilObjTestAccess.php.

        {
                if (is_null($pass))
                {
                        $pass = 0;
                }
                $questions = array();
                
                global $ilDB;
                $query = sprintf("SELECT test_fi FROM tst_active WHERE active_id = %s",
                        $ilDB->quote($active_id . "")
                );
                $result = $ilDB->query($query);
                $test_id = "";
                if ($result->numRows())
                {
                        $row = $result->fetchRow(DB_FETCHMODE_ASSOC);
                        $test_id = $row["test_fi"];
                }
                else
                {
                        return $questions;
                }
                $query = sprintf("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",
                        $ilDB->quote($test_id . "")
                );
                $result = $ilDB->query($query);
                if ($result->numRows())
                {
                        // standard test
                        while ($row = $result->fetchRow(DB_FETCHMODE_ASSOC))
                        {
                                array_push($questions, $row);
                        }
                }
                else
                {
                        // random test
                        $query = sprintf("SELECT qpl_questions.question_id, qpl_questions.points FROM qpl_questions, tst_test_random_question WHERE tst_test_random_question.question_fi = qpl_questions.question_id AND tst_test_random_question.active_fi = %s AND tst_test_random_question.pass = %s ORDER BY tst_test_random_question.sequence",
                                $ilDB->quote($active_id . ""),
                                $ilDB->quote($pass . "")
                        );
                        $result = $ilDB->query($query);
                        if ($result->numRows())
                        {
                                while ($row = $result->fetchRow(DB_FETCHMODE_ASSOC))
                                {
                                        array_push($questions, $row);
                                }
                        }
                }
                return $questions;
        }

ilObjTestAccess::_hasFinished ( a_user_id,
a_obj_id 
) [static]

Returns information if a specific user has finished a test.

Parameters:
integer $user_id Database id of the user
integer test obj_id
Returns:
bool public

Definition at line 298 of file class.ilObjTestAccess.php.

References $res, and _getTestIDFromObjectID().

Referenced by _checkCondition().

        {
                global $ilDB;

                $query = sprintf("SELECT active_id FROM tst_active WHERE user_fi = %s AND test_fi = %s AND tries > '0'",
                        $ilDB->quote($a_user_id . ""),
                        $ilDB->quote(ilObjTestAccess::_getTestIDFromObjectID($a_obj_id) . "")
                );
                $res = $ilDB->query($query);

                return $res->numRows() ? true : false;
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilObjTestAccess::_isComplete ( a_obj_id  ) 

Returns true, if a test is complete for use.

Returns true, if a test is complete for use

Returns:
boolean True, if the test is complete for use, otherwise false public

Definition at line 398 of file class.ilObjTestAccess.php.

References _getQuestionCount(), and _getTestIDFromObjectID().

        {
                global $ilDB;
                
                $test_id = ilObjTestAccess::_getTestIDFromObjectID($a_obj_id);
                $query = sprintf("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",
                        $ilDB->quote($test_id . "")
                );
                $result = $ilDB->query($query);
                $found = $result->numRows();
                if ($found)
                {
                        $row = $result->fetchRow(DB_FETCHMODE_ASSOC);
                        // 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;
                }
        }

Here is the call graph for this function:

ilObjTestAccess::_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.

Returns TRUE if the user with the user id $user_id passed the test with the object id $a_obj_id

Parameters:
int $user_id The user id
int $a_obj_id The object id
Returns:
boolean TRUE if the user passed the test, FALSE otherwise

Definition at line 145 of file class.ilObjTestAccess.php.

References $user, ilObjTest::_getCompleteEvaluationData(), ASS_MarkSchema::_getMatchingMarkFromObjId(), and _getMaxPointsForTestPass().

Referenced by _checkCondition().

        {
                global $ilDB;
                $query = sprintf("SELECT tst_test_pass_result.*, tst_tests.pass_scoring, tst_tests.random_test, tst_tests.test_id FROM tst_test_pass_result, tst_active, tst_tests, object_data WHERE object_data.obj_id = tst_tests.obj_fi AND tst_active.test_fi = tst_tests.test_id AND tst_active.user_fi = %s AND object_data.obj_id = %s AND tst_test_pass_result.active_fi = tst_active.active_id ORDER BY tst_test_pass_result.pass",
                        $ilDB->quote($user_id . ""),
                        $ilDB->quote($a_obj_id . "")
                );
                $result = $ilDB->query($query);
                $points = array();
                while ($row = $result->fetchRow(DB_FETCHMODE_ASSOC))
                {
                        array_push($points, $row);
                }
                $reached = 0;
                $max = 0;
                if ($points[0]["pass_scoring"] == 0)
                {
                        $reached = $points[count($points)-1]["points"];
                        $max = ilObjTestAccess::_getMaxPointsForTestPass($points[count($points)-1]["random_test"], $user_id, $points[count($points)-1]["test_id"], $points[count($points)-1]["pass"]);
                        if (!strlen($max))
                        {
                                include_once "./Modules/Test/classes/class.ilObjTest.php";
                                $r = ilObjTest::_getCompleteEvaluationData($points[count($points)-1]["test_id"], false, $points[count($points)-1]["active_fi"]);
                                $p = $r->getParticipants();
                                if (!is_null($p))
                                {
                                        $user = $p[$points[count($points)-1]["active_fi"]];
                                        if (!is_null($user))
                                        {
                                                return $user->getPassed();
                                        }
                                }
                        }
                }
                else
                {
                        foreach ($points as $row)
                        {
                                if ($row["points"] > $reached) 
                                {
                                        $max = ilObjTestAccess::_getMaxPointsForTestPass($row["random_test"], $user_id, $row["test_id"], $row["pass"]);
                                        $reached = $row["points"];
                                        if (!strlen($max))
                                        {
                                                include_once "./Modules/Test/classes/class.ilObjTest.php";
                                                $r = ilObjTest::_getCompleteEvaluationData($points[count($points)-1]["test_id"], false, $points[count($points)-1]["active_fi"]);
                                                $p = $r->getParticipants();
                                                if (!is_null($p))
                                                {
                                                        $user = $p[$points[count($points)-1]["active_fi"]];
                                                        if (!is_null($user))
                                                        {
                                                                return $user->getPassed();
                                                        }
                                                }
                                        }
                                }
                        }
                }
                include_once "./Modules/Test/classes/class.assMarkSchema.php";
                $percentage = (!$max) ? 0 : ($reached / $max) * 100.0;
                $mark = ASS_MarkSchema::_getMatchingMarkFromObjId($a_obj_id, $percentage);
                return ($mark["passed"]) ? TRUE : FALSE;
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilObjTestAccess::_lookupCreationComplete ( a_obj_id  ) 

checks wether all necessary parts of the test are given

Definition at line 268 of file class.ilObjTestAccess.php.

Referenced by _checkAccess(), and ilObjTestListGUI::getProperties().

        {
                global $ilDB;

                $q = sprintf("SELECT * FROM tst_tests WHERE obj_fi=%s",
                        $ilDB->quote($a_obj_id)
                );
                $result = $ilDB->query($q);
                if ($result->numRows() == 1)
                {
                        $row = $result->fetchRow(DB_FETCHMODE_OBJECT);
                }

                if (!$row->complete)
                {
                        return false;
                }

                return true;
        }

Here is the caller graph for this function:

ilObjTestAccess::_lookupOnlineTestAccess ( a_test_id,
a_user_id 
)

Checks if a user is allowd to run an online exam.

Checks if a user is allowd to run an online exam

Returns:
mixed true if the user is allowed to run the online exam or if the test isn't an online exam, an alert message if the test is an online exam and the user is not allowed to run it public

Definition at line 525 of file class.ilObjTestAccess.php.

References $lng.

Referenced by ilObjTestListGUI::getProperties(), and ilObjTestGUI::infoScreen().

        {
                global $ilDB, $lng;
                
                $query = sprintf("SELECT tst_tests.* FROM tst_tests WHERE tst_tests.obj_fi = %s",
                        $ilDB->quote($a_test_id . "")
                );
                $result = $ilDB->query($query);
                if ($result->numRows())
                {
                        $row = $result->fetchRow(DB_FETCHMODE_ASSOC);
                        if ($row["fixed_participants"])
                        {
                                $query = sprintf("SELECT * FROM tst_invited_user WHERE test_fi = %s AND user_fi = %s",
                                        $ilDB->quote($row["test_id"] . ""),
                                        $ilDB->quote($a_user_id . "")
                                );
                                $result = $ilDB->query($query);
                                if ($result->numRows())
                                {
                                        $row = $result->fetchRow(DB_FETCHMODE_ASSOC);
                                        if (strcmp($row["clientip"],"")!=0 && strcmp($row["clientip"],$_SERVER["REMOTE_ADDR"])!=0)
                                        {
                                                return $lng->txt("tst_user_wrong_clientip");
                                        }
                                        else
                                        {
                                                return true;
                                        }
                                }
                                else
                                {
                                        return $lng->txt("tst_user_not_invited");
                                }
                        }
                        else
                        {
                                return true;
                        }
                }
                else
                {
                        return true;
                }
        }

Here is the caller graph for this function:


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