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). | |
| _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. | |
| & | _getTestResult ($user_id, $test_obj_id) |
| Calculates the results of a test for a given user. | |
| _isComplete ($a_obj_id) | |
| Returns true, if a test is complete for use. | |
| _getQuestionCount ($a_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. | |
Static Public Member Functions | |
| _hasFinished ($a_user_id, $a_obj_id) | |
| Returns information if a specific user has finished a test. | |
Definition at line 38 of file class.ilObjTestAccess.php.
| 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.
| 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) |
Reimplemented from ilObjectAccess.
Definition at line 55 of file class.ilObjTestAccess.php.
References $ilAccess, $ilUser, $lng, $rbacsystem, and _lookupCreationComplete().
{
global $ilUser, $lng, $rbacsystem, $ilAccess;
if ($a_user_id == "")
{
$a_user_id = $ilUser->getId();
}
switch ($a_permission)
{
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 95 of file class.ilObjTestAccess.php.
References $ilias, $result, _getTestResult(), and _hasFinished().
Referenced by ilCourseContentInterface::cci_start_objects(), and ilCourseStart::isFullfilled().
{
global $ilias;
switch($a_operator)
{
case 'passed':
$result = ilObjTestAccess::_getTestResult($ilias->account->getId(), $a_obj_id);
if ($result["passed"] == 1)
{
return true;
}
else
{
return false;
}
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::_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 136 of file class.ilObjTestAccess.php.
Referenced by ilObjTestListGUI::init().
{
$commands = array
(
array("permission" => "read", "cmd" => "run", "lang_var" => "tst_run",
"default" => true),
array("permission" => "write", "cmd" => "", "lang_var" => "edit"),
array("permission" => "write", "cmd" => "eval_a", "lang_var" => "tst_anon_eval"),
array("permission" => "write", "cmd" => "eval_stat", "lang_var" => "tst_statistical_evaluation")
);
return $commands;
}
Here is the caller graph for this function:| ilObjTestAccess::_getQuestionCount | ( | $ | a_test_id | ) |
Calculates the number of questions in a test.
Calculates the number of questions in a test
Definition at line 359 of file class.ilObjTestAccess.php.
References $num, $query, $result, and $row.
Referenced by _isComplete().
{
global $ilDB;
$num = 0;
$query = sprintf("SELECT * FROM tst_tests WHERE test_id = %s",
$ilDB->quote($a_test_id)
);
$result = $ilDB->query($query);
if ($result->numRows != 1) return 0;
$row = $result->fetchRow(DB_FETCHMODE_ASSOC);
if ($row["random_test"] == 1)
{
if ($row["random_question_count"] > 0)
{
$num = $row["random_question_count"];
}
else
{
$query = sprintf("SELECT * FROM tst_test_random WHERE test_fi = %s ORDER BY test_random_id",
$ilDB->quote($a_test_id . "")
);
$result = $ilDB->query($query);
if ($result->numRows())
{
while ($row = $result->fetchRow(DB_FETCHMODE_ASSOC))
{
$num += $row["num_of_q"];
}
}
}
}
else
{
$query = sprintf("SELECT question_fi FROM tst_test_question WHERE test_fi = %s",
$ilDB->quote($a_test_id . "")
);
$result = $ilDB->query($query);
$num = $result->numRows();
}
return $num;
}
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
| integer | $object_id The object id |
Definition at line 209 of file class.ilObjTestAccess.php.
References $query, $result, and $row.
Referenced by _getTestResult(), _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::_getTestResult | ( | $ | user_id, | |
| $ | test_obj_id | |||
| ) |
Calculates the results of a test for a given user.
Calculates the results of a test for a given user and returns the failed/passed status
Definition at line 234 of file class.ilObjTestAccess.php.
References $query, $result, $row, $user_id, and _getTestIDFromObjectID().
Referenced by _checkCondition().
{
global $ilDB;
$test_result = array();
$query = sprintf("SELECT tst_mark.*, tst_tests.* FROM tst_mark, tst_tests WHERE tst_mark.test_fi = tst_tests.test_id AND tst_tests.obj_fi = %s ORDER BY tst_mark.minimum_level",
$ilDB->quote($test_obj_id . "")
);
$result = $ilDB->query($query);
if ($result->numRows())
{
$test_result["marks"] = array();
$min_passed_percentage = 100;
while ($row = $result->fetchRow(DB_FETCHMODE_ASSOC))
{
if (($row["passed"] == 1) && ($row["minimum_level"] < $min_passed_percentage))
{
$min_passed_percentage = $row["minimum_level"];
}
array_push($test_result["marks"], $row);
}
// count points
$query = sprintf("SELECT qpl_questions.*, tst_test_result.points AS reached_points FROM qpl_questions, tst_test_result WHERE qpl_questions.question_id = tst_test_result.question_fi AND tst_test_result.test_fi = %s AND tst_test_result.user_fi = %s",
$ilDB->quote(ilObjTestAccess::_getTestIDFromObjectID($test_obj_id) . ""),
$ilDB->quote($user_id . "")
);
$result = $ilDB->query($query);
$max_points = 0;
$reached_points = 0;
while ($row = $result->fetchRow(DB_FETCHMODE_ASSOC))
{
$max_points += $row["points"];
$reached_points += $row["reached_points"];
}
$test_result["max_points"] = $max_points;
$test_result["reached_points"] = $reached_points;
// calculate the percentage of the reached points
$solved = 0;
if ($max_points > 0)
{
$solved = ($reached_points / $max_points) * 100.0;
}
// get the mark for the reached points
$mark_percentage = 0;
$mark_value = null;
foreach ($test_result["marks"] as $key => $value)
{
if (($value["minimum_level"] <= $solved) && ($mark_percentage < $value["minimum_level"]))
{
$mark_percentage = $value["minimum_level"];
$mark_value = $value;
}
}
$test_result["mark"] = $mark_value;
// get the passed state
$test_result["passed"] = $test_result["mark"][passed];
}
return $test_result;
}
Here is the call graph for this function:
Here is the caller graph for this function:| ilObjTestAccess::_hasFinished | ( | $ | a_user_id, | |
| $ | a_obj_id | |||
| ) | [static] |
Returns information if a specific user has finished a test.
| integer | $user_id Database id of the user | |
| integer | test obj_id |
Definition at line 187 of file class.ilObjTestAccess.php.
References $query, $res, and _getTestIDFromObjectID().
Referenced by _checkCondition(), and ilCourseObjectiveResult::isSuggested().
{
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
Definition at line 302 of file class.ilObjTestAccess.php.
References $obj_id, $query, $result, $row, _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::_lookupCreationComplete | ( | $ | a_obj_id | ) |
checks wether all necessary parts of the test are given
Definition at line 157 of file class.ilObjTestAccess.php.
References $q, $result, and $row.
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
Definition at line 412 of file class.ilObjTestAccess.php.
References $lng, $query, $result, and $row.
Referenced by ilObjTestListGUI::getProperties().
{
global $ilDB, $lng;
$test_result = array();
$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["test_type_fi"] == 4)
{
$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:
1.7.1