ILIAS  Release_5_0_x_branch Revision 61816
 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.
 _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.
 _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
 _checkCondition ($a_obj_id, $a_operator, $a_value, $a_usr_id)
 check condition
 _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.
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.
static getConditionOperators ()
 Get possible conditions operators.
static checkCondition ($a_obj_id, $a_operator, $a_value, $a_usr_id)
 check condition
static hasFinished ($a_user_id, $a_obj_id)
 Returns (request cached) information if a specific user has finished at least one test pass.
static _isOffline ($a_obj_id)
 returns the objects's OFFline status
static _isOnline ($a_obj_id)
 returns the objects's ONline status

Protected Member Functions

 updateTestResultCache ($a_user_id, $a_obj_id)
 Update test result cache.

Static Private Attributes

static $hasFinishedCache = array()

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:
class.ilObjTestAccess.php 61351 2015-11-20 10:00:13Z gitmgr

Definition at line 20 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 37 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::_checkGoto (   $a_target)

check whether goto script will succeed

Reimplemented from ilObjectAccess.

Definition at line 889 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("read", "", $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 410 of file class.ilObjTestAccess.php.

Referenced by ilObjTestListGUI\init().

{
$commands = array
(
array("permission" => "write", "cmd" => "questionsTabGateway", "lang_var" => "tst_edit_questions"),
array("permission" => "write", "cmd" => "ilObjTestSettingsGeneralGUI::showForm", "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 92 of file class.ilObjTestAccess.php.

References $ilDB, $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 736 of file class.ilObjTestAccess.php.

References $ilDB, $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 795 of file class.ilObjTestAccess.php.

References $ilDB, $lng, $result, and $row.

Referenced by assFileUpload\handleSubmission(), ilTestSession\increaseTestPass(), ilTestScoringGUI\saveManScoringParticipantScreen(), ilTestSessionDynamicQuestionSet\saveToDb(), 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 822 of file class.ilObjTestAccess.php.

References $ilDB, $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::_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 644 of file class.ilObjTestAccess.php.

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

Referenced by ilWebAccessChecker\checkAccessTestQuestion().

{
global $ilDB;
$query = "
SELECT DISTINCT t.obj_fi
FROM tst_tests t
INNER JOIN tst_rnd_quest_set_qpls r
ON t.test_id = r.test_fi
WHERE r.pool_fi = %s
";
$result = $ilDB->queryF($query, array('integer'), array($qpl_id));
$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 604 of file class.ilObjTestAccess.php.

References $ilDB, and $result.

{
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);
}
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 500 of file class.ilObjTestAccess.php.

References $ilDB, $result, and $row.

Referenced by 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 516 of file class.ilObjTestAccess.php.

References $ilDB, $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::_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 575 of file class.ilObjTestAccess.php.

References $ilDB, $query, $res, and $row.

{
global $ilDB;
$query = "
SELECT tst_tests.complete
FROM object_data
INNER JOIN tst_tests
ON tst_tests.obj_fi = object_data.obj_id
WHERE object_data.obj_id = %s
";
$res = $ilDB->queryF($query, array('integer'), array($a_obj_id));
while( $row = $ilDB->fetchAssoc($res) )
{
return (bool)$row['complete'];
}
return false;
}
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 915 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 929 of file class.ilObjTestAccess.php.

References $ilDB, $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 130 of file class.ilObjTestAccess.php.

References $ilDB, $pass, $res, $result, $row, ASS_MarkSchema\_getMatchingMarkFromObjId(), 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";
$res = assQuestion::_updateTestPassResults($active_id, $pass, null, $a_obj_id);
$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";
$res = assQuestion::_updateTestPassResults($active_id, $pass, null, $a_obj_id);
$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 432 of file class.ilObjTestAccess.php.

References $ilDB, $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 624 of file class.ilObjTestAccess.php.

References $ilDB, $result, and $row.

Referenced by ilTestSession\increaseTestPass(), ilTestSessionDynamicQuestionSet\saveToDb(), 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 674 of file class.ilObjTestAccess.php.

References $ilDB, $lng, $result, and $row.

Referenced by ilObjTestGUI\buildPageViewToolbar(), ilObjTestListGUI\getProperties(), 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:

static ilObjTestAccess::checkCondition (   $a_obj_id,
  $a_operator,
  $a_value,
  $a_usr_id 
)
static

check condition

this method is called by ilConditionHandler

Implements ilConditionHandling.

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

References _isPassed(), hasFinished(), isFailed(), ilConditionHandler\OPERATOR_FAILED, ilConditionHandler\OPERATOR_FINISHED, ilConditionHandler\OPERATOR_NOT_FINISHED, and ilConditionHandler\OPERATOR_PASSED.

Referenced by ilCourseStart\isFullfilled(), and ilContainerStartObjects\isFullfilled().

{
include_once './Services/AccessControl/classes/class.ilConditionHandler.php';
switch($a_operator)
{
return ilObjTestAccess::_isPassed($a_usr_id, $a_obj_id);
break;
return ilObjTestAccess::isFailed($a_usr_id, $a_obj_id);
return ilObjTestAccess::hasFinished($a_usr_id,$a_obj_id);
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:

static ilObjTestAccess::getConditionOperators ( )
static
static ilObjTestAccess::hasFinished (   $a_user_id,
  $a_obj_id 
)
static

Returns (request cached) information if a specific user has finished at least one test pass.

Parameters
integer$user_idobj_id of the user
integer$a_obj_idobj_id of the test
Returns
bool

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

References $ilDB, $lng, and ilObjectFactory\getInstanceByObjId().

Referenced by checkCondition().

{
if( !isset(self::$hasFinishedCache["{$a_user_id}:{$a_obj_id}"]) )
{
require_once 'Modules/Test/classes/class.ilTestParticipantData.php';
require_once 'Modules/Test/classes/class.ilTestSessionFactory.php';
require_once 'Modules/Test/classes/class.ilTestPassesSelector.php';
global $ilDB, $lng;
$testOBJ = ilObjectFactory::getInstanceByObjId($a_obj_id);
$partData = new ilTestParticipantData($ilDB, $lng);
$partData->setUserIds(array($a_user_id));
$partData->load($testOBJ->getTestId());
$activeId = $partData->getActiveIdByUserId($a_user_id);
$testSessionFactory = new ilTestSessionFactory($testOBJ);
$testSession = $testSessionFactory->getSession($activeId);
$testPassesSelector = new ilTestPassesSelector($ilDB, $testOBJ);
$testPassesSelector->setActiveId($activeId);
$testPassesSelector->setLastFinishedPass($testSession->getLastFinishedPass());
self::$hasFinishedCache["{$a_user_id}:{$a_obj_id}"] = count($testPassesSelector->getClosedPasses());
}
return self::$hasFinishedCache["{$a_user_id}:{$a_obj_id}"];
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Returns TRUE if the user with the user id $user_id failed 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 failed the test, FALSE otherwise

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

References $ilDB, $pass, $res, $result, $ret, $row, ASS_MarkSchema\_getMatchingMarkFromObjId(), and updateTestResultCache().

Referenced by checkCondition().

{
global $ilDB;
$ret = self::updateTestResultCache($user_id, $a_obj_id);
if(!$ret)
{
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)
);
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";
$res = assQuestion::_updateTestPassResults($active_id, $pass, null, $a_obj_id);
$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";
$res = assQuestion::_updateTestPassResults($active_id, $pass, null, $a_obj_id);
$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["failed"]) ? TRUE : FALSE;
}
else
{
$row = $ilDB->fetchAssoc($result);
return ($row['failed']) ? TRUE : FALSE;
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjTestAccess::updateTestResultCache (   $a_user_id,
  $a_obj_id 
)
protected

Update test result cache.

Parameters
type$a_user_id
type$a_obj_id

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

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

Referenced by isFailed().

{
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($a_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($a_user_id, $a_obj_id)
);
$row = $ilDB->fetchAssoc($result);
if ($row['active_id'] > 0)
{
include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
return true;
}
else
{
return false;
}
}
else
{
return true;
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Field Documentation

ilObjTestAccess::$hasFinishedCache = array()
staticprivate

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


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