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. | |
& | _getTestQuestions ($active_id, $pass=NULL) |
& | _getTestResult ($active_id, $pass=NULL) |
Calculates the results of a test for a given user. | |
_isComplete ($a_obj_id) | |
Returns true, if a test is complete for use. | |
_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 | |
Static Public Member Functions | |
_hasFinished ($a_user_id, $a_obj_id) | |
Returns information if a specific user has finished a test. |
Definition at line 39 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 56 of file class.ilObjTestAccess.php.
References $lng, $rbacsystem, 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; }
ilObjTestAccess::_checkCondition | ( | $ | a_obj_id, | |
$ | a_operator, | |||
$ | a_value | |||
) |
check condition
this method is called by ilConditionHandler
Reimplemented from ilObjectAccess.
Definition at line 97 of file class.ilObjTestAccess.php.
References $ilias, $result, ilObjTest::_getActiveTestUser(), _getTestIDFromObjectID(), _getTestResult(), and _hasFinished().
Referenced by ilCourseContentInterface::cci_start_objects(), and ilCourseStart::isFullfilled().
{ global $ilias; switch($a_operator) { case 'passed': include_once "./assessment/classes/class.ilObjTest.php"; $test_id = ilObjTest::_getTestIDFromObjectID($a_obj_id); $active = ilObjTest::_getActiveTestUser($ilias->account->getId(), $test_id); if(!is_object($active)) { return false; } $result = ilObjTestAccess::_getTestResult($active->active_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; }
ilObjTestAccess::_checkGoto | ( | $ | a_target | ) |
check whether goto script will succeed
Reimplemented from ilObjectAccess.
Definition at line 577 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 145 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" => "write", "cmd" => "eval_stat", "lang_var" => "tst_statistical_evaluation") ); return $commands; }
& 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
Definition at line 544 of file class.ilObjTestAccess.php.
References $results, ilObjTest::_getCompleteEvaluationData(), and _getTestIDFromObjectID().
Referenced by ilLPStatusTestPassed::_getStatusInfo().
{ $passed_users = array(); include_once 'assessment/classes/class.ilObjTest.php'; $test_id = ilObjTest::_getTestIDFromObjectID($a_obj_id); $results =& ilObjTest::_getCompleteEvaluationData($test_id, FALSE); if (is_object($results)) { $participants =& $results->getParticipants(); foreach ($participants as $participant) { if (is_object($participant)) { array_push($passed_users, array( "user_id" => $participant->getUserID(), "max_points" => $participant->getMaxpoints(), "reached_points" => $participant->getReached(), "mark_short" => $participant->getMark(), "mark_official" => $participant->getMarkOfficial(), "passed" => $participant->getPassed(), "failed" => (!$participant->getPassed()) ) ); } } } return $passed_users; }
ilObjTestAccess::_getQuestionCount | ( | $ | test_id | ) |
Calculates the number of questions in a test.
Calculates the number of questions in a test
Definition at line 427 of file class.ilObjTestAccess.php.
References $query, $result, and $row.
Referenced by _isComplete().
{ global $ilDB; $num = 0; $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); 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; }
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 217 of file class.ilObjTestAccess.php.
References $query, $result, and $row.
Referenced by _checkCondition(), _getPassedUsers(), _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; }
& ilObjTestAccess::_getTestQuestions | ( | $ | active_id, | |
$ | pass = NULL | |||
) |
Definition at line 233 of file class.ilObjTestAccess.php.
References $query, $result, and $row.
Referenced by _getTestResult().
{ 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::_getTestResult | ( | $ | active_id, | |
$ | pass = NULL | |||
) |
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 296 of file class.ilObjTestAccess.php.
References $key, $query, $result, $row, assQuestion::_getReachedPoints(), and _getTestQuestions().
Referenced by _checkCondition().
{ global $ilDB; $test_result = array(); $query = sprintf("SELECT tst_mark.*, tst_tests.* FROM tst_mark, tst_tests, tst_active WHERE tst_mark.test_fi = tst_tests.test_id AND tst_tests.test_id = tst_active.test_fi AND tst_active.active_id = %s ORDER BY tst_mark.minimum_level", $ilDB->quote($active_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); } $questions =& ilObjTestAccess::_getTestQuestions($active_id, $pass); $max_points = 0; $reached_points = 0; foreach ($questions as $row) { include_once "./assessment/classes/class.assQuestion.php"; $preached = assQuestion::_getReachedPoints($active_id, $row["question_id"], $pass); $max_points += $row["points"]; $reached_points += $preached; } switch ($test_result["marks"][0]["score_cutting"]) { case 0: // SCORE_CUT_QUESTION break; case 1: // SCORE_CUT_TEST if ($reached_points < 0) $reached_points = 0; break; } $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; }
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 195 of file class.ilObjTestAccess.php.
References $query, $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; }
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 370 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; } }
ilObjTestAccess::_lookupCreationComplete | ( | $ | a_obj_id | ) |
checks wether all necessary parts of the test are given
Definition at line 165 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; }
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 481 of file class.ilObjTestAccess.php.
References $lng, $query, $result, and $row.
Referenced by ilObjTestListGUI::getProperties(), and ilObjTestGUI::infoScreen().
{ 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; } }