ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilObjTestAccess Class Reference

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.
 _checkCondition ($a_obj_id, $a_operator, $a_value, $a_usr_id=0)
 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.
 _lookupObjIdForTestId ($a_test_id)
 Lookup object id for test id.
 _getQuestionCount ($test_id)
 Calculates the number of questions in a test.
 _getRandomTestsForQuestionPool ($qpl_id)
 Get all tests using a question pool for random selection.
 _lookupOnlineTestAccess ($a_test_id, $a_user_id)
 Checks if a user is allowd to run an online exam.
 _getParticipantData ($active_id)
 Retrieves a participant name from active id.
 _getParticipantId ($active_id)
 Get user id for active id.
_getPassedUsers ($a_obj_id)
 Returns an array containing the users who passed the test.
 _checkGoto ($a_target)
 check whether goto script will succeed
- Public Member Functions inherited from ilObjectAccess
 _preloadData ($a_obj_ids, $a_ref_ids)
 Preload data.

Static Public Member Functions

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.
 _hasFinished ($a_user_id, $a_obj_id)
 Returns information if a specific user has finished a test.
static _isOffline ($a_obj_id)
 returns the objects's OFFline status
static _isOnline ($a_obj_id)
 returns the objects's ONline status

Detailed Description

Class ilObjTestAccess.

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

Author
Helmut Schottmueller helmu.nosp@m.t.sc.nosp@m.hottm.nosp@m.uell.nosp@m.er@ma.nosp@m.c.co.nosp@m.m
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

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_cmdcommand (not permission!)
string$a_permissionpermission
int$a_ref_idreference id
int$a_obj_idobject id
int$a_user_iduser 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 $ilUser, $lng, _lookupCreationComplete(), and IL_NO_OBJECT_ACCESS.

{
global $ilUser, $lng, $rbacsystem, $ilAccess;
if ($a_user_id == "")
{
$a_user_id = $ilUser->getId();
}
$is_admin = $rbacsystem->checkAccessOfUser($a_user_id,'write',$a_ref_id);
// check "global" online switch
if(!self::_isOnline($a_obj_id) && !$is_admin)
{
$ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
return false;
}
switch ($a_permission)
{
case "visible":
case "read":
!$is_admin)
{
$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":
{
$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,
  $a_usr_id = 0 
)

check condition

this method is called by ilConditionHandler

Reimplemented from ilObjectAccess.

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

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

Referenced by ilCourseStart\isFullfilled().

{
global $ilUser;
$a_usr_id = $a_usr_id ? $a_usr_id : $ilUser->getId();
switch($a_operator)
{
case 'passed':
return ilObjTestAccess::_isPassed($a_usr_id, $a_obj_id);
break;
case 'finished':
return ilObjTestAccess::_hasFinished($a_usr_id,$a_obj_id);
case 'not_finished':
return !ilObjTestAccess::_hasFinished($a_usr_id,$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 808 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 284 of file class.ilObjTestAccess.php.

Referenced by ilObjTestListGUI\init().

{
$commands = array
(
array("permission" => "write", "cmd" => "showPage", "lang_var" => "tst_edit_questions"),
array("permission" => "write", "cmd" => "properties", "lang_var" => "settings"),
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.

Parameters
boolean$randomTRUE if the test is a random test, otherwise FALSE
int$test_idThe test id
int$passThe test pass
Returns
int The available points for the test pass

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

References $pass, $result, and $row.

{
global $ilDB;
$max = 0;
if ($random)
{
$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",
array('integer','integer','integer'),
array($test_id, $pass, $user_id)
);
if ($result->numRows())
{
$row = $ilDB->fetchAssoc($result);
$max = $row["maxpoints"];
}
}
else
{
$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",
array('integer'),
array($test_id)
);
if ($result->numRows())
{
$row = $ilDB->fetchAssoc($result);
$max = $row["maxpoints"];
}
}
return $max;
}
ilObjTestAccess::_getParticipantData (   $active_id)

Retrieves a participant name from active id.

Parameters
integer$active_idActive ID of the participant
Returns
string The output name of the user public

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

References $lng, $result, $row, ilObjTest\_lookupAnonymity(), and ilObjUser\_lookupName().

Referenced by assQuestion\_setReachedPoints(), ilTestResultsToXML\exportActiveIDs(), and ilObjTestGUI\participantsObject().

{
global $lng, $ilDB;
$result = $ilDB->queryF("SELECT * FROM tst_active WHERE active_id = %s",
array("integer"),
array($active_id)
);
$row = $ilDB->fetchAssoc($result);
$user_id = $row["user_fi"];
$test_id = $row["test_fi"];
$importname = $row['importname'];
$result = $ilDB->queryF("SELECT obj_fi FROM tst_tests WHERE test_id = %s",
array("integer"),
array($test_id)
);
$row = $ilDB->fetchAssoc($result);
$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($importname))
{
$name = $importname . ' (' . $lng->txt('imported') . ')';
}
else 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::_getParticipantId (   $active_id)

Get user id for active id.

Parameters
intactive ID of the participant
Returns
int user id

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

References $lng, $result, and $row.

Referenced by assFileUpload\handleSubmission(), ilTestSession\increaseTestPass(), ilTestScoringGUI\saveManScoringParticipantScreen(), and ilTestSession\saveToDb().

{
global $lng, $ilDB;
$result = $ilDB->queryF("SELECT user_fi FROM tst_active WHERE active_id = %s",
array("integer"),
array($active_id)
);
$row = $ilDB->fetchAssoc($result);
return $row["user_fi"];
}

+ Here is the caller graph for this function:

& ilObjTestAccess::_getPassedUsers (   $a_obj_id)

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 741 of file class.ilObjTestAccess.php.

References $data, $result, $row, and assQuestion\_updateTestResultCache().

Referenced by ilLPStatusTestPassed\_getStatusInfo().

{
global $ilDB;
$passed_users = array();
// Maybe SELECT DISTINCT(tst_active.user_fi)... ?
$userresult = $ilDB->queryF("
SELECT tst_active.active_id, COUNT(tst_sequence.active_fi) sequences
FROM tst_tests
INNER JOIN tst_active
ON tst_active.test_fi = tst_tests.test_id
LEFT JOIN tst_sequence
ON tst_sequence.active_fi = tst_active.active_id
WHERE tst_tests.obj_fi = %s
GROUP BY tst_active.active_id
",
array('integer'), array($a_obj_id)
);
$all_participants = array();
$notAttempted = array();
while ($row = $ilDB->fetchAssoc($userresult))
{
if($row['sequences'] == 0)
{
$notAttempted[$row['active_id']] = $row['active_id'];
}
$all_participants[$row['active_id']] = $row['active_id'];
}
$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'));
$found_all = ($result->numRows() == count($all_participants)) ? true : false;
if (!$found_all)
{
// if the result cache entries do not exist, create them
$found_participants = array();
while ($data = $ilDB->fetchAssoc($result))
{
array_push($found_participants, $data['active_fi']);
}
foreach ($all_participants as $active_id)
{
if (!in_array($active_id, $found_participants))
{
include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
}
}
$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'));
}
while ($data = $ilDB->fetchAssoc($result))
{
if( isset($notAttempted[$data['active_fi']]) )
{
$data['failed'] = 0;
$data['passed'] = 0;
}
$data['user_id'] = $data['user_fi'];
array_push($passed_users, $data);
}
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.

Returns
int The number of questions in the test public

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

References $result, $row, $test, and _getTestData().

Referenced by _isComplete().

{
global $ilDB;
$num = 0;
if ($test["random_test"] == 1)
{
if ($test["random_question_count"] > 0)
{
$num = $test["random_question_count"];
}
else
{
$result = $ilDB->queryF("SELECT SUM(num_of_q) questioncount FROM tst_test_random WHERE test_fi = %s ORDER BY test_random_id",
array('integer'),
array($test_id)
);
if ($result->numRows())
{
$row = $ilDB->fetchAssoc($result);
$num = $row["questioncount"];
}
}
}
else
{
$result = $ilDB->queryF("SELECT test_question_id FROM tst_test_question WHERE test_fi = %s",
array('integer'),
array($test_id)
);
$num = $result->numRows();
}
return $num;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjTestAccess::_getRandomTestsForQuestionPool (   $qpl_id)

Get all tests using a question pool for random selection.

Parameters
intquestion pool id
Returns
array list if test obj ids public

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

References $query, $result, $row, and $tests.

Referenced by ilWebAccessChecker\checkAccessTestQuestion().

{
global $ilDB;
$query = 'SELECT DISTINCT t.obj_fi '
.'FROM tst_tests t '
.'INNER JOIN tst_test_random r '
.'ON t.test_id = r.test_fi '
.'WHERE r.questionpool_fi = '
. $ilDB->quote($qpl_id, 'integer');
$result = $ilDB->query($query);
$tests = array();
while ($row = $ilDB->fetchAssoc($result))
{
$tests[] = $row['obj_fi'];
}
return $tests;
}

+ Here is the caller graph for this function:

& ilObjTestAccess::_getTestData (   $test_id)

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

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

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

References $result.

Referenced by _getQuestionCount().

{
global $ilDB;
$result = $ilDB->queryF("SELECT * FROM tst_tests WHERE test_id = %s",
array('integer'),
array($test_id)
);
if (!$result->numRows())
{
return 0;
}
return $ilDB->fetchAssoc($result);
}

+ Here is the caller graph for this function:

ilObjTestAccess::_getTestIDFromObjectID (   $object_id)

Returns the ILIAS test id for a given object id.

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

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

References $result, and $row.

Referenced by _hasFinished(), _isComplete(), and ilLPStatusTestFinished\getParticipants().

{
global $ilDB;
$test_id = FALSE;
$result = $ilDB->queryF("SELECT test_id FROM tst_tests WHERE obj_fi = %s",
array('integer'),
array($object_id)
);
if ($result->numRows())
{
$row = $ilDB->fetchAssoc($result);
$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 365 of file class.ilObjTestAccess.php.

References $pass, $result, and $row.

{
if (is_null($pass))
{
$pass = 0;
}
$questions = array();
global $ilDB;
$result = $ilDB->queryF("SELECT test_fi FROM tst_active WHERE active_id = %s",
array('integer'),
array($active_id)
);
$test_id = "";
if ($result->numRows())
{
$row = $ilDB->fetchAssoc($result);
$test_id = $row["test_fi"];
}
else
{
return $questions;
}
$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",
array('integer'),
array($test_id)
);
if ($result->numRows())
{
// standard test
while ($row = $ilDB->fetchAssoc($result))
{
array_push($questions, $row);
}
}
else
{
// random test
$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",
array('integer','integer'),
array($active_id, $pass)
);
if ($result->numRows())
{
while ($row = $ilDB->fetchAssoc($result))
{
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_idDatabase id of the user
integertest obj_id
Returns
bool public

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

References $res, and _getTestIDFromObjectID().

Referenced by _checkCondition().

{
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;
}

+ 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
boolean True, if the test is complete for use, otherwise false public

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

References $result, $row, $test, _getQuestionCount(), and _getTestIDFromObjectID().

{
global $ilDB;
$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
{
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:

static ilObjTestAccess::_isOffline (   $a_obj_id)
static

returns the objects's OFFline status

Used in ListGUI and Learning Progress

Parameters
int$a_obj_id
Returns
bool

Reimplemented from ilObjectAccess.

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

References _isOnline().

{
// global $ilUser;
// return (self::_lookupOnlineTestAccess($a_obj_id, $ilUser->getId()) !== true) ||
// (!ilObjTestAccess::_lookupCreationComplete($a_obj_id));
return !self::_isOnline($a_obj_id);
}

+ Here is the call graph for this function:

static ilObjTestAccess::_isOnline (   $a_obj_id)
static

returns the objects's ONline status

Parameters
integer$a_obj_id
Returns
boolean $online

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

References $query, and $result.

Referenced by _isOffline(), and ilObjTestListGUI\getProperties().

{
global $ilDB;
$query = "
SELECT test_id
FROM tst_tests
WHERE obj_fi = %s
AND online_status = 1
";
$result = $ilDB->queryF( $query, array('integer'), array($a_obj_id) );
return $result->numRows() == 1;
}

+ Here is the caller graph for this function:

static ilObjTestAccess::_isPassed (   $user_id,
  $a_obj_id 
)
static

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

Parameters
int$user_idThe user id
int$a_obj_idThe object id
Returns
boolean TRUE if the user passed the test, FALSE otherwise

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

References $pass, $res, $result, $row, ASS_MarkSchema\_getMatchingMarkFromObjId(), assQuestion\_updateTestPassResults(), and assQuestion\_updateTestResultCache().

Referenced by _checkCondition(), and ilLPStatusTestPassed\determineStatus().

{
global $ilDB;
$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",
array('integer','integer'),
array($user_id, $a_obj_id)
);
if (!$result->numRows())
{
$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",
array('integer','integer'),
array($user_id, $a_obj_id)
);
$row = $ilDB->fetchAssoc($result);
if ($row['active_id'] > 0)
{
include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
}
else
{
return false;
}
}
$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",
array('integer','integer'),
array($user_id, $a_obj_id)
);
if (!$result->numRows())
{
$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",
array('integer','integer'),
array($user_id, $a_obj_id)
);
$points = array();
while ($row = $ilDB->fetchAssoc($result))
{
array_push($points, $row);
}
$reached = 0;
$max = 0;
if ($points[0]["pass_scoring"] == 0)
{
$reached = $points[count($points)-1]["points"];
$max = $points[count($points)-1]["maxpoints"];
if (!$max)
{
$active_id = $points[count($points)-1]["active_fi"];
$pass = $points[count($points)-1]["pass"];
if (strlen($active_id) && strlen($pass))
{
include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
$max = $res['maxpoints'];
$reached = $res['points'];
}
}
}
else
{
foreach ($points as $row)
{
if ($row["points"] > $reached)
{
$reached = $row["points"];
$max = $row["maxpoints"];
if (!$max)
{
$active_id = $row["active_fi"];
$pass = $row["pass"];
if (strlen($active_id) && strlen($pass))
{
include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
$max = $res['maxpoints'];
$reached = $res['points'];
}
}
}
}
}
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;
}
else
{
$row = $ilDB->fetchAssoc($result);
return ($row['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 306 of file class.ilObjTestAccess.php.

References $result, and $row.

Referenced by _checkAccess().

{
global $ilDB;
$result = $ilDB->queryF("SELECT complete FROM tst_tests WHERE obj_fi=%s",
array('integer'),
array($a_obj_id)
);
if ($result->numRows() == 1)
{
$row = $ilDB->fetchAssoc($result);
}
return ($row['complete']) ? true : false;
}

+ Here is the caller graph for this function:

ilObjTestAccess::_lookupObjIdForTestId (   $a_test_id)

Lookup object id for test id.

Parameters
inttest id
Returns
int object id

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

References $result, and $row.

Referenced by ilTestSession\increaseTestPass(), and ilTestSession\saveToDb().

{
global $ilDB;
$result = $ilDB->queryF("SELECT obj_fi FROM tst_tests WHERE test_id = %s",
array('integer'),
array($a_test_id)
);
$row = $ilDB->fetchAssoc($result);
return $row["obj_fi"];
}

+ 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.

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 593 of file class.ilObjTestAccess.php.

References $lng, $result, and $row.

Referenced by ilObjTestGUI\buildPageViewToolbar(), ilObjTestListGUI\getProperties(), ilObjTestGUI\infoScreen(), and ilObjTestGUI\questionsObject().

{
global $ilDB, $lng;
$result = $ilDB->queryF("SELECT tst_tests.* FROM tst_tests WHERE tst_tests.obj_fi = %s",
array('integer'),
array($a_test_id)
);
if ($result->numRows())
{
$row = $ilDB->fetchAssoc($result);
if ($row["fixed_participants"])
{
$result = $ilDB->queryF("SELECT * FROM tst_invited_user WHERE test_fi = %s AND user_fi = %s",
array('integer','integer'),
array($row["test_id"], $a_user_id)
);
if ($result->numRows())
{
$row = $ilDB->fetchAssoc($result);
if (trim($row['clientip']) != "")
{
$row['clientip'] = preg_replace("/[^0-9.?*,:]+/","",$row['clientip']);
$row['clientip'] = str_replace(".","\\.",$row['clientip']);
$row['clientip'] = str_replace(Array("?","*",","), Array("[0-9]","[0-9]*","|"), $row['clientip']);
if (!preg_match("/^".$row['clientip']."$/", $_SERVER["REMOTE_ADDR"]))
{
return $lng->txt("tst_user_wrong_clientip");
}
else
{
return true;
}
}
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: